Library: glWrapper

Developed or developing a new product in PureBasic? Tell the world about it.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Library: glWrapper

Post by traumatic »

PUREBASIC glWrapper


With this tiny library you can use all GL-Commands and GLU-Routines
(that originally require doubles) with floats, making them usable
within PureBasic.

It works through simple casting, so values are 'cut'.
Often, the extra-precision isn't needed anyway.

Don't like it? Don't use it!


Note: To use the commands, call them with an additional underscore,
e.g. glOrtho__() instead of glOrtho_().


I wrote this back in june 2002 and finally decided to release this
because I still see lots of questions in the forum regarding OpenGL.
Maybe you'll find this useful. Use at your own risk!



I hope I didn't forget anything important, here's a list of the
wrapped commands and routines:

Code: Select all

	GL Commands :
	-------------

	( only those without corresponding float versions, e.g. you
	  won't find glColor3d() because you can use glColor3f() )

	   glClearDepth()
	   glDepthRange()
	   glClipPlane()
	   glFrustum()
	   glGetClipPlane() 
	   glOrtho()


	GLU Routines :
	--------------
	
	  gluCylinder()
	  gluDisk()
	  gluLookAt()
	  gluOrtho2D()
	  gluPartialDisk()
	  gluPerspective()
	  gluPickMatrix()
	  gluProject()
	  gluSphere()
	  gluTessVertex()
	  gluUnProject()



Get it here: http://files.connection-refused.org/glWrapper.zip
Good programmers don't comment their code. It was hard to write, should be hard to read.
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post by halo »

I get a crash when using GluUnProject(). This function is a little different than most Glu functions because it pokes a double float to the objx,y, and z pointers, which the user then returns. My guess is this is an oversight in the wrapper, since it is a rather advanced command.

gluUnProject
The gluUnProject function maps window coordinates to object coordinates.

int gluUnProject(
GLdouble winx,
GLdouble winy,
GLdouble winz,
const GLdouble modelMatrix[16],
const GLdouble projMatrix[16],
const GLint viewport[4],
GLdouble *objx,
GLdouble *objy,
GLdouble *objz
);
Parameters
winx, winy, winz
The window coordinates to be mapped.
modelMatrix
The modelview matrix (as from a glGetDoublev call).
projMatrix
The projection matrix (as from a glGetDoublev call).
viewport
The viewport (as from a glGetIntegerv call).
objx, objy, objz
The computed object coordinates.
Return Values
If the function succeeds, the return value is GL_TRUE.

If the function fails, the return value is GL_FALSE.

Remarks
The gluUnProject function maps the specified window coordinates into object coordinates using modelMatrix, projMatrix, and viewport. The result is stored in objx, objy, and objz.

Requirements
Windows NT/2000: Requires Windows NT 3.5 or later.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Header: Declared in Glu.h.
Library: Use Glu32.lib.

See Also
glGet, glGetDoublev, glGetIntegerv, gluProject
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

I think it's quite safe to assume you want me to answer your question... ;)


See, there have been about 4300 views of this thread and not even
a single answer (except yours), the lib is 2 years old and I can't find
the source anymore. I don't even do OpenGL anymore 8O

As you said, there's possibly a bug in the lib - I don't know, I never
used neither gluProject() nor gluUnProject() to be honest :)

How do you retrieve the Modelview- / Projection Matrix and the Viewport?
Does this work?
Good programmers don't comment their code. It was hard to write, should be hard to read.
Post Reply