From c9f837f21d7f2324c838891ec0d43cf7feff0cb9 Mon Sep 17 00:00:00 2001 From: Bryan Hoyle Date: Wed, 20 Jun 2012 14:23:22 -0400 Subject: [PATCH] Opengl can open saves now, just need to get it to render accurately later --- Makefile | 11 +++++----- src/OpenGLHeaders.h | 4 ++-- src/PowderToySDL.cpp | 2 +- src/Renderer.cpp | 1 - src/Renderer.h | 2 +- src/simulation/SaveRenderer.cpp | 36 +++++++++++++++++++-------------- 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index cf663f26b..01c2e122a 100644 --- a/Makefile +++ b/Makefile @@ -21,13 +21,13 @@ powder-x: build/powder-x powder-x.jnilib: build/powder-x.jnilib build/powder-release.exe: CFLAGS += -DWIN32 -O3 -ftree-vectorize -msse2 -funsafe-math-optimizations -ffast-math -fomit-frame-pointer -funsafe-loop-optimizations -Wunsafe-loop-optimizations -build/powder-release.exe: LFLAGS := -lmingw32 -lregex -lws2_32 -lSDLmain -lpthread -lSDL -lm -lbz2 -llua -lfftw3f-3 -mwindows +build/powder-release.exe: LFLAGS := -lmingw32 -lregex -lws2_32 -lSDLmain -lpthread -lSDL -lm -lbz2 -llua5.1 -lfftw3f-3 -mwindows build/powder.exe: CFLAGS += -DWIN32 build/powder.exe: LFLAGS := -lmingw32 -lregex -lws2_32 -lSDLmain -lpthread -lSDL -lm -lbz2 -llua -lfftw3f-3 #-mwindows -build/powder-release: CFLAGS += -DLIN32 -O3 -ftree-vectorize -msse2 -funsafe-math-optimizations -ffast-math -fomit-frame-pointer -funsafe-loop-optimizations -Wunsafe-loop-optimizations -build/powder-release: LFLAGS := -lSDL -lm -lbz2 -llua -lfftw3f -build/powder: CFLAGS += -DLIN32 -build/powder: LFLAGS := -lSDL -lm -lbz2 -llua -lfftw3f +build/powder-release: CFLAGS += -DLIN32 -O3 -ftree-vectorize -msse3 -funsafe-math-optimizations -ffast-math -fomit-frame-pointer -funsafe-loop-optimizations -Wunsafe-loop-optimizations -I/usr/include/SDL -I/usr/include/lua50 -DOGLR -DPIX32OGL -DPIXALPHA +build/powder-release: LFLAGS := -lSDL -lm -lbz2 -llua5.1 -lfftw3f -lGL -lGLEW -ggdb +build/powder: CFLAGS += -DLIN32 -DOGLR -DPIX32OGL -DPIXALPHA -I/usr/include/SDL -I/usr/include/lua50 +build/powder: LFLAGS := -lSDL -lm -lbz2 -llua5.1 -lfftw3f -lGL -lGLEW -ggdb #build/powder-x: CFLAGS += -DMACOSX -I/Library/Frameworks/SDL.framework/Headers -I/Library/Frameworks/Lua.framework/Headers -I/Library/Frameworks/OpenGL.framework/Headers -DOGLR -DPIX32OGL -DPIXALPHA #build/powder-x: LFLAGS := -lm -lbz2 -lfftw3f -framework SDL -framework Lua -framework Cocoa -framework OpenGL build/powder-x: CFLAGS += -DMACOSX -I/Library/Frameworks/SDL.framework/Headers -I/Library/Frameworks/Lua.framework/Headers -DPIX32BGRA @@ -45,7 +45,6 @@ build/powder-res.o: resources/powder-res.rc resources/powder.ico resources/docum mv resources/powder-res.o build/powder-res.o build/powder-release: $(SOURCES) $(CPPC) $(CFLAGS) $(OFLAGS) $(LDFLAGS) $(SOURCES) $(LFLAGS) -o $@ - strip $@ build/powder.exe: buildpaths-powder.exe generate $(patsubst build/obj/%.o,build/obj/powder.exe/%.o,$(OBJS)) build/powder-res.o $(CPPC_WIN) $(CFLAGS) $(OFLAGS) $(LDFLAGS) $(patsubst build/obj/%.o,build/obj/powder.exe/%.o,$(OBJS)) build/powder-res.o $(LFLAGS) -o $@ -ggdb diff --git a/src/OpenGLHeaders.h b/src/OpenGLHeaders.h index 3f925acde..8a8347256 100644 --- a/src/OpenGLHeaders.h +++ b/src/OpenGLHeaders.h @@ -18,7 +18,7 @@ #else -//#include +#include #include #include -#endif \ No newline at end of file +#endif diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index d268f578c..53f902756 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -114,7 +114,7 @@ SDL_Surface * SDLOpen() surface = SDL_SetVideoMode(XRES + BARSIZE, YRES + MENUSIZE, 32, SDL_OPENGL); #endif -#if defined(WIN32) && defined(OGLR) +#if defined(OGLR) int status = glewInit(); if(status != GLEW_OK) { diff --git a/src/Renderer.cpp b/src/Renderer.cpp index 53727aefe..b16602ade 100644 --- a/src/Renderer.cpp +++ b/src/Renderer.cpp @@ -4,7 +4,6 @@ * Created on: Jan 7, 2012 * Author: Simon */ - #include #include #include diff --git a/src/Renderer.h b/src/Renderer.h index 08befa632..8ad6a58c3 100644 --- a/src/Renderer.h +++ b/src/Renderer.h @@ -2,7 +2,7 @@ #define RENDERER_H #include -#if defined(OGLR) +#ifdef OGLR #include "OpenGLHeaders.h" #endif diff --git a/src/simulation/SaveRenderer.cpp b/src/simulation/SaveRenderer.cpp index cfa83c6d3..ba4653c05 100644 --- a/src/simulation/SaveRenderer.cpp +++ b/src/simulation/SaveRenderer.cpp @@ -19,6 +19,7 @@ SaveRenderer::SaveRenderer(){ Thumbnail * SaveRenderer::Render(GameSave * save) { +#ifndef OGLR Thumbnail * tempThumb = NULL; int width, height; width = save->blockWidth; @@ -30,26 +31,31 @@ Thumbnail * SaveRenderer::Render(GameSave * save) g->Clear(); sim->clear_sim(); - if(sim->Load(save)) - goto finish; - - ren->render_parts(); - - dst = pData = (pixel *)malloc(PIXELSIZE * ((width*CELL)*(height*CELL))); - - for(int i = 0; i < height*CELL; i++) + if(!sim->Load(save)) { - memcpy(dst, src, (width*CELL)*PIXELSIZE); - dst+=(width*CELL);///PIXELSIZE; - src+=XRES+BARSIZE; + ren->render_parts(); + + pData = (pixel *)malloc(PIXELSIZE * ((width*CELL)*(height*CELL))); + dst = pData; + for(int i = 0; i < height*CELL; i++) + { + printf("%d\n",i); + memcpy(dst, src, (width*CELL)*PIXELSIZE); + dst+=(width*CELL);///PIXELSIZE; + src+=XRES+BARSIZE; + } + + tempThumb = new Thumbnail(0, 0, pData, ui::Point(width*CELL, height*CELL)); } - - tempThumb = new Thumbnail(0, 0, pData, ui::Point(width*CELL, height*CELL)); - -finish: if(pData) free(pData); return tempThumb; +#else + VideoBuffer buffer(64, 64); + buffer.SetCharacter(32, 32, 'x', 255, 255, 255, 255); + Thumbnail * thumb = new Thumbnail(0, 0, buffer.Buffer, ui::Point(64, 64)); + return thumb; +#endif } Thumbnail * SaveRenderer::Render(unsigned char * saveData, int dataSize)