summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xMakefile11
-rw-r--r--includes/engine.h16
-rw-r--r--includes/glbase.h20
-rw-r--r--mogltk/engine.cpp24
-rw-r--r--mogltk/glbase.cpp51
5 files changed, 118 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index cd4f9d4..63950b4 100755
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,11 @@
#!/usr/bin/make -f
-CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror -Iincludes `sdl-config --cflags` -DHAVE_ZLIB
-LDFLAGS=-lz `sdl-config --libs`
+CPPFLAGS=-Wall -g -O3 -mcpu=i686 -Werror -Iincludes `sdl-config --cflags` -DHAVE_ZLIB
+LDFLAGS=-lz `sdl-config --libs` -lGL
CXX=g++
-SUBDIRS = psxdev generic lib Xenogears VP MegamanX5 PcsxSrc
-TARGET = lzss dlzss cd-tool str-player crypto-search bgrep dte-tool ffx-convert
+SUBDIRS = psxdev generic lib Xenogears VP MegamanX5 mogltk
+TARGET = lzss dlzss cd-tool str-player crypto-search bgrep dte-tool ffx-convert gltest
all: subdirs ${TARGET}
@@ -39,6 +39,9 @@ bgrep: bgrep.o includes/generic.h generic/generic.a Makefile
ffx-convert: ffx-convert.o generic/generic.a Makefile
${CXX} ffx-convert.o generic/generic.a -o ffx-convert ${LDFLAGS}
+gltest: gltest.o mogltk/mogltk.a generic/generic.a Makefile
+ ${CXX} gltest.o mogltk/mogltk.a generic/generic.a -o gltest ${LDFLAGS}
+
clean:
for d in ${SUBDIRS} ; do make -C $$d clean || exit -1 ; done
rm -f *.o ${TARGET} compil.c
diff --git a/includes/engine.h b/includes/engine.h
new file mode 100644
index 0000000..e7a4f6b
--- /dev/null
+++ b/includes/engine.h
@@ -0,0 +1,16 @@
+#ifndef __ENGINE_H__
+#define __ENGINE_H__
+
+#include "Exceptions.h"
+
+namespace mogltk {
+ class engine {
+ public:
+ static int setup() throw(GeneralException);
+ static int GetInited();
+ private:
+ static int inited;
+ };
+};
+
+#endif
diff --git a/includes/glbase.h b/includes/glbase.h
new file mode 100644
index 0000000..98fd537
--- /dev/null
+++ b/includes/glbase.h
@@ -0,0 +1,20 @@
+#ifndef __GLBASE_H__
+#define __GLBASE_H__
+
+#include <SDL.h>
+#include "Exceptions.h"
+
+namespace mogltk {
+ class glbase {
+ public:
+ static int setup(int w = 640, int h = 480, int flags = 0) throw(GeneralException);
+ static int GetWidth(void);
+ static int GetHeight(void);
+ static int GetInited(void);
+ private:
+ static int width, height, inited;
+ static SDL_Surface * surface;
+ };
+};
+
+#endif
diff --git a/mogltk/engine.cpp b/mogltk/engine.cpp
new file mode 100644
index 0000000..ff40514
--- /dev/null
+++ b/mogltk/engine.cpp
@@ -0,0 +1,24 @@
+#include <SDL.h>
+#include "engine.h"
+#include "generic.h"
+
+int mogltk::engine::inited = 0;
+
+int mogltk::engine::setup() throw(GeneralException) {
+ if (inited) {
+ printm(M_WARNING, "mogltk::engine::startup() called twice, ignoring second call.\n");
+ return -1;
+ }
+ if (SDL_Init(0) < 0) {
+ throw GeneralException("Unable to start SDL base system");
+ }
+ atexit(SDL_Quit);
+
+ inited = 1;
+
+ return 0;
+}
+
+int mogltk::engine::GetInited() {
+ return inited;
+}
diff --git a/mogltk/glbase.cpp b/mogltk/glbase.cpp
new file mode 100644
index 0000000..71fcaa0
--- /dev/null
+++ b/mogltk/glbase.cpp
@@ -0,0 +1,51 @@
+#include "glbase.h"
+#include "engine.h"
+#include "generic.h"
+#include <SDL.h>
+#include <SDL_opengl.h>
+
+int mogltk::glbase::width, mogltk::glbase::height, mogltk::glbase::inited = 0;
+SDL_Surface * mogltk::glbase::surface = 0;
+
+int mogltk::glbase::setup(int w, int h, int flags) throw(GeneralException) {
+ if (inited) {
+ printm(M_WARNING, "mogltk::glbase::setup called twice, ignoring second call...\n");
+ return -1;
+ }
+
+ width = w;
+ height = h;
+
+ mogltk::engine::setup();
+ if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
+ throw GeneralException(String("Couldn't initialise Video SubSystem: ") + SDL_GetError());
+ }
+
+ if (!(surface = SDL_SetVideoMode(width, height, 0, flags | SDL_OPENGL))) {
+ throw GeneralException(String("Couldn't set GL mode: ") + SDL_GetError());
+ }
+
+ printm(M_INFO, "Video resolution: %dx%dx%d\n", surface->w, surface->h, surface->format->BitsPerPixel);
+ printm(M_INFO, "\n");
+ printm(M_INFO, "OpenGL infos\n");
+ printm(M_INFO, "------------\n");
+ printm(M_INFO, String("Vendor : ") + (char *) glGetString(GL_VENDOR) + "\n");
+ printm(M_INFO, String("Renderer : ") + (char *) glGetString(GL_RENDERER) + "\n");
+ printm(M_INFO, String("Version : ") + (char *) glGetString(GL_VERSION) + "\n");
+ printm(M_INFO, String("Extensions: ") + (char *) glGetString(GL_EXTENSIONS) + "\n");
+
+ inited = 1;
+ return 0;
+}
+
+int mogltk::glbase::GetWidth(void) {
+ return width;
+}
+
+int mogltk::glbase::GetHeight(void) {
+ return height;
+}
+
+int mogltk::glbase::GetInited(void) {
+ return inited;
+}