math-to-OpenGL guide

Hi. Does anyone know of a book or online resource that shows a mathematical expression immediately followed by its code implementation in OpenGL?

Can you explain what sort of maths you want done in GL ? GPU calculations with complex shaders, or plotting a graph, or blending textures ?

Maybe try http://www.gpgpu.org/

Here’s an example of what I have in mind.

Let’s take vector math as an example…
Suppose I’m learning about cross-product (which I am) and I see something in a book that states, given vectors A and B -

the formula for calculating cross-product is:
cross.x = (A.y * B.z) - (B.y * A.z)
cross.y = (A.z * B.x) - (B.z * A.x)
cross.z = (A.x * B.y) - (B.x * A.y)

and the way to express this through OpenGL API functions is (I’m just making something up below, because I have no idea):
GL_VECTOR A
GL_VECTOR B
GL_VECTOR CROSS = glCrossProduct(A, B)

• now I can access my GL_VECTOR.x, GL_VECTOR.y and GL_VECTOR.z values

I’d like to see a lot of core math applied in this way so I can understand how to render different concepts via OpenGL.

I hope this makes sense.
Thanks.

you’re expecting way too much- opengl is not a math library. you have to implement your cross or dot products by yourself or find a freeware library that does.

Most introductory-level graphics API books have a chapter on 3D math. They explain vectors, normals, matrices, translation, rotation and quaternions. They discuss the math involved in the object space/world space calculations.

What I’m looking for is an OpenGL code snippet for each of these math concepts. I want to be able to put the math and the code side-by-side and understand how the graphics API is expressing/displaying the math.

If there’s no such book or online resource, I’ll be sure to write one myself and cash-in once I figure it out.

Sweet! I found exactly what I was looking for.

There’s a GREAT web resource with reams of pages! This resource explains basic to advanced graphics math, each math concept accompanied by the OpenGL function that performs it. It directly relates the math constituents to the OpenGL function’s parameters.

This will be an invaluable aid to a newbie like me.

There is a book/library called OpenGeometry. It might have some things you are looking for.

Which GREAT web resource about maths and opengl you found. Can you post that link on the forum? So that it will be helpfull to all newbies like me.

For those who requested it, below is information about the site I found.
***PLEASE NOTE: Because this site and its materials are accessible through the internet, I’m assuming it is open to the public.

The site is not easy to navigate, nor is the entire site about OpenGL. Therefore, you will need to browse through the URL structure and see what’s of use to you.

Pages 13, 14, 18, 23, 26, 28, 30, 31, 39, … of the following file fit well into what I was looking for:
< http://cs.hofstra.edu/courses/2003/fall/csc171/A/handouts/math/lect54hand.pdf >

I can’t open this site, so i can’t get the resouces.
Could you email me a copy of it?
you can send to my email:
shichongdong80@hotmail.com <2M
or
shichongdong80@gmail.com >2M

hmm… there wasnt much on vector cross or dot products though…