Opengl ';基因对象名称';未创建有效的TextureObject
我试图在Haskell中编写一个测试,将纹理加载到OpenGL并在屏幕上渲染。我把所有的东西都加载到我的程序中,但是当我渲染纹理时,它变成了一个白色的块。在查找时,我发现这可能是由于Opengl ';基因对象名称';未创建有效的TextureObject,opengl,haskell,Opengl,Haskell,我试图在Haskell中编写一个测试,将纹理加载到OpenGL并在屏幕上渲染。我把所有的东西都加载到我的程序中,但是当我渲染纹理时,它变成了一个白色的块。在查找时,我发现这可能是由于TextureObject无效造成的。所以我添加了一个测试来发现: t <- genObjectName isobj <- isObjectName t if not isobj then error "Could not bind object name." else do ...
TextureObject
无效造成的。所以我添加了一个测试来发现:
t <- genObjectName
isobj <- isObjectName t
if not isobj
then error "Could not bind object name."
else do
...
t在OpenGL 2.9中,您没有像使用GenoObjectName
/GenoObjectNames
那样多。在它不再正确之前使用过的大多数地方。不幸的是,我所发现的任何地方都没有记录到OpenGL Haskell绑定2.9对API的重大更改
例如,对于着色器,在2.9之前,您可能会编写如下内容:
createVertexShader :: Shader s => String -> IO s
createVertexShader source =
do
[s] <- genObjectNames 1
shaderSource s $= [source]
compileShader s
return s
对于程序,您不使用genObjectNames
,而是使用createProgram
对于纹理,您仍然使用genObjectNames
,例如textureBinding
根据Andon M.Coleman的反馈,您拨打的电话是:
GLuint tex;
glGenTextures(1, &tex);
if (!glIsTexture(tex)) {
fprintf(stderr, "Could not bind object name.\n");
exit(1);
}
根据for纹理
:
A name returned by glGenTextures, but not yet associated with a texture by calling glBindTexture, is not the name of a texture.
您是否有有效的OpenGL上下文?您可以通过调用GL.get GL.errors
找出函数调用失败的原因。这些结果实际上是您应该期望的结果。在OpenGL(纹理)对象成为有效对象之前,需要至少绑定一次。它基本上是一个保留名称,直到您首先绑定它,然后在绑定它之后,它被分配状态等(换句话说,成为一个实例化的对象)。我将写这作为一个答案,但我不太确定这些函数名如何与实际的OpenGL API调用相关联:-\
A name returned by glGenTextures, but not yet associated with a texture by calling glBindTexture, is not the name of a texture.