OpenGL minimum working example?
Hi. I tried to get an OpenGL MWE from https://github.com/ronsaldo/uffi-opengl in both Windows 8.1 and MacOS without luck. What I tried so far is to render a simple figure in a new window, adding this method to UFFIOpenGLOffscreenSamples:
sample2
" self new sample2 " | context gl fb | context := UFFIOpenGLContext new. gl := context gl. fb := context offscreenBufferExtent: 300@300. context asCurrentDo: [ fb activate. gl " loadIdentity;" clear: GL_COLOR_BUFFER_BIT; begin: GL_QUADS; color3f_red: 1.0 green: 0.0 blue: 0.0; vertex3f_x: 0.0 y: 0.0 z: 0.0; vertex3f_x: 0.5 y: 0.0 z: 0.0; vertex3f_x: 0.5 y: 0.5 z: 0.0; vertex3f_x: 0.0 y: 0.5 z: 0.0; end; flush ]. fb asForm asMorph openInWindow. However the result is that VM hangs in both platforms. Any advice what I'm missing? Cheers, Hernán
On Tue, 13 Nov 2018 at 03:37, Hernán Morales Durand < hernan.morales@gmail.com> wrote:
Hi.
I tried to get an OpenGL MWE from https://github.com/ronsaldo/uffi-opengl in both Windows 8.1 and MacOS without luck. What I tried so far is to render a simple figure in a new window, adding this method to UFFIOpenGLOffscreenSamples:
You may also be interested in "Use Metal instead of OpenGL for the main VM Window in OS X" ... https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/306 cheers -ben
Hi Hernan, I just added two new examples, UFFIOpenGLOffscreenSamples >> #triangle and UFFIOpenGLOffscreenSamples >> #quad (using your vertices). I tested it on Linux and on OS X. triangle " self new triangle " | context gl fb colorProgram vertexBuffer | context := UFFIOpenGLContext new. colorProgram := self colorProgramFor: context. vertexBuffer := self immutableVertexBufferFor: context withPackedFloats: { " x y z r g b a " { -0.5 . 0.5 . 0.0 . 1.0 . 0.0 . 0.0 . 1.0 }. { 0.5 . 0.5 . 0.0 . 0.0 . 1.0 . 0.0 . 1.0 }. { 0.0 . -0.5 . 0.0 . 0.0 . 0.0 . 1.0 . 1.0 }. }. gl := context gl. fb := context offscreenBufferExtent: 640@480. context asCurrentDo: [ fb activate. gl viewport_x: 0 y: 0 width: 640 height: 480; clearColor_red: 0.0 green: 0.0 blue: 0.0 alpha: 1.0; clear: GL_COLOR_BUFFER_BIT; useProgram: colorProgram validHandle; bindBuffer_target: GL_ARRAY_BUFFER buffer: vertexBuffer validHandle. self activateDefaultVertexLayoutOn: context. gl drawArrays_mode: GL_TRIANGLES first: 0 count: 3 ]. fb asForm asMorph openInWindow. Best regards, Ronie El mar., 13 nov. 2018 a las 1:23, Ben Coman (<btc@openinworld.com>) escribió:
On Tue, 13 Nov 2018 at 03:37, Hernán Morales Durand < hernan.morales@gmail.com> wrote:
Hi.
I tried to get an OpenGL MWE from https://github.com/ronsaldo/uffi-opengl in both Windows 8.1 and MacOS without luck. What I tried so far is to render a simple figure in a new window, adding this method to UFFIOpenGLOffscreenSamples:
You may also be interested in "Use Metal instead of OpenGL for the main VM Window in OS X" ... https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/306
cheers -ben
participants (3)
-
Ben Coman -
Hernán Morales Durand -
Ronie Salgado