Quadric Draw Styles

BlitzMax Forums/BlitzMax OpenGL Programming/Quadric Draw Styles

I maybe missing something out with this example test with the preset shapes, and would love to know what's up with it.

Can anyone see why this code wont render the sphere with the QuadricDrawStyle command?

'----------------------------------
' pre built shapes testies
' SPHERE with Quadric Line Drawing
' thanks: Nehe / Extron / BB & Co.
'---------------------------------- 

Const XRES=640
Const YRES=480
Const RRES= 16

bglCreateContext(XRES,YRES,RRES,0,BGL_BACKBUFFER | BGL_DEPTHBUFFER | BGL_FULLSCREEN)
HideMouse


'
' The Variables
'
Global quadratic:Int Ptr													' Storage For Our Quadratic Objects

Global LightAmbient:Float[]=	[0.5, 0.5, 0.5, 1.0]
Global LightDiffuse:Float[]=	[1.0, 1.0, 1.0, 1.0]
Global LightPosition:Float[]=	[0.0, 0.0, 2.0, 1.0]

Global Texname:Int[3]													' Storage For 3 Textures

Global xrot:Float
Global yrot:Float
Global zrot:Float

InitOpenGL()


'
' the main program loop. 												
'
While Not KeyHit(KEY_ESCAPE) Or MouseHit(1)

	RenderOpenGL	()
	bglSwapBuffers	()
Wend



Function RenderOpenGL()

	glClear 			(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)			' Clear Screen And The Depth Buffer
	glLoadIdentity		()											' Reset Current Modelview Matrix
	glTranslatef		(0.0,0.0,-5)
	glRotatef			(xrot,1.0,0.0,0.0)
	glRotatef			(yrot,0.0,1.0,0.0)
	glRotatef			(zrot,0.0,0.0,1.0)
	glBindTexture		(GL_TEXTURE_2D, Texname[0])
	
	gluQuadricDrawStyle	(quadratic,GLU_LINE)
	gluSphere			(quadratic,1.0,32,32)							' Draw A Sphere 

	xrot:+.1
	yrot:+.1
	zrot:+.1
	
End Function



Function InitOpenGL()
	
	LoadGlTextures		()
	glEnable			(GL_TEXTURE_2D)									' Enable Texture Mapping
	glShadeModel		(GL_SMOOTH)										' Enable Smooth Shading
	glClearColor		(0.0, 0.0, 0.0, 0.5)								' Black Background
	glClearDepth		(1.0)											' Depth Buffer Setup
	glEnable			(GL_DEPTH_TEST)									' Enables Depth Testing
	glDepthFunc		(GL_LEQUAL)										' The Type Of Depth Testing To Do
	glHint			(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)				' Really Nice Perspective 

	glLightfv			(GL_LIGHT1, GL_AMBIENT, LightAmbient)					' Setup The Ambient Light
	glLightfv			(GL_LIGHT1, GL_DIFFUSE, LightDiffuse)					' Setup The Diffuse Light
	glLightfv			(GL_LIGHT1, GL_POSITION,LightPosition)					' Position The Light
	glEnable			(GL_LIGHT1)										' Enable Light One

	quadratic			=Int Ptr gluNewQuadric()								' Create Pointer To Quadric Object 
	
	gluQuadricNormals	(quadratic, GLU_SMOOTH)								' Create Smooth Normals
	gluQuadricTexture	(quadratic, GL_TRUE)								' Create Texture Coords

	glViewport		(0,0,XRES,YRES)									' Set viewport
	glMatrixMode		(GL_PROJECTION)									' Select The Projection Matrix
	glLoadIdentity		()												' Reset The Projection Matrix
	gluPerspective		(45.0,Float(XRES)/Float(YRES),0.1,100.0)				' Calculate Aspect Ratio 
	glMatrixMode		(GL_MODELVIEW)										' Select The Modelview Matrix
	glLoadIdentity		()

End Function 



Function LoadGLTextures()
	
	Local Text:TPixmap =LoadPixmap("media/texture1.png")

	glGenTextures(1, Varptr Texname[0])									' Create a Texture
	
	
	'
	' Create a MipMapped Texture
	'
	glBindTexture		(GL_TEXTURE_2D, Texname[0])
	glTexParameteri	(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	glTexParameteri	(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
	gluBuild2DMipmaps	(GL_TEXTURE_2D, 3, Text.width, Text.height, GL_RGB, GL_UNSIGNED_BYTE, Text.pixels)

End Function


Thanks,
Thumbz

Maybe a bug!

The first thing I've found is GLU_SMOOTH and GLU_LINE aren't actually defined anywhere!!! Which means they are zreo.

Try putting

Strict

at the top of your programs to see any variables/functions that are not given any value etc.

Looking into now for ya..............

Colonel
NRG Studio

Cheers Col! :)

I added Strict and it told me that the identifier GLU_LINE was not found.

Maybe I've got it inputted wrong???
gluQuadricDrawStyle (quadratic, GLU_LINE )



Thanks for checking it out!

I've found some values :)

GLU_POINT = 100010
GLU_LINE = 100011
GLU_FILL = 100012
GLU_SILHOUETTE = 100013

Works for me :)

Also you'll need these

GLU_SMOOTH = 100000
GLU_FLAT = 100001
GLU_NONE = 100002

Have fun

Thanks mate!
So it this then a bug in BMAX?

Dunno mate. Only got bmax yesterday ! Still finding me feet as to what is included and what isn't.

Looks like BRL forgot to include them though eh!!!!

I've only had it a few days too myself.
A big change in the approach.

Thanks for finding those values out mate!
Nice one :)

The reason why we don't have 'native' access to those parameters is because in the opengl.bmx file they are all REM'd out!!!!

Don't know why?? Is there anything we can do??

Anyone????

It's defined in glu.h under folder GL in glew.mod

@Extron:

I checked this and it looks like glew.mod doesn't load in glu.h . It looks like it will if you have a MAC but not pc!!

In the opengl.bmx file the constants are actually commented out!!

I'm still getting into this so I might be wrong?

This does need to be resolved though!

Cheers

It's not commented for me in opengl.bmx

Really? I'm on PC. You?

The ModuleInfo shows version 1.00

Is yours the same? I'm talking about 'mod/pub.mod/opengl.mod/opengl.bmx'

Regards

Sorry your are right (long block of rem :) ).
But it's defined Global and not constante.

Any answers on a postcard to why these Open GL extensions arent properly introduced into BMAX yet (On Win OS)?