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

Author Topic: ContextSettings interfering with sprite  (Read 1322 times)

0 Members and 2 Guests are viewing this topic.

newobj

  • Newbie
  • *
  • Posts: 2
    • View Profile
ContextSettings interfering with sprite
« on: September 14, 2017, 07:29:32 pm »
Hi.

I'm trying to use Nuklear with SFML (see https://github.com/vurtun/nuklear/blob/master/demo/sfml_opengl3/main.cpp). Nuklear requires a particular specification of ContexSettings:

sf::ContextSettings settings(24, 8, 4, 3, 3);
 

However, when this ContexSettings is used, it causes sprites to not render. I've isolated the issue to the following sample code:

#include <SFML/Graphics.hpp>
int main() {
    sf::ContextSettings settings(24, 8, 4, 3, 3);
    sf::RenderWindow window(sf::VideoMode(800, 600), "Demo", sf::Style::Default, settings);
    sf::Texture texture;
    if (!texture.loadFromFile("res/tex/logo.png")) exit(-1);
    sf::Sprite sprite(texture);
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed) window.close();
        }
        window.clear(sf::Color::Black);
        window.draw(sprite);
        window.display();
    }
    return 0;
}
 

if I ignore the ContexSettings, e.g.

sf::RenderWindow window(sf::VideoMode(800, 600), "Demo", sf::Style::Default/*, settings*/);
 

then my sprite renders fine (but nuklear doesn't work).

What exactly is it about those ContextSettings that causes my sprite to not render?

Thanks!

newobj

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: ContextSettings interfering with sprite
« Reply #1 on: September 14, 2017, 08:10:25 pm »
Oh, I see. I'm on OSX. So I can only have Legacy or Core context. But SFML Graphics module doesn't work if I pick Core context. So I'm confused.

On OSX I can only have Legacy OpenGL 2.1 then if I want to also use SFML Graphics??

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: ContextSettings interfering with sprite
« Reply #2 on: September 14, 2017, 08:25:28 pm »
Yes, this is an unfortunate limitation on macOS and a reason more to move SFML to a different/modern setup.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/