Jump to content
  • Advertisement
  • entries
  • comments
  • views

About this blog

Game engine design using C++, My Projects etc.

Entries in this blog


vortxGE : Threads

After reading lots of tech papers/blogs on C++11 threads I redesigned the way the engine handles threading.

Developers can now change threads manually per Scene, each pipeline : Move, Optimise are now batch threaded for better performance. after lots of testing this approch seems to work better under heavy load and being scalable its my new method of choice.

Here is some code from the engine that creates threads based on nodes.void lsNode::MoveThread( lsScene* scn, lsOpenGL* opengl, double delta ){#ifdef VORTX_DEBUG_NODES cout th; lsNode *ptr; int threads = 1; int tc = 0; // Threads if( scn ) { threads = scn->getThreads(); } else { threads = thread::hardware_concurrency() * 2; } // cycle through child and its next nodes ptr = getNode_list(); while( ptr ) { // Add thread th.push_back( thread( &lsNode::Move, ptr, scn, opengl, delta ) ); tc++; // check our thread count if(( tc >= threads )||( ptr->getNext_node() == NULL )) {#ifdef VORTX_DEBUG_NODETHREADS // debug cout getNext_node(); } // pass it on if( getNode_list() ) getNode_list()->MoveThread( scn, opengl, delta ); if( getNext_node() ) getNext_node()->MoveThread( scn, opengl, delta );}




C++11 Threads

I was just brushing up on some C++11 concepts the last few nights (looking for parts of the engine to improve) and noticed quite a few people struggling with threads inside classes, as in using a class object as a thread. Some of the responses were so confusing to say the least.

Also they were struggling with std::cout while threads were running. So here's some example code of these problems all in one. I hope it points someone in the right direction.

lsThread2.h / .cpp
lsThread.h / .cpp
core.h / .cpp
main.cpp// file : core.h#ifndef cppThreads_core_h#define cppThreads_core_h#include #include #include #include using namespace std;/*! Base class Used to start some lsThread objects. */class core{public: core(); virtual ~core(); void run(); void logText( const string& val, int tid ); private: int nr_threads; mutex m;};#endif// file : core.cpp?#include "core.h"#include "lsThread.h"core::core(){ nr_threads = 10;}core::~core(){}void core::run(){ cout th; lsThread *mt = new lsThread[nr_threads]; //Launch a group of threads for( int i = 0; i .setTid( i ); // Shows how to pass args to the start function in lsThread th.push_back( thread( &lsThread::start, mt, this, 5 ) ); } //Join the threads with the main thread which core is running for( auto &t : th ) { t.join(); } // delete our array of lsThread objects delete [] mt; cout

Above: a base class that runs in the main thread.// file : lsThread.h?#ifndef cppThreads_lsThread_h#define cppThreads_lsThread_h#include #include #include class core;using namespace std;/*! Thread class Nothing special about this class, you could thread any class. */class lsThread{public: lsThread(); virtual ~lsThread(); virtual void start( core *c, int val ); void setTid( int val ) { tid = val; } private: int tid; };#endif// File : lsThread.cpp#include "core.h"#include "lsThread.h"#include "lsThread2.h"lsThread::lsThread(){ tid = 0;}lsThread::~lsThread(){}void lsThread::start( core *c, int val ){ c->logText( "lsThread start", tid ); // Here we create some more threads with a new class, based on the passed value. vector th; int nr_threads = val; lsThread2 *mt = new lsThread2[nr_threads]; //Launch a group of threads for( int i = 0; i .setTid( i ); th.push_back( thread( &lsThread2::start, mt, c ) ); } // Join the threads with the current thread // This could be any of the threads created by the core class. for( auto &t : th ) { t.join(); } // delete our array of lsThread2 objects. delete [] mt;}

Above: This class show how to launch more threads inside the current thread.
// File : lsThread2.h#ifndef cppThreads_lsThread2_h#define cppThreads_lsThread2_h#include #include #include class core;using namespace std;class lsThread2{public: lsThread2(); virtual ~lsThread2(); virtual void start( core *c ); void setTid( int val ) { tid = val; } private: int tid;};#endif// File : lsThread2.cpp#include "core.h"#include "lsThread2.h"lsThread2::lsThread2(){ tid = 0;}lsThread2::~lsThread2(){}void lsThread2::start( core *c ){ // In this thread we just call the core class logging function c->logText( "lsThread2 start", tid );}

Above: Simple thread that will just output a message to stdout.// File : main.cpp#include "core.h"int main(int argc, const char * argv[]){ // Thread demo core *c = new core(); c->run(); delete c; return 0;}

Above: And last but not least the main()

I've kept this example as simple as possible but still trying to show as much as possible. Hope it helps someone.





My Business

Well I've been away from GameDev.net for what seems like forever. It has been a hard road but I'm up and running with the new business. First App is on the AppStore and I created a Online Shop for my site too.

The plan is to start making some money to fund future Games using my engine, once the engine is done I'll release it free. With any luck this means jobs for others and I get back to coding full time. All this hard work is taking me away from what I love! CODE






Still Alive

I have been very busy setting up the new Business, sadly this meant I couldn't work on vortxGE. I have created 3 other Apps for iPhone/iPad and Mac OS X. This has been taking up all my time. I'm also in the middle of creating a new website for the Business : http://www.leestripp.com still under construction.

I'm just adding this entry to say I will be back soon with some vortxGE updates.





vortxGE : Update

Started work on the Game level system, for this I needed to add hierarchy support to the Controls and also get that working in vortxEDIT. A recap on Controls in vortxGE, a control is a building block inside the engine for anything from a Viewer, Composite, Game Levels and so on. I wanted to be able to stack Levels on top of a LevelLoader control for example. This is all done and tested, as in the linking etc...

Now has support for loading Mesh assets and also simple Object adding. In the image you can see I was playing around with adding existing cubes but this could be any object I export from Blender. I also did even more code cleanups to do with Memory management. No ARC used anymore.




vortxGE : Level Loading

Here is a little insight into how I work, I always plan out major systems on paper before I ever start coding them, I don't go overboard with tones of detail because this is just off the top of my head. Things may change as I write the code and I make changes to this document as I go. If I don't do this stage I find it takes 10x longer to write the code. This also gives a great reference for later Product documentation.


Level Progression Games

How level loading works
In vortxEDIT, create a LevelLoader control and as many Level controls you need for your game. The loader should hold an lsViewer that displays lsLevel loading progress or whatever you like, as long as the user knows something is loading. A lsLevel control holds a filename of the vortxEDIT Level project to be loaded and a pointer to the lsGame instance needed for the level data. GamePlay controls are created by the game developer and trigger game end, restart and set scores in the lsLevel.

An lsGame control is used to hold the current lsLevel loaded data and gameplay pointer. You only need one lsGame control, the lsLevelLoader should create this control and pass it to lslevel classes.

Create your Level files using vortxEDIT as single projects containing everything you need for that levels game play, other in-game objects can always be added at runtime.

Sandbox Games

How Sandbox works
lsSandBox class manages many lsSandBoxZone classes. Because a sandbox is really one massive level it should control lsSandBoxZone loading and releasing data into the lsGame class. An lsSandBoxZone controls all its asset loading and releasing in turn. Using zones should give greater flexibility to the developer and his/her target platform. Smaller zones can leave a smaller memory footprint. LsSandBoxZone's will be triggered by distance from the player/camera and must dynamically add/remove data from the lsGame class depending on the distance.

This structure looks like the lsLevelLoader structure but it in no way works the same way. Keep this in mind when you create your lsGamePlay subclass.




vortxGE : single code base

After playing with the IOS engine code base for a while now I was confident I could recombine the 2 engine code bases together.... 4 hours later its all done and working very well, even sorted a small bug when a mesh file was missing and the engine still tried to access its bounding sphere for culling

vortxEDIT and iPhone/iPad projects are all under the same workspace now, very nice.




vortxEDIT : Save

Been working hard at getting a save project feature working in vortxEDIT. This output will also be used by the Engine to load games
Small changes to the asset manager were done.

Here is the project file output so far. Just getting the basic elements down.

# vortxEDIT v1.0 by Lee A. Stripp
# Shaders
add_shader light_tex_dn
add_shader quad
add_shader debug
# Assets
add_asset texture data/textures/tech_2_2_d.tga
add_asset texture data/textures/tech_2_2_n.tga
add_asset mesh data/meshes/Cube.vbm
# Controls
add_composite Composite
add_scene Scene
add_object Quad Scene
add_camera Camera Scene
add_pass DR Scene
add_viewer Viewer
add_scene Scene
add_object Scene#Grid Scene
add_camera Camera Scene
add_light point Light Scene
add_object Point#Light#Empty Light
add_object Test#Cube Scene
add_pass FBO Scene

I have also been working on a saveGameState() function that will save the current state the game is in, a save game if you will.




vortxEDIT : Control View

I have now changed the Scene TreeView into a TreeView for the engine, showing all controls and sub-systems. This took a bit of work :-)

