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

Author Topic: Not able to draw with SFML on OpenGL 4.3 core context  (Read 1491 times)

0 Members and 1 Guest are viewing this topic.

Woodfighter

  • Newbie
  • *
  • Posts: 1
    • View Profile
Not able to draw with SFML on OpenGL 4.3 core context
« on: March 22, 2015, 06:41:14 pm »
Hey,

I am trying to write a simple game with my own OpenGL 4.3 core 3D graphics renderer and sfml for 2D stuff.
I want to use sfml for a simple HUD and later for a GUI (with sfgui, for example).
Currently I am not even able to draw a simple sf::CircleShape on top of my 3D scene. :'(

        sf::CircleShape shape(10000);
        shape.setFillColor(sf::Color::Red);
        while(isExecuting_)
        {
            const sf::Vector2i& oldMousePos = sf::Mouse::getPosition(*this);
            sf::Event event;
            while(this->pollEvent(event))
            {
                if(event.type == sf::Event::Closed)
                {
                    // end the program
                    isExecuting_ = false;
                }
                if(event.type == sf::Event::Resized)
                {
                    // adjust the viewport when the window is resized
                    glViewport(0, 0, event.size.width, event.size.height);
                    getSceneRenderer()->setRenderSize(event.size.width, event.size.height);
                }
                if(event.type == sf::Event::KeyPressed)
                {
                    if(event.key.code == sf::Keyboard::R)
                    {
                        std::unique_ptr<sf::Image> image = getSceneRenderer()->getBackbuffer()->getTextureImage();
                        image->saveToFile("Screenshot.png");
                    }
                }
            }

            const sf::Clock clock;
            getSceneRenderer()->renderScene();
            this->pushGLStates();
            //this->clear(sf::Color::Blue); //This works and clears the screen completely
            this->draw(shape);
            this->popGLStates();
            this->display();
 

This is my current 3D renderer: https://github.com/ElHolzi/WoodEngine/blob/master/GFX/SceneRenderer.cpp

Kind regards,

Woodfighter


zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Not able to draw with SFML on OpenGL 4.3 core context
« Reply #1 on: March 22, 2015, 06:42:16 pm »
SFML uses legacy OpenGL functions and therefore requires a compatibility context.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor