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

Author Topic: sf::ContextSettings, opengl version hint  (Read 9506 times)

0 Members and 1 Guest are viewing this topic.

mercurio7891

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
sf::ContextSettings, opengl version hint
« on: January 29, 2011, 04:27:54 pm »
hi, I have a nvidia 8600 which can support opengl 3.3, however no matter what value i put as the value for the major, minor parameters in ContextSettings, it always create a opengl2.0 context instead.

Is there something I am missing out?

regards

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::ContextSettings, opengl version hint
« Reply #1 on: January 29, 2011, 05:39:30 pm »
How do you know that it's a 2.0 context?
Laurent Gomila - SFML developer

mercurio7891

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
sf::ContextSettings, opengl version hint
« Reply #2 on: January 29, 2011, 07:09:06 pm »
After creating the window, I use window_.GetSettings() and check the version from there

devlin

  • Full Member
  • ***
  • Posts: 128
    • View Profile
sf::ContextSettings, opengl version hint
« Reply #3 on: January 29, 2011, 08:58:38 pm »
I don't know if GetSettings calls this internally - but:
Code: [Select]
glGetString(GL_VERSION);
might give you another answer.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::ContextSettings, opengl version hint
« Reply #4 on: January 29, 2011, 11:35:26 pm »
GetSettings gives you what was used to create the context, so if it says 2.0 it is 2.0. If you get that, it means that the extensions needed to create a 3.0 context were not found or didn't work. Are you sure that your driver supports it?
Laurent Gomila - SFML developer

mercurio7891

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
sf::ContextSettings, opengl version hint
« Reply #5 on: January 30, 2011, 12:06:54 pm »
Yes my driver support it, I am using a nvidia 8600GT which support opengl 3.3. I have use the GPU caps viewer tool and have run their opengl 3.3 demo

http://www.ozone3d.net/gpu_caps_viewer/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::ContextSettings, opengl version hint
« Reply #6 on: January 30, 2011, 05:52:31 pm »
Maybe you can debug a little bit inside SFML and see what's wrong? The relevant code is at the end of the Create function in src/SFML/Window/Linux/GlxContext.cpp.
Laurent Gomila - SFML developer

mercurio7891

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
sf::ContextSettings, opengl version hint
« Reply #7 on: January 31, 2011, 04:47:49 pm »
Hi, Laurent, just wondering, did you update on the context creation part some time while ago??

This is because the current snap shot that I have is about 1-2 week ago, and I was thinking of confirming with you before I tinker around the source.

The link to the 2.0 snap shot seems down, so I can't really check it.

p.s I also found that the Antialiasing settings is not setting right, and I am running SFML on windows 7

regards

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::ContextSettings, opengl version hint
« Reply #8 on: January 31, 2011, 04:52:42 pm »
I haven't worked on this part for a long time, you can safely work with the revision that you have.
Laurent Gomila - SFML developer

mercurio7891

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
sf::ContextSettings, opengl version hint
« Reply #9 on: January 31, 2011, 06:19:14 pm »
Hi, Laurent,

I think the problem is because there is no existing rendering context before the usage wglGetProcAddress. Since I think wglGetProcAddress requires an existing context before it can be used.

regards

devlin

  • Full Member
  • ***
  • Posts: 128
    • View Profile
sf::ContextSettings, opengl version hint
« Reply #10 on: January 31, 2011, 07:02:53 pm »
There is an existing internal rendering context up even before you create a window.

If what you say was true, how come I get a 4.0.10151 Compability Profile context just fine? :)

mercurio7891

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
sf::ContextSettings, opengl version hint
« Reply #11 on: January 31, 2011, 07:17:08 pm »
I think the exisiting internal rendering context only apply if you create on the main thread. When I create my window on the main thread, it didn't have any problems. The problem only appear when I change all the window creation to run from a separate thread.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
sf::ContextSettings, opengl version hint
« Reply #12 on: January 31, 2011, 07:19:52 pm »
forgot to set the thread as the active one for the window? Don't know if it matters.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

mercurio7891

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
sf::ContextSettings, opengl version hint
« Reply #13 on: January 31, 2011, 07:31:18 pm »
the way I got around it was to create a dummy context on the stack just before it create the actual context.

Code: [Select]

GlContext* GlContext::New(const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings)
{
    //I added this line
    ContextType dummyContext(&referenceContext);

    ContextType* context = new ContextType(&referenceContext, owner, bitsPerPixel, settings);

    // Enable antialiasing if needed
    if (context->GetSettings().AntialiasingLevel > 0)
        glEnable(GL_MULTISAMPLE_ARB);

    return context;
}


and I also modified the code for selecting the version context to create, because although my card supports 3.3 if I chose 4.0, it would fail and jump to 2.0 instead :(

regards

mercurio7891

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
sf::ContextSettings, opengl version hint
« Reply #14 on: January 31, 2011, 07:55:46 pm »
Just wondering, Laurent, is it safe to comment out this line:

Code: [Select]

WglContext::WglContext(WglContext* shared) :
myWindow       (NULL),
myDeviceContext(NULL),
myContext      (NULL),
myOwnsWindow   (true)
{
    // Creating a dummy window is mandatory: we could create a memory DC but then
    // its pixel format wouldn't match the regular contexts' format, and thus
    // wglShareLists would always fail. Too bad...

    // Create a dummy window (disabled and hidden)
    myWindow = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, 1, 1, NULL, NULL, GetModuleHandle(NULL), NULL);
    ShowWindow(myWindow, SW_HIDE);
    myDeviceContext = GetDC(myWindow);

    // Create the context
    if (myDeviceContext)
        CreateContext(shared, VideoMode::GetDesktopMode().BitsPerPixel, ContextSettings(0, 0, 0));

    // Activate the context
    //SetActive(true); <<<<----- is it safe to comment out this line?
}


I am not sure if other part of SFML relies on this behavior or uses this variant of the constructor that takes in a WglContext.

Currently the only one I am seeing that uses it is the defaultContext, so I am not very sure. If we comment it out, we can use the default context to set it as the current context before creating any window. something like:

Code: [Select]

GlContext* GlContext::New(const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings)
{
    //Now we can use the default context that was created globally.
    defaultContext.SetActive(true);

    ContextType* context = new ContextType(&referenceContext, owner, bitsPerPixel, settings);

    // Enable antialiasing if needed
    if (context->GetSettings().AntialiasingLevel > 0)
        glEnable(GL_MULTISAMPLE_ARB);

    return context;
}


The reason I was asking if it was ok to comment out the SetActive in the constructor was because the default context is still active on the main thread and can't be used on other threads.

regards