Sign in to follow this  
JamesCobras

OpenGl Matrices?!

Recommended Posts

When i was using Directx, i could fiddle with matrices and get exactly the results i wanted. But since beginning OpenGL i have found no way to deal with matrices like in directx. I have done several google searches but have found no list of functions that generate and manipulate the matrices. Can i have a link or something to these function please? Or do these functions not exist and i have to find some way of hacking it with the: glTranslatef glRotatef etc... functions. I'm programming in c++ How am i supposed to do things like animation if i cannot create and handle matrices efficiently through openGL Any comments welcome. JamesCobras

Share this post


Link to post
Share on other sites
Functions like glTranslatef, glRotatef and others have been removed from OpenGL.
Start by reading the specification.
You are supposed to to do the matrix calculation yourself or use a library like GLM and assign the result to a uniform or do the calculations directly in the shader.

Quote:
Original post by JamesCobras
How am i supposed to do things like animation if i cannot create and handle matrices efficiently through openGL

OpenGL is a low level API to make use of the GPU, libraries for linear algebra are available separately, easy to use ones like GLM or heavily optimized ones like Intel MKL.

Share this post


Link to post
Share on other sites
I'm trying to find the functions in OpenGl that are similar to directx, and i can't believe that matrices aren't part of of OpenGl, as they are for Directx.

Which functions should i be using if not

glTranslatef
glRotatef

It's what NeHe uses, what should i do instead?

JamesCobras

Share this post


Link to post
Share on other sites
You can construct your own matrices (manually or with a third party library) and then use glMutlMatrixf() to apply it. Some additional matrix functions are provided by GLU.

Can you give us more specific examples of which functions you want to be able to use?

Share this post


Link to post
Share on other sites
Use GLM.
As I said OpenGL is a low level API and it has a very specific task. It let you tell the GPU what to do. Matrix operation that are performed on CPU (in contrasted to the GPU) have nothing to do with OpenGL just like there is no function to read a texture from a file.
If OpenGL is too low level for you use a game engine that (should) contain such utility functions or use libraries like GLM.
Also it takes just few hours to write some matrix and vector classes.

NeHe tutorials are very old. Some new tutorials were written by I don't know where they are. Some OpenGL 3.2 samples can be found here:
http://nopper.tv/opengl_3_2.html

Note that many other things have also changed, the whole fixed function pipeline has been removed. In OpenGL 3.2 you have to use shaders.
This does not mean that the functions are not there, you can learn from NeHe and use all those deprecated functions but keep in mind that the tutorial are for OpenGL 1.5 or like that.
Quote:
Original post by rip-off
You can construct your own matrices (manually or with a third party library) and then use glMutlMatrixf() to apply it. Some additional matrix functions are provided by GLU.

MultMatrix was also removed in OpenGL 3.2 .

Share this post


Link to post
Share on other sites
multimatrix() and the other matrix function that i found is the exact kind of function that i was looking for, cheers!

However i believe this is only in OpenGL 3.0 and below.

I had a look at the specification of OpenGL 3.2 and found no way of transforming anything. as i'm new to opengl is there anything i'm missing, how are you supposed to deal with transforms with no functions to do it?

JamesCobras

Share this post


Link to post
Share on other sites
Quote:
I had a look at the specification of OpenGL 3.2 and found no way of transforming anything. as i'm new to opengl is there anything i'm missing, how are you supposed to deal with transforms with no functions to do it?
As mentioned earlier, you build the transform matrices yourself and assign them to a shader constant, or construct the matrix within the shader program itself.

If you're talking about functions like D3DXMatrixWhatever(), part of the problem is that you're comparing apples and oranges. OpenGL and Direct3D are roughly comparable, but DirectX is a larger framework (for which there is no direct equivalent for OpenGL) that encompasses sound, input, and a number of conveniences such as mesh handling and 3-d math.

Unfortunately, with OpenGL, you kind of have to cobble those functionalities together from different libraries, or use a higher-level engine that takes care of the details for you.

To answer your question though, again, you build the transforms yourself, using an existing math library or your own math code.

Share this post


Link to post
Share on other sites
Yep, sorry when i said Directx i meant Direct3D.

I thought the matrix functions were included in that... sounds like they were not so sorry for the original post looking like comparing two different things.

Cheers for the help and clearing things up.

Better start building up my code and start work with matrices.

JamesCobras

Share this post


Link to post
Share on other sites
Quote:
Original post by JamesCobras
i can't believe that matrices aren't part of of OpenGl, as they are for Directx


Matrices are not directly a part of Direct3D, they never have been instead Microsoft provides a library called D3DX which houses various helper functions, interfaces and structures such as D3DXMATRIX or D3DXSprite, D3DXMesh and so on and so forth. All of which can be replaced by your own classes, functions etc (for nonserious projects i like to try and replace some of the functionality provided by D3DX with my own code for practice, very fun :P).

I would'nt know because i dont use OpenGl but this GLM library seems to be a replacement for D3DX Matrices in terms of OpenGL so do what the guys are saying here, and download it already :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Kambiz


NeHe tutorials are very old. Some new tutorials were written by I don't know where they are. Some OpenGL 3.2 samples can be found here:
http://nopper.tv/opengl_3_2.html

Sorry for asking:

I know, i'm not wasting my time learning from old tutorials, but regarding to learning curve, would you suggest to use tutorials about newer versions of OpenGL?

Share this post


Link to post
Share on other sites
I don't know whether any newer and good tutorials are available but you can try searching for some. You need to start somewhere and learn the basic concepts that are mostly independent of the API. After getting some experience you can keep yourself up to date by reading the specifications and publications.
Shading, lighting, shadowing techniques, animation, post processing effects,... are techniques that you can learn independent of the API.

Both OpenGL and Direct3D basically let you render triangles. Learning the API itself is not such a big deal. Just keep reading and programming.

[Edited by - Kambiz on March 8, 2010 3:52:30 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this