   New game screenshot
  My new game engine is coming along. I am sort of doing a "blog" on my site about development of my game engine, dubbed SKEngine, after my son. I was going to use OGRE and had some good screens, but it was hard to implement, for me, because I couldn't follow the developers mind. I figured creating a new game engine from scratch would also be a good learning expierence. This engine will be used in Tread Wars my  3D tank battle game, nothing spectacular, but hopefully a nice learning expierence. I am hoping to add the terrain feature next, and cultivate the engine to use better OO techniques.Some might think this is a joke, but it took me 3 days to get to the point of this screenshot: http://highend.stuffsoft.com/index.php?module=My_eGallery&do=showpic&pid=5I know its childish to some but I am very proud of it. Writing a 3D game engine is a whole lot more then writing a scenegraph or render. Just getting my engine to a point of having some sort of OO design is what took the most time, and I still had to make skEngine, the main engine, a global  Hopefully I can find some suggestions on encapsulating this, so it doesn't have to be so global.You can also view the structure of my current engine design, sorry but its mostly the render pipeline, at http://www.highendgaming.com/docs/ .As always anyone who cares to leave any constructive criticism or opinions please do so. Thanks again for your time in reading this post![edited by - codeguy on February 2, 2004 8:51:55 PM]
  You could ALWAYS simply make a pointer to the engine object... and make that pointer global 9maybe youve already done this) but if you have the time, just pass a pointer of the engine object around... ;  Ah to tell you the truth I didn''t think about that. I was thinking along the lines of creating a static member and then doing a sort of singleton extraction, but your method sounds much better.The problem is that the main engine holds the LPDIRECT3DEVICE9 object used for rendering the scene, and I noticed that I needed this for my mesh classes, and in order to get it I decided to make the class that holds it global.Why didn''t I think of the ideal as a global pointer?!?! Thanks for that idea, I may change it to a global pointer now. Now that I am thinking about it I have to pull out my book on C++ and see what the benefits of a global pointer versus object would be. Now that I think of it thats how the D3D samples are written with global pointers to the D3Device and Render object.Thanks for that tip!   Sam--Tread Wars - Tank Battle gamePowered by SKEnginehttp://www.highendgaming.com ;  Might I mention namespaces? They're good for making globals not clutter up the main namespace. As for singletons, I made a little class for this... which prevents you from having to use a global.template< class SingletonClass > class Singleton{    static unsigned int references;    static SingletonClass * Data;public:    Singleton( void )    {   if (!Data) Data = new SingletonClass;   ++references;    }    ~Singleton( void )    {   if ((! --references) && (Data)) delete Data;    }    SingletonClass * operator->( void )    {   return Data;    }};template< class SingletonClass > unsigned int Singleton::references = 0;template< class SingletonClass > SingletonClass * Singleton::Data = 0;   To use this code, anything that needs to use the singleton simply creates one of the singleton wrapper instances. This simple example relies on NOT doing multithreading (in which case ++ and -- need to be replaces with guaranteed atomic actions) and deletes the class as soon as it's no longer in use.More complex versions of this that I've used work together with manager classes and delete only and the end of a game, or the program, and work with multithreading.Example code:#include <iostream>#include "singleton.hh" //the singleton class as outlined aboveclass PeanutsSingleton{public:   void Shout( void ) {std::cout << "Peanuts!!!" << std::endl;   }};class PeanutsUser {    Singleton< PeanutsSingleton > Peanuts;public:    void Use ( void ) { Peanuts->Shout(); Peanuts->Shout(); Peanuts->Shout();    }};int main ( int argc , char ** argv ) {  Singleton< PeanutsSingleton > Peanuts; //initializes singleton  Peanuts->Shout(); //Shouts once  PeanutsUser User; //creates another reference, does NOT re-initialize.  User.Use(); //Shouts three times  //Both singleton handles are destroyed at the end of this function, so the shared PeanutsSingleton gets deleted here.}   Again, the sample code you'll probably want to adapt to better suit your needs... if done right, you can prevent unused modules of an engine from being initialized if they're not needed. Aka, for a completely multipurpouse engine (UI, 3d rendering, etc) the 3d part need not be initialized if it's being used for an office application.  -Mike-------edit: also, when I use this class I usually make a typedef so I don't have to type Singleton< SingletonClass > every time. Also, you'll still have the namespace clutter of the Singleton class, and each class implementing the singleton stuff.   [edited by - MaulingMonkey on February 2, 2004 9:30:21 PM];  Mauling Monkey thank you so much for that implementation. If you don''t mind, I may fold it into the next revision of my engine, which there will be a lot of in the coming months. I just picked up a new C++ book on the concepts of design and usage such as Singletons, factories, etc... and one on Extreme Programming, so forgive me if my knowledge has yet to catch up to what you have displayed. I was thinking of using namespaces but I got so taken aback doing "using namespace std;" or "using std::string;" etc... I didn''t think I would need namespaces as I am trying to encapsulate everything, but you are right it may clutter up the main namespace if I fail to do so, I better start implementing it now.When I get into writing the Process manager or physics section of my engine, your Singleton implementation may come in very handy so I am going to try and include it soon. I was currently working on generating a heightfield terrain and just brute forcing all the verts onto the screen. Hopefully, any card that uses a GForce or higher card can handle a 32x32 24-bit grayscale generated heightfield terrain using 20.0 as a map scale factor.Thanks again MaulingMonkey your input and contribution was just what I was looking for when I posted my screenshot. I really appreciate the help!   In the making Tread Wars - Tank Battle gamePowered by SKEnginehttp://www.highendgaming.com ;  Yay for teapots!  No seriously dude, that''s probably pretty impressive.  I don''t know enough about it yet lol. ;  Namespaces are extremely simple. Let''s say you have a class called Math, with a static function called Cosine. To call that function from somewhere else in the program, you say:Result = Math::Cosine( 3.14159 );Now let''s say the Math class is nothing but a list of static functions, and the only reason the class exists is to organize those functions (as a subset of Math) so they don''t have to be globals. You could just leave things the way they are, or you can make Math a namespace instead of a class.The namespace will be declared like this:namespace Math{    float Cosine ( float );};Note the function''s no longer declared as static. To use this namespace, you either say:Result = Math::Cosine( 3.14159 );or:using namespace Math;Result = Cosine( 3.14159 );std is a namespace because you wouldn''t want a standard library to use globals called ''string'', ''vector'', etc., since it''s likely someone else would want things named that. So by putting them all in the namespace ''std'', you use std::string, std::vector, etc., to indicate those types. Or you say ''using namespace std;'' which you can just say once at the top of the file and then it''ll be assumed that you''re using the std namespace.   ~CGameProgrammer( ); -- Post screenshots of your projects. 100+ posts already in the archives. ;  CGameProgrammer thanks for the further clarification. I am trying to implement namespaces into the new revision of the engine, in order to sort out the problems you have listed.I am trying now to put in a brute force terrain, to at least, have a little more eye candy, but the TRIANGLE_STRIP implementation in D3D is killing me. The way you draw it in OGL is simpler then than D3D as I had to create a seperate array, copy all the verts I had in a buffer, and then draw the TRIANGLE_STRIP from there.Btw, I like DEVIMG a lot when I have something worth posting I am going to throw it up there. Right now other developers might not get a kick out of teapot, but it was the engine and object creation behind it that was more difficult then anything.   [edited by - codeguy on February 4, 2004 1:14:47 PM];  I am just going to keep re-using this thread. If the mods feel this is inappropriate please let me know. I just don't want to keep starting another thread for basically the same subject matter.After a week of debating I finally came up with a new addition to my game engine. The terrain class. It is basically just a brute force approach I generate a heightfield using a RAW image file format, created with Paint Shop PRO, and then render the terrain to screen. It is HIGHLY inefficient, but, I am excited just getting to this point. I am planning on adding some lights and terrain next so we can actually view some of the terrain contour instead of the flat ambient light thing I have going on.I almost gave up this whole week as I was trying to figure out how do I render this 2D array to my computer screen using DirectX? I kept wanting to render the entire strip of triangles (I am currently using a 32x32 RAW image), but I just decided to render 2 triangles at a time. I might put adding in font support just to see what my screen rate is at this time, but its probably still high because of the fact that I have ambient lighting and no texturing going on. This is really better then the teapot screen I had, and I was really proud of that one. I can't wait to get this textured, just have to figure out what size to make the texture. A quad is currently 20x20 for the terrain.You can view the latest screen here. As always any opinions or advice would be recommended.    In the making Tread Wars - Tank Battle gamePowered by SKEnginehttp://www.highendgaming.com [edited by - codeguy on February 8, 2004 12:39:41 AM];  Morale is a big thing when coding, so my friend, here you have:Nice Job, Keep It Up!! :D   [Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD]    [Yann  L.][Enginuity]  [Penny Arcade]  [MSDN][VS  RoadMap][Humus][BSPs][UGP][NeHe]"I say we take off and nuke the entire site from orbit. It''s the only way to be sure." 