Skip to content
Browse files

30 bit framebuffer setup/testing

  • Loading branch information...
1 parent 45b291f commit 58b63620725f186ee6c5821be575fab85e1b6863 @dcnieho committed Apr 22, 2013
View
9 freeglut/progs/demos/One/one.c
@@ -301,12 +301,19 @@ int main( int argc, char** argv )
int menuID, subMenuA, subMenuB;
glutInitDisplayString( "stencil~2 rgb double depth>=16 samples" );
- glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE );
glutInitWindowPosition( 100, 100 );
glutInit( &argc, argv );
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_GLUTMAINLOOP_RETURNS);
+ glutSetOption(GLUT_WINDOW_RED_SIZE,8);
+ glutSetOption(GLUT_WINDOW_GREEN_SIZE,8);
+ glutSetOption(GLUT_WINDOW_BLUE_SIZE,8);
+ glutSetOption(GLUT_WINDOW_ALPHA_SIZE,8);
+ glutSetOption(GLUT_WINDOW_DEPTH_SIZE,32);
+ glutSetOption(GLUT_WINDOW_STENCIL_SIZE,0);
+ glutSetOption(GLUT_MULTISAMPLE,4);
glutMenuStatusFunc( SampleMenuStatus );
glutIdleFunc( SampleIdle );
View
12 freeglut/src/egl/fg_window_egl.c
@@ -36,12 +36,12 @@ int fghChooseConfig(EGLConfig* config) {
#else
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
#endif
- EGL_BLUE_SIZE, 1,
- EGL_GREEN_SIZE, 1,
- EGL_RED_SIZE, 1,
- EGL_ALPHA_SIZE, (fgState.DisplayMode & GLUT_ALPHA) ? 1 : 0,
- EGL_DEPTH_SIZE, (fgState.DisplayMode & GLUT_DEPTH) ? 1 : 0,
- EGL_STENCIL_SIZE, (fgState.DisplayMode & GLUT_STENCIL) ? 1 : 0,
+ EGL_BLUE_SIZE, fgState.BlueBits,
+ EGL_GREEN_SIZE, fgState.GreenBits,
+ EGL_RED_SIZE, fgState.RedBits,
+ EGL_ALPHA_SIZE, (fgState.DisplayMode & GLUT_ALPHA) ? fgState.AlphaBits : 0,
+ EGL_DEPTH_SIZE, (fgState.DisplayMode & GLUT_DEPTH) ? fgState.DepthBits : 0,
+ EGL_STENCIL_SIZE, (fgState.DisplayMode & GLUT_STENCIL) ? fgState.StencilBits : 0,
EGL_SAMPLE_BUFFERS, (fgState.DisplayMode & GLUT_MULTISAMPLE) ? 1 : 0,
EGL_SAMPLES, (fgState.DisplayMode & GLUT_MULTISAMPLE) ? fgState.SampleNumber : 0,
EGL_NONE
View
12 freeglut/src/fg_init.c
@@ -55,6 +55,12 @@ SFG_Display fgDisplay;
SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */
{ 300, 300, GL_TRUE }, /* Size */
GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH, /* DisplayMode */
+ 8, /* Red bit depth requested */
+ 8, /* Green bit depth requested */
+ 8, /* Blue bit depth requested */
+ 8, /* Alpha bit depth requested */
+ 24, /* Depth bit depth requested */
+ 8, /* Stencil bit depth requested */
GL_FALSE, /* Initialised */
GLUT_TRY_DIRECT_CONTEXT, /* DirectContext */
GL_FALSE, /* ForceIconic */
@@ -276,6 +282,12 @@ void fgDeinitialize( void )
fgState.Size.Use = GL_TRUE;
fgState.DisplayMode = GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH;
+ fgState.RedBits = 8;
+ fgState.GreenBits = 8;
+ fgState.BlueBits = 8;
+ fgState.AlphaBits = 8;
+ fgState.DepthBits = 24;
+ fgState.StencilBits = 8;
fgState.DirectContext = GLUT_TRY_DIRECT_CONTEXT;
fgState.ForceIconic = GL_FALSE;
View
7 freeglut/src/fg_internal.h
@@ -277,7 +277,14 @@ struct tagSFG_State
{
SFG_XYUse Position; /* The default windows' position */
SFG_XYUse Size; /* The default windows' size */
+
unsigned int DisplayMode; /* Display mode for new windows */
+ unsigned int RedBits; /* Red bit depth requested */
+ unsigned int GreenBits; /* Green bit depth requested */
+ unsigned int BlueBits; /* Blue bit depth requested */
+ unsigned int AlphaBits; /* Alpha bit depth requested */
+ unsigned int DepthBits; /* Depth bit depth requested */
+ unsigned int StencilBits; /* Stencil bit depth requested */
GLboolean Initialised; /* freeglut has been initialised */
View
19 freeglut/src/fg_state.c
@@ -109,6 +109,25 @@ void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
fgState.SampleNumber = value;
break;
+ case GLUT_WINDOW_RED_SIZE:
+ fgState.RedBits = value;
+ break;
+ case GLUT_WINDOW_GREEN_SIZE:
+ fgState.GreenBits = value;
+ break;
+ case GLUT_WINDOW_BLUE_SIZE:
+ fgState.BlueBits = value;
+ break;
+ case GLUT_WINDOW_ALPHA_SIZE:
+ fgState.AlphaBits = value;
+ break;
+ case GLUT_WINDOW_DEPTH_SIZE:
+ fgState.DepthBits = value;
+ break;
+ case GLUT_WINDOW_STENCIL_SIZE:
+ fgState.StencilBits = value;
+ break;
+
case GLUT_SKIP_STALE_MOTION_EVENTS:
fgState.SkipStaleMotion = value;
break;
View
54 freeglut/src/mswin/fg_window_mswin.c
@@ -44,6 +44,9 @@ typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAt
#define WGL_SUPPORT_OPENGL_ARB 0x2010
#define WGL_DOUBLE_BUFFER_ARB 0x2011
#define WGL_COLOR_BITS_ARB 0x2014
+#define WGL_RED_BITS_ARB 0x2015
+#define WGL_GREEN_BITS_ARB 0x2017
+#define WGL_BLUE_BITS_ARB 0x2019
#define WGL_ALPHA_BITS_ARB 0x201B
#define WGL_DEPTH_BITS_ARB 0x2022
#define WGL_STENCIL_BITS_ARB 0x2023
@@ -195,52 +198,47 @@ static void fghFillPFD( PIXELFORMATDESCRIPTOR *ppfd, HDC hdc, unsigned char laye
flags |= PFD_STEREO;
}
-#if defined(_MSC_VER)
-#pragma message( "fgSetupPixelFormat(): there is still some work to do here!" )
-#endif
-
/* Specify which pixel format do we opt for... */
ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR);
ppfd->nVersion = 1;
ppfd->dwFlags = flags;
if( fgState.DisplayMode & GLUT_INDEX ) {
ppfd->iPixelType = PFD_TYPE_COLORINDEX;
- ppfd->cRedBits = 0;
- ppfd->cGreenBits = 0;
- ppfd->cBlueBits = 0;
+ ppfd->cColorBits = (BYTE) GetDeviceCaps( hdc, BITSPIXEL );
ppfd->cAlphaBits = 0;
} else {
ppfd->iPixelType = PFD_TYPE_RGBA;
- ppfd->cRedBits = 8;
- ppfd->cGreenBits = 8;
- ppfd->cBlueBits = 8;
- ppfd->cAlphaBits = ( fgState.DisplayMode & GLUT_ALPHA ) ? 8 : 0;
+ ppfd->cColorBits = fgState.RedBits+fgState.GreenBits+fgState.BlueBits;
+ ppfd->cAlphaBits = ( fgState.DisplayMode & GLUT_ALPHA ) ? fgState.AlphaBits : 0;
}
- ppfd->cColorBits = 24;
+ ppfd->cDepthBits = ( fgState.DisplayMode & GLUT_DEPTH ) ? fgState.DepthBits : 0;
+ ppfd->cStencilBits = ( fgState.DisplayMode & GLUT_STENCIL ) ? fgState.StencilBits : 0;
+
+ ppfd->cAccumBits = ( fgState.DisplayMode & GLUT_ACCUM ) ? 1 : 0;
+
+ ppfd->cAuxBuffers = fghNumberOfAuxBuffersRequested();
+ ppfd->iLayerType = layer_type;
+
+ /* According to docs, leave all these to zero, they are ignored */
+ ppfd->cRedBits = 0;
ppfd->cRedShift = 0;
+ ppfd->cGreenBits = 0;
ppfd->cGreenShift = 0;
+ ppfd->cBlueBits = 0;
ppfd->cBlueShift = 0;
ppfd->cAlphaShift = 0;
- ppfd->cAccumBits = ( fgState.DisplayMode & GLUT_ACCUM ) ? 1 : 0;
+
ppfd->cAccumRedBits = 0;
ppfd->cAccumGreenBits = 0;
ppfd->cAccumBlueBits = 0;
ppfd->cAccumAlphaBits = 0;
- /* Hmmm, or 32/0 instead of 24/8? */
- ppfd->cDepthBits = 24;
- ppfd->cStencilBits = 8;
-
- ppfd->cAuxBuffers = fghNumberOfAuxBuffersRequested();
- ppfd->iLayerType = layer_type;
ppfd->bReserved = 0;
ppfd->dwLayerMask = 0;
ppfd->dwVisibleMask = 0;
ppfd->dwDamageMask = 0;
-
- ppfd->cColorBits = (BYTE) GetDeviceCaps( hdc, BITSPIXEL );
}
static void fghFillPixelFormatAttributes( int *attributes, const PIXELFORMATDESCRIPTOR *ppfd )
@@ -252,6 +250,10 @@ static void fghFillPixelFormatAttributes( int *attributes, const PIXELFORMATDESC
ATTRIB_VAL( WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB );
ATTRIB_VAL( WGL_COLOR_BITS_ARB, ppfd->cColorBits );
+ /* Should this be uncommented? Probably */
+ //ATTRIB_VAL( WGL_RED_BITS_ARB, fgState.RedBits );
+ //ATTRIB_VAL( WGL_GREEN_BITS_ARB, fgState.GreenBits );
+ //ATTRIB_VAL( WGL_BLUE_BITS_ARB, fgState.BlueBits );
ATTRIB_VAL( WGL_ALPHA_BITS_ARB, ppfd->cAlphaBits );
ATTRIB_VAL( WGL_DEPTH_BITS_ARB, ppfd->cDepthBits );
ATTRIB_VAL( WGL_STENCIL_BITS_ARB, ppfd->cStencilBits );
@@ -326,6 +328,7 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
fghFillPixelFormatAttributes( attributes, ppfd );
bValid = wglChoosePixelFormatARBProc(hDC, attributes, fAttributes, 1, &iPixelFormat, &numFormats);
+ printf("bValid: %i, numFormats: %i\n",bValid, numFormats);
if ( bValid && numFormats > 0 )
{
pixelformat = iPixelFormat;
@@ -342,6 +345,15 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
success = ( pixelformat != 0 ) && ( checkOnly || SetPixelFormat( current_hDC, pixelformat, ppfd ) );
+
+ /*printf("The current window has %i red bits, %i green bits, %i blue bits and %i alpha bits\n",ppfd->cRedBits,ppfd->cGreenBits,ppfd->cBlueBits,ppfd->cAlphaBits);
+ printf("It furthermore has %i depth bits and %i stencil bits\n",ppfd->cDepthBits,ppfd->cStencilBits);
+ printf("----------\n");
+ DescribePixelFormat(current_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), ppfd);
+ printf("The current window has %i red bits, %i green bits, %i blue bits and %i alpha bits\n",ppfd->cRedBits,ppfd->cGreenBits,ppfd->cBlueBits,ppfd->cAlphaBits);
+ printf("It furthermore has %i depth bits and %i stencil bits\n",ppfd->cDepthBits,ppfd->cStencilBits);
+ printf("==========\n");*/
+
if (checkOnly)
DeleteDC(current_hDC);
View
2 freeglut/src/x11/fg_state_x11_glx.c
@@ -86,15 +86,13 @@ int fghPlatformGlutGetGLX ( GLenum eWhat )
# 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;
View
12 freeglut/src/x11/fg_window_x11_glx.c
@@ -52,11 +52,11 @@ int fghChooseConfig(GLXFBConfig* fbconfig)
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 );
+ ATTRIB_VAL( GLX_RED_SIZE, fgState.RedBits );
+ ATTRIB_VAL( GLX_GREEN_SIZE, fgState.GreenBits );
+ ATTRIB_VAL( GLX_BLUE_SIZE, fgState.BlueBits );
if( fgState.DisplayMode & GLUT_ALPHA ) {
- ATTRIB_VAL( GLX_ALPHA_SIZE, 1 );
+ ATTRIB_VAL( GLX_ALPHA_SIZE, fgState.AlphaBits );
}
}
@@ -69,11 +69,11 @@ int fghChooseConfig(GLXFBConfig* fbconfig)
}
if( fgState.DisplayMode & GLUT_DEPTH ) {
- ATTRIB_VAL( GLX_DEPTH_SIZE, 1 );
+ ATTRIB_VAL( GLX_DEPTH_SIZE, fgState.DepthBits );
}
if( fgState.DisplayMode & GLUT_STENCIL ) {
- ATTRIB_VAL( GLX_STENCIL_SIZE, 1 );
+ ATTRIB_VAL( GLX_STENCIL_SIZE, fgState.StencilBits );
}
if( fgState.DisplayMode & GLUT_ACCUM ) {

0 comments on commit 58b6362

Please sign in to comment.
Something went wrong with that request. Please try again.