SFML community forums

Help => Graphics => Topic started by: kreed on June 03, 2011, 10:16:44 am

Title: SFML 2.0 Creating OpenGL 3.2 Context
Post by: kreed on June 03, 2011, 10:16:44 am
I have been trying to create a simple OpenGL 3.2 context in SFML 2.0 and enable anti aliasing.

#1 Is there a way to find out WHAT OpenGL version is being used?

#2 Anti-Aliasing doesn't look like its working.

This is what I'm getting as output.
(http://i.imgur.com/fauZ6.png) (http://imgur.com/fauZ6)

I'm trying this :
Code: [Select]

#include <SFML/Graphics.hpp>
 
 int main()
 {
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
sf::ContextSettings::ContextSettings(8, 8, 4, 3, 2);

sf::Shape shape;

shape.AddPoint(10, 10, sf::Color::Red, sf::Color::White);
shape.AddPoint(300, 112, sf::Color::Green, sf::Color::White);
shape.AddPoint(10, 300, sf::Color::Blue, sf::Color::White);

shape.EnableFill(true);
shape.EnableOutline(true);
shape.SetOutlineThickness(10);

    while (window.IsOpened())
    {
         sf::Event event;
         while (window.PollEvent(event))
         {
             if (event.Type == sf::Event::Closed)
                 window.Close();
         }
window.Draw(shape);
         window.Display();
     }
 
     return EXIT_SUCCESS;
 }



Thanks for any/all help.

EXTRA SPECIAL thanks to you Laurent, I am new to SFML but love it already.
Title: SFML 2.0 Creating OpenGL 3.2 Context
Post by: Laurent on June 03, 2011, 10:47:25 am
Quote
#1 Is there a way to find out WHAT OpenGL version is being used?

window.GetSettings().MajorVersion/MinorVersion

Quote
#2 Anti-Aliasing doesn't look like its working.

Are you on Linux?
Title: SFML 2.0 Creating OpenGL 3.2 Context
Post by: kreed on June 03, 2011, 02:26:22 pm
No, I am currently on Windows 7 64-bit. I just realized that I also never actually loaded/compile/linked/used and shaders. Does SFML automatically assume default shader usage in the 3.0+ contexts?

Thanks for everything,
Kreed
Title: SFML 2.0 Creating OpenGL 3.2 Context
Post by: Laurent on June 03, 2011, 02:42:05 pm
Quote
I just realized that I also never actually loaded/compile/linked/used and shaders. Does SFML automatically assume default shader usage in the 3.0+ contexts?

Nop. SFML creates compatibility profiles so that it can still use fixed-pipeline functions.

For anti-aliasing, make sure that it's not forced to OFF in your graphics driver.
Title: SFML 2.0 Creating OpenGL 3.2 Context
Post by: kreed on June 03, 2011, 02:46:47 pm
ah, that is actually an amazingly GOOD thing to do so no complaints there. If it is forced to OFF how could I turn it on? I am using an NVIDIA GTX 465. I know it supports all the way up to 4.1 rendering contexts, but I want to support more platforms so I'm shooting for a middle ground. I also have my drivers installed with full OpenGL 3.2+ support.
Title: SFML 2.0 Creating OpenGL 3.2 Context
Post by: Laurent on June 03, 2011, 02:49:42 pm
You should have a GUI with your driver, to play with its settings. Something like "nVidia configuration panel".
Title: SFML 2.0 Creating OpenGL 3.2 Context
Post by: kreed on June 03, 2011, 03:03:01 pm
Hmm, it isn't forced off, it said its based on the program settings, but I tried making it default to the settings, and there was no change.
Title: SFML 2.0 Creating OpenGL 3.2 Context
Post by: Laurent on June 03, 2011, 03:05:35 pm
If you print window.GetSettings().AntialiasingLevel, what do you see? 0 or 4?
Title: SFML 2.0 Creating OpenGL 3.2 Context
Post by: kreed on June 03, 2011, 03:55:32 pm
Ah, I wish I had tried this before I have left! I will have to get back to you with what I get later today. Thanks for all the help so far.
Title: SFML 2.0 Creating OpenGL 3.2 Context
Post by: kreed on June 03, 2011, 10:51:29 pm
it prints a 0.
Title: SFML 2.0 Creating OpenGL 3.2 Context
Post by: kreed on June 04, 2011, 12:29:39 am
Also, I noticed that the shape object seems to be for 2D objects only, not 3d.

What would you recommend is the best way to set up SFML 2.0 to render 3D graphics using OpenGL 3.2+
Title: SFML 2.0 Creating OpenGL 3.2 Context
Post by: Laurent on June 04, 2011, 10:59:16 am
Quote
it prints a 0.

So there should be a message in the standard output (the console), right?

Quote
What would you recommend is the best way to set up SFML 2.0 to render 3D graphics using OpenGL 3.2+

There's no best way to setup SFML for 3D, what you do is enough.
Title: SFML 2.0 Creating OpenGL 3.2 Context
Post by: azurfire on June 05, 2011, 09:19:03 pm
You are only calling the ContextSettings constructor, you aren't passing it to the RenderWindow constructor.

Here is what I use in my project, except using Window instead of RenderWindow:

Code: [Select]
sf::Window window(sf::VideoMode(800, 600, 32), "Game", sf::Style::Close, sf::ContextSettings(24, 8, 16, 3, 3));