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

Author Topic: SFML 2.0 Creating OpenGL 3.2 Context  (Read 6176 times)

0 Members and 1 Guest are viewing this topic.

kreed

  • Newbie
  • *
  • Posts: 14
    • View Profile
SFML 2.0 Creating OpenGL 3.2 Context
« 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.


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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML 2.0 Creating OpenGL 3.2 Context
« Reply #1 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?
Laurent Gomila - SFML developer

kreed

  • Newbie
  • *
  • Posts: 14
    • View Profile
SFML 2.0 Creating OpenGL 3.2 Context
« Reply #2 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML 2.0 Creating OpenGL 3.2 Context
« Reply #3 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.
Laurent Gomila - SFML developer

kreed

  • Newbie
  • *
  • Posts: 14
    • View Profile
SFML 2.0 Creating OpenGL 3.2 Context
« Reply #4 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML 2.0 Creating OpenGL 3.2 Context
« Reply #5 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".
Laurent Gomila - SFML developer

kreed

  • Newbie
  • *
  • Posts: 14
    • View Profile
SFML 2.0 Creating OpenGL 3.2 Context
« Reply #6 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML 2.0 Creating OpenGL 3.2 Context
« Reply #7 on: June 03, 2011, 03:05:35 pm »
If you print window.GetSettings().AntialiasingLevel, what do you see? 0 or 4?
Laurent Gomila - SFML developer

kreed

  • Newbie
  • *
  • Posts: 14
    • View Profile
SFML 2.0 Creating OpenGL 3.2 Context
« Reply #8 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.

kreed

  • Newbie
  • *
  • Posts: 14
    • View Profile
SFML 2.0 Creating OpenGL 3.2 Context
« Reply #9 on: June 03, 2011, 10:51:29 pm »
it prints a 0.

kreed

  • Newbie
  • *
  • Posts: 14
    • View Profile
SFML 2.0 Creating OpenGL 3.2 Context
« Reply #10 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+

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML 2.0 Creating OpenGL 3.2 Context
« Reply #11 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.
Laurent Gomila - SFML developer

azurfire

  • Newbie
  • *
  • Posts: 6
    • View Profile
SFML 2.0 Creating OpenGL 3.2 Context
« Reply #12 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));