Started adding more Properties, here's an exsample of the Test cube with some changed material values.




vortxEDIT : Property editing

Back after a short break and working on the editor.

All properties can now be edited manually. Image shows the default scene modified using this method. Also changed the Asset view to show textures better.




vortxEDIT : Asset treeview

hmmmmm, almost right :-) I'm still a little confused with how you handle root nodes in a NSOutlineView Node tree. So I just show the Root node here in the Asset view far right.

If anyone has any ideas please let me know thanks !




vortxEDIT : Cocoa multiple OpenGL views

Finally got 2 openGL views working in a single window. Cocoa seems to be very fussy about the order and timing of some of the calls to its helper context class. Here is my call flow

Here is my init

- (id)initWithFrame: (NSRect)frame
self = [super initWithFrame: frame];
if (self)
doDraw = NO;
doInit = YES;

NSOpenGLPixelFormatAttribute attrs[] = {
NSOpenGLPFADepthSize, 32,
0 };
m_PixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes: attrs];
/* Check if initWithAttributes succeeded. */
if( m_PixelFormat == nil )
/* initWithAttributes failed. Try to alloc/init with a different list of attributes. */
NSLog(@"ERROR: Pixel Formal NOT supported");

m_Context = [[NSOpenGLContext alloc] initWithFormat:m_PixelFormat shareContext:nil];
if( m_Context == nil )
/* initWithAttributes failed. Try to alloc/init with a different list of attributes. */
NSLog(@"ERROR: GL Context not created");
} else
[m_Context makeCurrentContext];
[m_Context setView:self];
return self;

