summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.win3217
-rw-r--r--gl.cpp76
-rw-r--r--gl.h43
-rw-r--r--main.cpp21
-rw-r--r--scene.cpp11
-rw-r--r--scene.h4
6 files changed, 159 insertions, 13 deletions
diff --git a/Makefile.win32 b/Makefile.win32
new file mode 100644
index 0000000..9981c58
--- /dev/null
+++ b/Makefile.win32
@@ -0,0 +1,17 @@
+CXX=g++
+LD=g++
+TARGET=foo.exe
+#OBJECTS=$(shell ls *.cpp | sed 's/cpp/o/')
+OBJECTS=gl.o gui.o main.o terrain.o noiseutils/noiseutils.o scene.o shader.o tool.o vector.o video.o
+#-D_GNU_SOURCE=1 -D_REENTRANT
+CPPFLAGS=-IC:/mingw/include/SDL -IC:/mingw/include/CEGUI/ -g -mconsole #-mwin32
+LDFLAGS=-lCEGUIOpenGLRenderer -lCEGUIBase -lCEGUITGAImageCodec -lCEGUITinyXMLParser -lCEGUIFalagardWRBase -lCEGUISILLYImageCodec
+LDFLAGS+=-lSDL_image -lfreetype -lz -lpcre -lopengl32 -lglu32 -lwinmm -lmingw32 -lSDLmain -lSDL -ljpeg -lstdc++ -lboost_filesystem -lboost_system -lnoise
+
+all: $(TARGET)
+
+$(TARGET): $(OBJECTS)
+ $(LD) -o $@ $^ $(LDFLAGS)
+
+clean:
+ del $(OBJECTS) $(TARGET)
diff --git a/gl.cpp b/gl.cpp
new file mode 100644
index 0000000..54ab4c5
--- /dev/null
+++ b/gl.cpp
@@ -0,0 +1,76 @@
+#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 (*glUniform2f)(GLint, GLfloat, GLfloat);
+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");
+ glUniform2f = (void(*)(GLint, GLfloat, GLfloat))SDL_GL_GetProcAddress("glUniform2f");
+ 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..1d3a151 100644
--- a/gl.h
+++ b/gl.h
@@ -1,7 +1,50 @@
#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 (*glUniform2f)(GLint, GLfloat, GLfloat);
+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/main.cpp b/main.cpp
index d6ad962..3dc9e27 100644
--- a/main.cpp
+++ b/main.cpp
@@ -3,25 +3,34 @@
#include "gl.h"
+#include <SDL_image.h>
+
int main(int argc, char **argv) {
video::width = 1280;
video::height = 720;
video::init();
+ IMG_Init(IMG_INIT_PNG | IMG_INIT_JPG);
+
+#ifdef WIN32
+ win32_gl_init();
+#endif
- Scene scene;
+ Scene *scene = new Scene();
SDL_ShowCursor(SDL_DISABLE);
SDL_WarpMouse(video::width/2, video::height/2);
- scene.last_time = SDL_GetTicks();
- scene.update();
- while(scene.running) {
- scene.events();
- scene.render();
+ scene->last_time = SDL_GetTicks();
+ scene->update();
+ std::cout << "foo" << std::endl;
+ while(scene->running) {
+ scene->events();
+ scene->render();
SDL_Delay(1);
}
+ delete scene;
video::free();
return 0;
diff --git a/scene.cpp b/scene.cpp
index bf49c57..cc7db04 100644
--- a/scene.cpp
+++ b/scene.cpp
@@ -7,6 +7,7 @@
#include "gl.h"
+#include <unistd.h>
#include <cmath>
#include <queue>
@@ -52,8 +53,8 @@ Scene::Scene() {
terrain = new Terrain();
/* load font */
- font = new FTTextureFont("fonts/VeraMono.ttf");
- font->FaceSize(10);
+ //font = new FTTextureFont("fonts/VeraMono.ttf");
+ //font->FaceSize(10);
GUI::init();
}
@@ -63,7 +64,7 @@ Scene::~Scene() {
delete tool;
if(terrain)
delete terrain;
- delete font;
+ //delete font;
}
void Scene::lookat() {
@@ -447,7 +448,7 @@ void Scene::render() {
glPopMatrix();
video::ortho();
- float height = font->LineHeight();
+ /*float height = font->LineHeight();
glColor3f(1, 1, 1);
glTranslatef(0, video::height-height, 0);
font->Render((boost::format("chunks: %d gravity: %d steps: %d")
@@ -463,7 +464,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 82c1100..e700351 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;
Terrain *terrain;
- FTFont *font;
+ //FTFont *font;
GUI *gui;
Tool *tool;