diff --git a/gl/gloffscreen.h b/gl/gloffscreen.h index 462db31c31..96a2fd1d3c 100644 --- a/gl/gloffscreen.h +++ b/gl/gloffscreen.h @@ -43,27 +43,6 @@ struct _GloContext; typedef struct _GloContext GloContext; -/* Format flags for glo_surface_create */ -#define GLO_FF_ALPHA_MASK (0x0001) -#define GLO_FF_NOALPHA (0x0000) -#define GLO_FF_ALPHA (0x0001) - -#define GLO_FF_BITS_MASK (0x00F0) -#define GLO_FF_BITS_16 (0x0020) -#define GLO_FF_BITS_24 (0x0030) -#define GLO_FF_BITS_32 (0x0040) - -#define GLO_FF_DEPTH_MASK (0x0F00) -#define GLO_FF_DEPTH_16 (0x0100) -#define GLO_FF_DEPTH_24 (0x0200) -#define GLO_FF_DEPTH_32 (0x0300) - -#define GLO_FF_STENCIL_MASK (0xF000) -#define GLO_FF_STENCIL_8 (0x1000) - -/* The only currently supported format */ -#define GLO_FF_DEFAULT (GLO_FF_BITS_24|GLO_FF_DEPTH_24) - /* Change current context */ void glo_set_current(GloContext *context); @@ -71,22 +50,12 @@ void glo_set_current(GloContext *context); bool glo_check_extension(const char* ext_name); void* glo_get_extension_proc(const char* extProc); -/* Create an OpenGL context for a certain - * pixel format. formatflags are from the - * GLO_ constants */ -GloContext *glo_context_create(int formatFlags); +/* Create an OpenGL context */ +GloContext *glo_context_create(void); /* Destroy a previouslu created OpenGL context */ void glo_context_destroy(GloContext *context); -/* Functions to decode the format flags */ -int glo_flags_get_depth_bits(int formatFlags); -int glo_flags_get_stencil_bits(int formatFlags); -void glo_flags_get_rgba_bits(int formatFlags, int *rgba); -int glo_flags_get_bytes_per_pixel(int formatFlags); -/* Score how close the given format flags match. 0=great, >0 not so great */ -int glo_flags_score(int formatFlagsExpected, int formatFlagsReal); - /* Note that this is top-down, not bottom-up as glReadPixels would do. */ void glo_readpixels(GLenum gl_format, GLenum gl_type, unsigned int bytes_per_pixel, unsigned int stride, diff --git a/gl/gloffscreen_cgl.c b/gl/gloffscreen_cgl.c index b3761f0a04..f42b311417 100644 --- a/gl/gloffscreen_cgl.c +++ b/gl/gloffscreen_cgl.c @@ -40,7 +40,7 @@ struct _GloContext { /* Create an OpenGL context for a certain pixel format. formatflags are from * the GLO_ constants */ -GloContext *glo_context_create(int formatFlags) +GloContext *glo_context_create(void) { CGLError err; diff --git a/gl/gloffscreen_common.c b/gl/gloffscreen_common.c index b9a53618b0..ea77b10c52 100644 --- a/gl/gloffscreen_common.c +++ b/gl/gloffscreen_common.c @@ -29,84 +29,6 @@ #include "qemu-common.h" #include "gloffscreen.h" -int glo_flags_get_depth_bits(int formatFlags) { - switch ( formatFlags & GLO_FF_DEPTH_MASK ) { - case GLO_FF_DEPTH_16: return 16; - case GLO_FF_DEPTH_24: return 24; - case GLO_FF_DEPTH_32: return 32; - default: return 0; - } -} - -int glo_flags_get_stencil_bits(int formatFlags) { - switch ( formatFlags & GLO_FF_STENCIL_MASK ) { - case GLO_FF_STENCIL_8: return 8; - default: return 0; - } -} - -void glo_flags_get_rgba_bits(int formatFlags, int *rgba) { - int alpha = (formatFlags & GLO_FF_ALPHA) != 0; - switch ( formatFlags & GLO_FF_BITS_MASK ) { - case GLO_FF_BITS_16: - rgba[0] = alpha ? 4 : 5; - rgba[1] = alpha ? 4 : 6; - rgba[2] = alpha ? 4 : 5; - rgba[3] = alpha ? 4 : 0; - break; - case GLO_FF_BITS_24: - // ignore alpha - rgba[0] = 8; - rgba[1] = 8; - rgba[2] = 8; - rgba[3] = 0; - break; - case GLO_FF_BITS_32: - rgba[0] = 8; - rgba[1] = 8; - rgba[2] = 8; - rgba[3] = 8; - break; - default: - rgba[0] = 8; - rgba[1] = 8; - rgba[2] = 8; - rgba[3] = 0; - break; - } -} - -int glo_flags_get_bytes_per_pixel(int formatFlags) { - switch ( formatFlags & GLO_FF_BITS_MASK ) { - case GLO_FF_BITS_16: return 2; - case GLO_FF_BITS_24: return 3; - case GLO_FF_BITS_32: return 4; - default: return 3; - } -} - -int glo_flags_score(int formatFlagsExpected, int formatFlagsReal) { - if (formatFlagsExpected == formatFlagsReal) return 0; - int score = 1; - // we wanted alpha, but we didn't get it - if ((formatFlagsExpected&GLO_FF_ALPHA_MASK) < - (formatFlagsReal&GLO_FF_ALPHA_MASK)) - score++; - // less bits than we expected - if ((formatFlagsExpected&GLO_FF_BITS_MASK) < - !(formatFlagsReal&GLO_FF_BITS_MASK)) - score++; - // less depth bits than we expected - if ((formatFlagsExpected&GLO_FF_DEPTH_MASK) < - !(formatFlagsReal&GLO_FF_DEPTH_MASK)) - score++; - // less stencil bits than we expected - if ((formatFlagsExpected&GLO_FF_STENCIL_MASK) < - !(formatFlagsReal&GLO_FF_STENCIL_MASK)) - score++; - return score; -} - void glo_readpixels(GLenum gl_format, GLenum gl_type, unsigned int bytes_per_pixel, unsigned int stride, diff --git a/gl/gloffscreen_glx.c b/gl/gloffscreen_glx.c index 79bd8023b8..c28d70bed9 100644 --- a/gl/gloffscreen_glx.c +++ b/gl/gloffscreen_glx.c @@ -43,9 +43,8 @@ struct _GloContext { static Display* x_display; -/* Create an OpenGL context for a certain pixel format. formatflags are from - * the GLO_ constants */ -GloContext *glo_context_create(int formatFlags) +/* Create an OpenGL context */ +GloContext *glo_context_create(void) { static bool initialized = false; @@ -60,23 +59,22 @@ GloContext *glo_context_create(int formatFlags) } GloContext *context = (GloContext *)g_malloc0(sizeof(GloContext)); - int rgbaBits[4]; - glo_flags_get_rgba_bits(formatFlags, rgbaBits); - int fb_attribute_list[] = { GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_RED_SIZE, rgbaBits[0], - GLX_GREEN_SIZE, rgbaBits[1], - GLX_BLUE_SIZE, rgbaBits[2], - GLX_ALPHA_SIZE, rgbaBits[3], - GLX_DEPTH_SIZE, glo_flags_get_depth_bits(formatFlags), - GLX_STENCIL_SIZE, glo_flags_get_stencil_bits(formatFlags), + GLX_RED_SIZE, 8, + GLX_GREEN_SIZE, 8, + GLX_BLUE_SIZE, 8, + GLX_ALPHA_SIZE, 8, + GLX_DEPTH_SIZE, 24, + GLX_STENCIL_SIZE, 8, GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, None }; int nelements; - GLXFBConfig* configs = glXChooseFBConfig(x_display, DefaultScreen(x_display), fb_attribute_list, &nelements); + GLXFBConfig* configs = glXChooseFBConfig(x_display, + DefaultScreen(x_display), + fb_attribute_list, &nelements); if (configs == NULL) { return NULL; } if (nelements == 0) { return NULL; } diff --git a/gl/gloffscreen_wgl.c b/gl/gloffscreen_wgl.c index 884ef7c789..6b2faf80ec 100644 --- a/gl/gloffscreen_wgl.c +++ b/gl/gloffscreen_wgl.c @@ -58,7 +58,6 @@ struct GloMain glo; int glo_inited = 0; struct _GloContext { - int formatFlags; /* Pixel format returned by wglChoosePixelFormat */ int wglPixelFormat; /* We need a pbuffer to make a context of the right pixelformat :( */ @@ -166,17 +165,12 @@ static void glo_kill(void) { UnregisterClass(GLO_WINDOW_CLASS, glo.hInstance); } -/* Create an OpenGL context for a certain pixel format. formatflags are from - * the GLO_ constants */ -GloContext *glo_context_create(int formatFlags) { - GloContext *context; - +GloContext *glo_context_create(void) { if (!glo_inited) glo_init(); - context = (GloContext *)malloc(sizeof(GloContext)); + GloContext *context = (GloContext *)malloc(sizeof(GloContext)); memset(context, 0, sizeof(GloContext)); - context->formatFlags = formatFlags; /* pixel format attributes */ const int pf_attri[] = { diff --git a/hw/xbox/nv2a.c b/hw/xbox/nv2a.c index 4028363ce1..5f95d45608 100644 --- a/hw/xbox/nv2a.c +++ b/hw/xbox/nv2a.c @@ -3363,7 +3363,7 @@ static void pgraph_init(NV2AState *d) /* fire up opengl */ - pg->gl_context = glo_context_create(GLO_FF_DEFAULT); + pg->gl_context = glo_context_create(); assert(pg->gl_context); #ifdef DEBUG_NV2A_GL