Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6641015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:45:40+00:00 2026-05-25T23:45:40+00:00

I have a running program that uses glVertexPointer, glNormalPointer etc to draw a large

  • 0

I have a running program that uses glVertexPointer, glNormalPointer etc to draw a large number of elements. This works around 30 FPS. Now I’ve reach a point where integrating shaders would be a viable option (each vertex need to have a color calculated based on a specific class).
1. Now my first question is how much would using shaders affect my FPS ? My current implementation (which I’m 99.99% is flawed in at least some way, will post code below) drops the FPS drastically to 3 FPS. If this kind of drop in FPS is normal there is no point to struggle with this.

Now for some code. My shaders look like:

 vertexsource = """
                  attribute vec3 position; 
                  attribute vec3 normal;
                  varying vec3 norm; 
                  varying vec3 color_out;
                  uniform vec3 color_in;

                  void main() 
                  { 
                      gl_Position = gl_ModelViewProjectionMatrix * vec4( position,1);
                      color_out = color_in; 
                      norm = normal;
                  }""" 
fragmentsource = """ 
                  varying vec3 norm; 
                  varying vec3 color_out;
                  void main() 
                  { 
                      gl_FragColor = vec4( color_out, 1.0);
                  }""" 
vshader = compileShader( vertexsource, GL_VERTEX_SHADER )
fshader = compileShader( fragmentsource, GL_FRAGMENT_SHADER )
program = compileProgram( vshader, fshader ) 
color = glGetUniformLocation( program, "color_in")
normal = glGetAttribLocation( program, "normal" )
position = glGetAttribLocation( program, "position" )
glUseProgram( program )
glUniform3fv( color, 3, (0,0,1) )
return position, normal

So I return position and normal because I will use them later to pass the actual vertices and normals. Right from here I have a question. Without shaders I just pass the normals and vertices arrays using VertexPointer and NormalPointer and OpenGL handles the rest.
2. I’ve read that shaders have gl_Vertex and gl_Normal attributes build in. How do I pass the values from my VBO’s to these ? As you can see currently I’m passing my vertexes position to the attribute position and my normals to normal, but I’m not doing anything with the normals as I don’t know what.

The drawing is done like this:

    glEnableVertexAttribArray( self.position )
    glEnableVertexAttribArray( self.normal )      
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.bufferVertices)
    glVertexAttribPointer( self.position, 3, GL_FLOAT, GL_FALSE, 0, None )          
    glEnableClientState(GL_NORMAL_ARRAY);
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.bufferNormals)
    glVertexAttribPointer( self.normal, 3, GL_FLOAT, GL_FALSE, 0, None )
    glDrawElements(GL_TRIANGLES, len(self.triangles) , GL_UNSIGNED_SHORT, ADT.voidDataPointer(self.triangles))

Here self.bufferVertices, self.bufferNormals are VBO’s containg my vertices and normals. self.triangles indices array. It draws the correct indices so far but my FPS is very low as mentioned.

  1. Is this drawing sequence correct? Also are there other things that when enabled could conflict with the shader? (GL_LIGHTNING, GL_DEPTH_TEST and so on)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:45:41+00:00Added an answer on May 25, 2026 at 11:45 pm

    Are you compiling your shader each time you call that function (the first code)?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an automated test running on my program that generates some large MPG
I have a program that is running inside eclipse right now and uses a
I have just converted a program that uses winsock to unicode, and im running
I am looking for a method to monitor a running program that I have
I now have a running Java program which only lacks of the final step,that
I have a Matlab program that is running longer than I'd like it to.
I have been trying to create a Ruby program that will be running online
I have a python script that ends with running a program (iexpress.exe) in a
I have a program in Octave that has a loop - running a function
In my C# program, I have a thread that represents a running test, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.