Skip to content

Commit 85b2d33

Browse files
author
Tim Sheerman-Chase
committed
Check available opengl version
1 parent 0d7343b commit 85b2d33

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

common2d.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ def link_shader_program(vertex_shader, fragment_shader):
9292
return program
9393

9494
def init_shader_program():
95+
versionString = gl.glGetString(gl.GL_VERSION).split(" ")
96+
openglVersionString = versionString[0]
97+
openglVersionNums = map(int, openglVersionString.split("."))
98+
if openglVersionNums[0] < 3 or (openglVersionNums[0] == 3 and openglVersionNums[1] < 3):
99+
exit("Requires opengl 3.3 or better, you have {0}".format(openglVersionString))
100+
95101
# background color
96102
gl.glClearColor(0, 0, 0, 0)
97103
# create a Vertex Buffer Object with the specified data

common3d.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import OpenGL
44
from OpenGL.GL import *
5+
import OpenGL.GL as gl
56
from OpenGL.GL.shaders import *
67
from OpenGL.GLU import *
78
from OpenGL.arrays import vbo
@@ -32,6 +33,12 @@
3233

3334
# initialization
3435
def init():
36+
versionString = gl.glGetString(gl.GL_VERSION).split(" ")
37+
openglVersionString = versionString[0]
38+
openglVersionNums = map(int, openglVersionString.split("."))
39+
if openglVersionNums[0] < 3 or (openglVersionNums[0] == 3 and openglVersionNums[1] < 3):
40+
exit("Requires opengl 3.3 or better, you have {0}".format(openglVersionString))
41+
3542
out = {}
3643
# create shader
3744
vs = compileShader(strVS, GL_VERTEX_SHADER)

0 commit comments

Comments
 (0)