PDA

View Full Version : Layers



MemLeak
03-12-2003, 11:18 AM
Hi guys!

I'm creating a CAD Application with opengl. I would like to have the possibility to display every objects or only some of them. Some kind of layers I guess.

So I would like to have an idea to start with...

Thanks for helping

Regards

Antorian
03-12-2003, 12:33 PM
I don't think your problem is purely about OpenGL.
It's only the way you made your code that will allow you to perform several layers.
ie: use pointer list on Object (header list references the layer) and render only the list you have selected.
For CAD design it's obvious that object aren't cast by Z axes but by layers.
So look for a way to sort your object in your code and render only selected lists(or layers).
May be I'm wrong , or I could have not correctly understood your question.
Sorry for my poor English http://www.opengl.org/discussion_boards/ubb/smile.gif

rgpc
03-12-2003, 06:15 PM
*sigh* http://www.opengl.org/discussion_boards/ubb/frown.gif





if (ptrObj->bVisible)
ptrObj->Draw();

jwatte
03-12-2003, 07:06 PM
Here's how I would try doing it (first go; don't know if I'd have to re-factor it later)





template< class T > class LayerDraw {
public:
LayerDraw( LayerWhich const & lw ) : lw_( lw ) { }
void operator()( T::iterator ptr ) {
if( lw_.layerVisible( *ptr ) ) {
for_each( (*ptr).items_.begin(), (*ptr).items_.end(), ItemDraw() );
}
}
private:
LayerWhich const & lw_;
};


for_each( layers.begin(); layers.end(); LayerDraw( which ) );



Trivia quiz: how much OpenGL is in this code snippet?

rgpc
03-12-2003, 07:33 PM
Trivia quiz: how much OpenGL is in this code snippet?

There's three answers to your trivia quiz...

1. If you take ope out of "operator", then n and g out of "begin" and finally l out of "layervisible" then you've got opengl...

2. If your engine is based on opengl then it must be entirely opengl based so it's valid...

3. A BIG fat None (Aka as per usual)

Perhaps it's actually an advanced question so it doesn't need to have opengl in it.


Ps. Oooh STL... http://www.opengl.org/discussion_boards/ubb/wink.gif

[EDIT] Stoopid quotes...

[This message has been edited by rgpc (edited 03-12-2003).]