Add missing new _glx files
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1197 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
5d6c1b44f4
commit
468a43416d
6
.gitattributes
vendored
6
.gitattributes
vendored
@ -119,20 +119,24 @@ freeglut/freeglut/src/util/xparsegeometry_repl.c -text
|
|||||||
freeglut/freeglut/src/util/xparsegeometry_repl.h -text
|
freeglut/freeglut/src/util/xparsegeometry_repl.h -text
|
||||||
freeglut/freeglut/src/x11 svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11 svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/x11/fg_cursor_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_cursor_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/x11/fg_display_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_display_x11_glx.c -text
|
||||||
freeglut/freeglut/src/x11/fg_ext_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_ext_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/x11/fg_gamemode_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_gamemode_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/x11/fg_glutfont_definitions_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_glutfont_definitions_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/x11/fg_init_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_init_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/x11/fg_input_devices_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_input_devices_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/x11/fg_internal_x11.h svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_internal_x11.h svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
|
freeglut/freeglut/src/x11/fg_internal_x11_glx.h -text
|
||||||
freeglut/freeglut/src/x11/fg_joystick_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_joystick_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/x11/fg_main_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_main_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/x11/fg_menu_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_menu_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/x11/fg_spaceball_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_spaceball_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/x11/fg_state_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_state_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
|
freeglut/freeglut/src/x11/fg_state_x11_glx.c -text
|
||||||
freeglut/freeglut/src/x11/fg_structure_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_structure_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/x11/fg_window_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_window_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
|
freeglut/freeglut/src/x11/fg_window_x11_glx.c -text
|
||||||
|
freeglut/freeglut/src/x11/fg_window_x11_glx.h -text
|
||||||
freeglut/freeglut/src/x11/fg_xinput_x11.c -text svnc_svn_005fkeywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/x11/fg_xinput_x11.c -text svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||||
freeglut/web-src/basic_page.php svn_keywords=Author+Date+Id+Revision
|
freeglut/web-src/basic_page.php svn_keywords=Author+Date+Id+Revision
|
||||||
freeglut/web-src/docs/api.php svn_keywords=Author+Date+Id+Revision
|
freeglut/web-src/docs/api.php svn_keywords=Author+Date+Id+Revision
|
||||||
|
84
freeglut/freeglut/src/x11/fg_internal_x11_glx.h
Normal file
84
freeglut/freeglut/src/x11/fg_internal_x11_glx.h
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* freeglut_internal_x11.h
|
||||||
|
*
|
||||||
|
* The freeglut library private include file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||||
|
* Creation date: Fri Jan 20, 2012
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FREEGLUT_INTERNAL_X11_GLX_H
|
||||||
|
#define FREEGLUT_INTERNAL_X11_GLX_H
|
||||||
|
|
||||||
|
/* If GLX is too old, we will fail during runtime when multisampling
|
||||||
|
is requested, but at least freeglut compiles. */
|
||||||
|
#ifndef GLX_SAMPLE_BUFFERS
|
||||||
|
# define GLX_SAMPLE_BUFFERS 0x80A8
|
||||||
|
#endif
|
||||||
|
#ifndef GLX_SAMPLES
|
||||||
|
# define GLX_SAMPLES 0x80A9
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB
|
||||||
|
#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_CONTEXT_MAJOR_VERSION_ARB
|
||||||
|
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_CONTEXT_MINOR_VERSION_ARB
|
||||||
|
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_CONTEXT_FLAGS_ARB
|
||||||
|
#define GLX_CONTEXT_FLAGS_ARB 0x2094
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_CONTEXT_PROFILE_MASK_ARB
|
||||||
|
#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_CONTEXT_DEBUG_BIT_ARB
|
||||||
|
#define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
|
||||||
|
#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_CONTEXT_CORE_PROFILE_BIT_ARB
|
||||||
|
#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
|
||||||
|
#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_RGBA_FLOAT_TYPE
|
||||||
|
#define GLX_RGBA_FLOAT_TYPE 0x20B9
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_RGBA_FLOAT_BIT
|
||||||
|
#define GLX_RGBA_FLOAT_BIT 0x00000004
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
213
freeglut/freeglut/src/x11/fg_state_x11_glx.c
Normal file
213
freeglut/freeglut/src/x11/fg_state_x11_glx.c
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
/*
|
||||||
|
* fg_state_x11_glx.c
|
||||||
|
*
|
||||||
|
* X11-specific freeglut state query methods.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||||
|
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||||
|
* Creation date: Sat Feb 4 2012
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <GL/freeglut.h>
|
||||||
|
#include "fg_internal.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Queries the GL context about some attributes
|
||||||
|
*/
|
||||||
|
int fgPlatformGetConfig( int attribute )
|
||||||
|
{
|
||||||
|
int returnValue = 0;
|
||||||
|
int result; /* Not checked */
|
||||||
|
|
||||||
|
if( fgStructure.CurrentWindow )
|
||||||
|
result = glXGetFBConfigAttrib( fgDisplay.pDisplay.Display,
|
||||||
|
fgStructure.CurrentWindow->Window.pContext.FBConfig,
|
||||||
|
attribute,
|
||||||
|
&returnValue );
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fghPlatformGlutGetGLX ( GLenum eWhat )
|
||||||
|
{
|
||||||
|
switch( eWhat )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* The window/context specific queries are handled mostly by
|
||||||
|
* fgPlatformGetConfig().
|
||||||
|
*/
|
||||||
|
case GLUT_WINDOW_NUM_SAMPLES:
|
||||||
|
{
|
||||||
|
int nsamples = 0;
|
||||||
|
#ifdef GLX_VERSION_1_3
|
||||||
|
glGetIntegerv(GL_SAMPLES, &nsamples);
|
||||||
|
#endif
|
||||||
|
return nsamples;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The rest of GLX queries under X are general enough to use a macro to
|
||||||
|
* check them
|
||||||
|
*/
|
||||||
|
# define GLX_QUERY(a,b) case a: return fgPlatformGetConfig( b );
|
||||||
|
|
||||||
|
GLX_QUERY( GLUT_WINDOW_RGBA, GLX_RGBA );
|
||||||
|
GLX_QUERY( GLUT_WINDOW_DOUBLEBUFFER, GLX_DOUBLEBUFFER );
|
||||||
|
GLX_QUERY( GLUT_WINDOW_BUFFER_SIZE, GLX_BUFFER_SIZE );
|
||||||
|
GLX_QUERY( GLUT_WINDOW_STENCIL_SIZE, GLX_STENCIL_SIZE );
|
||||||
|
GLX_QUERY( GLUT_WINDOW_DEPTH_SIZE, GLX_DEPTH_SIZE );
|
||||||
|
GLX_QUERY( GLUT_WINDOW_RED_SIZE, GLX_RED_SIZE );
|
||||||
|
GLX_QUERY( GLUT_WINDOW_GREEN_SIZE, GLX_GREEN_SIZE );
|
||||||
|
GLX_QUERY( GLUT_WINDOW_BLUE_SIZE, GLX_BLUE_SIZE );
|
||||||
|
GLX_QUERY( GLUT_WINDOW_ALPHA_SIZE, GLX_ALPHA_SIZE );
|
||||||
|
GLX_QUERY( GLUT_WINDOW_ACCUM_RED_SIZE, GLX_ACCUM_RED_SIZE );
|
||||||
|
GLX_QUERY( GLUT_WINDOW_ACCUM_GREEN_SIZE, GLX_ACCUM_GREEN_SIZE );
|
||||||
|
GLX_QUERY( GLUT_WINDOW_ACCUM_BLUE_SIZE, GLX_ACCUM_BLUE_SIZE );
|
||||||
|
GLX_QUERY( GLUT_WINDOW_ACCUM_ALPHA_SIZE, GLX_ACCUM_ALPHA_SIZE );
|
||||||
|
GLX_QUERY( GLUT_WINDOW_STEREO, GLX_STEREO );
|
||||||
|
|
||||||
|
# undef GLX_QUERY
|
||||||
|
|
||||||
|
/* I do not know yet if there will be a fgChooseVisual() function for Win32 */
|
||||||
|
case GLUT_DISPLAY_MODE_POSSIBLE:
|
||||||
|
{
|
||||||
|
/* We should not have to call fghChooseConfig again here. */
|
||||||
|
GLXFBConfig config;
|
||||||
|
return fghChooseConfig(&config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is system-dependant */
|
||||||
|
case GLUT_WINDOW_FORMAT_ID:
|
||||||
|
if( fgStructure.CurrentWindow == NULL )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return fgPlatformGetConfig( GLX_VISUAL_ID );
|
||||||
|
|
||||||
|
default:
|
||||||
|
fgWarning( "glutGet(): missing enum handle %d", eWhat );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size)
|
||||||
|
{
|
||||||
|
int *array;
|
||||||
|
|
||||||
|
int attributes[9];
|
||||||
|
GLXFBConfig * fbconfigArray; /* Array of FBConfigs */
|
||||||
|
int fbconfigArraySize; /* Number of FBConfigs in the array */
|
||||||
|
int attribute_name = 0;
|
||||||
|
|
||||||
|
array = NULL;
|
||||||
|
*size = 0;
|
||||||
|
|
||||||
|
switch (eWhat)
|
||||||
|
{
|
||||||
|
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.pDisplay.Display,
|
||||||
|
fgDisplay.pDisplay.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.pDisplay.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;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
266
freeglut/freeglut/src/x11/fg_window_x11_glx.c
Normal file
266
freeglut/freeglut/src/x11/fg_window_x11_glx.c
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
/*
|
||||||
|
* fg_window_x11_glx.c
|
||||||
|
*
|
||||||
|
* Window management methods for X11 with GLX
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||||
|
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||||
|
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||||
|
* Creation date: Thur Feb 2 2012
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define FREEGLUT_BUILDING_LIB
|
||||||
|
#include <GL/freeglut.h>
|
||||||
|
#include "fg_internal.h"
|
||||||
|
|
||||||
|
/* pushing attribute/value pairs into an array */
|
||||||
|
#define ATTRIB(a) attributes[where++]=(a)
|
||||||
|
#define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chooses a visual basing on the current display mode settings
|
||||||
|
*/
|
||||||
|
|
||||||
|
int fghChooseConfig(GLXFBConfig* fbconfig)
|
||||||
|
{
|
||||||
|
GLboolean wantIndexedMode = GL_FALSE;
|
||||||
|
int attributes[ 100 ];
|
||||||
|
int where = 0, numAuxBuffers;
|
||||||
|
|
||||||
|
/* First we have to process the display mode settings... */
|
||||||
|
if( fgState.DisplayMode & GLUT_INDEX ) {
|
||||||
|
ATTRIB_VAL( GLX_BUFFER_SIZE, 8 );
|
||||||
|
/* Buffer size is selected later. */
|
||||||
|
|
||||||
|
ATTRIB_VAL( GLX_RENDER_TYPE, GLX_COLOR_INDEX_BIT );
|
||||||
|
wantIndexedMode = GL_TRUE;
|
||||||
|
} else {
|
||||||
|
ATTRIB_VAL( GLX_RED_SIZE, 1 );
|
||||||
|
ATTRIB_VAL( GLX_GREEN_SIZE, 1 );
|
||||||
|
ATTRIB_VAL( GLX_BLUE_SIZE, 1 );
|
||||||
|
if( fgState.DisplayMode & GLUT_ALPHA ) {
|
||||||
|
ATTRIB_VAL( GLX_ALPHA_SIZE, 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( fgState.DisplayMode & GLUT_DOUBLE ) {
|
||||||
|
ATTRIB_VAL( GLX_DOUBLEBUFFER, True );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( fgState.DisplayMode & GLUT_STEREO ) {
|
||||||
|
ATTRIB_VAL( GLX_STEREO, True );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( fgState.DisplayMode & GLUT_DEPTH ) {
|
||||||
|
ATTRIB_VAL( GLX_DEPTH_SIZE, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( fgState.DisplayMode & GLUT_STENCIL ) {
|
||||||
|
ATTRIB_VAL( GLX_STENCIL_SIZE, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( fgState.DisplayMode & GLUT_ACCUM ) {
|
||||||
|
ATTRIB_VAL( GLX_ACCUM_RED_SIZE, 1 );
|
||||||
|
ATTRIB_VAL( GLX_ACCUM_GREEN_SIZE, 1 );
|
||||||
|
ATTRIB_VAL( GLX_ACCUM_BLUE_SIZE, 1 );
|
||||||
|
if( fgState.DisplayMode & GLUT_ALPHA ) {
|
||||||
|
ATTRIB_VAL( GLX_ACCUM_ALPHA_SIZE, 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
numAuxBuffers = fghNumberOfAuxBuffersRequested();
|
||||||
|
if ( numAuxBuffers > 0 ) {
|
||||||
|
ATTRIB_VAL( GLX_AUX_BUFFERS, numAuxBuffers );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( fgState.DisplayMode & GLUT_SRGB ) {
|
||||||
|
ATTRIB_VAL( GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, True );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fgState.DisplayMode & GLUT_MULTISAMPLE) {
|
||||||
|
ATTRIB_VAL(GLX_SAMPLE_BUFFERS, 1);
|
||||||
|
ATTRIB_VAL(GLX_SAMPLES, fgState.SampleNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Push a terminator at the end of the list */
|
||||||
|
ATTRIB( None );
|
||||||
|
|
||||||
|
{
|
||||||
|
GLXFBConfig * fbconfigArray; /* Array of FBConfigs */
|
||||||
|
int fbconfigArraySize; /* Number of FBConfigs in the array */
|
||||||
|
|
||||||
|
|
||||||
|
/* Get all FBConfigs that match "attributes". */
|
||||||
|
fbconfigArray = glXChooseFBConfig( fgDisplay.pDisplay.Display,
|
||||||
|
fgDisplay.pDisplay.Screen,
|
||||||
|
attributes,
|
||||||
|
&fbconfigArraySize );
|
||||||
|
|
||||||
|
if (fbconfigArray != NULL)
|
||||||
|
{
|
||||||
|
int result; /* Returned by glXGetFBConfigAttrib, not checked. */
|
||||||
|
|
||||||
|
|
||||||
|
if( wantIndexedMode )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* In index mode, we want the largest buffer size, i.e. visual
|
||||||
|
* depth. Here, FBConfigs are sorted by increasing buffer size
|
||||||
|
* first, so FBConfigs with the largest size come last.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int bufferSizeMin, bufferSizeMax;
|
||||||
|
|
||||||
|
/* Get bufferSizeMin. */
|
||||||
|
result =
|
||||||
|
glXGetFBConfigAttrib( fgDisplay.pDisplay.Display,
|
||||||
|
fbconfigArray[0],
|
||||||
|
GLX_BUFFER_SIZE,
|
||||||
|
&bufferSizeMin );
|
||||||
|
/* Get bufferSizeMax. */
|
||||||
|
result =
|
||||||
|
glXGetFBConfigAttrib( fgDisplay.pDisplay.Display,
|
||||||
|
fbconfigArray[fbconfigArraySize - 1],
|
||||||
|
GLX_BUFFER_SIZE,
|
||||||
|
&bufferSizeMax );
|
||||||
|
|
||||||
|
if (bufferSizeMax > bufferSizeMin)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Free and reallocate fbconfigArray, keeping only FBConfigs
|
||||||
|
* with the largest buffer size.
|
||||||
|
*/
|
||||||
|
XFree(fbconfigArray);
|
||||||
|
|
||||||
|
/* Add buffer size token at the end of the list. */
|
||||||
|
where--;
|
||||||
|
ATTRIB_VAL( GLX_BUFFER_SIZE, bufferSizeMax );
|
||||||
|
ATTRIB( None );
|
||||||
|
|
||||||
|
fbconfigArray = glXChooseFBConfig( fgDisplay.pDisplay.Display,
|
||||||
|
fgDisplay.pDisplay.Screen,
|
||||||
|
attributes,
|
||||||
|
&fbconfigArraySize );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*fbconfig = fbconfigArray[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*fbconfig = NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
XFree(fbconfigArray);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void fghFillContextAttributes( int *attributes ) {
|
||||||
|
int where = 0, contextFlags, contextProfile;
|
||||||
|
|
||||||
|
if ( !fghIsLegacyContextVersionRequested() ) {
|
||||||
|
ATTRIB_VAL( GLX_CONTEXT_MAJOR_VERSION_ARB, fgState.MajorVersion );
|
||||||
|
ATTRIB_VAL( GLX_CONTEXT_MINOR_VERSION_ARB, fgState.MinorVersion );
|
||||||
|
}
|
||||||
|
|
||||||
|
contextFlags =
|
||||||
|
fghMapBit( fgState.ContextFlags, GLUT_DEBUG, GLX_CONTEXT_DEBUG_BIT_ARB ) |
|
||||||
|
fghMapBit( fgState.ContextFlags, GLUT_FORWARD_COMPATIBLE, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB );
|
||||||
|
if ( contextFlags != 0 ) {
|
||||||
|
ATTRIB_VAL( GLX_CONTEXT_FLAGS_ARB, contextFlags );
|
||||||
|
}
|
||||||
|
|
||||||
|
contextProfile =
|
||||||
|
fghMapBit( fgState.ContextProfile, GLUT_CORE_PROFILE, GLX_CONTEXT_CORE_PROFILE_BIT_ARB ) |
|
||||||
|
fghMapBit( fgState.ContextProfile, GLUT_COMPATIBILITY_PROFILE, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB );
|
||||||
|
if ( contextProfile != 0 ) {
|
||||||
|
ATTRIB_VAL( GLX_CONTEXT_PROFILE_MASK_ARB, contextProfile );
|
||||||
|
}
|
||||||
|
|
||||||
|
ATTRIB( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef GLXContext (*CreateContextAttribsProc)(Display *dpy, GLXFBConfig config,
|
||||||
|
GLXContext share_list, Bool direct,
|
||||||
|
const int *attrib_list);
|
||||||
|
|
||||||
|
GLXContext fghCreateNewContext( SFG_Window* window )
|
||||||
|
{
|
||||||
|
/* for color model calculation */
|
||||||
|
int menu = ( window->IsMenu && !fgStructure.MenuContext );
|
||||||
|
int index_mode = ( fgState.DisplayMode & GLUT_INDEX );
|
||||||
|
|
||||||
|
/* "classic" context creation */
|
||||||
|
Display *dpy = fgDisplay.pDisplay.Display;
|
||||||
|
GLXFBConfig config = window->Window.pContext.FBConfig;
|
||||||
|
int render_type = ( !menu && index_mode ) ? GLX_COLOR_INDEX_TYPE : GLX_RGBA_TYPE;
|
||||||
|
GLXContext share_list = NULL;
|
||||||
|
Bool direct = ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT );
|
||||||
|
GLXContext context;
|
||||||
|
|
||||||
|
/* new context creation */
|
||||||
|
int attributes[9];
|
||||||
|
CreateContextAttribsProc createContextAttribs = (CreateContextAttribsProc) fgPlatformGetProcAddress( "glXCreateContextAttribsARB" );
|
||||||
|
|
||||||
|
/* glXCreateContextAttribsARB not found, yet the user has requested the new context creation */
|
||||||
|
if ( !createContextAttribs && !fghIsLegacyContextRequested() ) {
|
||||||
|
fgWarning( "OpenGL >2.1 context requested but glXCreateContextAttribsARB is not available! Falling back to legacy context creation" );
|
||||||
|
fgState.MajorVersion = 2;
|
||||||
|
fgState.MinorVersion = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If nothing fancy has been required, simply use the old context creation GLX API entry */
|
||||||
|
if ( fghIsLegacyContextRequested() || !createContextAttribs )
|
||||||
|
{
|
||||||
|
context = glXCreateNewContext( dpy, config, render_type, share_list, direct );
|
||||||
|
if ( context == NULL ) {
|
||||||
|
fghContextCreationError();
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* color index mode is not available anymore with OpenGL 3.0 */
|
||||||
|
if ( render_type == GLX_COLOR_INDEX_TYPE ) {
|
||||||
|
fgWarning( "color index mode is deprecated, using RGBA mode" );
|
||||||
|
}
|
||||||
|
|
||||||
|
fghFillContextAttributes( attributes );
|
||||||
|
|
||||||
|
context = createContextAttribs( dpy, config, share_list, direct, attributes );
|
||||||
|
if ( context == NULL ) {
|
||||||
|
fghContextCreationError();
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fgPlatformSetWindow ( SFG_Window *window )
|
||||||
|
{
|
||||||
|
if ( window )
|
||||||
|
{
|
||||||
|
glXMakeContextCurrent(
|
||||||
|
fgDisplay.pDisplay.Display,
|
||||||
|
window->Window.Handle,
|
||||||
|
window->Window.Handle,
|
||||||
|
window->Window.Context
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
35
freeglut/freeglut/src/x11/fg_window_x11_glx.h
Normal file
35
freeglut/freeglut/src/x11/fg_window_x11_glx.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* fg_window_x11_glx.c
|
||||||
|
*
|
||||||
|
* Window management methods for X11 with GLX
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||||
|
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||||
|
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||||
|
* Creation date: Thur Feb 2 2012
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __FG_WINDOW_X11_GLX_H__
|
||||||
|
#define __FG_WINDOW_X11_GLX_H__
|
||||||
|
|
||||||
|
extern int fghChooseConfig( GLXFBConfig* fbconfig );
|
||||||
|
extern GLXContext fghCreateNewContext( SFG_Window* window );
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user