and here is the drawRect

- (void)drawRect:(NSRect)rect
[m_Context makeCurrentContext];
[m_Context setView:self];

if( [self inLiveResize] )
// Not sure yet :-)
doDraw = YES;

// Only draw if timer fires
if (doDraw)
doDraw = NO;

[self draw];
[m_Context flushBuffer];

I use a Timer to set the doDraw BOOL as not to force a drawRect. I also still need to read more about inLiveResize to see if I can still update the engine or not.

Here I setup the timer and a default scene, this function is called in applicationDidFinishLaunching, as you can see my engine is C++ and I'm finding that mixing ObjC and C++ is working very well.

NSLog(@"startup: Init game...");

[m_Context makeCurrentContext];
[m_Context clearDrawable];
[m_Context setView:self];

// cpp code: Create our demoapp
// This sets up the engine and keeps the custom view clean
default_scene = new DefaultScene();
if( default_scene )
// cpp code: init our app, needs active GL context
default_scene->InitEngine( 60.0 );
// Add engine update timer
m_Timer = [NSTimer scheduledTimerWithTimeInterval:1.0/60.0
target:self selector:@selector(triggerGameDraw:)
userInfo:nil repeats:YES];


I'm posting this in the hope it will help someone else having issues with Cocoa/OpenGL.




vortxEDIT : Cocoa

After making my first ever Cocoa app for cataloging my fish I catch, yep I love to fish. I had to start somewhere.

I just jumped right in the deep end with the vortxGE Scene Editor called vortxDEIT, this follows my old editor written in Nokia Qt using C++. But I really wanted to make a native Mac OS X app (Cocoa) for scene editing as this is my main platform these days.

So far it displays all scene node objects and the main Game View.

Left : The Scenes TreeView
Top Middle : Game View
Bottom Middle : Properties
Top Right : Asset Viewer
Bottom Right : Asset TreeView

The interface may change a lot from this design, my aim is to get something up and running fast. Later I'll redesign or even remake the app.





How many games have you worked on?

About 10 all up, last 4 were: 2up, Bi-Yo, Lolly World and CrossFate.

What do you work on in games, and how did you learn to do it?

Well I work on many areas, 3D Modelling, Animation, Programming etc... I'm self-taught from the age of 12, once at school I found like minded friends who really helped focus my learning (Not the school :-) ).

