Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Error with window.pushGLStates(); and window.popGLStates();  (Read 2725 times)

0 Members and 1 Guest are viewing this topic.

Gauzr

  • Newbie
  • *
  • Posts: 20
    • View Profile
After my last post I made earlier today, I fixed the issue I had by removing the pushGLStates and popGLStates, but I need this to draw some text with an openGL shape. I don't understand why it won't work  with my SFML, I read the tutorials about using OpenGL. From what I can see, it should work fine. I'm not sure though.

It gives me this error:
First-chance exception at 0x02A1D6AE (nvoglv32.dll) in sfmlGame.exe: 0xC0000005: Access violation reading location 0x00000000.



                ...

                glDrawArrays(GL_TRIANGLE_STRIP, 0, 36);
                               
                window.pushGLStates();
                window.draw(wlcmtxt);
                window.popGLStates();
               
                window.display();

 
« Last Edit: June 21, 2015, 10:17:02 pm by Gauzr »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Error with window.pushGLStates(); and window.popGLStates();
« Reply #1 on: June 22, 2015, 12:30:52 am »
I already mentioned it in the other post and I even emphasized it again, to avoid exactly such an unhelpful problem description:
Without a minimal complete example*, we can't say anything. Just make sure that your drivers are up-to-date and that you link everything correctly.

________
* In order to save your and our time and to avoid unnecessary questions, it is absolutely crucial that you read that post carefully.
« Last Edit: June 22, 2015, 12:33:32 am by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Gauzr

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Error with window.pushGLStates(); and window.popGLStates();
« Reply #2 on: June 23, 2015, 05:20:19 pm »
I don't know what you're asking from me nexus, my drivers are fully updated, I included a "minimal code example" in my last post, I've read the post, my linkers are fine, I even tested my included code on another PC - drawing the text works fine.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Error with window.pushGLStates(); and window.popGLStates();
« Reply #3 on: June 23, 2015, 05:25:40 pm »
Here are two different links to essentially the same that Nexus is asking:

 - Short, Self Contained, Correct (Compilable), Example
 - How To Ask Questions The Smart Way

Read both links (and the one Nexus gave you) and it should be clear what is being asked for.
Hope that helps :)
« Last Edit: June 23, 2015, 05:27:28 pm by Jesper Juhl »

Gauzr

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Error with window.pushGLStates(); and window.popGLStates();
« Reply #4 on: June 23, 2015, 06:02:56 pm »
If this isn't good enough, I really don't know what is - this was the shortest I could make it:

