On 17 May 2013 10:21, kilon <[email protected]> wrote:
> Thank you all for your replies. I have used the solution I get new errors
> now. Is there an example how to create a context with NBOpenGL because the
> examples NBOpenGL is coming with are confusing at best ?
>

Pharo2.0
Latest update: #20590

(ConfigurationOfNBOpenGL project version: '2.0') load

GLTTRenderingDemo new openInWorld

(works well.. no errors whatsoever)

See a superclass (GLViewportMorph).

The context created using:

display := NBGLDisplay extent: self extent.

To get access to OpenGL API (a subinstance of NBOpenGL)

just use:

display gl.

The actual class, responsible for creating OpenGL context is
one of NBGLContextDriver subclasses, since
it is highly platform-specific.


driver := NBGLContextDriver createContext: 100@100.
gl := driver gl.

The display (NBGLDisplay) wraps around driver and has some initialization
to set up defaults and resource management to make sure resources
released when it garbage collected
(the driver does not, and you must free it explicitly).

To use GL API , just send #gl message to either display or driver:

drawCube

        | gl |
        gl := display gl.
        

        gl translatef_x: -1.5 y: 0 z: -60.
        gl rotatef_angle: rotationAngle x: 0 y: 1  z: 0.
                                                
        gl
                begin: GL_TRIANGLES;                                            
                                                        
               ...
                end.
                
Please note, that in NBGLContextDriver(s) i hardcoded many things like
pixel format,
and NBOffscreenDisplay rendering into offscreen buffer etc.

That means, if you want to create own initializer, i would start from
making own driver.
Sorry but the stuff there is highly platform specific.
Making a generic driver which would accept some initialization options
(like pixel format, number of buffers etc) while freeing user from
platform-specific horrors is something which could be done in future.
But as i said before, the devil is always in details , and i would
just leave this to application developer.

P.S. If , by chance, you wanna make things less confusing and more
obvious, feel free to contribute to the project,
i can add you as developer.
You can change/improve anything. I only asking to keep
GLTTRenderingDemo working :)

> --
> View this message in context: 
> http://forum.world.st/Understanding-NBOpenGL-tp4686514p4688138.html
> Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
>



-- 
Best regards,
Igor Stasenko.

Reply via email to