On Thu, Oct 11, 2012 at 8:39 AM, PGGB <[email protected]> wrote:
> I've been messing around with Factor the last couple weeks and it is a lot of 
> fun. At the same time I am learning some graphics programming with OpenGL. 
> Now even though version 3.2 was added with Lion, the windows Factor creates 
> only seem to allow version 2.1.
>
> I was looking for a way to add the required flag but my knowledge of both 
> Cocoa and Factor is to small to really know what I am doing. Does anyone have 
> any suggestions?

OS X only supports core profile OpenGL 3.2, so to get a 3.2-capable
context, you have to ask for one explicitly by initializing the
NSOpenGLPixelFormat with these attributes:

```
    NSOpenGLPixelFormatAttribute pfa[] = {
        /* ... other attributes ... */
        NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
        0
    };
```

You could make this work in Factor by adding a `core-profile` symbol
to `ui.pixel-formats`, and updating `ui.backend.cocoa` to use those
pixel format attributes. You could then create a core profile window
with this code:

```
USE: ui.gadgets.worlds.null
<world-attributes>
    "Core Profile World" >>title
    null-world >>world-class
    {
        windowed
        double-buffered
        backing-store
        T{ depth-bits f 24 }
        core-profile
    } >>pixel-format-attributes
    { 512 512 } >>pref-dim
    f swap open-window*
```

That will open a window and leave the window object on the listener's
stack. You can then use `into-window` to send GL commands to the
window interactively:

```
dup [ 1.0 1.0 0.0 0.0 glClearColor GL_COLOR_BUFFER_BIT glClear ] into-window
```

Note that, although compatibility profile contexts in OS X report 2.1,
on most 3.2-capable graphics cards, all of the 3.2 features are also
supported by ARB extensions to 2.1, and Factor's OpenGL binding is
smart enough to substitute ARB or EXT entry points for standardized
entry points when the standard entry points are unavailable. If you
can't get core profile mode to work, you should be able to write 3.2
code and have it still just work, if your graphics driver supports
3.2.

-Joe

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to