renpy / pygame_sdl2

Reimplementation of portions of the pygame API using SDL2.
GNU Lesser General Public License v2.1
329 stars 66 forks source link

Setting GL version #37

Closed Sasszem closed 5 years ago

Sasszem commented 8 years ago

In SDL, there's a way to set GL's version, with

SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, maj);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, min);

Is there a way to do this in PyGame-SDL2?

(I know that display.set_gl_attribute() calls SDL_GL_SetAttribute(), but there's no constalnt for SDL_GL_CONTEXT_MINOR_VERSION and SDL_GL_CONTEXT_MAJOR_VERSION)

renpytom commented 8 years ago

pygame_sdl2 already exposes:

pygame_sdl2.GL_CONTEXT_MAJOR_VERSION

and

pygame_sdl2.GL_CONTEXT_MINOR_VERSION

for you.

Sasszem commented 8 years ago

Thanks, it looks like working, but I still got the same result of glGetString(GL_VERSION). My code:

pygame.display.gl_set_attribute(pygame.GL_CONTEXT_MAJOR_VERSION, 4)
pygame.display.gl_set_attribute(pygame.GL_CONTEXT_MINOR_VERSION, 4)

But OpenGL still returns 3.0 Mesa 11.0.2 as version. (It can cause a bit of compatibility problems that you renamed display.set_gl_attribute to display.gl_set_attribute)

renpytom commented 8 years ago

I don't know that would be. We pass this over to SDL2, and I believe it hands it to the video drivers. It's possible that you'd have to also use

SDL_GL_CONTEXT_PROFILE_CORE = 1 pygame.display.gl_set_attribute(pygame.GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE)

or

SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 2 pygame.display.gl_set_attribute(pygame.GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG)

or both.

According to http://www.pygame.org/docs/ref/display.html#pygame.display.gl_set_attribute the name of the function is gl_set_attribute. So I don't think I renamed anything.

Sasszem commented 8 years ago

Still get 3.0 Mesa 11.0.2 as GL's version, and 1.30 as GL_SHADING_LANGUAGE_VERSION.

renpytom commented 8 years ago

Are you on Linux? If so, can you run glxinfo to see what's supported? Looking at https://mesamatrix.net/ , it looks like a number of Mesa drivers only support GL3.3.

Sasszem commented 8 years ago

glxinfo | grep Mesa returns:

client glx vendor string: Mesa Project and SGI OpenGL renderer string: Mesa DRI Intel(R) Haswell Desktop OpenGL core profile version string: 3.3 (Core Profile) Mesa 11.0.2 OpenGL version string: 3.0 Mesa 11.0.2 OpenGL ES profile version string: OpenGL ES 3.0 Mesa 11.0.2

Looks like you was right, the dirver dosn't really support newer GL versions... But the C code from http://www.opengl-tutorial.org/ used GLSL

version 330, & compiled & worked on this PC...