For OpenGL to process shader code, it must process and compile it for the GPU. To do this, we need to write a dedicated function. Open Utils.py. It will only have the map_value () function in it. Add the following code:
from OpenGL.GL import *
import numpy as np
def map_value(current_min, current_max, new_min,
new_max, value) :
def compile_shader(shader_type, shader_source):
shader_id = glCreateShader(shader_type)
glShaderSource(shader_id, shader_source)
glCompileShader(shader_id)
compile_success = glGetShaderiv(shader_id,
GL_COMPILE_STATUS)
if not compile_success:
error_message = glGetShaderInfoLog(shader_id)
glDeleteShader(shader_id)
error_message = “\n” +
error_message.decode(“utf-8”)
raise Exception(error_message)
return shader_id