• What are you working on?
    1,001 replies, posted
Here's mine: [cpp] unsigned fileSize(const std::string &file) { return boost::filesystem::file_size(file); } [/cpp] I guarantee you it's portable.
[QUOTE=nullsquared;16036755]Here's mine: [cpp] unsigned fileSize(const std::string &file) { return boost::filesystem::file_size(file); } [/cpp] I guarantee you it's portable.[/QUOTE] Boost is using stat btw: [cpp] BOOST_FILESYSTEM_DECL uintmax_pair file_size_api( const std::string & ph ) { struct stat path_stat; if ( ::stat( ph.c_str(), &path_stat ) != 0 ) return std::make_pair( error_code( errno, system_category ), 0 ); if ( !S_ISREG( path_stat.st_mode ) ) return std::make_pair( error_code( EPERM, system_category ), 0 ); return std::make_pair( ok, static_cast<boost::uintmax_t>(path_stat.st_size) ); }[/cpp] I didn't know about that stat function/struct - it's a nice thing :D
Here's some of my latest work, I already made a huge blog post about it so no sense making one again here: [url]http://www.mzzt.net/2009/07/04/new-file-updated-files-sneak-peaks/[/url] [QUOTE=garry;16004840][code] //Filter out the WM_ERASEBKGND message if(m.Msg != 0x14) { System::Windows::Forms::ListView::OnNotifyMessage(m); }[/code][/QUOTE] You know you can just override the OnPaintBackground function and NOT call the ListView implementation of it to get the same effect, right? And it's cleaner and more .NET-y (IE you don't have to fool around with Windows API Window Messages, which aren't going to be portable to Mono for Linux, for instance, if you ever think about porting in the future). Or you set the AllPaintingInWmPaint control style, which IIRC skips the call to OnPaintBackground entirely. That's how I get rid of flicker in my controls. Automatic double buffering is nice though. Very convenient. And here's an awesome tip I figured out: If you want a transparent background in your controls but you also want no flickering, set AllPaintingInWmPaint and OptimizedDoubleBuffer. Override OnPaintBackground to do nothing, and then call the base class's OnPaintBackground function from within your overridden OnPaint, passing the double buffered Graphics object in the PaintEventArgs. The proper background will then be painted onto it to simulate transparency. :D [QUOTE=garry;16017374]This means that this object isn't just useful for networking, but you can use it in your editor to list and access all the entity's variables, or saving, or loading.[/QUOTE] Look into System.Reflection, it makes stuff like that a lot easier. Make an Attribute, attach it to any members you want to be listed (or not listed, depending on what you want the default to be), then do AnyObject.GetType.GetMembers to get a full member list and then you just GetCustomAttributes on each member to figure out whether you should include it in the list or not. Anyways with Reflection you don't have to worry about forgetting to update a list of members or typoing a member id or anything. Just add the members, apply an attribute if you don't want default behavior, and it "just works". I used Reflection and Attributes in creating a help system for a scripting framework I made: [img]http://x.mzzt.net/2009.06.24.17.18.10.png[/img] [img]http://x.mzzt.net/2009.06.18.14.13.35.png[/img] All that data is generated dynamically at runtime using data attached to classes and members using Attributes. If I change the help data or even the classes/members themselves the changes pop up next compile automatically.
Did you write that GUI yourself or is it some library?
Yeah I know about the reflection stuff - it's cool - but only the tools of my engine are coded in managed c++ - so it's no good for me.
Awesome shit, Are there any good C# Books, Or should I start on the internet?
[QUOTE=ZeekyHBomb;16036878]Boost is using stat btw: [cpp] BOOST_FILESYSTEM_DECL uintmax_pair file_size_api( const std::string & ph ) { struct stat path_stat; if ( ::stat( ph.c_str(), &path_stat ) != 0 ) return std::make_pair( error_code( errno, system_category ), 0 ); if ( !S_ISREG( path_stat.st_mode ) ) return std::make_pair( error_code( EPERM, system_category ), 0 ); return std::make_pair( ok, static_cast<boost::uintmax_t>(path_stat.st_size) ); }[/cpp] I didn't know about that stat function/struct - it's a nice thing :D[/QUOTE] That's the point. Using boost, I don't have to worry about implementation details. All I care about is that it works, and that it's cross platform ;)
Drawing spinning and scaling boxes in directx is apparently easier than drawing simple colored rectangles on the screen. Drawing text proved to be insanely simple. Drawing two triangles to form a quad works, but I have no control over their color, and scaling/translation matrices didn't seem to do anything. Creating a blank texture or loading one from a file and using that with sprites did nothing at all. Anyone have any suggestions on drawing rectangles?
You should have a color DWORD in your vertex struct.
[QUOTE=Overv;16038109]You should have a color DWORD in your vertex struct.[/QUOTE] Yeah I do, but changing that after locking/unlocking/creating the vertex buffer doesn't do anything. Unless I create a new buffer every frame, of course.
If you want simple 2D rectangles probably an idea to use D3DXSprite I think :ohdear:
[QUOTE=nullsquared;16037794]That's the point. Using boost, I don't have to worry about implementation details. All I care about is that it works, and that it's cross platform ;)[/QUOTE] I find implementations or certain things interesting, but it would take too much time to look at all, understand it and keep it in mind. At some cases it can help to know some stuff about implementations, like when you can avoid certain things and thus get a performance boost or size loss or when you have conflicting code. @Nevec: Did you do [url=http://msdn.microsoft.com/en-us/library/bb147265(VS.85).aspx]this[/url]?
Got prediction half done. At the moment the clientside can just stomp the variables before render. Need to make it optionally not update the variables from the server (thinking of some kind of network update rule that you can add to vars). Also need to add some kind of prediction like Valve's, so effects don't get sent to the client from the server if the event that caused it has already been succesfully pre-inactived on the client. But I think I've gotta make another gamemode for that. Well, probably not. I'll cross that bridge when I come to it. Need fakelag.
All this stuff hurts my brain [editline]05:31PM[/editline] like loads [editline]05:31PM[/editline] how do you faggots figure this shit out
[QUOTE=reviewmad;16038658]how do you faggots figure this shit out[/QUOTE] Step one: learn Step two: think Step three: ??? (possibly writing code) Step four: PROFIT!
[QUOTE=reviewmad;16038658]All this stuff hurts my brain [editline]05:31PM[/editline] like loads [editline]05:31PM[/editline] how do you faggots figure this shit out[/QUOTE] lern 2 lern Seriously it's easy. Also, just found a book on discrete mathematics from 1992. :lol: And an OpenGL book from 1997. Awesome. Loving the generic flat shaded plant with stencil shadows on the front cover.
[QUOTE=ZeekyHBomb;16038229]@Nevec: Did you do [url=http://msdn.microsoft.com/en-us/library/bb147265(VS.85).aspx]this[/url]?[/QUOTE] I didn't do that and my code works fine. [QUOTE=garry;16038586]Got prediction half done. At the moment the clientside can just stomp the variables before render. Need to make it optionally not update the variables from the server (thinking of some kind of network update rule that you can add to vars). Also need to add some kind of prediction like Valve's, so effects don't get sent to the client from the server if the event that caused it has already been succesfully pre-inactived on the client. But I think I've gotta make another gamemode for that. Well, probably not. I'll cross that bridge when I come to it. Need fakelag.[/QUOTE] To fake lag you could have a vector with all the messages that need to be sent and send the top message every [i]x[/i] miliseconds.
[QUOTE=reviewmad;16038658]All this stuff hurts my brain [editline]05:31PM[/editline] like loads [editline]05:31PM[/editline] how do you faggots figure this shit out[/QUOTE] Learn, build incrementally off it by learning or figuring things out. It might end up being significant or insignificant in the scheme of things. Massive leaps are impossible without a hearty imagination or an in-depth knowledge.
[img]http://imgkk.com/i/Zz2fPYX3.png[/img] Behold. Now I have to do powerup-system, map-system, scoring-system and menus. After that I can begin to work on the demo.
Well.. as they say, third time's the charm. This is the third time I rewrote the rectangle drawing stuff and it seems to work just perfectly now. And I managed to do that in five minutes or so. Here's a screen.. [IMG]http://i27.tinypic.com/2n1f5ad.png[/IMG] Though, I'm doing it the probably-less-efficient way of creating and destroying the buffer each frame.
you guys seriously need lessons on how to crop properly :D
[img]http://i27.tinypic.com/wvbsba.png[/img] It's a 2D platformer with wall climbing and such! (What's the shortest way to create a std::string such as "Pos: "+x+","+y where x and y are integers?)
boost::lexical_cast<std::string>(x)
I made a tostring function, I'm sure I saw a shorter way to do it somewhere though: [cpp]std::string ftos( float x ) { std::stringstream conv; conv << x; std::string temp; conv >> temp; return temp; }[/cpp] [editline]07:43PM[/editline] I made a tostring function, I'm sure I saw a shorter way to do it somewhere though: [cpp]std::string ftos( float x ) { std::stringstream conv; conv << x; std::string temp; conv >> temp; return temp; }[/cpp]
(boost::format("Pos: %1%,%2%") % x % y).str();
[QUOTE=Overv;16039613]I made a tostring function, I'm sure I saw a shorter way to do it somewhere though: [cpp]std::string ftos( float x ) { std::stringstream conv; conv << x; std::string temp; conv >> temp; return temp; }[/cpp] [editline]07:43PM[/editline] I made a tostring function, I'm sure I saw a shorter way to do it somewhere though: [cpp]std::string ftos( float x ) { std::stringstream conv; conv << x; std::string temp; conv >> temp; return temp; }[/cpp][/QUOTE] Thanks, this is pretty much what I need. I found a function, conv.str() returns the string.
If you go that way, you might as well wanna use templates: [cpp]template<typename T> std::string convert(const T &other) { std::stringstream temp; temp << other; return temp.str(); }[/cpp]
You can also use [i]sprintf[/i] which has the format item stuff. This is how I form some debug info.. [cpp]char* str = new char[ 256 ]; sprintf( str, "Some debug crap:\nCurTime: %.3f\nFrameTime: %.5f\nFps: %i\nSize: %i x %i", this->CurTime( ), this->FrameTime( ), this->Fps( ), width, height );[/cpp] The only limitation is that you need to use a predefined char pointer/array. Which either adds a bit overhead or limits the size of the string.
And it's not typesafe and could create buffer overflows. Which is why I prefer the boost::format-way :)
[QUOTE=ZeekyHBomb;16039622](boost::format("Pos: %1%,%2%") % x % y).str();[/QUOTE] this.
Sorry, you need to Log In to post a reply to this thread.