summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-04-29 22:10:14 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-04-29 22:10:14 +0200
commitae0130e815c353c7fc045d7bb510e919f0f87231 (patch)
treecbaf7e533335a3c7c0f08cac9c4f9955ebac2bd3
parent55e76bdaafa1e2a94fbd717335c1c7bd8c8fc156 (diff)
win32 port wip
-rw-r--r--gl.cpp74
-rw-r--r--gl.h42
-rw-r--r--gui.h2
-rw-r--r--main.cpp7
-rw-r--r--scene.cpp10
-rw-r--r--scene.h4
6 files changed, 132 insertions, 7 deletions
diff --git a/gl.cpp b/gl.cpp
new file mode 100644
index 0000000..8152f05
--- /dev/null
+++ b/gl.cpp
@@ -0,0 +1,74 @@
+#include "gl.h"
+
+#include <SDL.h>
+
+#ifdef WIN32
+
+void (*glGenBuffers)(GLsizei, GLuint*);
+void (*glDeleteBuffers)(GLsizei, GLuint*);
+void (*glBindBuffer)(GLenum, GLuint);
+void (*glBufferData)(GLenum, GLsizeiptr, const GLvoid*, GLenum);
+GLvoid* (*glMapBuffer)(GLenum, GLenum);
+GLboolean (*glUnmapBuffer)(GLenum);
+
+/* uniform */
+GLint (*glGetUniformLocation)(GLuint, const GLchar*);
+void (*glUniform1i)(GLint, GLint);
+void (*glUniform3f)(GLint, GLfloat, GLfloat, GLfloat);
+
+/* texture */
+void (*glActiveTexture)(GLenum);
+
+/* program/shader */
+GLuint (*glCreateProgram)(void);
+void (*glLinkProgram)(GLuint);
+void (*glGetProgramiv)(GLuint, GLenum, GLint*);
+void (*glGetProgramInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*);
+void (*glUseProgram)(GLuint);
+void (*glDeleteProgram)(GLuint);
+
+GLuint (*glCreateShader)(GLenum);
+void (*glShaderSource)(GLuint, GLsizei, const GLchar**, const GLint*);
+void (*glCompileShader)(GLuint);
+void (*glGetShaderiv)(GLuint, GLenum, GLint*);
+void (*glGetShaderInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*);
+
+void (*glAttachShader)(GLuint, GLuint);
+void (*glDetachShader)(GLuint, GLuint);
+void (*glDeleteShader)(GLuint);
+
+//GL_DeleteBuffers glDeleteBuffers = NULL;
+
+void win32_gl_init() {
+ glGenBuffers = (void(*)(GLsizei, GLuint*))SDL_GL_GetProcAddress("glGenBuffers");
+ glDeleteBuffers = (void(*)(GLsizei, GLuint*))SDL_GL_GetProcAddress("glDeleteBuffers");
+ glBindBuffer = (void(*)(GLenum, GLuint))SDL_GL_GetProcAddress("glBindBuffer");
+ glBufferData = (void(*)(GLenum, GLsizeiptr, const GLvoid*, GLenum))SDL_GL_GetProcAddress("glBufferData");
+ glMapBuffer = (GLvoid*(*)(GLenum, GLenum))SDL_GL_GetProcAddress("glMapBuffer");
+ glUnmapBuffer = (GLboolean(*)(GLenum))SDL_GL_GetProcAddress("glUnmapBuffer");
+
+ glGetUniformLocation = (GLint(*)(GLuint, const GLchar*))SDL_GL_GetProcAddress("glGetUniformLocation");
+ glUniform1i = (void(*)(GLint, GLint))SDL_GL_GetProcAddress("glUniform1i");
+ glUniform3f = (void(*)(GLint, GLfloat, GLfloat, GLfloat))SDL_GL_GetProcAddress("glUniform3f");
+
+ glActiveTexture = (void(*)(GLenum))SDL_GL_GetProcAddress("glActiveTexture");
+
+ glCreateProgram = (GLuint(*)(void))SDL_GL_GetProcAddress("glCreateProgram");
+ glLinkProgram = (void(*)(GLuint))SDL_GL_GetProcAddress("glLinkProgram");
+ glGetProgramiv = (void(*)(GLuint, GLenum, GLint*))SDL_GL_GetProcAddress("glGetProgramiv");
+ glGetProgramInfoLog = (void(*)(GLuint, GLsizei, GLsizei*, GLchar*))SDL_GL_GetProcAddress("glGetProgramInfoLog");
+ glUseProgram = (void(*)(GLuint))SDL_GL_GetProcAddress("glUseProgram");
+ glDeleteProgram = (void(*)(GLuint))SDL_GL_GetProcAddress("glDeleteProgram");
+
+ glCreateShader = (GLuint(*)(GLenum))SDL_GL_GetProcAddress("glCreateShader");
+ glShaderSource = (void(*)(GLuint, GLsizei, const GLchar**, const GLint*))SDL_GL_GetProcAddress("glShaderSource");
+ glCompileShader = (void(*)(GLuint))SDL_GL_GetProcAddress("glCompileShader");
+ glGetShaderiv = (void(*)(GLuint, GLenum, GLint*))SDL_GL_GetProcAddress("glGetShaderiv");
+ glGetShaderInfoLog = (void(*)(GLuint, GLsizei, GLsizei*, GLchar*))SDL_GL_GetProcAddress("glGetShaderInfoLog");
+
+ glAttachShader = (void(*)(GLuint, GLuint))SDL_GL_GetProcAddress("glAttachShader");
+ glDetachShader = (void(*)(GLuint, GLuint))SDL_GL_GetProcAddress("glDetachShader");
+ glDeleteShader = (void(*)(GLuint))SDL_GL_GetProcAddress("glDeleteShader");
+}
+
+#endif
diff --git a/gl.h b/gl.h
index bb28c20..575a0ec 100644
--- a/gl.h
+++ b/gl.h
@@ -1,7 +1,49 @@
#ifndef GL_H
#define GL_H
+#ifndef WIN32
#define GL_GLEXT_PROTOTYPES
+#endif
+
#include <SDL_opengl.h>
+#ifdef WIN32
+/* buffer */
+extern void (*glGenBuffers)(GLsizei, GLuint*);
+extern void (*glDeleteBuffers)(GLsizei, GLuint*);
+extern void (*glBindBuffer)(GLenum, GLuint);
+extern void (*glBufferData)(GLenum, GLsizeiptr, const GLvoid*, GLenum);
+extern GLvoid* (*glMapBuffer)(GLenum, GLenum);
+extern GLboolean (*glUnmapBuffer)(GLenum);
+
+/* uniform */
+extern GLint (*glGetUniformLocation)(GLuint, const GLchar*);
+extern void (*glUniform1i)(GLint, GLint);
+extern void (*glUniform3f)(GLint, GLfloat, GLfloat, GLfloat);
+
+/* texture */
+extern void (*glActiveTexture)(GLenum);
+
+/* program/shader */
+extern GLuint (*glCreateProgram)(void);
+extern void (*glLinkProgram)(GLuint);
+extern void (*glGetProgramiv)(GLuint, GLenum, GLint*);
+extern void (*glGetProgramInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*);
+extern void (*glUseProgram)(GLuint);
+extern void (*glDeleteProgram)(GLuint);
+
+extern GLuint (*glCreateShader)(GLenum);
+extern void (*glShaderSource)(GLuint, GLsizei, const GLchar**, const GLint*);
+extern void (*glCompileShader)(GLuint);
+extern void (*glGetShaderiv)(GLuint, GLenum, GLint*);
+extern void (*glGetShaderInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*);
+
+extern void (*glAttachShader)(GLuint, GLuint);
+extern void (*glDetachShader)(GLuint, GLuint);
+extern void (*glDeleteShader)(GLuint);
+
+void win32_gl_init();
+#endif
+
+
#endif
diff --git a/gui.h b/gui.h
index 30bf6dd..7e61197 100644
--- a/gui.h
+++ b/gui.h
@@ -1,6 +1,8 @@
#ifndef GUI_H
#define GUI_H
+#define CEGUI_STATIC
+
#include <CEGUI.h>
class GUI {
diff --git a/main.cpp b/main.cpp
index d6ad962..643b3b4 100644
--- a/main.cpp
+++ b/main.cpp
@@ -8,6 +8,13 @@ int main(int argc, char **argv) {
video::height = 720;
video::init();
+#ifdef WIN32
+ win32_gl_init();
+#ifdef CEGUI_STATIC
+#warning "cegui static"
+#endif
+#endif
+
Scene scene;
SDL_ShowCursor(SDL_DISABLE);
diff --git a/scene.cpp b/scene.cpp
index 6cb6cc7..7a2a740 100644
--- a/scene.cpp
+++ b/scene.cpp
@@ -61,8 +61,8 @@ Scene::Scene() {
qt = new Quadtree(w, h, heightmap);
/* load font */
- font = new FTTextureFont("fonts/VeraMono.ttf");
- font->FaceSize(10);
+ //font = new FTTextureFont("fonts/VeraMono.ttf");
+ //font->FaceSize(10);
GUI::init();
}
@@ -72,7 +72,7 @@ Scene::~Scene() {
delete tool;
if(qt)
delete qt;
- delete font;
+ //delete font;
}
void Scene::lookat() {
@@ -408,7 +408,7 @@ void Scene::render() {
}
video::ortho();
- float height = font->LineHeight();
+ /*float height = font->LineHeight();
glColor3f(1, 1, 1);
glTranslatef(0, video::height-height, 0);
font->Render((boost::format("%dx%d chunks: %d gravity: %d steps: %d")
@@ -424,7 +424,7 @@ void Scene::render() {
if(tool) {
glTranslatef(0, -height, 0);
font->Render((boost::format("Tool: %s") % tool->get_name()).str().c_str());
- }
+ }*/
/*if(selected) {
glTranslatef(0, height, 0);
//font->Render((boost::format("(%s %s %s %s)") % selected->a->str() % selected->b->str() % selected->c->str() % selected->d->str()).str().c_str());
diff --git a/scene.h b/scene.h
index 59f0c79..3131474 100644
--- a/scene.h
+++ b/scene.h
@@ -8,7 +8,7 @@
#include "gui.h"
#include "tool.h"
-#include <FTGL/ftgl.h>
+//#include <FTGL/ftgl.h>
class Scene {
public:
@@ -16,7 +16,7 @@ class Scene {
Vector3 pos;
float yvel;
Quadtree *qt;
- FTFont *font;
+ //FTFont *font;
GUI *gui;
Tool *tool;