GLBasic forum

Codesnippets => 3D-snippets => Topic started by: MrTAToad on 2009-Oct-29

Title: Wireframe mode
Post by: MrTAToad on 2009-Oct-29
Would be nice if there was a wireframe mode for objects.
Title: Re: Wireframe mode
Post by: Schranz0r on 2009-Oct-29
Take a look at : X_GETFACE
Title: Re: Wireframe mode
Post by: MrTAToad on 2009-Oct-29
Thats true - the only problem is that X_LINE could do with being sped up a bit.  The larger object would be slower to display than a native command.
Title: Re: Wireframe mode
Post by: Quentin on 2009-Oct-29
It is quite easy to use wireframe mode, if you use the OpenGL-Wrapper from Gernot

in the following example you'll have to add the files
3DPrimitives.gbas
gl.gbas
to your project and you can see the torus in wireframe mode

Code (glbasic) Select

CreateTorus(0, 2, 5, 20, 4, 0, 0, RGB(255, 255,255))

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)

WHILE TRUE
X_MAKE3D .1, 1000, 45
X_CAMERA 2, 2, -20, 0, 0, 0
X_AMBIENT_LT 0, RGB(255, 255, 255)
X_ROTATION phi, 1, 1, 0
X_DRAWOBJ 0, 0
INC phi, .2
SHOWSCREEN
WEND


you can switch back to filled mode easily with

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
Title: Re: Wireframe mode
Post by: MrTAToad on 2009-Oct-29
Ah, thats handy!
Title: Re: Wireframe mode
Post by: Quentin on 2009-Oct-29
by the way: as it seems that glPolygonMode is what X_CULLMODE is in GLBasic  ...

what about a second optional paramter for X_CULLMODE? e.g.  X_CULLMODE mode%, wire% = FALSE
Title: Re: Wireframe mode
Post by: bigsofty on 2009-Oct-29
Word to the wise, be aware that glPolygonMode is not available in OpenGLES, so anything off of a desktop probably does not support this code...
Title: Re: Wireframe mode
Post by: Quentin on 2009-Oct-30
hi Ocean,
sure, it's also possible to use these functions within the loop.

Code (glbasic) Select

CreateTorus(0, 2, 5, 20, 4, 0, 0, RGB(255, 255,255))
CreateSphere(1, 2, 10, RGB(255, 255, 255))

WHILE TRUE
X_MAKE3D .1, 1000, 45
X_CAMERA 2, 2, -20, 0, 0, 0
X_AMBIENT_LT 0, RGB(255, 255, 255)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
X_ROTATION phi, 1, 1, 0
X_DRAWOBJ 0, 0
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
X_MOVEMENT 0, 0, 2
X_ROTATION phi, 1, 0, 1
X_DRAWOBJ 1, 0
INC phi, .2
SHOWSCREEN
WEND


see also documentation here
http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/polygonmode.html (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/polygonmode.html)