How many people typically work on a game, and what did they work on?

Most of my projects have been 2 people but I have worked in a team of 12. In the team of 12, some people started on what they thought their strengths were but they soon found out they could do other things even better. Someone may be waiting on other team members to finish a: model for example, so they help out and find they did a better job. You must be willing to try new things in a large team, unless its a 100+ size team I guess.

What are the responsibilities of those people?

One team leader will set out tasks to perform. Then most people take set tasks to complete, with any luck they finish them and move on to another task (if they have other skills). Others are set one role for example, writers cant normally help out with programming etc...

Have you worked on a team?


How well did you cooperate with them/did you ever have any problems with other members? Did you interact with them outside the workspace?

I get along with others very well thankfully so this hasn't been an issue for me, Yet :-)
Yes I have had drinks outside the workplace with some people but not all, only in the 2 team member scenario.

What kind of lingo do you use when talking to people savvy in your field?

I'm a strong believer in K.I.S.S. I try to keep it simple even with other techies. If you keep things clear, the project will run much smoother.

What kinds of problems did you have to overcome in the parts you worked on?

I would say the main issues were always cross-platform related, second is keeping up-to-date with API changes. This is one reason I started writing my own game engine. Some APIs just break a lot, and your not in control so they could take weeks or even months to fix.

Did anyone help you overcome them?

Most of the time you can find an answer online through forums etc.. So yes, never be afraid to ask for help.

What kinds of tools do you use, and what do they do?

I can use many tools, too many to list so I'll just give a few examples.

3D: Blender, XSI, 3ds max, Lightwave.
Film/Video: FinalCut, Motion, MediaStudio, Avid, Shake.
IDE: Xcode, KDevelop, VisualStudio.
2D: Gimp, Photoshop.

To explain how these all work would take to long :-)

Have you ever helped someone else with a problem?

So many I've lost count.

If you've worked on a project that isn't your own, how does it feel to work towards someone else's idea?

You have to LOVE the project or get paid very well to keep your interest up. I know thats blunt but its true.

What is your workspace like?

I work from home, I like a very clean workspace so I don't spend half an hour looking for notes etc...

Are you paid? If so, how much?

Most projects yes, as for the amount, this could be anything from $500 - $1500. All depends on the work.

Do you work under a deadline, and if so, what is it like?

Yes you will have to deal with deadlines. I think this is one of the biggest pains on any project, knowing you must stop work on something that isn't perfect yet :-) You must be willing to stop or even pass something on to others to finish so the project has an end date. Very painfull.

What do people think about your work on these projects?

I've had some good and bad comments, don't take them to heart! If your able to redo the work just do it. Sometimes a group just wont see eye to eye, its best to say up front that its not working and move on.
Most projects I do I've been in control, so its not really an issue.

What do you think the "typical" game developer is like, in terms of personality?

hmmm, thats a hard one. All are very different. Some are outgoing and some like to be left alone.

Which demographics/backgrounds do game devs tend to fall into, based on your experience? Age, race, sex, class, location, etc.

I would never pigeon-hole anyone like this, you just never know what someone is capable of until you give them a chance. Game developers come from all walks of life.

On what basis do you consider a video game "good"?

If I knew this I'd be worth billions, the age old question. Tell me if you find the answer. :-)

Do you ever sacrifice the integrity of the original idea for something that more people will like?

You have to if your running any business. If you doing it for fun/yourself then no I wouldn't.

Do you take what people tend to like into account when making a game? (excluding basic things like working controls, a visible screen, etc)

Well not at first, remember you must get the game up and running first then listen to what people say about it, make changes that will make the game better and try not to destroy you vision in the process.

What is your opinion on the different kinds of platforms offered to developers?

They all have their good and bad points. Could go on for ever here.

What kind of elements do you think influence a child to grow into being a game dev?

I think playing lots of games as a kid helps but also having people around you that tell you you'll never finish that game really helps too. This really focuses me.

What were your first experiences with video games and how did they affect you thereafter?

I got an Atari for Christmas, what a machine. After that I begged my mother for a computer for maybe 2 years until she caved so I could learn how these games were made.

What do you think pushed you to becoming a game developer?

I'm the first in my family to program so I really don't know. I've always liked to pull things apart and see how they work from an early age. I started making games before I knew anyone else doing it, I did buy a lot of programming magazines maybe they helped.

