summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xMakefile2
-rw-r--r--PcsxSrc/Linux/Makefile5
-rw-r--r--includes/engine.h2
-rw-r--r--includes/glbase.h6
-rw-r--r--mogltk/glbase.cpp67
5 files changed, 75 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 63950b4..7de9365 100755
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
#!/usr/bin/make -f
CPPFLAGS=-Wall -g -O3 -mcpu=i686 -Werror -Iincludes `sdl-config --cflags` -DHAVE_ZLIB
-LDFLAGS=-lz `sdl-config --libs` -lGL
+LDFLAGS=-lz `sdl-config --libs` -lGL -lGLU
CXX=g++
SUBDIRS = psxdev generic lib Xenogears VP MegamanX5 mogltk
diff --git a/PcsxSrc/Linux/Makefile b/PcsxSrc/Linux/Makefile
index 3f194c9..6a6ca1d 100644
--- a/PcsxSrc/Linux/Makefile
+++ b/PcsxSrc/Linux/Makefile
@@ -53,7 +53,10 @@ pcsx: ${OBJS}
.PHONY: clean pcsx
clean:
- ${RM} *.o ../*.o ../${CPU}/*.o pcsx GladeGui.* GladeFuncs.*
+ ${RM} *.o ../*.o ../${CPU}/*.o pcsx
+
+fullclean: clean
+ ${RM} GladeGui.* GladeFuncs.*
../%.o: ../%.c
${CC} ${CFLAGS} -c -o $@ $<
diff --git a/includes/engine.h b/includes/engine.h
index e7a4f6b..bf53bab 100644
--- a/includes/engine.h
+++ b/includes/engine.h
@@ -4,7 +4,7 @@
#include "Exceptions.h"
namespace mogltk {
- class engine {
+ class engine : public Base {
public:
static int setup() throw(GeneralException);
static int GetInited();
diff --git a/includes/glbase.h b/includes/glbase.h
index 98fd537..78272eb 100644
--- a/includes/glbase.h
+++ b/includes/glbase.h
@@ -5,14 +5,16 @@
#include "Exceptions.h"
namespace mogltk {
- class glbase {
+ class glbase : public Base {
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);
+ static void Enter2DMode(void);
+ static void Leave2DMode(void);
private:
- static int width, height, inited;
+ static int width, height, inited, twoD;
static SDL_Surface * surface;
};
};
diff --git a/mogltk/glbase.cpp b/mogltk/glbase.cpp
index 71fcaa0..b2512ca 100644
--- a/mogltk/glbase.cpp
+++ b/mogltk/glbase.cpp
@@ -4,7 +4,7 @@
#include <SDL.h>
#include <SDL_opengl.h>
-int mogltk::glbase::width, mogltk::glbase::height, mogltk::glbase::inited = 0;
+int mogltk::glbase::width, mogltk::glbase::height, mogltk::glbase::inited = 0, mogltk::glbase::twoD = 0;
SDL_Surface * mogltk::glbase::surface = 0;
int mogltk::glbase::setup(int w, int h, int flags) throw(GeneralException) {
@@ -25,7 +25,10 @@ int mogltk::glbase::setup(int w, int h, int flags) throw(GeneralException) {
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);
+ float ratio = surface->w;
+ ratio /= surface->h;
+
+ printm(M_INFO, "Video resolution: %dx%dx%d (ratio = %3.2f)\n", surface->w, surface->h, surface->format->BitsPerPixel, ratio);
printm(M_INFO, "\n");
printm(M_INFO, "OpenGL infos\n");
printm(M_INFO, "------------\n");
@@ -35,6 +38,27 @@ int mogltk::glbase::setup(int w, int h, int flags) throw(GeneralException) {
printm(M_INFO, String("Extensions: ") + (char *) glGetString(GL_EXTENSIONS) + "\n");
inited = 1;
+
+ glViewport(0, 0, surface->w, surface->h);
+
+ glCullFace(GL_BACK);
+ glFrontFace(GL_CCW);
+ glEnable(GL_CULL_FACE);
+
+ glClearColor(0, 0, 0, 0);
+ glShadeModel(GL_SMOOTH);
+
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_LEQUAL);
+ glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluPerspective(60.0, ratio, 1.0, 1024.0);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
return 0;
}
@@ -49,3 +73,42 @@ int mogltk::glbase::GetHeight(void) {
int mogltk::glbase::GetInited(void) {
return inited;
}
+
+void mogltk::glbase::Enter2DMode(void) {
+ if (twoD)
+ return;
+
+ glPushAttrib(GL_ENABLE_BIT);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0.0, width, height, 0.0, 0.0, 1.0);
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
+
+ twoD = 1;
+}
+
+void mogltk::glbase::Leave2DMode(void) {
+ if (!twoD)
+ return;
+
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+
+ glPopAttrib();
+
+ twoD = 0;
+}