Haskell opengl属性未激活

Haskell opengl属性未激活,opengl,haskell,vertex-buffer,vertex-attributes,vertex-array-object,Opengl,Haskell,Vertex Buffer,Vertex Attributes,Vertex Array Object,我试图从顶点缓冲区对象渲染一些数据。然而,很少使用明胶和生料。 当程序运行时,它被卡在一个无限循环中,我得到了您在下面看到的错误 顶点着色器 #version 150 core in vec4 position; void main (void) { gl_Position = position; } 片段着色器 #version 150 core out vec4 color; void main (void) { color = vec4(0.0, 0.8, 1.

我试图从顶点缓冲区对象渲染一些数据。然而,很少使用明胶和生料。 当程序运行时,它被卡在一个无限循环中,我得到了您在下面看到的错误

顶点着色器

#version 150 core

in vec4 position;

void main (void)
{
    gl_Position = position;

}
片段着色器

#version 150 core

out vec4 color;

void main (void)
{
    color = vec4(0.0, 0.8, 1.0, 1.0);
}
我试过用430,但没用。所以我试着用150,因为我看到很多人都在用它。此外,我还尝试在使用raw的同时使用布局,但没有成功

使用实例

mesh :: [GLfloat]
mesh = [ 0.25, -0.25, 0.5
       ,-0.25, -0.25, 0.5
       , 0.25,  0.25, 0.5]

preMainLoop :: G.Window -> IO ()
preMainLoop window = do
    p <- loadShaderProgram [ ( VertexShader,   "frag.fs")
                           , ( FragmentShader, "vert.vs")]
    myVBO <- makeBuffer ArrayBuffer mesh
    vao <- makeVAO $ let vad = VertexArrayDescriptor 3 Float stride offset0"
                     in do
                         printErrorMsg "something else"
                         currentProgram $= Just (program p)
                         printErrorMsg "program"
                         bindBuffer ArrayBuffer $= Just myVBO
                         printErrorMsg "buffer"
                         enableAttrib p "position"
                         printErrorMsg "attribLocation"
                         setAttrib p "position" ToFloat vad
                         bindBuffer ArrayBuffer $= Nothing
    mainLoop window vao p

所以我尝试用opengl raw测试我的代码,这使它产生了我想要的结果

loc <- withCString "position" $ \pos -> glGetAttribLocation p pos
bindBuffer ArrayBuffer $= Just buffer
glEnableVertexAttribArray (fromIntegral loc)
glVertexAttribPointer (fromIntegral loc) 3 gl_FLOAT (fromIntegral gl_FALSE) 8 nl
loc GLGETATTIBLOCATION p位置
bindBuffer ArrayBuffer$=仅缓冲区
GlenableVertexAttributeArray(来自积分loc)
glVertexAttribPointer(来自积分loc)3 gl_浮点(来自积分gl_FALSE)8 nl

Wow,让我意识到我的Haskell有多生锈:)。而且gl+haskell感觉有点疯狂,gl是一个基于州的公司getAttrib与Haskell接口中的getActiveAttrib相同吗?着色器是否在该点实际编译和链接?如果你把一个故意的错误放进去会发生什么?我还注意到attrib有一些大小混合。程序中有4个浮点数,但有时有2个或3个。所以应该编译和链接着色器,我不知道getActiveAttrib。你所说的浮动大小与步幅有关,如果是这样的话,那么改变并不会改变任何东西。那么如果你在着色器中故意错误,你会在执行过程中得到不同的错误?attrib的事情:与我对您稍后需要的代码的有限理解非常不同。但真正发生的是您正在使用的gl库的深处。我很抱歉没有帮上忙,我承认我不知道如何解决这个问题。但我现在有点想亲自尝试Haskell+gl。
loc <- withCString "position" $ \pos -> glGetAttribLocation p pos
bindBuffer ArrayBuffer $= Just buffer
glEnableVertexAttribArray (fromIntegral loc)
glVertexAttribPointer (fromIntegral loc) 3 gl_FLOAT (fromIntegral gl_FALSE) 8 nl