Sign in to follow this  
putenuter

OpenGL From Vertex Shader back to OpenGL-Transformation ?

Recommended Posts

Hi there ! I just have programmed a custom vertex shader for my OpenGL-based game. But now I want to make it run even on graphic cards which are not able to load custom vertex shaders. So I want to compute all necessary transformations on the CPU. My Problem is, that I have to transform ALL Vertices (or Polygons) in my scene by a 4x4-matrix, which has to be recomputed every frame. Does anybody know which OpenGL-methods to use ? Do I have to modify the OpenGL-modelview-matrix or the projection matrix ? I am currently quite desperate about this issue, I hope somebody knows a option how to "migrate" a vertex shader back to the CPU.

Share this post


Link to post
Share on other sites
Quote:
Original post by putenuter
Hi there !

I just have programmed a custom vertex shader for my OpenGL-based game.
But now I want to make it run even on graphic cards which are not able to load custom vertex shaders. So I want to compute all necessary transformations on the CPU.

My Problem is, that I have to transform ALL Vertices (or Polygons) in my scene by a 4x4-matrix, which has to be recomputed every frame.

Does anybody know which OpenGL-methods to use ? Do I have to modify the OpenGL-modelview-matrix or the projection matrix ?

I am currently quite desperate about this issue, I hope somebody knows a option how to "migrate" a vertex shader back to the CPU.


Transform all vertices by a 4x4 matrix? That would very likely be the modelview matrix (load it with glLoadMatrix).
What is the purpose? Camera class? If it's a camera class, then yes, go for modelview.

Share this post


Link to post
Share on other sites
I just have programmed a custom vertex shader for my OpenGL-based game.
But now I want to make it run even on graphic cards which are not able to load custom vertex shaders. So I want to compute all necessary transformations on the CPU.


I think your should pass your computed values by glUniformXX to your shaders, all is according your own program.

To Disable shaders ? glUseProgram(0),please lookup some function in documents

Share this post


Link to post
Share on other sites
First of all, cross-posting is not good.

Second, why do you need a vertex shader for something so simple as transforming the vertices with a matrix? You are aware that vertex shaders is not the beginning of vertex transformations, right? There was life before them. It seems to me that you jumped directly to shaders without understanding the traditional pipeline first. You can compute the matrix and use glLoadMatrix() or glMultMatrix() to load it or multiply it with the current matrix respectively.

Third, what do you mean if you have to use the projection or the modelview matrix? It depends what is it that you want to do. It's probably the modelview, but if you have to ask you need to go back to the Red Book and learn the basics first well before you start messing with such advanced topics as shaders.

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