Implementing Jocelyn Frechot's changes -- see e-mail of Thursday, 11/8/2007 9:12 AM.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@735 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
afd73e99d6
commit
7f75464b6f
@ -73,11 +73,14 @@
|
||||
* Only one GLUT_AUXn bit may be used at a time.
|
||||
* Value 0x0400 is defined in OpenGLUT.
|
||||
*/
|
||||
#define GLUT_AUX 0x1000
|
||||
|
||||
#define GLUT_AUX1 0x1000
|
||||
#define GLUT_AUX2 0x2000
|
||||
#define GLUT_AUX3 0x4000
|
||||
#define GLUT_AUX4 0x8000
|
||||
|
||||
|
||||
/*
|
||||
* Process loop function, see freeglut_main.c
|
||||
*/
|
||||
@ -98,6 +101,7 @@ FGAPI void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) );
|
||||
* State setting and retrieval functions, see freeglut_state.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutSetOption ( GLenum option_flag, int value );
|
||||
FGAPI int * FGAPIENTRY glutGetModeValues(GLenum mode, int * size);
|
||||
/* A.Donev: User-data manipulation */
|
||||
FGAPI void* FGAPIENTRY glutGetWindowData( void );
|
||||
FGAPI void FGAPIENTRY glutSetWindowData(void* data);
|
||||
|
@ -161,6 +161,7 @@ static GLUTproc fghGetProcAddress( const char* procName )
|
||||
CHECK_NAME(glutWMCloseFunc);
|
||||
CHECK_NAME(glutMenuDestroyFunc);
|
||||
CHECK_NAME(glutSetOption);
|
||||
CHECK_NAME(glutGetModeValues);
|
||||
CHECK_NAME(glutSetWindowData);
|
||||
CHECK_NAME(glutGetWindowData);
|
||||
CHECK_NAME(glutSetMenuData);
|
||||
|
@ -79,7 +79,9 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */
|
||||
GLUT_EXEC_STATE_INIT, /* ExecState */
|
||||
NULL, /* ProgramName */
|
||||
GL_FALSE, /* JoysticksInitialised */
|
||||
GL_FALSE /* InputDevsInitialised */
|
||||
GL_FALSE, /* InputDevsInitialised */
|
||||
0, /* AuxiliaryBufferNumber */
|
||||
0 /* SampleNumber */
|
||||
};
|
||||
|
||||
|
||||
@ -893,7 +895,7 @@ void FGAPIENTRY glutInitDisplayString( const char* displayMode )
|
||||
break ;
|
||||
|
||||
case 36 : /* "aux": some number of aux buffers */
|
||||
glut_state_flag |= GLUT_AUX1;
|
||||
glut_state_flag |= GLUT_AUX;
|
||||
break ;
|
||||
|
||||
case 37 : /* Unrecognized */
|
||||
|
@ -302,6 +302,9 @@ struct tagSFG_State
|
||||
char *ProgramName; /* Name of the invoking program */
|
||||
GLboolean JoysticksInitialised; /* Only initialize if application calls for them */
|
||||
GLboolean InputDevsInitialised; /* Only initialize if application calls for them */
|
||||
|
||||
int AuxiliaryBufferNumber; /* Number of auxiliary buffers */
|
||||
int SampleNumber; /* Number of samples per pixel */
|
||||
};
|
||||
|
||||
/* The structure used by display initialization in freeglut_init.c */
|
||||
|
@ -116,6 +116,14 @@ void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
|
||||
fgStructure.CurrentWindow->State.Cursor = value;
|
||||
break;
|
||||
|
||||
case GLUT_AUX:
|
||||
fgState.AuxiliaryBufferNumber = value;
|
||||
break;
|
||||
|
||||
case GLUT_MULTISAMPLE:
|
||||
fgState.SampleNumber = value;
|
||||
break;
|
||||
|
||||
default:
|
||||
fgWarning( "glutSetOption(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
@ -720,4 +728,114 @@ int FGAPIENTRY glutLayerGet( GLenum eWhat )
|
||||
return -1;
|
||||
}
|
||||
|
||||
int * FGAPIENTRY glutGetModeValues(GLenum eWhat, int * size)
|
||||
{
|
||||
int * array;
|
||||
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
int attributes[9];
|
||||
GLXFBConfig * fbconfigArray; /* Array of FBConfigs */
|
||||
int fbconfigArraySize; /* Number of FBConfigs in the array */
|
||||
int attribute_name = 0;
|
||||
#endif
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED("glutGetModeValues");
|
||||
|
||||
array = NULL;
|
||||
*size = 0;
|
||||
|
||||
switch (eWhat)
|
||||
{
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
case GLUT_AUX:
|
||||
case GLUT_MULTISAMPLE:
|
||||
|
||||
attributes[0] = GLX_BUFFER_SIZE;
|
||||
attributes[1] = GLX_DONT_CARE;
|
||||
|
||||
switch (eWhat)
|
||||
{
|
||||
case GLUT_AUX:
|
||||
/*
|
||||
FBConfigs are now sorted by increasing number of auxiliary
|
||||
buffers. We want at least one buffer.
|
||||
*/
|
||||
attributes[2] = GLX_AUX_BUFFERS;
|
||||
attributes[3] = 1;
|
||||
attributes[4] = None;
|
||||
|
||||
attribute_name = GLX_AUX_BUFFERS;
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case GLUT_MULTISAMPLE:
|
||||
attributes[2] = GLX_AUX_BUFFERS;
|
||||
attributes[3] = GLX_DONT_CARE;
|
||||
attributes[4] = GLX_SAMPLE_BUFFERS;
|
||||
attributes[5] = 1;
|
||||
/*
|
||||
FBConfigs are now sorted by increasing number of samples per
|
||||
pixel. We want at least one sample.
|
||||
*/
|
||||
attributes[6] = GLX_SAMPLES;
|
||||
attributes[7] = 1;
|
||||
attributes[8] = None;
|
||||
|
||||
attribute_name = GLX_SAMPLES;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
fbconfigArray = glXChooseFBConfig(fgDisplay.Display,
|
||||
fgDisplay.Screen,
|
||||
attributes,
|
||||
&fbconfigArraySize);
|
||||
|
||||
if (fbconfigArray != NULL)
|
||||
{
|
||||
int * temp_array;
|
||||
int result; /* Returned by glXGetFBConfigAttrib. Not checked. */
|
||||
int previous_value;
|
||||
int i;
|
||||
|
||||
temp_array = malloc(sizeof(int) * fbconfigArraySize);
|
||||
previous_value = 0;
|
||||
|
||||
for (i = 0; i < fbconfigArraySize; i++)
|
||||
{
|
||||
int value;
|
||||
|
||||
result = glXGetFBConfigAttrib(fgDisplay.Display,
|
||||
fbconfigArray[i],
|
||||
attribute_name,
|
||||
&value);
|
||||
if (value > previous_value)
|
||||
{
|
||||
temp_array[*size] = value;
|
||||
previous_value = value;
|
||||
(*size)++;
|
||||
}
|
||||
}
|
||||
|
||||
array = malloc(sizeof(int) * (*size));
|
||||
for (i = 0; i < *size; i++)
|
||||
{
|
||||
array[i] = temp_array[i];
|
||||
}
|
||||
|
||||
free(temp_array);
|
||||
XFree(fbconfigArray);
|
||||
}
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
@ -219,12 +219,6 @@ void fgDestroyWindow( SFG_Window* window )
|
||||
|
||||
fghClearCallBacks( window );
|
||||
fgCloseWindow( window );
|
||||
#if TARGET_HOST_UNIX_X11
|
||||
if (window->Window.FBConfig != NULL)
|
||||
{
|
||||
XFree( window->Window.FBConfig );
|
||||
}
|
||||
#endif
|
||||
free( window );
|
||||
if( fgStructure.CurrentWindow == window )
|
||||
fgStructure.CurrentWindow = NULL;
|
||||
|
@ -128,19 +128,20 @@ GLXFBConfig* fgChooseFBConfig( void )
|
||||
ATTRIB_VAL( GLX_ACCUM_ALPHA_SIZE, 1 );
|
||||
}
|
||||
|
||||
if( fgState.DisplayMode & GLUT_AUX1 )
|
||||
ATTRIB_VAL( GLX_AUX_BUFFERS, 1 );
|
||||
if( fgState.DisplayMode & GLUT_AUX2 )
|
||||
ATTRIB_VAL( GLX_AUX_BUFFERS, 2 );
|
||||
if( fgState.DisplayMode & GLUT_AUX3 )
|
||||
ATTRIB_VAL( GLX_AUX_BUFFERS, 3 );
|
||||
if( fgState.DisplayMode & GLUT_AUX4 )
|
||||
ATTRIB_VAL( GLX_AUX_BUFFERS, 4 );
|
||||
if ( fgState.DisplayMode & GLUT_MULTISAMPLE )
|
||||
if ((fgState.DisplayMode & GLUT_AUX)
|
||||
|| (fgState.DisplayMode & GLUT_AUX1)
|
||||
|| (fgState.DisplayMode & GLUT_AUX2)
|
||||
|| (fgState.DisplayMode & GLUT_AUX3)
|
||||
|| (fgState.DisplayMode & GLUT_AUX4))
|
||||
{
|
||||
ATTRIB_VAL( GLX_SAMPLE_BUFFERS, 1 );
|
||||
ATTRIB_VAL(GLX_AUX_BUFFERS, fgState.AuxiliaryBufferNumber)
|
||||
}
|
||||
|
||||
if (fgState.DisplayMode & GLUT_MULTISAMPLE)
|
||||
{
|
||||
ATTRIB_VAL(GLX_SAMPLE_BUFFERS, 1)
|
||||
ATTRIB_VAL(GLX_SAMPLES, fgState.SampleNumber)
|
||||
}
|
||||
|
||||
/* Push a null at the end of the list */
|
||||
ATTRIB( None );
|
||||
@ -896,7 +897,7 @@ void fgCloseWindow( SFG_Window* window )
|
||||
glXDestroyContext( fgDisplay.Display, window->Window.Context );
|
||||
XFree( window->Window.FBConfig );
|
||||
XDestroyWindow( fgDisplay.Display, window->Window.Handle );
|
||||
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
|
||||
/* XFlush( fgDisplay.Display ); */ /* XXX Shouldn't need this */
|
||||
|
||||
#elif TARGET_HOST_MS_WINDOWS
|
||||
|
||||
|
Reference in New Issue
Block a user