我的问题是,当我想调用glUniform1f()时,会出现此错误:
ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
我只是不知道可能是什么原因造成的。
我的代码:
# initialization
glutInit() # initialize glut
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE)
glutInitWindowSize(width, height) # set window size
glutInitWindowPosition(0, 0) # set window position
window = glutCreateWindow(b"window") # create window with title
def make_shader(type, shader_src):
shader = glCreateShader(type)
glShaderSource(shader, shader_src)
glCompileShader(shader)
shader_ok = None
#show_info_log(shader,glGetShaderiv, glGetShaderInfoLog)
glGetShaderiv(shader, GL_COMPILE_STATUS, shader_ok)
if(not shader_ok): ####shader_ok is still None
glGetShaderInfoLog(shader)
print("failed to compile shader")
return shader
program = make_program(vertex_shader, fragment_shader)
texture = 0.33
uniform_texture = glGetUniformLocation(program, b"alpha[0]")
glViewport(0, 0, width, height)
glUseProgram(program)
glUniform1f(uniform_texture, texture) ####Fails with TypeError: Wrong type
我也无法从中获取任何日志:
glGetShaderInfoLog(shader)
或此
log = ctypes.ARRAY(ctypes.c_char, 100)
leng = ctypes.c_int(1)
glGetProgramiv(program, GL_INFO_LOG_LENGTH, leng)
glGetProgramInfoLog(program, leng, leng, log)
带有着色器的代码示例虽然不使用glUniform1f()仍然可以工作
答案 0 :(得分:0)
CristiFati是正确的,我必须指定glUniform1f方法的argtypes。