What personal rewards do you get from developing games?

Seeing a finished product is the greatest thing ever. All that hard work finally paying off, what a feeling. For me the money is secondary, if your in it for the money find another job.

Hope this helps




vortxGE : Lighting

Took a few days off to go fishing, now I'm back and hard at coding.

I worked on :

I added back in the light manager for scene objects, shaders only support 3 lights at the moment for forward renders.

With the new mesh system I had to rewrite the tangent calculations, good time to make some nice improvements.

Image 1 : iPad simulator

Image 2 : iMac 2010




vortxGE : Culling

I now have culling back in, sadly even after finding an extension for occlusion on IOS. I think its only available on iPad2, I just couldn't find any info on this... so here's what I added.

Frustum Culling

Mac OS X
Frustum Culling
Occlusion Culling

Frustum cull is just a given with both camera and light objects, to add occlusion all you need to do is add the Occlusion pass before your render scene pass.

Image shows the Occlusion in action, large cube set as Occluder hiding a smaller cube behind it.. Console shows the results.




vortxGE : Mesh loader

Okay where to start... Because I rewrote the Mesh/Batch classes I had a little more work to do with the new Mesh loader. The new loader now supports texture and shader loading automatically, mesh files are text based at the moment so their easy to edit and try new options... hmmm not so bad.

Engine is running on Mac, iPhone and iPad with all new features. Mac OS X OpenGL 2.1+, IOS 5.1 OpenGL ES 2.0

EDIT: And here is the Leaks test for app going in and out of Active/Background IOS state.




vortxGE : iPad and iPhone test

Most of the new redesign is in place and working, I now have Mac, iPhone and iPad code in sync.

Bullet Physics
Animation system - Cubic curves, Transforms and Materials.

Slow rotation is due to the screen recorder.





vortxGE : Custom Composites

Well I have started testing the so called composite Control, this control is just a scene render pipeline which makes it very powerful. Basically you can setup any type of scene and point fbo textures to an object. All the feature of scenes are the same (culling etc...), its just a scene.

Anyway the image below shows 2 scenes that connect from a quad in the composite scene to the Viewer scenes fbo output texture. The border around the quad is only there for debugging.




vortxGE : Render to Texture

I'm done adding render to texture, this is a full rewrite of the old code making it more generic and self contained. I've also added a new Control for rendering simple scenes/objects, very usefull. The pic below shows OpenGL Profiler with the FBO attached texture, showing the output of the viewer Control.




Render Pipeline

Just thought someone might like to see my flow chart for the basic render pipeline. I created this before I started working on the new engine. This is all implemented now and working well. As you may guess its a little more complex then whats shown here but you get the idea.

Added support for Retina displays and have done all tests, all scales work fine. Support for FBOs is in place and seems to work, I'll be running lots of tests first before I move on to the next TODO !

Overall things are progressing well.




vortxGE iPhone and iPad tests

Okay, I have been working on the iPhone and iPad version of the engine, here is the first tests. Seems to be working fine with full device rotation etc..

The white Quad is the composite Quad that will be used to render FBOs to screen. It may not look like it but there is a lot going on inside the engine so far.

more to come...




Back with a new focus

Well I was ment to take off 3 weeks, but things dont always work the way we want in life :-) Its been a Year and a bit since I last posted here. I'll try to explain why. I'll keep it short....

I was a 25% owner in a new online gaming company that was looking promising until the stockmarket went into freefall, oh well life's a bitch. Company folded, I moved somewhere quiet thinking I'll get stuck onto my engine and finish a game. This didn't happen, couldn't bring myself to code again, one year on and I'm back to my old self and now for the good stuff !!

vortxGE 3.0 is now under going a rewrite for Mac and ios (iPhone, iPad). It will get a slight flow redesign too , almost done. Here is a pic of the new composite Pipeline which is now just a generic Control object subclass, (Not to exciting yet) this will become clear as I update this blog more... Lets just say for now Controls are the building blocks of all subsystems in the engine. A control can be a Game Menu, a Game Level or even a AI process. So my composite Pipleline could just as well be a level really, but not needing all the features of a level of corse. This becomes a far more flexable method of constructing the engine.

more to come...




Easter !

Have a great Easter everyone, I'm offline for 3 weeks. Let the chocolate flow !!



  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!