@@ -644,11 +644,101 @@ OSMesaCreateContext( GLenum format, OSMesaContext sharelist )
644
644
GLAPI OSMesaContext GLAPIENTRY
645
645
OSMesaCreateContextExt ( GLenum format , GLint depthBits , GLint stencilBits ,
646
646
GLint accumBits , OSMesaContext sharelist )
647
+ {
648
+ int attribs [100 ], n = 0 ;
649
+
650
+ attribs [n ++ ] = OSMESA_FORMAT ;
651
+ attribs [n ++ ] = format ;
652
+ attribs [n ++ ] = OSMESA_DEPTH_BITS ;
653
+ attribs [n ++ ] = depthBits ;
654
+ attribs [n ++ ] = OSMESA_STENCIL_BITS ;
655
+ attribs [n ++ ] = stencilBits ;
656
+ attribs [n ++ ] = OSMESA_ACCUM_BITS ;
657
+ attribs [n ++ ] = accumBits ;
658
+ attribs [n ++ ] = 0 ;
659
+
660
+ return OSMesaCreateContextAttribs (attribs , sharelist );
661
+ }
662
+
663
+
664
+ /**
665
+ * New in Mesa 11.2
666
+ *
667
+ * Create context with attribute list.
668
+ */
669
+ GLAPI OSMesaContext GLAPIENTRY
670
+ OSMesaCreateContextAttribs (const int * attribList , OSMesaContext sharelist )
647
671
{
648
672
OSMesaContext osmesa ;
649
673
struct dd_function_table functions ;
650
674
GLint rind , gind , bind , aind ;
651
675
GLint redBits = 0 , greenBits = 0 , blueBits = 0 , alphaBits = 0 ;
676
+ GLenum format = OSMESA_RGBA ;
677
+ GLint depthBits = 0 , stencilBits = 0 , accumBits = 0 ;
678
+ int profile = OSMESA_COMPAT_PROFILE , version_major = 1 , version_minor = 0 ;
679
+ gl_api api_profile = API_OPENGL_COMPAT ;
680
+ int i ;
681
+
682
+ for (i = 0 ; attribList [i ]; i += 2 ) {
683
+ switch (attribList [i ]) {
684
+ case OSMESA_FORMAT :
685
+ format = attribList [i + 1 ];
686
+ switch (format ) {
687
+ case OSMESA_COLOR_INDEX :
688
+ case OSMESA_RGBA :
689
+ case OSMESA_BGRA :
690
+ case OSMESA_ARGB :
691
+ case OSMESA_RGB :
692
+ case OSMESA_BGR :
693
+ case OSMESA_RGB_565 :
694
+ /* legal */
695
+ break ;
696
+ default :
697
+ return NULL ;
698
+ }
699
+ break ;
700
+ case OSMESA_DEPTH_BITS :
701
+ depthBits = attribList [i + 1 ];
702
+ if (depthBits < 0 )
703
+ return NULL ;
704
+ break ;
705
+ case OSMESA_STENCIL_BITS :
706
+ stencilBits = attribList [i + 1 ];
707
+ if (stencilBits < 0 )
708
+ return NULL ;
709
+ break ;
710
+ case OSMESA_ACCUM_BITS :
711
+ accumBits = attribList [i + 1 ];
712
+ if (accumBits < 0 )
713
+ return NULL ;
714
+ break ;
715
+ case OSMESA_PROFILE :
716
+ profile = attribList [i + 1 ];
717
+ if (profile == OSMESA_COMPAT_PROFILE )
718
+ api_profile = API_OPENGL_COMPAT ;
719
+ else if (profile == OSMESA_CORE_PROFILE )
720
+ api_profile = API_OPENGL_CORE ;
721
+ else
722
+ return NULL ;
723
+ break ;
724
+ case OSMESA_CONTEXT_MAJOR_VERSION :
725
+ version_major = attribList [i + 1 ];
726
+ if (version_major < 1 )
727
+ return NULL ;
728
+ break ;
729
+ case OSMESA_CONTEXT_MINOR_VERSION :
730
+ version_minor = attribList [i + 1 ];
731
+ if (version_minor < 0 )
732
+ return NULL ;
733
+ break ;
734
+ case 0 :
735
+ /* end of list */
736
+ break ;
737
+ default :
738
+ fprintf (stderr , "Bad attribute in OSMesaCreateContextAttribs()\n" );
739
+ return NULL ;
740
+ }
741
+ }
652
742
653
743
rind = gind = bind = aind = 0 ;
654
744
if (format == OSMESA_RGBA ) {
@@ -742,7 +832,7 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
742
832
functions .UpdateState = osmesa_update_state ;
743
833
744
834
if (!_mesa_initialize_context (& osmesa -> mesa ,
745
- API_OPENGL_COMPAT ,
835
+ api_profile ,
746
836
osmesa -> gl_visual ,
747
837
sharelist ? & sharelist -> mesa
748
838
: (struct gl_context * ) NULL ,
@@ -819,6 +909,13 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
819
909
820
910
_mesa_compute_version (ctx );
821
911
912
+ if (ctx -> Version < version_major * 10 + version_minor ) {
913
+ _mesa_destroy_visual (osmesa -> gl_visual );
914
+ _mesa_free_context_data (ctx );
915
+ free (osmesa );
916
+ return NULL ;
917
+ }
918
+
822
919
/* Exec table initialization requires the version to be computed */
823
920
_mesa_initialize_dispatch_tables (ctx );
824
921
_mesa_initialize_vbo_vtxfmt (ctx );
@@ -1121,6 +1218,7 @@ struct name_function
1121
1218
static struct name_function functions [] = {
1122
1219
{ "OSMesaCreateContext" , (OSMESAproc ) OSMesaCreateContext },
1123
1220
{ "OSMesaCreateContextExt" , (OSMESAproc ) OSMesaCreateContextExt },
1221
+ { "OSMesaCreateContextAttribs" , (OSMESAproc ) OSMesaCreateContextAttribs },
1124
1222
{ "OSMesaDestroyContext" , (OSMESAproc ) OSMesaDestroyContext },
1125
1223
{ "OSMesaMakeCurrent" , (OSMESAproc ) OSMesaMakeCurrent },
1126
1224
{ "OSMesaGetCurrentContext" , (OSMESAproc ) OSMesaGetCurrentContext },
0 commit comments