Advertisement

ditching glu

Started by December 21, 2001 01:30 AM
18 comments, last by alargeduck 23 years, 2 months ago
i wanna ditch GLU from my projects. gluBuild2DMipmaps() should be easy to replace, but i have no clue what to do with gluPerspective(). Im guessing glFrustrum()?
I''m thinking yeah. Not really sure why gluPerspective would even exist if it were that simple though...

Later,
ZE.

[twitter]warrenm[/twitter]

Advertisement
glFrustrum and gluPerspective do the same thing. They just take different input.
I''m just curious why you would want to ditch GLU. IMHO It''s very useful, and it would be pretty unnecessary to implement the GLU functions yourself. Of course it won''t hurt to know how they work ''under the hood''.

Yes, you would use glFrustum instead of glPerspective. I seem to remember reading about an implementation for gluPerspective in either the Red Book or the Blue Book (both are available online in the "OpenGL" section of the "Articles & Resources" here at gamedev).

Surpringly, the Red Book recommends not using glFrustum.

------------------------------
Trent (ShiningKnight)
E-mail me
"Whoso is a man, is a nonconformist"
--Ralph Waldo Emerson
Download MESA''s source for a sample implementation, it contains a lot of interesting stuff.

go there: http://www.mesa3d.org/

Advertisement
I suspect the only reason the red book discourages using glFrustum is because if you get it wrong, things look very wierd. But like Kefdman says ... check out the Mesa source code.

  static voidfrustum(GLdouble left, GLdouble right,        GLdouble bottom, GLdouble top,         GLdouble nearval, GLdouble farval){   GLdouble x, y, a, b, c, d;   GLdouble m[16];   x = (2.0 * nearval) / (right - left);   y = (2.0 * nearval) / (top - bottom);   a = (right + left) / (right - left);   b = (top + bottom) / (top - bottom);   c = -(farval + nearval) / ( farval - nearval);   d = -(2.0 * farval * nearval) / (farval - nearval);#define M(row,col)  m[col*4+row]   M(0,0) = x;     M(0,1) = 0.0F;  M(0,2) = a;      M(0,3) = 0.0F;   M(1,0) = 0.0F;  M(1,1) = y;     M(1,2) = b;      M(1,3) = 0.0F;   M(2,0) = 0.0F;  M(2,1) = 0.0F;  M(2,2) = c;      M(2,3) = d;   M(3,0) = 0.0F;  M(3,1) = 0.0F;  M(3,2) = -1.0F;  M(3,3) = 0.0F;#undef M   glMultMatrixd(m);}void GLAPIENTRYgluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar){   GLdouble xmin, xmax, ymin, ymax;   ymax = zNear * tan(fovy * M_PI / 360.0);   ymin = -ymax;   xmin = ymin * aspect;   xmax = ymax * aspect;   /* don''t call glFrustum() because of error semantics (covglu) */   frustum(xmin, xmax, ymin, ymax, zNear, zFar);}  


From the Mesa Lib

Regards
Basically i just wanna know how to do things without glu.. an for some reason (stupid i know) i cant justify linking with glu when im only using two functions out of it.

Every byte shaved off counts, especially if someday i have to code a demo in 64k to safe my life...
Ah, more demo-lovers on this forum . Now that I think of it : has anyone a good link to a tutor how to make (opengl) programs as small as possible? Guess just using an executable-packer won''t do the trick....
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.
From Quake 1 source:

  void MYgluPerspective( GLdouble fovy, GLdouble aspect,		     GLdouble zNear, GLdouble zFar ){   GLdouble xmin, xmax, ymin, ymax;   ymax = zNear * tan( fovy * M_PI / 360.0 );   ymin = -ymax;   xmin = ymin * aspect;   xmax = ymax * aspect;   glFrustum( xmin, xmax, ymin, ymax, zNear, zFar );}  

This topic is closed to new replies.

Advertisement