How to initialize OpenGL context with PyGame instead of GLUT

I'm trying to start with OpenGL, using Python and PyGame.

I'm going to use PyGame instead of GLUT to do all the initializing, windows opening, input handling, etc.

However, my shaders are failing to compile, unless I specify exactly the version of OpenGL and profile.

They do compile with GLUT initialization from the book:

glutInit() glutInitDisplayMode(GLUT_RGBA) glutInitWindowSize(400, 400)  # this is what I need glutInitContextVersion(3, 3) glutInitContextProfile(GLUT_CORE_PROFILE)  glutCreateWindow("main") 

But, with simple PyGame initialization like this:

pygame.init() display = (400, 400) pygame.display.set_mode(display, pygame.DOUBLEBUF|pygame.OPENGL) 

which doesn't specify exact OpenGL version 3.3 and CORE_PROFILE, the same program would fail when trying to compile shaders:

RuntimeError: ('Shader compile failure (0): 0:2(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES\n', ['\n #version 330 core\n layout(location = 0) in vec4 position;\n void main()\n {\n gl_Position = position;\n }\n '], GL_VERTEX_SHADER)

My question is: how do I do this initialization with PyGame?

Replay

Category: opengl Time: 2016-07-29 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.115 (s). 12 q(s)