Access OpenGL State Variables in Cg

I need to access OpenGL state variables (such as MVP matrices) in my Cg shader program. I pass these values ​​to my Cg shader program manually using calls such as cgGLSetStateMatrixParameter()in my C / C ++ code. Is there an easier way to do this?

+3
source share
1 answer

If you use some fairly recent Cg profile (arbvp1 and later), your Cg shader programs can actually access the OpenGL state (MVP matrices, material and light parameters) directly. This makes recording these programs less painful.

Here are some of the state variables that can be accessed:

MVP matrices of all types:

state.matrix.mvp
state.matrix.inverse.mvp
state.matrix.modelview
state.matrix.inverse.modelview
state.matrix.modelview.invtrans
state.matrix.projection
state.matrix.inverse.projection

:

state.material.ambient
state.material.diffuse
state.material.specular
state.light[0].ambient

. OpenGL, OpenGL ARB Vertex (arbvp1) Cg.

:

  • OpenGL Cg.
  • . (: 1 state.light [1].ambient)
  • Cg. glLight().
+4

Source: https://habr.com/ru/post/1696430/


All Articles