Skip to content

Instantly share code, notes, and snippets.

@SimonDanisch
Created May 17, 2014 21:03
Show Gist options
  • Save SimonDanisch/55cd71d31bc42196b1fd to your computer and use it in GitHub Desktop.
Save SimonDanisch/55cd71d31bc42196b1fd to your computer and use it in GitHub Desktop.
using GLUT, ModernGL
function aglGetProcAddress(glFuncName::String)
tmp = "_"*glFuncName
if ccall(:NSIsSymbolNameDefined, Cint, (Ptr{Uint8},), tmp) == 0
return convert(Ptr{Void}, 0)
else
symbol = ccall(:NSLookupAndBindSymbol, Ptr{Void}, (Ptr{Uint8},), tmp)
return ccall(:NSAddressOfSymbol, Ptr{Void}, (Ptr{Void},), symbol)
end
end
glutInit()
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
glutInitWindowSize(10, 10)
glutInitWindowPosition(0, 0)
glutCreateWindow("dummy")
glGetStringPTR = aglGetProcAddress("glGetString")
println("glGetStringPTR: ", glGetStringPTR)
gl_version = ccall(glGetStringPTR, Ptr{Cuchar}, (GLenum,), GL_VERSION)
println("version: ", bytestring(gl_version))
vertexArraysPTR = aglGetProcAddress("glGenVertexArrays")
println("vertexArrayPTR: ", vertexArraysPTR)
ids = Cuint[42]
ccall(vertexArraysPTR, Void, (GLsizei, Ptr{GLuint}), 1, ids)
println("varray id: ", ids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment