Jump to content
  • Advertisement
Sign in to follow this  

OpenGL glRasterPos - crash

This topic is 4786 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to write a modelling program, but the program just became to big (more than 10000 lines I guess) and unstructured. So I tried to structurize the whole mess. Now my program craches when I try to execute it. I have isolised the code where the error occurs:
        // OpenGL Settings
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);      // blending mode
        glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);                // line mode
        glShadeModel(GL_SMOOTH);                                // Enable smooth shading
        glClearDepth(1.0f);                                     // Depth buffer setup
        glEnable(GL_DEPTH_TEST);                                // Enables depth testing
        glDepthFunc(GL_LEQUAL);                                 // The type of depth testing to do
        glEnable(GL_SCISSOR_TEST);                              // only pixels in box will be affected (standard)

while(!win.getQuitMessage() && *win.errorTitle=='\0')
            // Code for reading input
            //Set viewport
            glViewport (0, 0, 800, 720);
            glMatrixMode(GL_PROJECTION);           // reset projection matrix
            glOrtho(-2.0f, 2.0f, -2.0f, 2.0f, 1.0f, -1.0f);
            glClearColor(0.72f, 0.72f, 0.72f, 0.5f);
            glRasterPos3f(0.2f, 0.2f, -0.1);

The program works fine (or should i say "doesn't crach") if I erase the glRasterPos3f command. I just have no idea whats the problem. (the unstructurized version worked fine)

Share this post

Link to post
Share on other sites
I see you have turned on GL_SCISSOR_TEST, but you don't seem to have actually set the size and position of the scissor box. glRasterPos probably needs this to be set if the scissor test is enabled.

Share this post

Link to post
Share on other sites
This doesn't seem to be the problem.
OpenGL Bible says: By default, the scissor rectangle is the size of the window where rendering takes place.

When i remove the "glEnable(GL_SCISSOR_TEST);" command, the error still occurs.

Share this post

Link to post
Share on other sites
It's a pain, you can't generate z=0 in eye space on the tranform of glRasterPos or you get a divide by zero. One of the reasons glWindowPos is better. You can get GLee to access it easily. If you actually want the coordinates transformed then glRasterPos is the function to use, but you have to deal with that divide by zero on eyez=0.

Oops, should have looked at the code. You just set the model view matrix so that doesn't seem to be the problem.

Share this post

Link to post
Share on other sites
This is so weird. I continued structurizing the program, and left the glRaterPos3f command. Basicly i just added some code to draw the grid.

The only OpenGL specific commands I added are:


glColor3f(0.48f, 0.48f, 0.48f);

(The draw-grid-code just draws a bunch of lines in a for-loop)

At the end of this code I added the line "glRasterPos3f(1.0f, 1.0f, 1.0f);".
And now this doesn't cause the program to crash.
I have no idea why. (but i can bare this - the program works)

[Edited by - Kwak on November 5, 2005 10:58:55 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!