Author Topic: Wireframe mode  (Read 4479 times)

MrTAToad

  • Guest
Wireframe mode
« on: 2009-Oct-29 »
Would be nice if there was a wireframe mode for objects.

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5014
  • O Rly?
    • View Profile
Re: Wireframe mode
« Reply #1 on: 2009-Oct-29 »
Take a look at : X_GETFACE
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

MrTAToad

  • Guest
Re: Wireframe mode
« Reply #2 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.

Offline Quentin

  • Prof. Inline
  • *****
  • Posts: 915
    • View Profile
Re: Wireframe mode
« Reply #3 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)
« Last Edit: 2009-Oct-29 by Quentin »

MrTAToad

  • Guest
Re: Wireframe mode
« Reply #4 on: 2009-Oct-29 »
Ah, thats handy!

Offline Quentin

  • Prof. Inline
  • *****
  • Posts: 915
    • View Profile
Re: Wireframe mode
« Reply #5 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

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2613
    • View Profile
Re: Wireframe mode
« Reply #6 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...
« Last Edit: 2009-Oct-29 by bigsofty »
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline Quentin

  • Prof. Inline
  • *****
  • Posts: 915
    • View Profile
Re: Wireframe mode
« Reply #7 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
« Last Edit: 2009-Oct-31 by Quentin »