void welcomescreen()
{
    sf::ContextSettings contextSettings;
    contextSettings.depthBits = 48;

    sf::RenderWindow windowo(sf::VideoMode(640, 480), "gameTest", sf::Style::Default, contextSettings);
    windowo.resetGLStates();    
        windowo.setVerticalSyncEnabled(true);
   
    sf::Font txt;
        txt.loadFromFile("resources/armyfont.ttf");
    sf::Text wlcmtxt;  
    wlcmtxt.setFont(txt);                                                               //text
    wlcmtxt.setScale(1.4, 1.4);
    wlcmtxt.setString("gameTest");
    wlcmtxt.setOrigin(-130, -0);

    windowo.setActive();
    glClearDepth(1.f);
    glClearColor(0.f, 0.f, 0.f, 1.f);
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);

    glDisable(GL_LIGHTING);
    glDisable(GL_TEXTURE_2D);
    glViewport(0, 0, windowo.getSize().x, windowo.getSize().y);

     // make 3d cube
    GLfloat cube[] =
    {
      -50, -50, -50, 0, 0, 1, 1,
        -50, 50, -50, 0, 0, 1, 1,
        -50, -50, 50, 0, 0, 1, 1,        
        -50, -50, 50, 0, 0, 1, 1,
        -50, 50, -50, 0, 0, 1, 1,
        -50, 50, 50, 0, 0, 1, 1,

        50, -50, -50, 0, 1, 0, 1,      
        50, 50, -50, 0, 1, 0, 1,
        50, -50, 50, 0, 1, 0, 1,
        50, -50, 50, 0, 1, 0, 1,
        50, 50, -50, 0, 1, 0, 1,
        50, 50, 50, 0, 1, 0, 1,

        -50, -50, -50, 1, 0, 0, 1,        
        50, -50, -50, 1, 0, 0, 1,
        -50, -50, 50, 1, 0, 0, 1,
        -50, -50, 50, 1, 0, 0, 1,
        50, -50, -50, 1, 0, 0, 1,
        50, -50, 50, 1, 0, 0, 1,

        -50, 50, -50, 0, 1, 1, 1,
        50, 50, -50, 0, 1, 1, 1,
        -50, 50, 50, 0, 1, 1, 1,        
        -50, 50, 50, 0, 1, 1, 1,
        50, 50, -50, 0, 1, 1, 1,
        50, 50, 50, 0, 1, 1, 1,

        -50, -50, -50, 1, 0, 1, 1,
        50, -50, -50, 1, 0, 1, 1,
        -50, 50, -50, 1, 0, 1, 1,      
        -50, 50, -50, 1, 0, 1, 1,
        50, -50, -50, 1, 0, 1, 1,
        50, 50, -50, 1, 0, 1, 1,

        -50, -50, 50, 1, 1, 0, 1,
        50, -50, 50, 1, 1, 0, 1,
        -50, 50, 50, 1, 1, 0, 1,
        -50, 50, 50, 1, 1, 0, 1,      
        50, -50, 50, 1, 1, 0, 1,
        50, 50, 50, 1, 1, 0, 1,

    };

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    glVertexPointer(3, GL_FLOAT, 7 * sizeof(GLfloat), cube);
    glColorPointer(4, GL_FLOAT, 7 * sizeof(GLfloat), cube + 3);

    glDisableClientState(GL_NORMAL_ARRAY);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);

    while (windowo.isOpen())
    {

        sf::Event event;
        while (windowo.pollEvent(event))
        {
         
            if (event.type == sf::Event::Resized)
                glViewport(0, 0, event.size.width, event.size.height);
        }
     
               
                glClearColor(1.0, 1.0, 1.0, 1.0);

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glColor3f(1.0f, 0.0f, 0.0f);

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0.f, 0.f, -200.f);
     
        // Draw the cube
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 36);
       
        windowo.pushGLStates();
                windowo.draw(wlcmtxt);                             //Problem
        windowo.popGLStates();
   
        windowo.display();
    }
}
 
« Last Edit: June 23, 2015, 06:10:28 pm by Gauzr »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Error with window.pushGLStates(); and window.popGLStates();
« Reply #5 on: June 23, 2015, 06:09:14 pm »
Why should we help you if you don't even bother reading our posts and the links we give you? ::)

I don't want to appear rude, but if I explicitly and repeatedly highlight the importance of a minimal complete example and Jesper gives you further hints, I at least expect you to take those seriously, and invest the 5 minutes to carefully read what you're given.

My link unambiuously states "It is important that the code is complete, so people can test it"... so please follow those simple points. Read the link again slowly and make sure you apply every single step, before posting.
« Last Edit: June 23, 2015, 06:11:56 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Error with window.pushGLStates(); and window.popGLStates();
« Reply #6 on: June 23, 2015, 10:02:42 pm »
Just to reinforce what has been said already, one reason it should be complete is that, to test what you gave us, we have to modify and/or complete it. I actually did this and it works fine but who is to know if your code is working or not as it may be something I added that inadvertently fixed it.

Also, I googled that driver and the very first hit was this: http://stackoverflow.com/questions/24539951/opengl-nvoglv32-dll-error
You remember Google, right?  ;)

p.s. Why are you setting a negative origin to move the text instead of setting a positive position?
« Last Edit: June 23, 2015, 10:10:38 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything