July 14, 2016 at 6:57 am #2123
Hello, I am trying to port some OpenGL stuff, I have some problems figuring out the API. What I am trying to do is something like this. http://www.monkey-x.com/Community/posts.php?topic=8510Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859Namespace opengltest#Import "<mojo>"Using std..Using mojo..Using gles20..Function Main:Void()New AppInstanceNew OpenGLTestApp.Run()EndClass OpenGLTest Extends WindowField dataBuffer:DataBufferMethod New()' Set verticesLocal vertices:Float = New Float(-1, -1, 1, -1, 0, 1)' Load databufferLocal dataBuffer:DataBuffer = New DataBuffer(vertices.Length * 4)For Local i := 0 Until vertices.LengthdataBuffer.PokeFloat(i * 4, vertices[i])NextPrint("Length of dataBuffer " + dataBuffer.Length)Self.dataBuffer = dataBuffer' Create vertex bufferLocal vertexBuffer:UIntglGenBuffers(0, Varptr(vertexBuffer))glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer)glBufferData(GL_ARRAY_BUFFER, dataBuffer.Length, Varptr(dataBuffer), GL_STATIC_DRAW)Print("Address of vertexBuffer " + UInt(vertexBuffer))Local queryBufferSize:Int = 0glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, Varptr(queryBufferSize))Print("Size of vertexBuffer " + queryBufferSize)EndMethod OnRender(canvas:Canvas) OverrideglClearColor(0.2, 0.2, 0.2, 1.0)glClear(GL_COLOR_BUFFER_BIT)glEnableVertexAttribArray(0)glVertexAttribPointer(0, 3, GL_FLOAT, False, 0, Varptr(dataBuffer))glDrawArrays(GL_TRIANGLES, 0, 3)canvas.DrawText("Monkey2 OpenGL Test", 10, 10)EndEndJuly 14, 2016 at 10:45 am #2130
Monkey2 currently only implements GLES2.0, which means you need to create shaders and so on before you can draw anything.
Also, you can’t yet render directly to OpenGL in mojo – coming soon though.July 14, 2016 at 11:23 am #2131
OK Thanks.July 19, 2016 at 8:29 pm #2284
To clarify, you at least need a vertex shader and fragment shader. Assuming you just need a simple pass-through shader that does a texture lookup or solid color, I’m sure there are a lot of us here who could help.
Like Mark says, you also might need to make your own render buffer instead of using mojo’s canvas to get things to play nicely. If you read the last blog post, there should be a GLWindow class soon that can do that for you.
You must be logged in to reply to this topic.