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

Open GL faces

Started by real_man Sep 18, 2000 at 3:38 PM 4 replies 250+ views
Original Post
real_man
real_man
to draw a cube in OpenGL you need something like this.... glBegin(GL_QUADS); glColor3f(0.0f,1.0f,0.0f); glVertex3f( 1.0f, 1.0f,-1.0f); glVertex3f(-1.0f, 1.0f,-1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glVertex3f( 1.0f,-1.0f, 1.0f); glVertex3f(-1.0f,-1.0f, 1.0f); glVertex3f(-1.0f,-1.0f,-1.0f); glVertex3f( 1.0f,-1.0f,-1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glVertex3f(-1.0f,-1.0f, 1.0f); glVertex3f( 1.0f,-1.0f, 1.0f); glVertex3f( 1.0f,-1.0f,-1.0f); glVertex3f(-1.0f,-1.0f,-1.0f); glVertex3f(-1.0f, 1.0f,-1.0f); glVertex3f( 1.0f, 1.0f,-1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glVertex3f(-1.0f, 1.0f,-1.0f); glVertex3f(-1.0f,-1.0f,-1.0f); glVertex3f(-1.0f,-1.0f, 1.0f); glVertex3f( 1.0f, 1.0f,-1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glVertex3f( 1.0f,-1.0f, 1.0f); glVertex3f( 1.0f,-1.0f,-1.0f); glEnd(); Basicly you have to set the vertexs for every face. Is there a way to share the faces... Like say I got glBegin(GL_QUADS); glColor3f(0.0f,1.0f,0.0f); glVertexnum (1) glVertex3f(-1.0f,-1.0f,-1.0f); glVertexnum (2) glVertex3f( 1.0f,-1.0f,-1.0f); glVertexnum (3) glVertex3f( 1.0f, 1.0f,-1.0f); glVertexnum (4) glVertex3f(-1.0f, 1.0f,-1.0f); glVertexnum (5) glVertex3f(-1.0f,-1.0f, 1.0f); glVertexnum (6) glVertex3f( 1.0f,-1.0f, 1.0f); glVertexnum (7) glVertex3f( 1.0f, 1.0f, 1.0f); glVertexnum (8) glVertex3f(-1.0f, 1.0f, 1.0f); gl??? (1,2,3) //face number 1 //front gl??? (2,3,4) //face number 2 //front gl??? (5,6,7) //face number 3 //back gl??? (6,7,8) //face number 4 //back gl??? (1,3,5) //face number 5 //left gl??? (3,5,7) //face number 6 //left gl??? (2,4,6) //face number 7 //right gl??? (4,6,8) //face number 8 //right gl??? (3,4,7) //face number 9 //top gl??? (4,7,8) //face number 10//top gl??? (1,2,5) //face number 11//bottom gl??? (2,5,6) //face number 12//bottom glEnd(); but this time I only have the 8 required vertexes but there shared instead of having every quad have it''s own vertex. gl??? and glVertexnum are hypothetical commands I am not sure exist. Is there a way to set polygons on to selected vertexes like the above example? The reason why I want to do it that way is it saves memory(for large objects) but requires more processing power. any ideas? maybe I should just do it the conventional way
Snale
Snale
You could make a display list out of it alla and just use

glCallList( listhandle );

and it would be drawn..

Or you could use quadstrips, to share vertices between faces. The catch is that the quads must be sent to Gl in correct order, otherwise you can get really weird results.

To use quadstrips you write:

glBegin( GL_QUAD_STRIP ); instead of glBegin( GL_QUADS );



Snale
+--Java Game

Edited by - Snale on September 18, 2000 5:41:10 PM
Galileo430
Galileo430
Ok I have 2 bones to pick.

1) No there is no gl??? function that will let you do what you want it to do. You would have to write your own.

2) Most 3d hardware does not support GL_QUADS and if it does it''s slow. If you want to draw things use triangles (GL_TRIANGLES). It''s good to get used to it from the start. If you step into D3D there is no QUAD function (I think I heard that somewhere).
------------------------------------------------------------I wrote the best video game ever, then I woke up...
real_man
real_man
I realize that....In my program I use GL_TRIANGLE but I used GL_QUADS for simplicity

One more thing. Where can I get a OGL reference as good as the one for direct3d?

It seems like there isn''t much decriptions about what each function does.(maybe I just havn''t been to the right places)
zedzeek
zedzeek
urrrggg try vertex arrays, lookup glDrawElements etc i wrote a short demo a couple of days ago that uses them check out the cva extension here http://members.xoom.com/myBollux it draws the same object (a star) immediately and also with drawelements
zedzeek
zedzeek
urrrggg try vertex arrays, lookup glDrawElements etc i wrote a short demo a couple of days ago that uses them check out the cva extension here http://members.xoom.com/myBollux it draws the same object (a star) immediately and also with drawelements

Topic Locked

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

Sign in to reply to this topic.