View Single Post
  #2  
Old 11-14-2008, 01:22 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I don't think you are doing anything wrong. I tried your sample code and my draw time is 0.04 using a GeForce 8800 GTS. This might be an issue with your OpenGL drivers.

FYI, you don't have to create your own elapsed time uniform. OpenSceneGraph supplies the following global uniforms that you can use in any shader:
Code:
int osg_FrameNumber;
float osg_FrameTime;
float osg_DeltaFrameTime;
So you can modify your example to use this global uniform instead:
Code:
import viz
import vizshape

viz.go()
vizshape.addGrid()
viz.MainView.setPosition(0, 1, -5)

vert = """
uniform float osg_FrameTime;

void main() {  
  if( gl_MultiTexCoord0.y > 0.0) {
    gl_Vertex.x += sin(gl_Vertex.x * 0.2 + osg_FrameTime * 1.0) * gl_MultiTexCoord0.y * 0.2;
    gl_Vertex.z += sin(gl_Vertex.y * 0.2 + osg_FrameTime * 1.0) * gl_MultiTexCoord0.y * 0.2;    
  }
  
  gl_FrontColor = gl_Color;
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
"""

shape = vizshape.addQuad()
shader = viz.addShader(vert = vert)
shape.apply(shader)
Reply With Quote