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

Author Topic: window title displaying junk  (Read 2399 times)

0 Members and 1 Guest are viewing this topic.

iride

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
window title displaying junk
« on: August 23, 2012, 06:20:40 pm »

#pragma comment(lib, "sfml-graphics.lib")
#pragma comment(lib, "sfml-window.lib")
#pragma comment(lib, "sfml-system.lib")
#pragma comment(lib, "sfml-audio.lib")


#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")


#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <SFML/Audio.hpp>

int main()
{
    // create the window
        sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Close, sf::ContextSettings());
             

    // load resources, initialize the OpenGL states, ...
        glClearColor (0.0, 0.0, 0.0, 0.0);
        glClear (GL_COLOR_BUFFER_BIT);
        glColor3f (1.0, 1.0, 1.0);
        glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);


    // run the main loop
    bool running = true;
    while (running)
    {
        // handle events
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                // end the program
                running = false;
            }
            else if (event.type == sf::Event::Resized)
            {
                // adjust the viewport when the window is resized
                glViewport(0, 0, event.size.width, event.size.height);
            }
        }

        // clear the buffers
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // draw...
                glBegin(GL_POLYGON);
                        glVertex3f (0.25, 0.25, 0.0);
                        glVertex3f (0.75, 0.25, 0.0);
                        glVertex3f (0.75, 0.75, 0.0);
                        glVertex3f (0.25, 0.75, 0.0);
                glEnd();



        // end the current frame (internally swaps the front and back buffers)
        window.display();
    }

    // release resources...

    return 0;
}

The above code is displaying junk window title, not "OpenGL".
What did I do wrong?
I'm using 2.0

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: window title displaying junk
« Reply #1 on: August 23, 2012, 06:30:23 pm »
You're linking against the release libraries (without the '-d' postfix) but you're compile your application as debug. You can't mix release and debug with SFML. ;)

I strongly advice you against the use of #pragma comment linker commands, linking settings are not part of C++ code but are properties of the project, thus you should put them into the project settings, as explained in the official tutorial. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

iride

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: window title displaying junk
« Reply #2 on: August 23, 2012, 08:52:23 pm »
Thanks, i solved the problem.

I noticed that I didn't have to call glFlush() to render

does window.display() include glFlush()?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: window title displaying junk
« Reply #3 on: August 23, 2012, 09:41:08 pm »
Quote
does window.display() include glFlush()?
Yes.
Laurent Gomila - SFML developer