OpenGL minimum working example?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

OpenGL minimum working example?

hernanmd
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

Reply | Threaded
Open this post in threaded view
|

Re: OpenGL minimum working example?

tomo
Hello Hernan,

I have partially working code at
http://smalltalkhub.com/#!/~tomooda/Jun4Pharo

My code still have two problems that
* depending on resolution, projection matrix can't be properly set, and
* it freezes pharo when switching to fullscreen

Best Regards,
---
tomo

Reply | Threaded
Open this post in threaded view
|

Re: OpenGL minimum working example?

tomo
Hello Hernan,

I tested the code only on Mac.
---
tomo

2018/11/13(Tue) 8:27 Tomohiro Oda <[hidden email]> wrote:

>
> Hello Hernan,
>
> I have partially working code at
> http://smalltalkhub.com/#!/~tomooda/Jun4Pharo
>
> My code still have two problems that
> * depending on resolution, projection matrix can't be properly set, and
> * it freezes pharo when switching to fullscreen
>
> Best Regards,
> ---
> tomo

Reply | Threaded
Open this post in threaded view
|

Re: OpenGL minimum working example?

hernanmd
Hello Tomo,

Thank you, very interesting project!
BTW to load Jun4Pharo with UFFI OpenGL the expression is:

Gofer new
    smalltalkhubUser: 'tomooda' project: 'Jun4Pharo';
    configurationOf: #Jun;
    load.
(Smalltalk at: #ConfigurationOfJun) project development load: #('Core').

There are only a few warnings during installation:

This package depends on the following classes:
  TabActionButton
  NewListRenderer
  NewList
  Tab
  TabBar
You must resolve these dependencies before you will be able to load
these definitions:
  NewList>>#drawOnAthensCanvas:
  NewListRenderer>>#drawOnAthensCanvas:
  NewListRenderer>>#drawSubmorphsOnAthensCanvas:
  Tab>>#createClosedPolygonPathFrom:on:
  Tab>>#createLinesPathFrom:on:
  Tab>>#drawOnAthensCanvas:
  TabActionButton>>#drawOnAthensCanvas:
  TabBar>>#drawLinesOnAthensCanvas:
  TabBar>>#drawLinesWithSelection:
  TabBar>>#drawSubmorphsOnAthensCanvas:

Most examples works also on Windows on Pharo 7. However the UFFI
OpenGL freezes the image if launched on full-screen.

Cheers,

Hernán


El lun., 12 nov. 2018 a las 20:41, Tomohiro Oda
(<[hidden email]>) escribió:

>
> Hello Hernan,
>
> I tested the code only on Mac.
> ---
> tomo
>
> 2018/11/13(Tue) 8:27 Tomohiro Oda <[hidden email]> wrote:
> >
> > Hello Hernan,
> >
> > I have partially working code at
> > http://smalltalkhub.com/#!/~tomooda/Jun4Pharo
> >
> > My code still have two problems that
> > * depending on resolution, projection matrix can't be properly set, and
> > * it freezes pharo when switching to fullscreen
> >
> > Best Regards,
> > ---
> > tomo
>

Reply | Threaded
Open this post in threaded view
|

Re: OpenGL minimum working example?

Ben Coman
In reply to this post by hernanmd


On Tue, 13 Nov 2018 at 03:37, Hernán Morales Durand <[hidden email]> 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" ...

cheers -ben
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL minimum working example?

Ronie Salgado
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 (<[hidden email]>) escribió:


On Tue, 13 Nov 2018 at 03:37, Hernán Morales Durand <[hidden email]> 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" ...

cheers -ben