LIBS += -lavformat -lavcodec -lavutil -lm -lopengl32 -lglu32 -lgdi32
endif
ifdef CONFIG_LINUX
-LIBS += -lavformat -lavcodec -lavutil -lm -lGL
+LIBS += -lavformat -lavcodec -lavutil -lm -lGL -lXcomposite -lXext
endif
ifdef CONFIG_DARWIN
# FIXME: disabled codec on Mac now
GL_CUR_PATH = $(SRC_PATH)/tizen/src/hw
GL_CFLAGS += -I$(GL_CUR_PATH) -I$(SRC_PATH)/fpu
-GL_CFLAGS += $(addprefix -I$(SRC_PATH)/,$(TARGET_DIRS)) $(QEMU_CFLAGS) $(CFLAGS)
+GL_CFLAGS += -I$(SRC_PATH)/i386-softmmu $(QEMU_CFLAGS) $(CFLAGS)
parse_gl_h: parse_gl_h.c
$(CC) -g -o $@ $<
$(CC) $(GL_CFLAGS) $(DEFINES) $(GL_LDFLAGS) -c -o $@ $<
endif #CONFIG_GL
+
+ifdef CONFIG_OPENGLES
+
+parse_gl_h: parse_gl_h.c
+ $(CC) -g -o $@ $<
+
+gl_mangled.h: parse_gl_h
+ ./parse_gl_h mangle 2>/dev/null
+
+gl_mangled.c: gl_mangled.h
+ ./parse_gl_h mangle 2>/dev/null
+
+gloffscreen_glx.o gloffscreen_wgl.o gloffscreen_xcomposite.o: gl_mangled.h
+maru_sdl.o gloffscreen_test.o gloffscreen_common.o: gl_mangled.h
+
+obj-y += gl_mangled.o
+
+endif #CONFIG_OPENGLES
###########################################################
endif #!CONFIG_DARWIN
###########################################################
## opengl library for i386
obj-$(CONFIG_GL) += virtio-gl.o
-obj-$(CONFIG_GL) += helper_opengl.o opengl_exec.o mesa_mipmap.o gloffscreen_common.o
-obj-$(CONFIG_GL) += gloffscreen_test.o gloffscreen_xcomposite.o gloffscreen_wgl.o
+obj-$(CONFIG_GL) += helper_opengl.o opengl_exec.o mesa_mipmap.o gloffscreen_wgl.o
obj-$(CONFIG_NO_GL) += virtio-gl-stub.o
+obj-y += gloffscreen_test.o gloffscreen_xcomposite.o gloffscreen_common.o
###########################################################
endif
}
}
+static void gen_mangled_gl(FuncDesc *funcs_p, int func_cnt)
+{
+ int i, j;
+ FILE *header = fopen("gl_mangled.h", "w");
+ FILE *source = fopen("gl_mangled.c", "w");
+ char** args;
+
+ assert(header && source);
+
+ /* Manually add glGetString */
+ args = malloc(1 * sizeof(char*));
+ args[0] = strdup("GLenum");
+ funcs_p[func_cnt].type = strdup("const GLubyte *");
+ funcs_p[func_cnt].name = strdup("glGetString");
+ funcs_p[func_cnt].nargs = 1;
+ funcs_p[func_cnt].args = args;
+ func_cnt++;
+
+ fprintf(header, "/* This file is generated by parse_gl_h.c - DO NOT EDIT ! */\n\n");
+ fprintf(header, "#include <GL/gl.h>\n\n");
+ fprintf(header, "typedef struct mglHDL {\n");
+
+ for (i = 0; i < func_cnt; ++i) {
+ fprintf(header, "\t%s (*%s)(", funcs_p[i].type, funcs_p[i].name);
+ if (funcs_p[i].nargs == 1 && !strncmp(funcs_p[i].args[0], "void", 4)) {
+ free(funcs_p[i].args[0]);
+ funcs_p[i].nargs = 0;
+ fprintf(header, "void");
+ }
+ fprintf_prototype_args(header, &funcs_p[i]);
+ fprintf(header, ");\n");
+ }
+ fprintf(header, "} mglHDL;\n\n");
+
+ fprintf(header, "extern mglHDL mgl_hdl;\n\n");
+ fprintf(header, "int mgl_load_symbols(const char *libname);\n");
+ fprintf(header, "int mgl_unload(void);\n\n");
+
+ for (i = 0; i < func_cnt; ++i) {
+ fprintf(header, "#define %s mgl_hdl.%s\n", funcs_p[i].name, funcs_p[i].name);
+ }
+
+ fprintf(header, "\n");
+
+ fprintf(source, "/* This file is generated by parse_gl_h.c - DO NOT EDIT ! */\n\n");
+ fprintf(source, "#include <stdio.h>\n#include \"gl_mangled.h\"\n\n");
+ fprintf(source, "#ifdef _WIN32\n#include <Windows.h>\n"
+ "typedef HINSTANCE handle_t;\n#else\n#include <dlfcn.h>\n"
+ "typedef void * handle_t;\n#endif\n\n");
+ fprintf(source, "mglHDL mgl_hdl;\n");
+ fprintf(source, "static handle_t mgl_lib_hdl;\n\n");
+
+ fprintf(source, "static inline handle_t mgl_load_lib(const char *libname)\n{\n"
+ "#ifdef _WIN32\n\treturn LoadLibrary(libname);\n"
+ "#else\n\treturn dlopen(libname, RTLD_LAZY | RTLD_LOCAL);\n"
+ "#endif\n}\n\n");
+
+ fprintf(source, "static inline void *mgl_load_sym(const char *symname)\n{\n"
+ "#ifdef _WIN32\n\treturn GetProcAddress(mgl_lib_hdl, symname);\n"
+ "#else\n\treturn dlsym(mgl_lib_hdl, symname);\n"
+ "#endif\n}\n\n");
+
+ fprintf(source, "int mgl_unload(void)\n{\n"
+ "#ifdef _WIN32\n\treturn FreeLibrary(mgl_lib_hdl);\n"
+ "#else\n\treturn dlclose(mgl_lib_hdl);\n"
+ "#endif\n}\n\n");
+
+ fprintf(source, "int mgl_load_symbols(const char *libname)\n{\n"
+ "\tif (!(mgl_lib_hdl = mgl_load_lib(libname))) {\n"
+ "\t\tfprintf(stderr, \"ERROR: Couldn't load %%s library!\\n\", libname);\n"
+ "\t\treturn 1;\n\t}\n\n");
+
+ for (i = 0; i < func_cnt; ++i) {
+ fprintf(source, "\tif (!(%s = mgl_load_sym(\"%s\"))) {\n"
+ "\t\tmgl_unload();\n\t\t"
+ "fprintf(stderr, \"function %s not found!\\n\");\n\t\treturn 1;\n\t}\n\n",
+ funcs_p[i].name, funcs_p[i].name, funcs_p[i].name);
+ }
+
+ fprintf(source, "\treturn 0;\n}\n");
+
+ for (i = 0; i < func_cnt; ++i) {
+ free(funcs_p[func_cnt].name);
+ free(funcs_p[func_cnt].type);
+ for (; funcs_p[func_cnt].nargs; --funcs_p[func_cnt].nargs) {
+ free(funcs_p[func_cnt].args[funcs_p[func_cnt].nargs - 1]);
+ }
+ free(funcs_p[func_cnt].args);
+ }
+
+ fclose(header);
+ fclose(source);
+}
+
int main(int argc, char* argv[])
{
FuncDesc funcDesc[3000];
funcDescCount = parse(f, funcDesc, 0, 1);
fclose(f);
+ if ((argc > 1) && !strncmp(argv[1], "mangle", 6)) {
+ gen_mangled_gl(funcDesc, funcDescCount);
+ return 0;
+ }
+
f = fopen(GL_INCLUDE_PATH"mesa_glext.h", "r");
assert(f);
/*if (!f)
f = fopen("/usr/include/GL/glext.h", "r");*/
funcDescCount = parse(f, funcDesc, funcDescCount, 0);
fclose(f);
-
+
FILE* header = fopen("gl_func.h", "w");
FILE* client_stub = fopen("client_stub.c", "w");
FILE* server_stub = fopen("server_stub.c", "w");