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

Author Topic: OpenGL 2 context?  (Read 6034 times)

0 Members and 1 Guest are viewing this topic.

golgoth

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
OpenGL 2 context?
« on: August 11, 2010, 05:18:08 pm »
Greetings everyone,

I'm using SFML 2.0, Glew 1.5.5 with a gforce 8800… I'm wondering how to create an OpenGL 2.x context.

#define GLEW_STATIC
#include <opengl/glew.h>
#include <opengl/glut.h> /// gluPickMatrix.
…SNIP
sf::ContextSettings l_settings;
l_settings.MajorVersion= 2;
l_settings.MinorVersion= 0;

Still creates a 3.x context… what am I missing?

thx

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
OpenGL 2 context?
« Reply #1 on: August 11, 2010, 05:43:42 pm »
Nothing :)

What is your OS? Which revision of SFML 2 do you use? How do you check the version of the created context?

Can you provide a complete and minimal code that reproduces this problem?
Laurent Gomila - SFML developer

golgoth

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
OpenGL 2 context?
« Reply #2 on: August 11, 2010, 06:57:57 pm »
Hi Laurent,

I'm using Windows XP 64 with Visual Studio 2008.
Not sure about the version of SFML (still trying to figure how SVN repository works) but I've compiled the SFML 2.0 snapshot less than a week ago.

I'm using glGetString(GL_VERSION)) right after sf::window is being created.

My project is fairly complex so it would be tedious to reproduce. If nothing obvious pops out, I'll try a test project.

thx

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
OpenGL 2 context?
« Reply #3 on: August 11, 2010, 07:36:08 pm »
Quote
My project is fairly complex so it would be tedious to reproduce

Do you mean that...
Code: [Select]
int main()
{
    sf::ContextSettings settings;
    settings.MajorVersion = 2;
    settings.MinorVersion = 0;

    sf::Window window(sf::VideoMode(800, 600), "SFML test", sf::Style::Default, settings);

    const GLubyte* version = glGetString(GL_VERSION);
    return 0;
}

...doesn't reproduce the problem?
Laurent Gomila - SFML developer

golgoth

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
OpenGL 2 context?
« Reply #4 on: August 11, 2010, 08:07:36 pm »
Yes it does indeed,

const GLubyte* version = glGetString(GL_VERSION);  return 3.3.0

while

sf::ContextSettings settings = window.GetSettings(); retrun 2.0

I embed my sf::window in a QT widget so I was not quite sure where was the problem, hope it helps.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
OpenGL 2 context?
« Reply #5 on: August 11, 2010, 08:19:46 pm »
Technically, the code can't create an OpenGL 3 context if settings.MajorVersion is less than 3.

I'm not sure that glGetString(GL_VERSION) returns the version of the current context, maybe it returns something more generic like the maximum GL version that the driver supports. I couldn't find a clear documentation about that.

From opengl.org:
Quote
GL_VERSION Returns a version or release number.

So helpful... :lol:
Laurent Gomila - SFML developer

golgoth

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
OpenGL 2 context?
« Reply #6 on: August 11, 2010, 08:38:50 pm »
Don’t get me wrong here, I'm definitely inclined to trust your say, but I must find a way to validate which one is telling the truth. :wink:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
OpenGL 2 context?
« Reply #7 on: August 11, 2010, 09:28:01 pm »
Well, creating an OpenGL 3 context requires to use a totally different code compared to regular contexts, and SFML doesn't use this code if settings.MajorVersion < 3. So it's clearly not a GL 3 context that you get.

However I'd feel better if one could tell me exactly what GL_VERSION is supposed to mean.
Laurent Gomila - SFML developer

przemo_li

  • Newbie
  • *
  • Posts: 6
    • View Profile
OpenGL 2 context?
« Reply #8 on: August 26, 2010, 07:51:03 pm »
Code: [Select]
#include <SFML/OpenGL.hpp>
#include <SFML/Window.hpp>

int main()
{
    sf::ContextSettings settings;
    settings.MajorVersion = 2;
    settings.MinorVersion = 0;

    sf::Window window(sf::VideoMode(800, 600), "SFML test", sf::Style::Default, settings);

    const GLubyte* version = glGetString(GL_VERSION);
    return 0;
}


Code: [Select]
przemoli@przemoli-laptop:~/Programowanie/OGLProjekt$ g++ -c ogl_version.cpp -I/home/przemoli/Programowanie/sfml2/include
przemoli@przemoli-laptop:~/Programowanie/OGLProjekt$ g++ -o ogl_version ogl_version.o -lsfml2-window -lsfml2-system -lGLU -L/home/przemoli/Programowanie/sfml2/lib/
przemoli@przemoli-laptop:~/Programowanie/OGLProjekt$ /lib/ld-linux.so.2 --library-path /home/przemoli/Programowanie/sfml2/lib/ ./ogl_version
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server "� Ъ�
"
      after 115 requests (114 known processed) with 0 events remaining.


Te same komendy, działają dla tutoriala o OpenGL. Co jest nie tak? (ati 5740, OGL 4.0 compatibility profile, catalyst 10.7)

przemo_li

  • Newbie
  • *
  • Posts: 6
    • View Profile
OpenGL 2 context?
« Reply #9 on: August 27, 2010, 09:45:45 am »
Sorry. It was late.

"Te same komendy, działają dla tutoriala o OpenGL. Co jest nie tak? (ati 5740, OGL 4.0 compatibility profile, catalyst 10.7)"

Translate as:

This build commands work fine for OGL tutorial. What is wrong? (ati 5740, OGL 4.0 compatibility profile, catalyst 10.7)

yuriks

  • Newbie
  • *
  • Posts: 2
    • View Profile
OpenGL 2 context?
« Reply #10 on: October 21, 2010, 12:18:58 pm »
This isn't a bug. Rather, in version 3.3 the standard was changed to allow implementations to return a 3.3 Compatibility (not Core) context when asked for < 3.x context, since the two are compatible.

 

anything