Hi Robert,

On Mar 2, 2012, at 11:39 , Robert Osfield wrote:

> Hi David,
> 
> On 2 March 2012 09:02, David Garcia <[email protected]> wrote:
>> 
>> Hi Robert,
>> 
>> Find attached my modifications to compile OSG under MAC OS X with GL3. It 
>> compiles OK but unfortunatelly I got errors when executing the sample app:
> 
> Do you mean the osgsimplegl3 sample app?  Another application?
> 

osgsimplegl3


>> Warning: TexGen::apply(State&) - not supported.
>> Warning: Material::apply(State&) - not supported.
>> Warning: TexGen::apply(State&) - not supported.
>> Warning: detected OpenGL error 'invalid enumerant' at after 
>> RenderBin::draw(..)
> 
> None of the TexGen and Material state attributes are supported by core
> GL3 so using these state attributes in the scene graph driving a GL3
> application is inappropriate.
> 

No idea, they appears when executing osgsimplegl3.

>> 
>> In any case it creates the right context:
>> glVersion=3.2, isGlslSupported=YES, glslLanguageVersion=1.5
>> 
>> The changes are:
>> 1) In GL I add two includes, three defines for missing symbols and an ifdef 
>> __APPLE__
>> 
>>    #if defined(OSG_GL3_AVAILABLE)
>>        #ifdef __APPLE__
>>                #include <OpenGL/OpenGL.h>
>>                #include <OpenGL/gl3.h>
>>                #define GLint64EXT GLint64
>>                #define GLuint64EXT GLuint64
>>                #define GL_BGRA_EXT GL_BGRA
>>        #else
>>                #include <GL3/gl3.h>
>>                #define GL3_PROTOTYPES 1
>>        #endif
> 
> Why did you swap the ordering of the #define GL3_PROTOTYPES 1 in the
> #else section?
> 

In OS X 10.7 gl3.h already defines GL3_PROTOTYPES, not required.


> Why do you include OpenGL/OpenGL.h?  This would include lots of OpenGL
> features that are inappropriate to a GL3 application.   What errors do
> you get if you just include gl3.h?

OpenGL defines CGL functions. I will check later today if it is required.

> 
>> 2) Setting the pixel format as Stephan suggests. I have protect the access 
>> to NSOpenGLProfileVersion3_2Core with an ifdef, different from the 
>> implementation in Win32.
>> 
>> In bool GraphicsWindowCocoa::realizeImplementation():
>> #if defined(OSG_GL3_AVAILABLE)
>>    if( _traits->glContextVersion == "3.2" ){
>>        OSG_NOTIFY( osg::INFO ) << "GL3: Attempting to create OpenGL3 
>> context." << std::endl;
>>        OSG_NOTIFY( osg::INFO ) << "GL3: version: " << 
>> _traits->glContextVersion << std::endl;
>> 
>>            attr[i++] = NSOpenGLPFAOpenGLProfile;
>>            attr[i++] = NSOpenGLProfileVersion3_2Core;
>>        }
>> #endif
> 
> What of the values of NSOpenGLProfileVersion are supported?  

NSOpenGLProfileVersion3_2Core was introduced in the 10.7 SDK and is defined in:
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSOpenGL.h

Is an enum with to values 0x1000 for the legacy version (pore OpenGL 3.0) and 
0x3200 for Open GL 3.2

> Is this a
> #define?  Could we avoid having the #if defined(..) here and just
> detect enable the 3_2 profile when the glContextVersion requests it?
> I'm a bit concerned about the tying of version number to 3.2 and this
> in turn requiring calling code to specifically ask for 3.2, but only
> for OSX.  I'd like to make things so they are more portable and
> robust.  For instance if one asks for 3.1 and only 3.2 is available it
> should be safe to just level the 3.2 profile handle it.  Only if one
> asks for something greater than 3.2 might one decide to issue a
> warning/error.
> 

I have not be able to found another way to activate it without using this enum. 
Rumors are that Mountain Lion will support extra values making the code uglier. 
Another solution will be to use the value of the enum (NSOpenGLPFAOpenGLProfile 
is 99 and NSOpenGLProfileVersion3_2Core is 0x3200) but seems even less elegant.


> 
>> 3) In osgsimplegl3, when compiling for Mac, the minimum version is 3.2
>> 
>> #ifdef __APPLE__
>>    const std::string version( "3.2" );
>> #else
>>    const std::string version( "3.1" );
>> #endif
> 
> I'd very much like to avoid pushing platform specifics into sample codes.
> 

In OS X is either legacy (pre OpenGL 3.0) or 3.2. A solution is to move the 
example to version 3.2 (upgrading maybe the functions to 1.5). As far as I know 
Windows and Linux supports 3.2 out of the box. Not sure about older versions 
and/or why do you code the example using 3.1.

If applying your suggestion "...if one asks for 3.1 and only 3.2..." will also 
work.

Thanks,

   David

> Robert.
> _______________________________________________
> osg-submissions mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

David Garcia 
Technical Director 


_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to