PDA

View Full Version : Stupid OPENGL



vish_3d
09-19-2009, 11: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,&nx,&ny,&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, 11: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, 03:48 AM
Stupid user. RTFM.

V-man
09-20-2009, 05: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];

glhLoadIdentityf2(mymatrix);
glhRotateAboutXf2(mymatrix, 45*CONVERT_TO_RADIANS);

myvertex[0]=1.1; myvertex[1]=1.2; myvertex[2]=0.5;
glhMultiplyMatrixByVector4by4f_2(3, myvertex, mymatrix, myresult);

Another lib on the main page is http://glm.g-truc.net
and there are plenty more here
http://www.gamedev.net/community/forums/forum.asp?forum_id=61

look at the list of free libraries. There are perhaps 100 of them which are for doing math.

and also, the Wiki : what is OpenGL
http://www.opengl.org/wiki/FAQ#What_is_OpenGL.3F