Implement EGL fgPlatformGlutGetModeValues and partial/reusable fgPlatformGlutGet
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1183 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
a729bc608f
commit
604018bc92
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -69,6 +69,7 @@ freeglut/freeglut/src/android/native_app_glue/android_native_app_glue.h -text
|
|||||||
freeglut/freeglut/src/egl/fg_display_egl.c -text
|
freeglut/freeglut/src/egl/fg_display_egl.c -text
|
||||||
freeglut/freeglut/src/egl/fg_init_egl.c -text
|
freeglut/freeglut/src/egl/fg_init_egl.c -text
|
||||||
freeglut/freeglut/src/egl/fg_internal_egl.h -text
|
freeglut/freeglut/src/egl/fg_internal_egl.h -text
|
||||||
|
freeglut/freeglut/src/egl/fg_state_egl.c -text
|
||||||
freeglut/freeglut/src/egl/fg_structure_egl.c -text
|
freeglut/freeglut/src/egl/fg_structure_egl.c -text
|
||||||
freeglut/freeglut/src/egl/fg_structure_egl.h -text
|
freeglut/freeglut/src/egl/fg_structure_egl.h -text
|
||||||
freeglut/freeglut/src/egl/fg_window_egl.c -text
|
freeglut/freeglut/src/egl/fg_window_egl.c -text
|
||||||
|
@ -102,6 +102,7 @@ ELSEIF(ANDROID)
|
|||||||
src/egl/fg_internal_egl.h
|
src/egl/fg_internal_egl.h
|
||||||
src/egl/fg_display_egl.c
|
src/egl/fg_display_egl.c
|
||||||
src/egl/fg_init_egl.c
|
src/egl/fg_init_egl.c
|
||||||
|
src/egl/fg_state_egl.c
|
||||||
src/egl/fg_structure_egl.c
|
src/egl/fg_structure_egl.c
|
||||||
src/egl/fg_structure_egl.h
|
src/egl/fg_structure_egl.h
|
||||||
src/egl/fg_window_egl.c
|
src/egl/fg_window_egl.c
|
||||||
|
@ -30,6 +30,12 @@
|
|||||||
#include <android/native_window.h>
|
#include <android/native_window.h>
|
||||||
#include "fg_internal.h"
|
#include "fg_internal.h"
|
||||||
|
|
||||||
|
int fgPlatformGlutDeviceGet ( GLenum eWhat )
|
||||||
|
{
|
||||||
|
fprintf(stderr, "fgPlatformGlutDeviceGet: STUB\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int fgPlatformGlutGet ( GLenum eWhat )
|
int fgPlatformGlutGet ( GLenum eWhat )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "fgPlatformGlutGet: STUB\n");
|
fprintf(stderr, "fgPlatformGlutGet: STUB\n");
|
||||||
@ -50,18 +56,17 @@ int fgPlatformGlutGet ( GLenum eWhat )
|
|||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int fgPlatformGlutDeviceGet ( GLenum eWhat )
|
default:
|
||||||
{
|
return fghPlatformGlutGetEGL(eWhat);
|
||||||
fprintf(stderr, "fgPlatformGlutDeviceGet: STUB\n");
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fgPlatformGlutLayerGet( GLenum eWhat )
|
int fgPlatformGlutLayerGet( GLenum eWhat )
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "fgPlatformGlutLayerGet: STUB\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is easy as layers are not implemented ;-)
|
* This is easy as layers are not implemented ;-)
|
||||||
*
|
*
|
||||||
@ -102,12 +107,3 @@ int fgPlatformGlutLayerGet( GLenum eWhat )
|
|||||||
/* And fail. That's good. Programs do love failing. */
|
/* And fail. That's good. Programs do love failing. */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "fgPlatformGlutGetModeValues: STUB\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
171
freeglut/freeglut/src/egl/fg_state_egl.c
Normal file
171
freeglut/freeglut/src/egl/fg_state_egl.c
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
/*
|
||||||
|
* fg_state_egl.c
|
||||||
|
*
|
||||||
|
* EGL-specific freeglut state query methods.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Sylvain Beucler
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
static int fgPlatformGetConfig( int attribute )
|
||||||
|
{
|
||||||
|
int returnValue = 0;
|
||||||
|
int result; /* Not checked */
|
||||||
|
|
||||||
|
if( fgStructure.CurrentWindow )
|
||||||
|
result = eglGetConfigAttrib( fgDisplay.pDisplay.egl.Display,
|
||||||
|
fgStructure.CurrentWindow->Window.pContext.egl.Config,
|
||||||
|
attribute,
|
||||||
|
&returnValue );
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fghPlatformGlutGetEGL ( GLenum eWhat )
|
||||||
|
{
|
||||||
|
int nsamples = 0;
|
||||||
|
|
||||||
|
switch( eWhat )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* The window/context specific queries are handled mostly by
|
||||||
|
* fgPlatformGetConfig().
|
||||||
|
*/
|
||||||
|
case GLUT_WINDOW_NUM_SAMPLES:
|
||||||
|
glGetIntegerv(GL_SAMPLES, &nsamples);
|
||||||
|
return nsamples;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The rest of GLX queries under X are general enough to use a macro to
|
||||||
|
* check them
|
||||||
|
*/
|
||||||
|
# define EGL_QUERY(a,b) case a: return fgPlatformGetConfig( b );
|
||||||
|
|
||||||
|
EGL_QUERY( GLUT_WINDOW_BUFFER_SIZE, EGL_BUFFER_SIZE );
|
||||||
|
EGL_QUERY( GLUT_WINDOW_STENCIL_SIZE, EGL_STENCIL_SIZE );
|
||||||
|
EGL_QUERY( GLUT_WINDOW_DEPTH_SIZE, EGL_DEPTH_SIZE );
|
||||||
|
EGL_QUERY( GLUT_WINDOW_RED_SIZE, EGL_RED_SIZE );
|
||||||
|
EGL_QUERY( GLUT_WINDOW_GREEN_SIZE, EGL_GREEN_SIZE );
|
||||||
|
EGL_QUERY( GLUT_WINDOW_BLUE_SIZE, EGL_BLUE_SIZE );
|
||||||
|
EGL_QUERY( GLUT_WINDOW_ALPHA_SIZE, EGL_ALPHA_SIZE );
|
||||||
|
|
||||||
|
# undef EGL_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 fgPlatformChooseFBConfig again here. */
|
||||||
|
EGLConfig config;
|
||||||
|
return fghChooseConfigEGL(&config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is system-dependant */
|
||||||
|
case GLUT_WINDOW_FORMAT_ID:
|
||||||
|
if( fgStructure.CurrentWindow == NULL )
|
||||||
|
return 0;
|
||||||
|
return fgPlatformGetConfig( EGL_NATIVE_VISUAL_ID );
|
||||||
|
|
||||||
|
default:
|
||||||
|
fgWarning( "glutGet(): missing enum handle %d", eWhat );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int* fgPlatformGlutGetModeValues(GLenum eWhat, int *size)
|
||||||
|
{
|
||||||
|
int *array;
|
||||||
|
|
||||||
|
int attributes[9];
|
||||||
|
int attribute_name = 0;
|
||||||
|
|
||||||
|
array = NULL;
|
||||||
|
*size = 0;
|
||||||
|
|
||||||
|
switch (eWhat)
|
||||||
|
{
|
||||||
|
case GLUT_AUX:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GLUT_MULTISAMPLE:
|
||||||
|
attributes[0] = EGL_BUFFER_SIZE;
|
||||||
|
attributes[1] = EGL_DONT_CARE;
|
||||||
|
attributes[2] = EGL_SAMPLE_BUFFERS;
|
||||||
|
attributes[3] = 1;
|
||||||
|
attributes[4] = EGL_SAMPLES;
|
||||||
|
attributes[5] = 1;
|
||||||
|
attributes[6] = EGL_NONE;
|
||||||
|
|
||||||
|
attribute_name = EGL_SAMPLES;
|
||||||
|
|
||||||
|
EGLConfig* configArray;
|
||||||
|
EGLConfig* config;
|
||||||
|
EGLint configArraySize = 0;
|
||||||
|
|
||||||
|
/* Get number of available configs */
|
||||||
|
if (!eglChooseConfig(fgDisplay.pDisplay.egl.Display,
|
||||||
|
attributes, NULL, 0,
|
||||||
|
&configArraySize))
|
||||||
|
break;
|
||||||
|
configArray = calloc(configArraySize, sizeof(EGLConfig));
|
||||||
|
|
||||||
|
if (!eglChooseConfig(fgDisplay.pDisplay.egl.Display,
|
||||||
|
attributes, configArray, configArraySize,
|
||||||
|
&configArraySize))
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* We get results in ascending order */
|
||||||
|
{
|
||||||
|
int * temp_array;
|
||||||
|
int previous_value;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
array = malloc(sizeof(int) * configArraySize);
|
||||||
|
previous_value = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < configArraySize; i++) {
|
||||||
|
int value;
|
||||||
|
eglGetConfigAttrib(fgDisplay.pDisplay.egl.Display,
|
||||||
|
configArray[i], attribute_name, &value);
|
||||||
|
if (value > previous_value)
|
||||||
|
{
|
||||||
|
previous_value = value;
|
||||||
|
temp_array[*size] = value;
|
||||||
|
(*size)++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
array = realloc(array, sizeof(int) * (*size));
|
||||||
|
}
|
||||||
|
free(configArray);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
Reference in New Issue
Block a user