From 965956ff2411bef4a26e66154fe56e6dc5d482ed Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 1 May 2011 21:24:44 +0200 Subject: Added makefile, debugging stuff. --- Makefile.win32 | 15 +++++++++++++++ main.cpp | 20 +++++++++++--------- quadtree.cpp | 9 ++++++++- scene.cpp | 10 ++++++++++ 4 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 Makefile.win32 diff --git a/Makefile.win32 b/Makefile.win32 new file mode 100644 index 0000000..710c370 --- /dev/null +++ b/Makefile.win32 @@ -0,0 +1,15 @@ +CXX=i486-mingw32-g++ +LD=i486-mingw32-g++ +TARGET=foo.exe +OBJECTS=$(shell ls *.cpp | sed 's/cpp/o/') +#-D_GNU_SOURCE=1 -D_REENTRANT +CPPFLAGS=-I/usr/i486-mingw32/include/SDL -I/usr/i486-mingw32/include/CEGUI/ -g -mconsole -mwin32 +LDFLAGS=-lCEGUIOpenGLRenderer -lCEGUIBase -lCEGUITGAImageCodec -lCEGUITinyXMLParser -lCEGUIFalagardWRBase -lSDL_image -lfreetype -lz -lpcre -lopengl32 -lglu32 -lwinmm -lmingw32 -lSDLmain -lSDL -ljpeg + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(LD) -o $@ $^ $(LDFLAGS) + +clean: + rm -f $(OBJECTS) $(TARGET) diff --git a/main.cpp b/main.cpp index 643b3b4..3dc9e27 100644 --- a/main.cpp +++ b/main.cpp @@ -3,32 +3,34 @@ #include "gl.h" +#include + 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(); -#ifdef CEGUI_STATIC -#warning "cegui static" -#endif #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/quadtree.cpp b/quadtree.cpp index 65c60ae..3b329ac 100644 --- a/quadtree.cpp +++ b/quadtree.cpp @@ -343,11 +343,15 @@ Quadtree::QuadNode* Quadtree::QuadChunk::find(float x, float y) { /* Quadtree */ Quadtree::Quadtree(int width, int height, float *heightmap) { + std::cout << "width: " << width << " height: " << height << std::endl; + std::cout << "heightmap: " << heightmap << std::endl; + this->width = width; this->height = height; heights = heightmap; - root = new QuadChunk(this, 0, 0, width-1, height-1); + this->root = new QuadChunk(this, 0, 0, width-1, height-1); + std::cout << "root: " << root << std::endl; normals = new Vector3[width*height]; for(int x = 0; x < width; x++) { @@ -439,15 +443,18 @@ Vector3 Quadtree::calc_normal(int x, int y) { void Quadtree::update(float x, float z) { std::queue q; + std::cout << "root: " << root << std::endl; q.push(root); while(!q.empty()) { QuadChunk *chunk = q.front(); q.pop(); + std::cout << "chunk: " << chunk << std::endl; if(!chunk->nodes) { for(int i = 0; i < 4; i++) q.push(chunk->children[i]); continue; } + std::cout << "foo" << std::endl; float d = chunk->distance(x, z); if(d < 100 && !chunk->vbo_object) { diff --git a/scene.cpp b/scene.cpp index 7a2a740..bcec2bf 100644 --- a/scene.cpp +++ b/scene.cpp @@ -6,6 +6,7 @@ #include "gl.h" +#include #include #include @@ -48,17 +49,25 @@ Scene::Scene() { /* load heightmap */ SDL_Surface *hm = IMG_Load("heightmap.png"); + std::cout << (boost::format("size: %dx%d") % hm->w % hm->h).str() << std::endl; + std::cout << "size: " << hm->w << "x" << hm->h << std::endl; + printf("size: %dx%d\n", hm->w, hm->h); float *heightmap = new float[hm->w * hm->h]; for(int x = 0; x < hm->w; x++) { for(int y = 0; y < hm->h; y++) { Uint8 *p = (Uint8*)hm->pixels + y * hm->pitch + x * hm->format->BytesPerPixel; + if(y*hm->w + x >= hm->w * hm->h) + std::cout << "foo" << std::endl; heightmap[y*hm->w + x] = ((float)(*p) / 256) * 20; } } int w = hm->w; int h = hm->h; SDL_FreeSurface(hm); + float *hmap = heightmap; + std::cout << "heightmap: " << heightmap << std::endl; qt = new Quadtree(w, h, heightmap); + std::cout << "qt: " << qt << std::endl; /* load font */ //font = new FTTextureFont("fonts/VeraMono.ttf"); @@ -140,6 +149,7 @@ bool Scene::select(int x, int y, float& px, float& py, float& pz) { } void Scene::update() { + std::cout << "qt: " << qt << std::endl; qt->update(pos.x, pos.z); } -- cgit v1.2.3