Results 1 to 5 of 5

Thread: shaders and GL_POINT_SPRITE_ARB

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2008
    Posts
    17

    shaders and GL_POINT_SPRITE_ARB

    I am working on a project that uses point sprites as rendering primitives. I want to manipulate output using vertex and fragment programs and can't seem to get them working together. Using Cg lib and compilation goes without errors. Here is my code, so please tell me what I am doing wrong.

    Code :
    Gl.glEnable(Gl.GL_BLEND);
    Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA); //set the blend function				
     
    float[] mat = new float[16];
     
    Gl.glPointSize(60);
     
    float[] quadratic =  { 1, 0f, 0.01f };			
    Gl.glPointParameterfvARB(Gl.GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic);
    Gl.glPointParameterfARB(Gl.GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f);
     
    float maxSize = 0.0f;
    Gl.glGetFloatv(Gl.GL_POINT_SIZE_MAX_ARB, out maxSize);
    Gl.glPointParameterfARB(Gl.GL_POINT_SIZE_MIN_ARB, 1.0f);
    Gl.glPointParameterfARB(Gl.GL_POINT_SIZE_MAX_ARB, maxSize);
     
    Gl.glTexEnvf(Gl.GL_POINT_SPRITE_ARB, Gl.GL_COORD_REPLACE_ARB, Gl.GL_TRUE);					
    Gl.glEnable(Gl.GL_POINT_SPRITE_ARB);
    Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture[0]);
     
    Gl.glDepthMask(Gl.GL_FALSE);
     
    // Track the combined model-view-projection matrix			
    CgGl.cgGLSetStateMatrixParameter(m_CGparam_modelViewProj,
    										CgGl.CG_GL_MODELVIEW_PROJECTION_MATRIX,
    										CgGl.CG_GL_MATRIX_IDENTITY);
    checkForCgError("setting state matrix parameter");
     
    Gl.glGetFloatv(Gl.GL_MODELVIEW_MATRIX, mat);
     
    Vector3f vRight = new Vector3f(mat[0], mat[4], mat[8]);
    Vector3f vUp = new Vector3f(mat[1], mat[5], mat[9]);
    Vector3f vCenter = new Vector3f(0.0f, 0.0f, 0.0f);
     
    SetShaderParameters();
    EnableShaders();
     
    //render
    Gl.glTranslatef(ViewerPosition.x, ViewerPosition.y, ViewerPosition.z - 100);
    Gl.glColor3f(1, 1, 0);
    Point3D centerPoint = new Point3D(25, -25, 0);
     
     
    Gl.glBegin(Gl.GL_POINTS);
    Gl.glVertex3f(centerPoint.x - 25, centerPoint.y - 25, 0);
    Gl.glVertex3f(centerPoint.x + 25, centerPoint.y - 25, 0);
    Gl.glVertex3f(centerPoint.x + 25, centerPoint.y + 25, 0);
    Gl.glVertex3f(centerPoint.x - 25, centerPoint.y + 25, 0);
    Gl.glEnd();
     
    Gl.glPopMatrix();
     
    //Gl.glCallList(lidarDisplList);
    Gl.glDepthMask(Gl.GL_TRUE);
     
    Gl.glDisable(Gl.GL_POINT_SPRITE_ARB);
     
    DisableShaders();

    shader load function - no errors
    Code :
    CgGl.cgGLBindProgram(m_CGp_vertexProgram);
    			checkForCgError("binding vertex program");
     
    			CgGl.cgGLEnableProfile(m_CG_vertexProfile);
    			checkForCgError("enabling vertex profile");
     
    			CgGl.cgGLBindProgram(m_CGp_fragmentProgram);
    			checkForCgError("binding fragment program");
     
    			CgGl.cgGLEnableProfile(m_CG_fragmentProfile);
    			checkForCgError("enabling fragment profile");

    shader disable function
    Code :
    		CgGl.cgGLDisableProfile(m_CG_fragmentProfile);
    			checkForCgError("disabling fragment profile");
     
    			CgGl.cgGLDisableProfile(m_CG_vertexProfile);
    			checkForCgError("disabling fragment profile");

  2. #2
    Junior Member Newbie
    Join Date
    Jun 2008
    Posts
    17

    Re: shaders and GL_POINT_SPRITE_ARB

    maybe I was a little to vague in description of the problem. When I run the program without enabling and disabling shaders the point sprite rendering works fine. An drawing normal points and with shaders enabled also works. It's just when I try to mix them the application draws blank screen.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2008
    Posts
    17

    Re: shaders and GL_POINT_SPRITE_ARB

    my mistake, sorry. shaders are working, I was just setting modelviewprojection matrix too early. I have a bigger problem now. All my points are rendered as normal points. Could be they are point sprites, but they are as small as normal points. Point distance attenuation is not working or something. Help?

  4. #4
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,294

    Re: shaders and GL_POINT_SPRITE_ARB

    You have to enable GL_VERTEX_PROGRAM_POINT_SIZE_ARB.

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2008
    Posts
    17

    Re: shaders and GL_POINT_SPRITE_ARB

    just figured this one out, thanks anyway

Similar Threads

  1. Replies: 7
    Last Post: 08-11-2012, 01:52 PM
  2. Shaders and VBO
    By Pedro Xavier Contla in forum OpenGL: GLSL
    Replies: 2
    Last Post: 02-13-2012, 09:17 AM
  3. rotating GL_POINT_SPRITE_ARB
    By milankoko in forum OpenGL: GLSL
    Replies: 10
    Last Post: 07-01-2008, 08:45 AM
  4. GL_POINT_SPRITE_ARB and glsl
    By azcoder in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 10-10-2007, 12:13 AM
  5. q3 like shaders
    By Lev in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 12-28-2000, 02:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean