|
Post by Nicky Peter Hollyoake on Dec 25, 2009 15:06:39 GMT -5
I asummed it was for faster performance, but I don't see no improvements. Without glCullFace dim x, y dim fps dim t
glTranslatef(0, 0, -3) 'glEnable(GL_CULL_FACE) 'glCullFace(GL_FRONT) TextMode(TEXT_OVERLAID)
t=tickcount() while TRUE glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) fps=fps+1 if tickcount()-t >= 1000 then t=tickcount() cls print fps fps=0 endif
glRotatef(1, 0, 1, 0) for y = 0 to 179 glBegin(GL_QUAD_STRIP) for x = 0 to 360 if x % 10 = 0 or y % 10 = 0 then glColor3f(1, 0, 0) else glColor3f(0, 0, 1) endif glVertex3f(cosd(x)*sind(y), sind(x)*sind(y), -cosd(y)):y=y+1 glVertex3f(cosd(x)*sind(y), sind(x)*sind(y), -cosd(y)):y=y-1 next glEnd() next DrawText() Swapbuffers() wend With glCullFace dim x, y dim fps dim t
glTranslatef(0, 0, -3) glEnable(GL_CULL_FACE) glCullFace(GL_FRONT) TextMode(TEXT_OVERLAID)
t=tickcount() while TRUE glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) fps=fps+1 if tickcount()-t >= 1000 then t=tickcount() cls print fps fps=0 endif
glRotatef(1, 0, 1, 0) for y = 0 to 179 glBegin(GL_QUAD_STRIP) for x = 0 to 360 if x % 10 = 0 or y % 10 = 0 then glColor3f(1, 0, 0) else glColor3f(0, 0, 1) endif glVertex3f(cosd(x)*sind(y), sind(x)*sind(y), -cosd(y)):y=y+1 glVertex3f(cosd(x)*sind(y), sind(x)*sind(y), -cosd(y)):y=y-1 next glEnd() next DrawText() Swapbuffers() wend I know I could use display lists, but thats the whole point of the test. Whats other peoples opinion, and for those who don't understand how it works, it gets rid of the front/back face of a polygon. Here, look at this. dim x, y dim fps dim t
glTranslatef(0, 0, -3) glEnable(GL_CULL_FACE) glCullFace(GL_FRONT) TextMode(TEXT_OVERLAID)
t=tickcount() while TRUE glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) fps=fps+1 if tickcount()-t >= 1000 then t=tickcount() cls print fps fps=0 endif
glRotatef(1, 0, 1, 0) for y = 0 to 160 glBegin(GL_QUAD_STRIP) for x = 0 to 360 if x % 10 = 0 or y % 10 = 0 then glColor3f(1, 0, 0) else glColor3f(0, 0, 1) endif glVertex3f(cosd(x)*sind(y), sind(x)*sind(y), -cosd(y)):y=y+1 glVertex3f(cosd(x)*sind(y), sind(x)*sind(y), -cosd(y)):y=y-1 next glEnd() next DrawText() Swapbuffers() wend - Nicky
|
|
|
Post by Nicky Peter Hollyoake on Dec 25, 2009 16:29:06 GMT -5
OK. Mixing it with "glPolygonMode" on linemode makes it run faster. dim s=glGenLists(1) dim x, y dim fps dim t
glNewList(s, GL_COMPILE) for y = 0 to 179 glBegin(GL_QUAD_STRIP) for x = 0 to 360 if x % 10 = 0 or y % 10 = 0 then glColor3f(1, 0, 0) else glColor3f(0, 0, 1) endif glVertex3f(cosd(x)*sind(y), sind(x)*sind(y), -cosd(y)):y=y+1 glVertex3f(cosd(x)*sind(y), sind(x)*sind(y), -cosd(y)):y=y-1 next glEnd() next glEndList()
glTranslatef(0, 0, -3) glEnable(GL_CULL_FACE) glCullFace(GL_FRONT) TextMode(TEXT_OVERLAID) ResizeText(10, 10)
t=tickcount() while TRUE glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glRotatef(1, 1, 1, 0) glPolygonMode(GL_FRONT, GL_POINT) glCallList(s) glPolygonMode(GL_FRONT, GL_FILL) fps=fps+1 glViewPort(0, 0, WindowWidth(), WindowHeight()) if tickcount()-t >= 1000 then t=tickcount() cls print fps fps=0 endif DrawText() Swapbuffers() wend Without them all ... dim s=glGenLists(1) dim x, y dim fps dim t
glNewList(s, GL_COMPILE) for y = 0 to 179 glBegin(GL_QUAD_STRIP) for x = 0 to 360 if x % 10 = 0 or y % 10 = 0 then glColor3f(1, 0, 0) else glColor3f(0, 0, 1) endif glVertex3f(cosd(x)*sind(y), sind(x)*sind(y), -cosd(y)):y=y+1 glVertex3f(cosd(x)*sind(y), sind(x)*sind(y), -cosd(y)):y=y-1 next glEnd() next glEndList()
glTranslatef(0, 0, -3) 'glEnable(GL_CULL_FACE) 'glCullFace(GL_FRONT) TextMode(TEXT_OVERLAID) ResizeText(30, 20)
t=tickcount() while TRUE glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glRotatef(1, 1, 1, 0) 'glPolygonMode(GL_FRONT, GL_POINT) glCallList(s) 'glPolygonMode(GL_FRONT, GL_FILL) fps=fps+1 glViewPort(0, 0, WindowWidth(), WindowHeight()) if tickcount()-t >= 1000 then t=tickcount() cls print fps fps=0 endif DrawText() Swapbuffers() wend Other people get faster performance? Is this a good way? - Nicky
|
|
|
Post by aphoticgenesis on Dec 25, 2009 20:39:11 GMT -5
here is how i would do it so you only apply it to specific things:
dim s=glGenLists(1) dim x, y dim fps dim t
glNewList(s, GL_COMPILE) for y = 0 to 179 glBegin(GL_QUAD_STRIP) for x = 0 to 360 if x % 10 = 0 or y % 10 = 0 then glColor3f(1, 0, 0) else glColor3f(0, 0, 1) endif glVertex3f(cosd(x)*sind(y), sind(x)*sind(y), -cosd(y)):y=y+1 glVertex3f(cosd(x)*sind(y), sind(x)*sind(y), -cosd(y)):y=y-1 next glEnd() next glEndList()
glTranslatef(0, 0, -3) TextMode(TEXT_OVERLAID) ResizeText(30, 20)
t=tickcount() while TRUE glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glRotatef(1, 1, 1, 0) glEnable(GL_CULL_FACE) glCullFace(GL_BACK) 'glPolygonMode(GL_FRONT, GL_POINT) glCallList(s) glDisable(GL_CULL_FACE) 'glPolygonMode(GL_FRONT, GL_FILL) fps=fps+1 glViewPort(0, 0, WindowWidth(), WindowHeight()) if tickcount()-t >= 1000 then t=tickcount() cls print fps fps=0 endif DrawText() Swapbuffers() wend
|
|
|
Post by DJLinux on Dec 25, 2009 20:44:41 GMT -5
It's not primary for speed
first it's more a switch
enable front faces only (camera is in front of the house) enable back faces only (camera is inside the house) enable both (useful for transparent glass rendering)
inside the house you can use the same vertexes but with new material or other textures
or if you load two models one is created with clock order triangles the other with counter clock order with the right culling mode you can render both
bla bla bla :-)
Joshy
|
|
|
Post by aphoticgenesis on Dec 25, 2009 21:02:09 GMT -5
It's not primary for speed first it's more a switch enable front faces only (camera is in front of the house) enable back faces only (camera is inside the house) enable both (useful for transparent glass rendering) inside the house you can use the same vertexes but with new material or other textures or if you load two models one is created with clock order triangles the other with counter clock order with the right culling mode you can render both bla bla bla :-) Joshy hes right, but frustum is....its basically checking whether an object is seen in the viewport and not rendering if its not seen
|
|
|
Post by Nicky Peter Hollyoake on Dec 25, 2009 21:07:39 GMT -5
It's not primary for speed first it's more a switch enable front faces only (camera is in front of the house) enable back faces only (camera is inside the house) enable both (useful for transparent glass rendering) inside the house you can use the same vertexes but with new material or other textures or if you load two models one is created with clock order triangles the other with counter clock order with the right culling mode you can render both bla bla bla :-) Joshy Different texture inside? How would I do that. Show me an example of this? - Nicky
|
|
|
Post by DJLinux on Dec 26, 2009 0:58:16 GMT -5
pseudo code if player_in_room then SetRightCullFaces(front_face) glBind(Interieur _texture) else SetRightCullFaces(back_face) glBind(building_textures) end if DrawTheHouse() i'm sure you know it self
|
|
|
Post by Darkjester on Dec 26, 2009 0:58:49 GMT -5
Draw 10000 faces filled with texture, without it, i actually do get a speed increase because, combinding glFrustum/glCullface() i get faster draw rate -darkjester
|
|
|
Post by Wayne Rayner on Dec 26, 2009 1:02:43 GMT -5
This sounds like a lovely OpenGL function that I might use for my latest project.
Ypurs Wayne Rayner
|
|
|
Post by aphoticgenesis on Dec 26, 2009 4:24:23 GMT -5
the glFrustum() function is useless unless you do the proper calculations to go into it
|
|
|
Post by Nicky Peter Hollyoake on Dec 26, 2009 10:48:40 GMT -5
pseudo code if player_in_room then SetRightCullFaces(front_face) glBind(Interieur _texture) else SetRightCullFaces(back_face) glBind(building_textures) end if DrawTheHouse() i'm sure you know it self Oh duh I was expecting you to say you can have a different texture of both sides of a face at the same time. Thanks anyways! - Nicky
|
|
|
Post by Darkjester on Dec 27, 2009 15:16:10 GMT -5
|
|
|
Post by aphoticgenesis on Dec 28, 2009 10:49:45 GMT -5
nice parts darkjester, but dont make it looks so easy, calculating frustum the right way takes an interemediate or advanced programmer, is not as simple as calling the functions with some numbers, its goes way past that if done well
|
|
|
Post by Darkjester on Dec 29, 2009 3:37:23 GMT -5
nice parts darkjester, but dont make it looks so easy, calculating frustum the right way takes an interemediate or advanced programmer, is not as simple as calling the functions with some numbers, its goes way past that if done well theres nothing really advanced about it, you just have to update the values based on position, think of it as part of a more sophisticated camera. -darkjester
|
|
|
Post by aphoticgenesis on Dec 29, 2009 20:23:07 GMT -5
im not talkin about the positions though, im talkin about the actual calculations for objects sizes and angle and all that good stuff
|
|