Skip to main content
GameDev.net gamedev.net
🔒 Locked

render manager

Started by supagu Mar 3, 2004 at 4:19 AM 9 replies 550+ views
Original Post
supagu
supagu
okay, my game updates everything 40 times per second, including the render que, so... traditionaly i have had a model class, and to render something you had to extend the model class, which is pretty limiting. I was thinking of some other way, and thinking function pointers would be nice, but function pointers dont work with OO code do they? any other ideas suggestions appreciated on a more flexible solution.
manuelb
manuelb
Use components, it''s very nice O.O., it''s very flexible. And don''t be afraid of using pointers in O.O., just take care.

Hope that helps.

--------------------------
Rory Gallagher and Chico Science music !!!!!!!
---------------------------
____
||
~~~~
|
/\
TT
--------------------------Rory Gallagher and Chico Science music !!!!!!!---------------------------____||~~~~|/TT
supagu
supagu
eh? more details? component?
rick_appleton
rick_appleton
Function pointers work fine with OO: clicky

And that's one possiblity. Something you might want to look into as your system gets more advanced, is to not let the models render themselves, but let them specify states, and hand of rendering to a seperate Render class/library.

edit: fixed clicky

[edited by - rick_appleton on March 3, 2004 5:41:57 AM]
supagu
supagu
LOL dud link....

supagu
supagu
so:

int(*RenderFn)( Camera& cam )

would work if i had:
int MyClass::Render( Camera& camera )

and
int SomeOtherclass::RendeR( Camera& camera )

?
McZ
McZ
why not create a unified way to render an object and call it something like cRenderAble? and then let the real object fill that class with all needed stuff that your RenderManager needs to render the object correctly.

just my thougths
manuelb
manuelb
Insted of to extend classes, you can put more functions to the object by referencing other objects, by agregation. I''m Sorry if it''s not clear, but my English is not very good. Also, try this book
http://www.amazon.com/exec/obidos/tg/detail/-/0201633612/002-4889295-0257642?v=glance

it''s very, very nice.

--------------------------
Rory Gallagher and Chico Science music !!!!!!!
---------------------------
____
||
~~~~
|
/\
TT
--------------------------Rory Gallagher and Chico Science music !!!!!!!---------------------------____||~~~~|/TT
supagu
supagu
hrmm, doesnt really work if the rendering is highly spcific :-/

rick_appleton
rick_appleton
No, it wouldn''t. But the next piece of code would (give or take a few errors:


class Camera
{
};

class Base
{
virtual void Render (Camera &cam) {};
};

class MyClassA : public Base
{
void Render (Camera &cam) { renderstuffhere };
};

class MyClassB : public Base
{
void Render (Camera &cam) { renderstuffhere };
};


int main()
{
Camera camera;

void (Base::*fncPtr) (Camera &cam) = Base::Render;

MyClassA aInstance;
MyClassB bInstance;

aIntance.(*fncPtr)(camera);
bIntance.(*fncPtr)(camera);

return 0;
}


although I''m not entirely sure the virtual Render functions would be accessed correctly like this. Anyone else care to comment?
supagu
supagu
no point using function pointers in that sample,
and thats currently what i used to do, i had a model class with Render(), but it also had info on meshes and materials, hrmm but it usually needs to be customised....

eg:

Model
{
Material
Matrix
Mesh
- polys
- default material(read from file)
}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.