mirror of https://github.com/xemu-project/xemu.git
rejig glo extension stuff
This commit is contained in:
parent
b9eda55bfb
commit
5a131570bb
|
@ -131,7 +131,7 @@ obj-y += hw/$(TARGET_BASE_ARCH)/
|
|||
endif
|
||||
|
||||
# OpenGl Support
|
||||
obj-gl-y += gl/gloffscreen_common.o
|
||||
obj-gl-y += gl/gloffscreen_common.o gl/glextensions.o
|
||||
obj-gl-$(CONFIG_WIN32) += gl/gloffscreen_wgl.o
|
||||
obj-gl-$(CONFIG_DARWIN) += gl/gloffscreen_cgl.o
|
||||
obj-gl-$(CONFIG_LINUX) += gl/gloffscreen_glx.o
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#include "gloffscreen.h"
|
||||
#include "glextensions.h"
|
||||
|
||||
void (*glFrameTerminatorGREMEDY)(void);
|
||||
|
||||
void glextensions_init(void)
|
||||
{
|
||||
glFrameTerminatorGREMEDY = glo_get_extension_proc("glFrameTerminatorGREMEDY");
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef GLEXTEENSIONS_H_
|
||||
#define GLEXTEENSIONS_H_
|
||||
|
||||
extern void (*glFrameTerminatorGREMEDY)(void);
|
||||
|
||||
void glextensions_init(void);
|
||||
|
||||
#endif
|
|
@ -29,6 +29,8 @@
|
|||
#ifndef GLOFFSCREEN_H_
|
||||
#define GLOFFSCREEN_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenGL/gl.h>
|
||||
#elif defined(_WIN32)
|
||||
|
@ -65,31 +67,30 @@ typedef struct _GloContext GloContext;
|
|||
#define GLO_FF_DEFAULT (GLO_FF_BITS_24|GLO_FF_DEPTH_24)
|
||||
|
||||
/* Change current context */
|
||||
extern void glo_set_current(GloContext *context);
|
||||
void glo_set_current(GloContext *context);
|
||||
|
||||
/* Check GL Extensions */
|
||||
extern GLboolean glo_check_extension(
|
||||
const GLubyte *extName, const GLubyte *extString);
|
||||
void* glo_get_extension_proc(const GLubyte *extProc);
|
||||
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 */
|
||||
extern GloContext *glo_context_create(int formatFlags);
|
||||
GloContext *glo_context_create(int formatFlags);
|
||||
|
||||
/* Destroy a previouslu created OpenGL context */
|
||||
extern void glo_context_destroy(GloContext *context);
|
||||
void glo_context_destroy(GloContext *context);
|
||||
|
||||
/* Functions to decode the format flags */
|
||||
extern int glo_flags_get_depth_bits(int formatFlags);
|
||||
extern int glo_flags_get_stencil_bits(int formatFlags);
|
||||
extern void glo_flags_get_rgba_bits(int formatFlags, int *rgba);
|
||||
extern int glo_flags_get_bytes_per_pixel(int formatFlags);
|
||||
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 */
|
||||
extern int glo_flags_score(int formatFlagsExpected, int formatFlagsReal);
|
||||
int glo_flags_score(int formatFlagsExpected, int formatFlagsReal);
|
||||
|
||||
/* Note that this is top-down, not bottom-up as glReadPixels would do. */
|
||||
extern void glo_readpixels(GLenum gl_format, GLenum gl_type,
|
||||
void glo_readpixels(GLenum gl_format, GLenum gl_type,
|
||||
unsigned int bytes_per_pixel, unsigned int stride,
|
||||
unsigned int width, unsigned int height, void *data);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "qemu-common.h"
|
||||
|
||||
|
@ -68,11 +69,9 @@ GloContext *glo_context_create(int formatFlags)
|
|||
return context;
|
||||
}
|
||||
|
||||
/* Check if an extension is available. */
|
||||
GLboolean glo_check_extension(const GLubyte *extName,
|
||||
const GLubyte *extString)
|
||||
void* glo_get_extension_proc(const char* ext_proc)
|
||||
{
|
||||
return gluCheckExtension(extName, extString);
|
||||
return dlsym(RTLD_NEXT, ext_proc);
|
||||
}
|
||||
|
||||
/* Set current context */
|
||||
|
|
|
@ -162,3 +162,22 @@ void glo_readpixels(GLenum gl_format, GLenum gl_type,
|
|||
glPixelStorei(GL_PACK_ROW_LENGTH, rl);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, pa);
|
||||
}
|
||||
|
||||
|
||||
bool glo_check_extension(const char* ext_name)
|
||||
{
|
||||
const char *ext_string = (const char *) glGetString(GL_EXTENSIONS);
|
||||
if (!ext_string) {
|
||||
return false;
|
||||
}
|
||||
const char* p = ext_string;
|
||||
const char* end = p + strlen(p);
|
||||
while (p < end) {
|
||||
size_t n = strcspn(p, " ");
|
||||
if ((strlen(ext_name) == n) && (strncmp(ext_name, p, n) == 0)) {
|
||||
return true;
|
||||
}
|
||||
p += (n + 1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -112,16 +112,9 @@ GloContext *glo_context_create(int formatFlags)
|
|||
return context;
|
||||
}
|
||||
|
||||
/* Check if an extension is available. */
|
||||
GLboolean glo_check_extension(const GLubyte *extName,
|
||||
const GLubyte *extString)
|
||||
void* glo_get_extension_proc(const char* ext_proc)
|
||||
{
|
||||
return gluCheckExtension(extName, extString);
|
||||
}
|
||||
|
||||
void* glo_get_extension_proc(const GLubyte *extProc)
|
||||
{
|
||||
return glXGetProcAddress(extProc);
|
||||
return glXGetProcAddress((const GLubyte *)ext_proc);
|
||||
}
|
||||
|
||||
/* Set current context */
|
||||
|
|
|
@ -281,26 +281,3 @@ void glo_context_destroy(GloContext *context)
|
|||
}
|
||||
free(context);
|
||||
}
|
||||
|
||||
|
||||
/* Check extension implementation for Windows.
|
||||
* The Glu 1.2 framework in Windows doesn't include them... */
|
||||
GLboolean glo_check_extension(const GLubyte *extName,
|
||||
const GLubyte *extString)
|
||||
{
|
||||
char *p = (char *) glGetString(GL_EXTENSIONS);
|
||||
char *end;
|
||||
if (p == NULL) {
|
||||
return GL_FALSE;
|
||||
}
|
||||
end = p + strlen(p);
|
||||
|
||||
while (p < end) {
|
||||
int n = strcspn(p, " ");
|
||||
if ((strlen(extName) == n) && (strncmp(extName, p, n) == 0)) {
|
||||
return GL_TRUE;
|
||||
}
|
||||
p += (n + 1);
|
||||
}
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "qemu/thread.h"
|
||||
#include "qapi/qmp/qstring.h"
|
||||
#include "gl/gloffscreen.h"
|
||||
#include "gl/glextensions.h"
|
||||
|
||||
#include "hw/xbox/swizzle.h"
|
||||
#include "hw/xbox/u_format_r11g11b10f.h"
|
||||
|
@ -2144,24 +2145,16 @@ static void pgraph_init(PGRAPHState *pg)
|
|||
pg->gl_context = glo_context_create(GLO_FF_DEFAULT);
|
||||
assert(pg->gl_context);
|
||||
|
||||
glextensions_init();
|
||||
|
||||
/* Check context capabilities */
|
||||
const GLubyte *extensions = glGetString(GL_EXTENSIONS);
|
||||
assert(glo_check_extension("GL_EXT_texture_compression_s3tc"));
|
||||
|
||||
assert(glo_check_extension((const GLubyte *)
|
||||
"GL_EXT_texture_compression_s3tc",
|
||||
extensions));
|
||||
assert(glo_check_extension("GL_EXT_framebuffer_object"));
|
||||
|
||||
assert(glo_check_extension((const GLubyte *)
|
||||
"GL_EXT_framebuffer_object",
|
||||
extensions));
|
||||
assert(glo_check_extension("GL_ARB_texture_rectangle"));
|
||||
|
||||
assert(glo_check_extension((const GLubyte *)
|
||||
"GL_ARB_texture_rectangle",
|
||||
extensions));
|
||||
|
||||
assert(glo_check_extension((const GLubyte *)
|
||||
"GL_ARB_vertex_array_bgra",
|
||||
extensions));
|
||||
assert(glo_check_extension("GL_ARB_vertex_array_bgra"));
|
||||
|
||||
GLint max_vertex_attributes;
|
||||
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_vertex_attributes);
|
||||
|
|
Loading…
Reference in New Issue