PDA

View Full Version : Stupid OPENGL

vish_3d
09-19-2009, 10:44 PM
Stupid OPEN GL

OpenGL says retrieve origin coordinate of vertex using pushmatrix,popmatrix.
How stupid.

see the program

double x,y,z;
x=1.1; y=1.2; z=0.5;
glRotate(45,1,0,0); // x axis

glBegin(GL_POINTS)
glVertex3d(x,y,z);
glEnd

I can print x,y,z value (hardcoded) Why push and pop is required
Instead, It should give function to find new cordinate after rotation.

orignal value of vertex x,y,z (no function needed it is hardcoded
i.e. 1.1, 1.2 and 0.5

what is value after rotation.

say function
angle=45
axis = 1;
double nx,ny,nz;
glNewValue(angle,axis,x,y,z,&amp;nx,&amp;ny,&amp;nz); // something like that
(THIS IS IMAGINARY FUNCTION)

so new value (WHICH IS NOT AVAILABLE,WHAT GLROTATE MODIFY X,Y,Z IS NOT KNOWN, SHOULD MAKE KNOWN) AND NOT WHAT IS KNOWN MAKE KNOWN
AGAIN WITH PUSH AND POP.

Regards

Ilian Dinev
09-19-2009, 10:55 PM
Ugh. OpenGL displays stuff, is not your maths-lib.
Make a Mat3x3 class to do your bidding.
A Mat3x3 can only contain rotation info, while a Mat4x4 can contain multiple concatenated rotation/scale/translation/skew/perspective transformations. Which are priceless for hierarchical transformation. Thus OpenGL keeps a stack of Mat4x4, to which you mathematically append transformations. Some transformations go to final MVP matrix, others to the Mat3x3 gl_NormalMatrix, etc etc - which the gpu uses to transform and light vertices.

Jan
09-20-2009, 02:48 AM
Stupid user. RTFM.

V-man
09-20-2009, 04:53 AM
Use a math lib. My lib is at http://www.geocities.com/vmelkon/glhlibrary.html

example:
float myvertex[3], mymatrix[16], myresult[3];