haskell-opengl / OpenGL

Haskell bindings to OpenGL
http://www.haskell.org/haskellwiki/OpenGL
BSD 3-Clause "New" or "Revised" License
147 stars 26 forks source link

Enable the use of VAOs on mac using apple extensions. #55

Closed schell closed 10 years ago

schell commented 10 years ago

I'm trying to use VAOs but mac requires the use of apple specific extension functions. Apple's VAO docs. It seems there are apple extension functions in OpenGLRaw What's the best way to integrate this? Double up all VAO functions with *Apple versions?

svenpanne commented 10 years ago

The underlying mechanism in OpenGLRaw already takes care of the various vendor suffixes like "APPLE", see https://github.com/haskell-opengl/OpenGLRaw/blob/master/src/Graphics/Rendering/OpenGL/Raw/Extensions.hs. On the Haskell side you normally only see the suffix-free names, but glBindVertexArrayAPPLE is an exception: It has different semantics than the ARB version of glBindVertexArray (the latter requires all ids to have been previously generated by glGenVertexArrays, while the former auto-generates an id if required). Therefore, OpenGLRaw exposes both versions, the ARB one without a suffix and the Apple version with an "APPLE" suffix. Luckily, such semantic difference are extremely rare when extensions are promoted.

So hopefully there is nothing to do for you, just drop the suffix. It might be the case that you have to use a feature from an Apple extension which is not yet in OpenGLRaw, it would be good to hear if that's the case or not.

schell commented 10 years ago

Okay, thanks for the explanation. I'm trying to use VAOs through GLUtils but am getting an "invalid operation" error on mac for code that works on linux, from @acowley's vinyl-gl tutorial http://www.arcadianvisions.com/blog/?p=388:

dirtVAO <- makeVAO $ do enableVertices' s dirtVerts
                             bindVertices dirtVerts
                             bindBuffer ElementArrayBuffer $= Just eb
     return $ \i -> do currentProgram $= Just (program s)
                       setUniforms s i
                       withVAO grassVAO . withTextures2D [grass] $
                         drawIndexedTris numGrassTris
                       withVAO dirtVAO . withTextures2D [dirt] $
                         drawIndexedTris numDirtTris

I've run into that same "invalid operation" error on my old mac that didn't support VAOs (it had an old OpenGL). After finding the apple specific functions I figured it was an issue of having to use those. I guess I need to get this code working with OpenGLRaw first to find the actual problem or stay with my current solution of not using VAOs.

acowley commented 10 years ago

@schell Please open a GLUtil or vinyl-gl issue if this is still a problem. I do most of my development on OS X, so any problems there come as a surprise!

schell commented 10 years ago

@acowley I will once I figure out what's going on, thanks! :+1: