diff --git a/SConscript b/SConscript index 1bc069a75..56c152654 100644 --- a/SConscript +++ b/SConscript @@ -506,11 +506,6 @@ if not GetOption('nolua') and not GetOption('renderer') and not GetOption('font' if GetOption('nohttp') or GetOption('renderer'): env.Append(CPPDEFINES=['NOHTTP']) -if GetOption('opengl') or GetOption('opengl-renderer'): - env.Append(CPPDEFINES=['OGLI', 'PIX32OGL']) - if GetOption('opengl-renderer'): - env.Append(CPPDEFINES=['OGLR']) - if GetOption('renderer'): env.Append(CPPDEFINES=['RENDERER']) diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index a6b3e7eb4..2066cd6bd 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -135,12 +135,6 @@ void CalculateMousePosition(int *x, int *y) *y = (globalMy - windowY) / scale; } -#ifdef OGLI -void blit() -{ - SDL_GL_SwapBuffers(); -} -#else void blit(pixel * vid) { SDL_UpdateTexture(sdl_texture, NULL, vid, WINDOWW * sizeof (Uint32)); @@ -150,7 +144,6 @@ void blit(pixel * vid) SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL); SDL_RenderPresent(sdl_renderer); } -#endif void RecreateWindow(); int SDLOpen() @@ -520,11 +513,7 @@ void EngineProcess() engine->GetForceIntegerScaling()); } -#ifdef OGLI - blit(); -#else blit(engine->g->vid); -#endif int frameTime = SDL_GetTicks() - frameStart; frameTimeAvg = frameTimeAvg * 0.8 + frameTime * 0.2; @@ -590,11 +579,8 @@ void BlueScreen(String detailMessage) while (SDL_PollEvent(&event)) if(event.type == SDL_QUIT) exit(-1); -#ifdef OGLI - blit(); -#else + blit(engine->g->vid); -#endif } } @@ -717,18 +703,6 @@ int main(int argc, char * argv[]) showDoubleScreenDialog = true; } -#ifdef OGLI - SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); - //glScaled(2.0f, 2.0f, 1.0f); -#endif -#if defined(OGLI) && !defined(MACOSX) - int status = glewInit(); - if(status != GLEW_OK) - { - fprintf(stderr, "Initializing Glew: %d\n", status); - exit(-1); - } -#endif ui::Engine::Ref().g = new Graphics(); ui::Engine::Ref().Scale = scale; ui::Engine::Ref().SetResizable(resizable); @@ -806,11 +780,9 @@ int main(int argc, char * argv[]) engine->g->drawrect((engine->GetWidth()/2)-100, (engine->GetHeight()/2)-25, 200, 50, 255, 255, 255, 180); engine->g->drawtext((engine->GetWidth()/2)-(Graphics::textwidth("Loading save...")/2), (engine->GetHeight()/2)-5, "Loading save...", style::Colour::InformationTitle.Red, style::Colour::InformationTitle.Green, style::Colour::InformationTitle.Blue, 255); -#ifdef OGLI - blit(); -#else + blit(engine->g->vid); -#endif + ByteString ptsaveArg = arguments["ptsave"]; try { diff --git a/src/graphics/Graphics.cpp b/src/graphics/Graphics.cpp index 5c14481f5..48761d9f0 100644 --- a/src/graphics/Graphics.cpp +++ b/src/graphics/Graphics.cpp @@ -1061,10 +1061,7 @@ pixel *Graphics::render_packed_rgb(void *image, int width, int height, int cmp_s VideoBuffer Graphics::DumpFrame() { -#ifdef OGLI -#else VideoBuffer newBuffer(WINDOWW, WINDOWH); std::copy(vid, vid+(WINDOWW*WINDOWH), newBuffer.Buffer); return newBuffer; -#endif } diff --git a/src/graphics/Graphics.h b/src/graphics/Graphics.h index 3b9c8a812..10299a899 100644 --- a/src/graphics/Graphics.h +++ b/src/graphics/Graphics.h @@ -2,9 +2,6 @@ #define GRAPHICS_H #include "common/String.h" -#if defined(OGLI) -#include "OpenGLHeaders.h" -#endif #include "Config.h" #include "common/tpt-inline.h" #include "Pixel.h" @@ -25,20 +22,6 @@ public: void Resize(int width, int height, bool resample = false, bool fixedRatio = true); TPT_INLINE void BlendPixel(int x, int y, int r, int g, int b, int a) { - #ifdef PIX32OGL - pixel t; - if (x<0 || y<0 || x>=Width || y>=Height) - return; - if (a!=255) - { - t = Buffer[y*(Width)+x]; - r = (a*r + (255-a)*PIXR(t)) >> 8; - g = (a*g + (255-a)*PIXG(t)) >> 8; - b = (a*b + (255-a)*PIXB(t)) >> 8; - a = a > PIXA(t) ? a : PIXA(t); - } - Buffer[y*(Width)+x] = PIXRGBA(r,g,b,a); - #else pixel t; if (x<0 || y<0 || x>=Width || y>=Height) return; @@ -50,18 +33,13 @@ public: b = (a*b + (255-a)*PIXB(t)) >> 8; } Buffer[y*(Width)+x] = PIXRGB(r,g,b); - #endif } TPT_INLINE void SetPixel(int x, int y, int r, int g, int b, int a) { if (x<0 || y<0 || x>=Width || y>=Height) return; - #ifdef PIX32OGL - Buffer[y*(Width)+x] = PIXRGBA(r,g,b,a); - #else Buffer[y*(Width)+x] = PIXRGB((r*a)>>8, (g*a)>>8, (b*a)>>8); - #endif } TPT_INLINE void AddPixel(int x, int y, int r, int g, int b, int a) @@ -92,14 +70,6 @@ class Graphics public: pixel *vid; int sdl_scale; -#ifdef OGLI - //OpenGL specific instance variables - GLuint vidBuf, textTexture; - void Reset(); - void LoadDefaults(); - void InitialiseTextures(); - void DestroyTextures(); - #endif //Common graphics methods in Graphics.cpp static char * GenerateGradient(pixel * colours, float * points, int pointcount, int size); diff --git a/src/graphics/Pixel.h b/src/graphics/Pixel.h index bcafa762e..2d20a05f9 100644 --- a/src/graphics/Pixel.h +++ b/src/graphics/Pixel.h @@ -24,16 +24,6 @@ #define PIXR(x) (((x)>>8)&0xFF) #define PIXG(x) (((x)>>16)&0xFF) #define PIXB(x) (((x)>>24)&0xFF) -#elif defined(PIX32OGL) -#undef PIXELCHANNELS -#define PIXELCHANNELS 4 -#define PIXPACK(x) (0xFF000000|((x)&0xFFFFFF)) //32bit ARGB in 32bit int: AARRGGBB -#define PIXRGB(r,g,b) (0xFF000000|((r)<<16)|((g)<<8)|((b))) -#define PIXRGBA(r,g,b,a) (((a)<<24)|((r)<<16)|((g)<<8)|((b))) -#define PIXA(x) (((x)>>24)&0xFF) -#define PIXR(x) (((x)>>16)&0xFF) -#define PIXG(x) (((x)>>8)&0xFF) -#define PIXB(x) ((x)&0xFF) #else #define PIXPACK(x) (x) //24bit RGB in 32bit int: 00RRGGBB. #define PIXRGB(r,g,b) (((r)<<16)|((g)<<8)|(b)) diff --git a/src/graphics/RasterGraphics.cpp b/src/graphics/RasterGraphics.cpp index a55175e5d..0b77d5884 100644 --- a/src/graphics/RasterGraphics.cpp +++ b/src/graphics/RasterGraphics.cpp @@ -3,8 +3,6 @@ #include #include -#ifndef OGLI - Graphics::Graphics(): sdl_scale(1) { @@ -34,5 +32,3 @@ void Graphics::Finalise() #undef VIDYRES #undef VIDXRES #undef PIXELMETHODS_CLASS - -#endif diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index a046ac4d5..56d04cae0 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -26,80 +26,14 @@ #include "lua/LuaSmartRef.h" #endif #include "hmap.h" -#ifdef OGLR -#include "Shaders.h" -#endif -#ifndef OGLI #define VIDXRES WINDOWW #define VIDYRES WINDOWH -#else -#define VIDXRES XRES -#define VIDYRES YRES -#endif void Renderer::RenderBegin() { -#ifdef OGLI -#ifdef OGLR - draw_air(); - draw_grav(); - DrawWalls(); - render_parts(); - render_fire(); - draw_other(); - draw_grav_zones(); - DrawSigns(); - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo); - glTranslated(0, MENUSIZE, 0); -#else - if(display_mode & DISPLAY_PERS) - { - std::copy(persistentVid, persistentVid+(VIDXRES*YRES), vid); - } - pixel * oldVid; - if(display_mode & DISPLAY_WARP) - { - oldVid = vid; - vid = warpVid; - std::fill(warpVid, warpVid+(VIDXRES*VIDYRES), 0); - } - - draw_air(); - draw_grav(); - DrawWalls(); - render_parts(); - if(display_mode & DISPLAY_PERS) - { - int i,r,g,b; - for (i = 0; i < VIDXRES*YRES; i++) - { - r = PIXR(vid[i]); - g = PIXG(vid[i]); - b = PIXB(vid[i]); - if (r>0) - r--; - if (g>0) - g--; - if (b>0) - b--; - persistentVid[i] = PIXRGB(r,g,b); - } - } - - render_fire(); - draw_other(); - draw_grav_zones(); - DrawSigns(); - if(display_mode & DISPLAY_WARP) - { - vid = oldVid; - } -#endif -#else if(display_mode & DISPLAY_PERS) { std::copy(persistentVid, persistentVid+(VIDXRES*YRES), vid); @@ -145,24 +79,11 @@ void Renderer::RenderBegin() } FinaliseParts(); -#endif } void Renderer::RenderEnd() { -#ifdef OGLI -#ifdef OGLR - glTranslated(0, -MENUSIZE, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo); - FinaliseParts(); RenderZoom(); -#else - RenderZoom(); - FinaliseParts(); -#endif -#else - RenderZoom(); -#endif } void Renderer::SetSample(int x, int y) @@ -172,355 +93,49 @@ void Renderer::SetSample(int x, int y) void Renderer::clearScreen(float alpha) { -#ifdef OGLR - GLint prevFbo; - if(alpha > 0.999f) - { - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo); - glClear(GL_COLOR_BUFFER_BIT); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo); - } - else - { - glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); - glColor4f(1.0f, 1.0f, 1.0f, alpha); - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo); - glBegin(GL_QUADS); - glVertex2f(0, 0); - glVertex2f(XRES, 0); - glVertex2f(XRES, YRES); - glVertex2f(0, YRES); - glEnd(); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo); - glBlendEquation(GL_FUNC_ADD); - } - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); -#endif -#ifdef OGLI -#ifndef OGLR - std::fill(vid, vid+(VIDXRES*VIDYRES), 0); -#endif -#else g->Clear(); -#endif } -#ifdef OGLR -void Renderer::checkShader(GLuint shader, const char * shname) -{ - GLint status; - glGetShaderiv(shader, GL_COMPILE_STATUS, &status); - if (status == GL_FALSE) - { - char errorBuf[ GL_INFO_LOG_LENGTH]; - int errLen; - glGetShaderInfoLog(shader, GL_INFO_LOG_LENGTH, &errLen, errorBuf); - fprintf(stderr, "Failed to compile %s shader:\n%s\n", shname, errorBuf); - exit(1); - } -} -void Renderer::checkProgram(GLuint program, const char * progname) -{ - GLint status; - glGetProgramiv(program, GL_LINK_STATUS, &status); - if (status == GL_FALSE) - { - char errorBuf[ GL_INFO_LOG_LENGTH]; - int errLen; - glGetShaderInfoLog(program, GL_INFO_LOG_LENGTH, &errLen, errorBuf); - fprintf(stderr, "Failed to link %s program:\n%s\n", progname, errorBuf); - exit(1); - } -} -void Renderer::loadShaders() -{ - GLuint vertexShader, fragmentShader; - - //Particle texture - vertexShader = glCreateShader(GL_VERTEX_SHADER); - fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); - - glShaderSource( vertexShader, 1, &fireVertex, NULL); - glShaderSource( fragmentShader, 1, &fireFragment, NULL); - - glCompileShader( vertexShader ); - checkShader(vertexShader, "FV"); - glCompileShader( fragmentShader ); - checkShader(fragmentShader, "FF"); - - fireProg = glCreateProgram(); - glAttachShader( fireProg, vertexShader ); - glAttachShader( fireProg, fragmentShader ); - glLinkProgram( fireProg ); - checkProgram(fireProg, "F"); - - //Lensing - vertexShader = glCreateShader(GL_VERTEX_SHADER); - fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); - - glShaderSource( vertexShader, 1, &lensVertex, NULL); - glShaderSource( fragmentShader, 1, &lensFragment, NULL); - - glCompileShader( vertexShader ); - checkShader(vertexShader, "LV"); - glCompileShader( fragmentShader ); - checkShader(fragmentShader, "LF"); - - lensProg = glCreateProgram(); - glAttachShader( lensProg, vertexShader ); - glAttachShader( lensProg, fragmentShader ); - glLinkProgram( lensProg ); - checkProgram(lensProg, "L"); - - //Air Velocity - vertexShader = glCreateShader(GL_VERTEX_SHADER); - fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); - - glShaderSource( vertexShader, 1, &airVVertex, NULL); - glShaderSource( fragmentShader, 1, &airVFragment, NULL); - - glCompileShader( vertexShader ); - checkShader(vertexShader, "AVX"); - glCompileShader( fragmentShader ); - checkShader(fragmentShader, "AVF"); - - airProg_Velocity = glCreateProgram(); - glAttachShader( airProg_Velocity, vertexShader ); - glAttachShader( airProg_Velocity, fragmentShader ); - glLinkProgram( airProg_Velocity ); - checkProgram(airProg_Velocity, "AV"); - - //Air Pressure - vertexShader = glCreateShader(GL_VERTEX_SHADER); - fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); - - glShaderSource( vertexShader, 1, &airPVertex, NULL); - glShaderSource( fragmentShader, 1, &airPFragment, NULL); - - glCompileShader( vertexShader ); - checkShader(vertexShader, "APV"); - glCompileShader( fragmentShader ); - checkShader(fragmentShader, "APF"); - - airProg_Pressure = glCreateProgram(); - glAttachShader( airProg_Pressure, vertexShader ); - glAttachShader( airProg_Pressure, fragmentShader ); - glLinkProgram( airProg_Pressure ); - checkProgram(airProg_Pressure, "AP"); - - //Air cracker - vertexShader = glCreateShader(GL_VERTEX_SHADER); - fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); - - glShaderSource( vertexShader, 1, &airCVertex, NULL); - glShaderSource( fragmentShader, 1, &airCFragment, NULL); - - glCompileShader( vertexShader ); - checkShader(vertexShader, "ACV"); - glCompileShader( fragmentShader ); - checkShader(fragmentShader, "ACF"); - - airProg_Cracker = glCreateProgram(); - glAttachShader( airProg_Cracker, vertexShader ); - glAttachShader( airProg_Cracker, fragmentShader ); - glLinkProgram( airProg_Cracker ); - checkProgram(airProg_Cracker, "AC"); -} -#endif void Renderer::FinaliseParts() { -#ifdef OGLR - glEnable( GL_TEXTURE_2D ); - if(display_mode & DISPLAY_WARP) - { - float xres = XRES, yres = YRES; - glUseProgram(lensProg); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, partsFboTex); - glUniform1i(glGetUniformLocation(lensProg, "pTex"), 0); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, partsTFX); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, XRES/CELL, YRES/CELL, GL_RED, GL_FLOAT, sim->gravx); - glUniform1i(glGetUniformLocation(lensProg, "tfX"), 1); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, partsTFY); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, XRES/CELL, YRES/CELL, GL_GREEN, GL_FLOAT, sim->gravy); - glUniform1i(glGetUniformLocation(lensProg, "tfY"), 2); - glActiveTexture(GL_TEXTURE0); - glUniform1fv(glGetUniformLocation(lensProg, "xres"), 1, &xres); - glUniform1fv(glGetUniformLocation(lensProg, "yres"), 1, &yres); - } - else - { - glBindTexture(GL_TEXTURE_2D, partsFboTex); - glBlendFunc(GL_ONE, GL_ONE); - } - - int sdl_scale = 1; - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_QUADS); - glTexCoord2d(1, 0); - //glVertex3f(XRES*sdl_scale, WINDOWH*sdl_scale, 1.0); - glVertex3f(XRES*sdl_scale, YRES*sdl_scale, 1.0); - glTexCoord2d(0, 0); - //glVertex3f(0, WINDOWH*sdl_scale, 1.0); - glVertex3f(0, YRES*sdl_scale, 1.0); - glTexCoord2d(0, 1); - //glVertex3f(0, MENUSIZE*sdl_scale, 1.0); - glVertex3f(0, 0, 1.0); - glTexCoord2d(1, 1); - //glVertex3f(XRES*sdl_scale, MENUSIZE*sdl_scale, 1.0); - glVertex3f(XRES*sdl_scale, 0, 1.0); - glEnd(); - - if(display_mode & DISPLAY_WARP) - { - glUseProgram(0); - - } - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable( GL_TEXTURE_2D ); -#endif - -#if defined(OGLI) && !defined(OGLR) if(display_mode & DISPLAY_WARP) { render_gravlensing(warpVid); } - g->draw_image(vid, 0, 0, VIDXRES, VIDYRES, 255); -#endif - -#if !defined(OGLR) && !defined(OGLI) - if(display_mode & DISPLAY_WARP) - { - render_gravlensing(warpVid); - } -#endif } void Renderer::RenderZoom() { if(!zoomEnabled) return; - #if defined(OGLR) - int sdl_scale = 1; - int origBlendSrc, origBlendDst; - float zcx1, zcx0, zcy1, zcy0, yfactor, xfactor, i; //X-Factor is shit, btw - xfactor = 1.0f/(float)XRES; - yfactor = 1.0f/(float)YRES; - yfactor*=-1.0f; - zcx1 = (zoomScopePosition.X)*xfactor; - zcx0 = (zoomScopePosition.X+zoomScopeSize)*xfactor; - zcy1 = (zoomScopePosition.Y-1)*yfactor; - zcy0 = ((zoomScopePosition.Y-1+zoomScopeSize))*yfactor; - - glGetIntegerv(GL_BLEND_SRC, &origBlendSrc); - glGetIntegerv(GL_BLEND_DST, &origBlendDst); - glBlendFunc(GL_ONE, GL_ZERO); - - glEnable( GL_TEXTURE_2D ); - //glReadBuffer(GL_AUX0); - glBindTexture(GL_TEXTURE_2D, partsFboTex); - - //Draw zoomed texture - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_QUADS); - glTexCoord2d(zcx1, zcy1); - glVertex2i(zoomWindowPosition.X, zoomWindowPosition.Y); - glTexCoord2d(zcx0, zcy1); - glVertex2i(zoomWindowPosition.X+(zoomScopeSize*ZFACTOR), zoomWindowPosition.Y); - glTexCoord2d(zcx0, zcy0); - glVertex2i(zoomWindowPosition.X+(zoomScopeSize*ZFACTOR), zoomWindowPosition.Y+(zoomScopeSize*ZFACTOR)); - glTexCoord2d(zcx1, zcy0); - glVertex2i(zoomWindowPosition.X, zoomWindowPosition.Y+(zoomScopeSize*ZFACTOR)); - glEnd(); - glBindTexture(GL_TEXTURE_2D, 0); - glDisable( GL_TEXTURE_2D ); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - //Lines to make the pixels stand out - glLineWidth(sdl_scale); - //glEnable(GL_LINE_SMOOTH); - glBegin(GL_LINES); - glColor4f(0.0f, 0.0f, 0.0f, 1.0f); - for(i = 0; i < zoomScopeSize; i++) + int x, y, i, j; + pixel pix; + pixel * img = vid; + clearrect(zoomWindowPosition.X-1, zoomWindowPosition.Y-1, zoomScopeSize*ZFACTOR+1, zoomScopeSize*ZFACTOR+1); + drawrect(zoomWindowPosition.X-2, zoomWindowPosition.Y-2, zoomScopeSize*ZFACTOR+3, zoomScopeSize*ZFACTOR+3, 192, 192, 192, 255); + drawrect(zoomWindowPosition.X-1, zoomWindowPosition.Y-1, zoomScopeSize*ZFACTOR+1, zoomScopeSize*ZFACTOR+1, 0, 0, 0, 255); + for (j=0; j Renderer_wtypes = LoadWalls(); @@ -704,33 +319,6 @@ void Renderer::DrawBlob(int x, int y, unsigned char cr, unsigned char cg, unsign void Renderer::DrawWalls() { -#ifdef OGLR - // terrible OpenGL "support" - GLint prevFbo; - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo); - glTranslated(0, MENUSIZE, 0); - - for (int y = 0; y < YRES/CELL; y++) - for (int x = 0; x < XRES/CELL; x++) - if (sim->bmap[y][x]) - { - unsigned char wt = sim->bmap[y][x]; - if (wt >= UI_WALLCOUNT) - continue; - pixel pc = sim->wtypes[wt].colour; - pixel gc = sim->wtypes[wt].eglow; - - int cr = PIXR(pc); - int cg = PIXG(pc); - int cb = PIXB(pc); - - fillrect(x*CELL, y*CELL, CELL, CELL, cr, cg, cb, 255); - } - - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo); - glTranslated(0, -MENUSIZE, 0); -#else for (int y = 0; y < YRES/CELL; y++) for (int x =0; x < XRES/CELL; x++) if (sim->bmap[y][x]) @@ -973,19 +561,13 @@ void Renderer::DrawWalls() fire_b[y][x] = cb; } } -#endif } void Renderer::DrawSigns() { int x, y, w, h; std::vector signs = sim->signs; -#ifdef OGLR - GLint prevFbo; - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo); - glTranslated(0, MENUSIZE, 0); -#endif + for (auto ¤tSign : signs) { if (currentSign.text.length()) @@ -1001,32 +583,19 @@ void Renderer::DrawSigns() int y = currentSign.y; int dx = 1 - currentSign.ju; int dy = (currentSign.y > 18) ? -1 : 1; -#ifdef OGLR - glBegin(GL_LINES); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glVertex2i(x, y); - glVertex2i(x+(dx*4), y+(dy*4)); - glEnd(); -#else for (int j = 0; j < 4; j++) { blendpixel(x, y, 192, 192, 192, 255); x += dx; y += dy; } -#endif } } } -#ifdef OGLR - glTranslated(0, -MENUSIZE, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo); -#endif } void Renderer::render_gravlensing(pixel * source) { -#ifndef OGLR int nx, ny, rx, ry, gx, gy, bx, by, co; int r, g, b; pixel t; @@ -1061,12 +630,10 @@ void Renderer::render_gravlensing(pixel * source) } } } -#endif } void Renderer::render_fire() { -#ifndef OGLR if(!(render_mode & FIREMODE)) return; int i,j,x,y,r,g,b,a; @@ -1103,7 +670,6 @@ void Renderer::render_fire() fire_g[j][i] = g>4 ? g-4 : 0; fire_b[j][i] = b>4 ? b-4 : 0; } -#endif } float temp[CELL*3][CELL*3]; @@ -1125,70 +691,6 @@ void Renderer::prepare_alpha(int size, float intensity) for (x=0; x 7) - continue; - glow_alphaf[c+x][c-y] += 0.02f; - glow_alphaf[c-x][c+y] += 0.02f; - glow_alphaf[c+x][c+y] += 0.02f; - glow_alphaf[c-x][c-y] += 0.02f; - } - } - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, glowAlpha); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 11, 11, GL_ALPHA, GL_FLOAT, glow_alphaf); - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - c = 3; - - for (x=-3; x<4; x++) - { - for (y=-3; y<4; y++) - { - if (abs(x)+abs(y) <2 && !(abs(x)==2||abs(y)==2)) - blur_alphaf[c+x][c-y] = 0.11f; - if (abs(x)+abs(y) <=3 && abs(x)+abs(y)) - blur_alphaf[c+x][c-y] = 0.08f; - if (abs(x)+abs(y) == 2) - blur_alphaf[c+x][c-y] = 0.04f; - } - } - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, blurAlpha); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 7, 7, GL_ALPHA, GL_FLOAT, blur_alphaf); - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); -#endif } void Renderer::render_parts() @@ -1202,25 +704,7 @@ void Renderer::render_parts() return; parts = sim->parts; elements = sim->elements; -#ifdef OGLR - float fnx, fny; - int cfireV = 0, cfireC = 0, cfire = 0; - int csmokeV = 0, csmokeC = 0, csmoke = 0; - int cblobV = 0, cblobC = 0, cblob = 0; - int cblurV = 0, cblurC = 0, cblur = 0; - int cglowV = 0, cglowC = 0, cglow = 0; - int cflatV = 0, cflatC = 0, cflat = 0; - int caddV = 0, caddC = 0, cadd = 0; - int clineV = 0, clineC = 0, cline = 0; - GLint origBlendSrc, origBlendDst, prevFbo; - glGetIntegerv(GL_BLEND_SRC, &origBlendSrc); - glGetIntegerv(GL_BLEND_DST, &origBlendDst); - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo); - //Render to the particle FBO - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo); - glTranslated(0, MENUSIZE, 0); -#else if (gridSize)//draws the grid { for (ny=0; nyparts_lastActiveIndex; i++) { if (sim->parts[i].type && sim->parts[i].type >= 0 && sim->parts[i].type < PT_NUM) { @@ -1240,10 +724,6 @@ void Renderer::render_parts() nx = (int)(sim->parts[i].x+0.5f); ny = (int)(sim->parts[i].y+0.5f); -#ifdef OGLR - fnx = sim->parts[i].x; - fny = sim->parts[i].y; -#endif if(nx >= XRES || nx < 0 || ny >= YRES || ny < 0) continue; @@ -1450,7 +930,6 @@ void Renderer::render_parts() if(pixel_mode & (FIREMODE | PMODE_GLOW)) pixel_mode = (pixel_mode & ~(FIREMODE|PMODE_GLOW)) | PMODE_BLUR; } - #ifndef OGLR //All colours are now set, check ranges if(colr>255) colr = 255; else if(colr<0) colr = 0; @@ -1469,7 +948,6 @@ void Renderer::render_parts() else if(fireb<0) fireb = 0; if(firea>255) firea = 255; else if(firea<0) firea = 0; - #endif //Pixel rendering if (pixel_mode & EFFECT_LINES) @@ -1526,49 +1004,6 @@ void Renderer::render_parts() } } -#ifdef OGLR - glColor4f(((float)colr)/255.0f, ((float)colg)/255.0f, ((float)colb)/255.0f, 1.0f); - glBegin(GL_LINE_STRIP); - if(t==PT_FIGH) - { - glVertex2f(fnx, fny+2); - glVertex2f(fnx+2, fny); - glVertex2f(fnx, fny-2); - glVertex2f(fnx-2, fny); - glVertex2f(fnx, fny+2); - } - else - { - glVertex2f(fnx-2, fny-2); - glVertex2f(fnx+2, fny-2); - glVertex2f(fnx+2, fny+2); - glVertex2f(fnx-2, fny+2); - glVertex2f(fnx-2, fny-2); - } - glEnd(); - glBegin(GL_LINES); - - if (colour_mode!=COLOUR_HEAT) - { - if (t==PT_STKM2) - glColor4f(100.0f/255.0f, 100.0f/255.0f, 1.0f, 1.0f); - else - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - } - - glVertex2f(nx, ny+3); - glVertex2f(cplayer->legs[0], cplayer->legs[1]); - - glVertex2f(cplayer->legs[0], cplayer->legs[1]); - glVertex2f(cplayer->legs[4], cplayer->legs[5]); - - glVertex2f(nx, ny+3); - glVertex2f(cplayer->legs[8], cplayer->legs[9]); - - glVertex2f(cplayer->legs[8], cplayer->legs[9]); - glVertex2f(cplayer->legs[12], cplayer->legs[13]); - glEnd(); -#else if (findingElement && findingElement == t) { legr = 255; @@ -1644,61 +1079,21 @@ void Renderer::render_parts() blendpixel(nx-1, ny+1, colr, colg, colb, 112); } } -#endif } if(pixel_mode & PMODE_FLAT) { -#ifdef OGLR - flatV[cflatV++] = nx; - flatV[cflatV++] = ny; - flatC[cflatC++] = ((float)colr)/255.0f; - flatC[cflatC++] = ((float)colg)/255.0f; - flatC[cflatC++] = ((float)colb)/255.0f; - flatC[cflatC++] = 1.0f; - cflat++; -#else vid[ny*(VIDXRES)+nx] = PIXRGB(colr,colg,colb); -#endif } if(pixel_mode & PMODE_BLEND) { -#ifdef OGLR - flatV[cflatV++] = nx; - flatV[cflatV++] = ny; - flatC[cflatC++] = ((float)colr)/255.0f; - flatC[cflatC++] = ((float)colg)/255.0f; - flatC[cflatC++] = ((float)colb)/255.0f; - flatC[cflatC++] = ((float)cola)/255.0f; - cflat++; -#else blendpixel(nx, ny, colr, colg, colb, cola); -#endif } if(pixel_mode & PMODE_ADD) { -#ifdef OGLR - addV[caddV++] = nx; - addV[caddV++] = ny; - addC[caddC++] = ((float)colr)/255.0f; - addC[caddC++] = ((float)colg)/255.0f; - addC[caddC++] = ((float)colb)/255.0f; - addC[caddC++] = ((float)cola)/255.0f; - cadd++; -#else addpixel(nx, ny, colr, colg, colb, cola); -#endif } if(pixel_mode & PMODE_BLOB) { -#ifdef OGLR - blobV[cblobV++] = nx; - blobV[cblobV++] = ny; - blobC[cblobC++] = ((float)colr)/255.0f; - blobC[cblobC++] = ((float)colg)/255.0f; - blobC[cblobC++] = ((float)colb)/255.0f; - blobC[cblobC++] = 1.0f; - cblob++; -#else vid[ny*(VIDXRES)+nx] = PIXRGB(colr,colg,colb); blendpixel(nx+1, ny, colr, colg, colb, 223); @@ -1710,20 +1105,11 @@ void Renderer::render_parts() blendpixel(nx-1, ny-1, colr, colg, colb, 112); blendpixel(nx+1, ny+1, colr, colg, colb, 112); blendpixel(nx-1, ny+1, colr, colg, colb, 112); -#endif } if(pixel_mode & PMODE_GLOW) { int cola1 = (5*cola)/255; -#ifdef OGLR - glowV[cglowV++] = nx; - glowV[cglowV++] = ny; - glowC[cglowC++] = ((float)colr)/255.0f; - glowC[cglowC++] = ((float)colg)/255.0f; - glowC[cglowC++] = ((float)colb)/255.0f; - glowC[cglowC++] = 1.0f; - cglow++; -#else + addpixel(nx, ny, colr, colg, colb, (192*cola)/255); addpixel(nx+1, ny, colr, colg, colb, (96*cola)/255); addpixel(nx-1, ny, colr, colg, colb, (96*cola)/255); @@ -1744,19 +1130,9 @@ void Renderer::render_parts() addpixel(nx-x, ny-y, colr, colg, colb, cola1); } } -#endif } if(pixel_mode & PMODE_BLUR) { -#ifdef OGLR - blurV[cblurV++] = nx; - blurV[cblurV++] = ny; - blurC[cblurC++] = ((float)colr)/255.0f; - blurC[cblurC++] = ((float)colg)/255.0f; - blurC[cblurC++] = ((float)colb)/255.0f; - blurC[cblurC++] = 1.0f; - cblur++; -#else for (x=-3; x<4; x++) { for (y=-3; y<4; y++) @@ -1769,61 +1145,10 @@ void Renderer::render_parts() blendpixel(x+nx, y+ny, colr, colg, colb, 10); } } -#endif } if(pixel_mode & PMODE_SPARK) { flicker = random_gen()%20; -#ifdef OGLR - //Oh god, this is awful - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 0.0f; - lineV[clineV++] = fnx-5; - lineV[clineV++] = fny; - cline++; - - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 1.0f - ((float)flicker)/30; - lineV[clineV++] = fnx; - lineV[clineV++] = fny; - cline++; - - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 0.0f; - lineV[clineV++] = fnx+5; - lineV[clineV++] = fny; - cline++; - - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 0.0f; - lineV[clineV++] = fnx; - lineV[clineV++] = fny-5; - cline++; - - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 1.0f - ((float)flicker)/30; - lineV[clineV++] = fnx; - lineV[clineV++] = fny; - cline++; - - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 0.0f; - lineV[clineV++] = fnx; - lineV[clineV++] = fny+5; - cline++; -#else gradv = 4*sim->parts[i].life + flicker; for (x = 0; gradv>0.5; x++) { addpixel(nx+x, ny, colr, colg, colb, gradv); @@ -1833,61 +1158,11 @@ void Renderer::render_parts() addpixel(nx, ny-x, colr, colg, colb, gradv); gradv = gradv/1.5f; } -#endif } if(pixel_mode & PMODE_FLARE) { flicker = random_gen()%20; -#ifdef OGLR - //Oh god, this is awful - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 0.0f; - lineV[clineV++] = fnx-10; - lineV[clineV++] = fny; - cline++; - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 1.0f - ((float)flicker)/40; - lineV[clineV++] = fnx; - lineV[clineV++] = fny; - cline++; - - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 0.0f; - lineV[clineV++] = fnx+10; - lineV[clineV++] = fny; - cline++; - - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 0.0f; - lineV[clineV++] = fnx; - lineV[clineV++] = fny-10; - cline++; - - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 1.0f - ((float)flicker)/30; - lineV[clineV++] = fnx; - lineV[clineV++] = fny; - cline++; - - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 0.0f; - lineV[clineV++] = fnx; - lineV[clineV++] = fny+10; - cline++; -#else gradv = flicker + fabs(parts[i].vx)*17 + fabs(sim->parts[i].vy)*17; blendpixel(nx, ny, colr, colg, colb, (gradv*4)>255?255:(gradv*4) ); blendpixel(nx+1, ny, colr, colg, colb, (gradv*2)>255?255:(gradv*2) ); @@ -1906,61 +1181,11 @@ void Renderer::render_parts() addpixel(nx, ny-x, colr, colg, colb, gradv); gradv = gradv/1.2f; } -#endif } if(pixel_mode & PMODE_LFLARE) { flicker = random_gen()%20; -#ifdef OGLR - //Oh god, this is awful - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 0.0f; - lineV[clineV++] = fnx-70; - lineV[clineV++] = fny; - cline++; - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 1.0f - ((float)flicker)/30; - lineV[clineV++] = fnx; - lineV[clineV++] = fny; - cline++; - - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 0.0f; - lineV[clineV++] = fnx+70; - lineV[clineV++] = fny; - cline++; - - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 0.0f; - lineV[clineV++] = fnx; - lineV[clineV++] = fny-70; - cline++; - - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 1.0f - ((float)flicker)/50; - lineV[clineV++] = fnx; - lineV[clineV++] = fny; - cline++; - - lineC[clineC++] = ((float)colr)/255.0f; - lineC[clineC++] = ((float)colg)/255.0f; - lineC[clineC++] = ((float)colb)/255.0f; - lineC[clineC++] = 0.0f; - lineV[clineV++] = fnx; - lineV[clineV++] = fny+70; - cline++; -#else gradv = flicker + fabs(parts[i].vx)*17 + fabs(parts[i].vy)*17; blendpixel(nx, ny, colr, colg, colb, (gradv*4)>255?255:(gradv*4) ); blendpixel(nx+1, ny, colr, colg, colb, (gradv*2)>255?255:(gradv*2) ); @@ -1979,7 +1204,6 @@ void Renderer::render_parts() addpixel(nx, ny-x, colr, colg, colb, gradv); gradv = gradv/1.01f; } -#endif } if (pixel_mode & EFFECT_GRAVIN) { @@ -2039,32 +1263,13 @@ void Renderer::render_parts() //Fire effects if(firea && (pixel_mode & FIRE_BLEND)) { -#ifdef OGLR - smokeV[csmokeV++] = nx; - smokeV[csmokeV++] = ny; - smokeC[csmokeC++] = ((float)firer)/255.0f; - smokeC[csmokeC++] = ((float)fireg)/255.0f; - smokeC[csmokeC++] = ((float)fireb)/255.0f; - smokeC[csmokeC++] = ((float)firea)/255.0f; - csmoke++; -#else firea /= 2; fire_r[ny/CELL][nx/CELL] = (firea*firer + (255-firea)*fire_r[ny/CELL][nx/CELL]) >> 8; fire_g[ny/CELL][nx/CELL] = (firea*fireg + (255-firea)*fire_g[ny/CELL][nx/CELL]) >> 8; fire_b[ny/CELL][nx/CELL] = (firea*fireb + (255-firea)*fire_b[ny/CELL][nx/CELL]) >> 8; -#endif } if(firea && (pixel_mode & FIRE_ADD)) { -#ifdef OGLR - fireV[cfireV++] = nx; - fireV[cfireV++] = ny; - fireC[cfireC++] = ((float)firer)/255.0f; - fireC[cfireC++] = ((float)fireg)/255.0f; - fireC[cfireC++] = ((float)fireb)/255.0f; - fireC[cfireC++] = ((float)firea)/255.0f; - cfire++; -#else firea /= 8; firer = ((firea*firer) >> 8) + fire_r[ny/CELL][nx/CELL]; fireg = ((firea*fireg) >> 8) + fire_g[ny/CELL][nx/CELL]; @@ -2080,208 +1285,17 @@ void Renderer::render_parts() fire_r[ny/CELL][nx/CELL] = firer; fire_g[ny/CELL][nx/CELL] = fireg; fire_b[ny/CELL][nx/CELL] = fireb; -#endif } if(firea && (pixel_mode & FIRE_SPARK)) { -#ifdef OGLR - smokeV[csmokeV++] = nx; - smokeV[csmokeV++] = ny; - smokeC[csmokeC++] = ((float)firer)/255.0f; - smokeC[csmokeC++] = ((float)fireg)/255.0f; - smokeC[csmokeC++] = ((float)fireb)/255.0f; - smokeC[csmokeC++] = ((float)firea)/255.0f; - csmoke++; -#else firea /= 4; fire_r[ny/CELL][nx/CELL] = (firea*firer + (255-firea)*fire_r[ny/CELL][nx/CELL]) >> 8; fire_g[ny/CELL][nx/CELL] = (firea*fireg + (255-firea)*fire_g[ny/CELL][nx/CELL]) >> 8; fire_b[ny/CELL][nx/CELL] = (firea*fireb + (255-firea)*fire_b[ny/CELL][nx/CELL]) >> 8; -#endif } } } } -#ifdef OGLR - - //Go into array mode - glEnableClientState(GL_COLOR_ARRAY); - glEnableClientState(GL_VERTEX_ARRAY); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - if(cflat) - { - // -- BEGIN FLAT -- // - //Set point size (size of fire texture) - glPointSize(1.0f); - - glColorPointer(4, GL_FLOAT, 0, &flatC[0]); - glVertexPointer(2, GL_INT, 0, &flatV[0]); - - glDrawArrays(GL_POINTS, 0, cflat); - - //Clear some stuff we set - // -- END FLAT -- // - } - - if(cblob) - { - // -- BEGIN BLOB -- // - glEnable( GL_POINT_SMOOTH ); //Blobs! - glPointSize(2.5f); - - glColorPointer(4, GL_FLOAT, 0, &blobC[0]); - glVertexPointer(2, GL_INT, 0, &blobV[0]); - - glDrawArrays(GL_POINTS, 0, cblob); - - //Clear some stuff we set - glDisable( GL_POINT_SMOOTH ); - // -- END BLOB -- // - } - - if(cglow || cblur) - { - // -- BEGIN GLOW -- // - //Start and prepare fire program - glEnable(GL_TEXTURE_2D); - glUseProgram(fireProg); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, glowAlpha); - glUniform1i(glGetUniformLocation(fireProg, "fireAlpha"), 0); - - glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT); - - //Make sure we can use texture coords on points - glEnable(GL_POINT_SPRITE); - glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); - glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE); - - //Set point size (size of fire texture) - glPointSize(11.0f); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - - if(cglow) - { - glColorPointer(4, GL_FLOAT, 0, &glowC[0]); - glVertexPointer(2, GL_INT, 0, &glowV[0]); - - glDrawArrays(GL_POINTS, 0, cglow); - } - - glPointSize(7.0f); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - if(cblur) - { - glBindTexture(GL_TEXTURE_2D, blurAlpha); - - glColorPointer(4, GL_FLOAT, 0, &blurC[0]); - glVertexPointer(2, GL_INT, 0, &blurV[0]); - - glDrawArrays(GL_POINTS, 0, cblur); - } - - //Clear some stuff we set - glDisable(GL_POINT_SPRITE); - glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); - glUseProgram(0); - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - // -- END GLOW -- // - } - - if(cadd) - { - // -- BEGIN ADD -- // - //Set point size (size of fire texture) - glPointSize(1.0f); - - glColorPointer(4, GL_FLOAT, 0, &addC[0]); - glVertexPointer(2, GL_INT, 0, &addV[0]); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glDrawArrays(GL_POINTS, 0, cadd); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - //Clear some stuff we set - // -- END ADD -- // - } - - if(cline) - { - // -- BEGIN LINES -- // - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glEnable( GL_LINE_SMOOTH ); - glColorPointer(4, GL_FLOAT, 0, &lineC[0]); - glVertexPointer(2, GL_FLOAT, 0, &lineV[0]); - - glDrawArrays(GL_LINE_STRIP, 0, cline); - - //Clear some stuff we set - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_LINE_SMOOTH); - // -- END LINES -- // - } - - if(cfire || csmoke) - { - // -- BEGIN FIRE -- // - //Start and prepare fire program - glEnable(GL_TEXTURE_2D); - glUseProgram(fireProg); - //glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, fireAlpha); - glUniform1i(glGetUniformLocation(fireProg, "fireAlpha"), 0); - - //Make sure we can use texture coords on points - glEnable(GL_POINT_SPRITE); - glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); - glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE); - - //Set point size (size of fire texture) - glPointSize(CELL*3); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - - if(cfire) - { - glColorPointer(4, GL_FLOAT, 0, &fireC[0]); - glVertexPointer(2, GL_INT, 0, &fireV[0]); - - glDrawArrays(GL_POINTS, 0, cfire); - } - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - if(csmoke) - { - glColorPointer(4, GL_FLOAT, 0, &smokeC[0]); - glVertexPointer(2, GL_INT, 0, &smokeV[0]); - - glDrawArrays(GL_POINTS, 0, csmoke); - } - - //Clear some stuff we set - glDisable(GL_POINT_SPRITE); - glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); - glUseProgram(0); - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - // -- END FIRE -- // - } - - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - - //Reset FBO - glTranslated(0, -MENUSIZE, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo); - - glBlendFunc(origBlendSrc, origBlendDst); -#endif } void Renderer::draw_other() // EMP effect @@ -2294,28 +1308,6 @@ void Renderer::draw_other() // EMP effect return; if (emp_decor>0) { -#ifdef OGLR - GLint prevFbo; - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo); - glTranslated(0, MENUSIZE, 0); - float femp_decor = ((float)emp_decor)/255.0f; - /*int r=emp_decor*2.5, g=100+emp_decor*1.5, b=255; - int a=(1.0*emp_decor/110)*255; - if (r>255) r=255; - if (g>255) g=255; - if (b>255) g=255; - if (a>255) a=255;*/ - glBegin(GL_QUADS); - glColor4f(femp_decor*2.5f, 0.4f+femp_decor*1.5f, 1.0f+femp_decor*1.5f, femp_decor/0.44f); - glVertex2f(0, MENUSIZE); - glVertex2f(XRES, MENUSIZE); - glVertex2f(XRES, WINDOWH); - glVertex2f(0, WINDOWH); - glEnd(); - glTranslated(0, -MENUSIZE, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo); -#else int r=emp_decor*2.5, g=100+emp_decor*1.5, b=255; int a=(1.0*emp_decor/110)*255; if (r>255) r=255; @@ -2327,7 +1319,6 @@ void Renderer::draw_other() // EMP effect { blendpixel(i, j, r, g, b, a); } -#endif } } @@ -2363,7 +1354,6 @@ void Renderer::draw_air() { if(!sim->aheat_enable && (display_mode & DISPLAY_AIRH)) return; -#ifndef OGLR if(!(display_mode & DISPLAY_AIR)) return; int x, y, i, j; @@ -2435,66 +1425,6 @@ void Renderer::draw_air() for (i=0; iair->vx); - glUniform1i(glGetUniformLocation(airProg, "airX"), 0); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, airVY); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, XRES/CELL, YRES/CELL, GL_GREEN, GL_FLOAT, sim->air->vy); - glUniform1i(glGetUniformLocation(airProg, "airY"), 1); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, airPV); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, XRES/CELL, YRES/CELL, GL_BLUE, GL_FLOAT, sim->air->pv); - glUniform1i(glGetUniformLocation(airProg, "airP"), 2); - glActiveTexture(GL_TEXTURE0); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_QUADS); - glTexCoord2d(1, 1); - glVertex3f(XRES*sdl_scale, YRES*sdl_scale, 1.0); - glTexCoord2d(0, 1); - glVertex3f(0, YRES*sdl_scale, 1.0); - glTexCoord2d(0, 0); - glVertex3f(0, 0, 1.0); - glTexCoord2d(1, 0); - glVertex3f(XRES*sdl_scale, 0, 1.0); - glEnd(); - - glUseProgram(0); - glBindTexture(GL_TEXTURE_2D, 0); - glTranslated(0, -MENUSIZE, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo); - glDisable( GL_TEXTURE_2D ); -#endif } void Renderer::draw_grav_zones() @@ -2537,11 +1467,8 @@ pixel Renderer::GetPixel(int x, int y) { if (x<0 || y<0 || x>=VIDXRES || y>=VIDYRES) return 0; -#ifdef OGLR - return 0; -#else + return vid[(y*VIDXRES)+x]; -#endif } Renderer::Renderer(Graphics * g, Simulation * sim): @@ -2568,15 +1495,11 @@ Renderer::Renderer(Graphics * g, Simulation * sim): { this->g = g; this->sim = sim; -#if !defined(OGLR) -#if defined(OGLI) - vid = new pixel[VIDXRES*VIDYRES]; -#else + vid = g->vid; -#endif + persistentVid = new pixel[VIDXRES*YRES]; warpVid = new pixel[VIDXRES*VIDYRES]; -#endif memset(fire_r, 0, sizeof(fire_r)); memset(fire_g, 0, sizeof(fire_g)); @@ -2668,149 +1591,6 @@ Renderer::Renderer(Graphics * g, Simulation * sim): flm_data = Graphics::GenerateGradient(fireColours, fireColoursPoints, fireColoursCount, 200); plasma_data = Graphics::GenerateGradient(plasmaColours, plasmaColoursPoints, plasmaColoursCount, 200); -#ifdef OGLR - //FBO Texture - glEnable(GL_TEXTURE_2D); - glGenTextures(1, &partsFboTex); - glBindTexture(GL_TEXTURE_2D, partsFboTex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, XRES, YRES, 0, GL_RGBA, GL_FLOAT, NULL); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); - - //FBO - glGenFramebuffers(1, &partsFbo); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo); - glEnable(GL_BLEND); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, partsFboTex, 0); - glBindTexture(GL_TEXTURE_2D, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); // Reset framebuffer binding - glDisable(GL_TEXTURE_2D); - - //Texture for air to be drawn - glEnable(GL_TEXTURE_2D); - glGenTextures(1, &airBuf); - glBindTexture(GL_TEXTURE_2D, airBuf); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, XRES/CELL, YRES/CELL, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); - - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - //Zoom texture - glEnable(GL_TEXTURE_2D); - glGenTextures(1, &zoomTex); - glBindTexture(GL_TEXTURE_2D, zoomTex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); - - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - //Texture for velocity maps for gravity - glEnable(GL_TEXTURE_2D); - glGenTextures(1, &partsTFX); - glBindTexture(GL_TEXTURE_2D, partsTFX); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, XRES/CELL, YRES/CELL, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); - - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - - glBindTexture(GL_TEXTURE_2D, 0); - glGenTextures(1, &partsTFY); - glBindTexture(GL_TEXTURE_2D, partsTFY); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, XRES/CELL, YRES/CELL, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); - - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - //Texture for velocity maps for air - //TODO: Combine all air maps into 3D array or structs - glEnable(GL_TEXTURE_2D); - glGenTextures(1, &airVX); - glBindTexture(GL_TEXTURE_2D, airVX); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, XRES/CELL, YRES/CELL, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); - - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - - glBindTexture(GL_TEXTURE_2D, 0); - glGenTextures(1, &airVY); - glBindTexture(GL_TEXTURE_2D, airVY); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, XRES/CELL, YRES/CELL, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); - - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - - glBindTexture(GL_TEXTURE_2D, 0); - glGenTextures(1, &airPV); - glBindTexture(GL_TEXTURE_2D, airPV); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, XRES/CELL, YRES/CELL, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); - - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - //Fire alpha texture - glEnable(GL_TEXTURE_2D); - glGenTextures(1, &fireAlpha); - glBindTexture(GL_TEXTURE_2D, fireAlpha); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, CELL*3, CELL*3, 0, GL_ALPHA, GL_FLOAT, NULL); - - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - //Glow alpha texture - glEnable(GL_TEXTURE_2D); - glGenTextures(1, &glowAlpha); - glBindTexture(GL_TEXTURE_2D, glowAlpha); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 11, 11, 0, GL_ALPHA, GL_FLOAT, NULL); - - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - - //Blur Alpha texture - glEnable(GL_TEXTURE_2D); - glGenTextures(1, &blurAlpha); - glBindTexture(GL_TEXTURE_2D, blurAlpha); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 7, 7, 0, GL_ALPHA, GL_FLOAT, NULL); - - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - //Temptexture - glEnable(GL_TEXTURE_2D); - glGenTextures(1, &textTexture); - glBindTexture(GL_TEXTURE_2D, textTexture); - - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - loadShaders(); -#endif prepare_alpha(CELL, 1.0f); } @@ -2833,9 +1613,7 @@ void Renderer::ClearAccumulation() std::fill(fire_r[0]+0, fire_r[(YRES/CELL)-1]+((XRES/CELL)-1), 0); std::fill(fire_g[0]+0, fire_g[(YRES/CELL)-1]+((XRES/CELL)-1), 0); std::fill(fire_b[0]+0, fire_b[(YRES/CELL)-1]+((XRES/CELL)-1), 0); -#ifndef OGLR std::fill(persistentVid, persistentVid+(VIDXRES*YRES), 0); -#endif } void Renderer::AddRenderMode(unsigned int mode) @@ -2947,30 +1725,18 @@ void Renderer::ResetModes() VideoBuffer Renderer::DumpFrame() { -#ifdef OGLR -#elif defined(OGLI) - VideoBuffer newBuffer(XRES, YRES); - std::copy(vid, vid+(XRES*YRES), newBuffer.Buffer); - return newBuffer; -#else VideoBuffer newBuffer(XRES, YRES); for(int y = 0; y < YRES; y++) { std::copy(vid+(y*WINDOWW), vid+(y*WINDOWW)+XRES, newBuffer.Buffer+(y*XRES)); } return newBuffer; -#endif } Renderer::~Renderer() { -#if !defined(OGLR) -#if defined(OGLI) - delete[] vid; -#endif delete[] persistentVid; delete[] warpVid; -#endif delete[] graphicscache; free(flm_data); free(plasma_data); @@ -2978,10 +1744,6 @@ Renderer::~Renderer() #define PIXELMETHODS_CLASS Renderer -#ifdef OGLR -#include "OpenGLDrawMethods.inl" -#else #include "RasterDrawMethods.inl" -#endif #undef PIXELMETHODS_CLASS diff --git a/src/graphics/Renderer.h b/src/graphics/Renderer.h index 71cbac112..2811c9a87 100644 --- a/src/graphics/Renderer.h +++ b/src/graphics/Renderer.h @@ -2,9 +2,6 @@ #define RENDERER_H #include -#ifdef OGLR -#include "OpenGLHeaders.h" -#endif #include "Graphics.h" #include "Config.h" @@ -97,13 +94,6 @@ public: void clearScreen(float alpha); void SetSample(int x, int y); -#ifdef OGLR - void checkShader(GLuint shader, const char * shname); - void checkProgram(GLuint program, const char * progname); - void loadShaders(); - GLuint vidBuf,textTexture; - GLint prevFbo; -#endif pixel * vid; pixel * persistentVid; pixel * warpVid; @@ -166,26 +156,6 @@ public: private: int gridSize; -#ifdef OGLR - GLuint zoomTex, airBuf, fireAlpha, glowAlpha, blurAlpha, partsFboTex, partsFbo, partsTFX, partsTFY, airPV, airVY, airVX; - GLuint fireProg, airProg_Pressure, airProg_Velocity, airProg_Cracker, lensProg; - GLuint fireV[(YRES*XRES)*2]; - GLfloat fireC[(YRES*XRES)*4]; - GLuint smokeV[(YRES*XRES)*2]; - GLfloat smokeC[(YRES*XRES)*4]; - GLuint blobV[(YRES*XRES)*2]; - GLfloat blobC[(YRES*XRES)*4]; - GLuint blurV[(YRES*XRES)*2]; - GLfloat blurC[(YRES*XRES)*4]; - GLuint glowV[(YRES*XRES)*2]; - GLfloat glowC[(YRES*XRES)*4]; - GLuint flatV[(YRES*XRES)*2]; - GLfloat flatC[(YRES*XRES)*4]; - GLuint addV[(YRES*XRES)*2]; - GLfloat addC[(YRES*XRES)*4]; - GLfloat lineV[(((YRES*XRES)*2)*6)]; - GLfloat lineC[(((YRES*XRES)*2)*6)]; -#endif }; #endif diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 64e986f43..e13dec6c8 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -2416,7 +2416,6 @@ void GameView::OnDraw() g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, alpha*0.5f); g->drawtext(XRES-16-textWidth, 16, sampleInfo.Build(), 255, 255, 255, alpha*0.75f); -#ifndef OGLI if (wavelengthGfx) { int i, cr, cg, cb, j, h = 3, x = XRES-19-textWidth, y = 10; @@ -2451,7 +2450,6 @@ void GameView::OnDraw() } } } -#endif if (showDebug) { diff --git a/src/gui/game/SignTool.cpp b/src/gui/game/SignTool.cpp index cf94199f9..0e85a7e44 100644 --- a/src/gui/game/SignTool.cpp +++ b/src/gui/game/SignTool.cpp @@ -212,20 +212,13 @@ void SignWindow::DoDraw() y = currentSign.y; dx = 1 - currentSign.ju; dy = (currentSign.y > 18) ? -1 : 1; -#ifdef OGLR - glBegin(GL_LINES); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glVertex2i(x, y); - glVertex2i(x+(dx*4), y+(dy*4)); - glEnd(); -#else + for (int j=0; j<4; j++) { g->blendpixel(x, y, 192, 192, 192, 255); x+=dx; y+=dy; } -#endif } } if(!signMoving) diff --git a/src/gui/interface/Engine.cpp b/src/gui/interface/Engine.cpp index f380a1946..fceee5c20 100644 --- a/src/gui/interface/Engine.cpp +++ b/src/gui/interface/Engine.cpp @@ -117,9 +117,7 @@ void Engine::ShowWindow(Window * window) } lastBuffer = (pixel*)malloc((width_ * height_) * PIXELSIZE); -#ifndef OGLI memcpy(lastBuffer, g->vid, (width_ * height_) * PIXELSIZE); -#endif windows.push(state_); mousePositions.push(ui::Point(mousex_, mousey_)); @@ -225,12 +223,10 @@ void Engine::Draw() if(lastBuffer && !(state_ && state_->Position.X == 0 && state_->Position.Y == 0 && state_->Size.X == width_ && state_->Size.Y == height_)) { g->Clear(); -#ifndef OGLI memcpy(g->vid, lastBuffer, (width_ * height_) * PIXELSIZE); if(windowOpenState < 20) windowOpenState++; g->fillrect(0, 0, width_, height_, 0, 0, 0, 255-std::pow(.98, windowOpenState)*255); -#endif } else { diff --git a/src/gui/interface/Panel.cpp b/src/gui/interface/Panel.cpp index cee6fe38d..dab4b8a3d 100644 --- a/src/gui/interface/Panel.cpp +++ b/src/gui/interface/Panel.cpp @@ -13,30 +13,7 @@ Panel::Panel(Point position, Point size): ViewportPosition(0, 0), mouseInside(false) { -#ifdef OGLI - GLint lastVid; - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &lastVid); - - glEnable(GL_TEXTURE_2D); - glGenTextures(1, &myVidTex); - glBindTexture(GL_TEXTURE_2D, myVidTex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, WINDOWW, WINDOWH, 0, GL_RGBA, GL_FLOAT, NULL); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); - - //FBO - glGenFramebuffers(1, &myVid); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, myVid); - glEnable(GL_BLEND); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, myVidTex, 0); - glBindTexture(GL_TEXTURE_2D, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); // Reset framebuffer binding - glDisable(GL_TEXTURE_2D); - - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, lastVid); -#else myVid = new pixel[WINDOWW*WINDOWH]; -#endif } Panel::~Panel() @@ -45,12 +22,8 @@ Panel::~Panel() { delete children[i]; } -#ifdef OGLI - glDeleteTextures(1, &myVidTex); - glDeleteFramebuffers(1, &myVid); -#else + delete[] myVid; -#endif } void Panel::AddChild(Component* c) @@ -97,17 +70,10 @@ void Panel::Draw(const Point& screenPos) // draw ourself first XDraw(screenPos); -#ifdef OGLI - GLint lastVid; - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &lastVid); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, myVid); - glClearColor(1.0f, 0.0f, 0.0f, 0.0f); - glClear(GL_COLOR_BUFFER_BIT); -#else + pixel * lastVid = ui::Engine::Ref().g->vid; ui::Engine::Ref().g->vid = myVid; std::fill(myVid, myVid+(WINDOWW*WINDOWH), 0); -#endif // attempt to draw all children for (size_t i = 0; i < children.size(); ++i) @@ -127,32 +93,6 @@ void Panel::Draw(const Point& screenPos) } } -#ifdef OGLI - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, lastVid); - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, myVidTex); - - int x = screenPos.X, y = screenPos.Y; - int h = Size.Y, w = Size.X; - - double texX = double(Size.X)/WINDOWW, texY = 1, texYB = 1-(double(Size.Y)/WINDOWH); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_QUADS); - glTexCoord2d(0, texYB); - glVertex2f(x, y+h); - glTexCoord2d(texX, texYB); - glVertex2f(x+w, y+h); - glTexCoord2d(texX, texY); - glVertex2f(x+w, y); - glTexCoord2d(0, texY); - glVertex2f(x, y); - glEnd(); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); -#else ui::Engine::Ref().g->vid = lastVid; //dst=(pixel *)sdl_scrn->pixels+y*sdl_scrn->pitch/PIXELSIZE+x; @@ -160,7 +100,6 @@ void Panel::Draw(const Point& screenPos) { std::copy(myVid+(row*WINDOWW), myVid+(row*WINDOWW)+Size.X, lastVid+((screenPos.Y+row)*WINDOWW)+screenPos.X); } -#endif } void Panel::Tick(float dt) diff --git a/src/gui/interface/Panel.h b/src/gui/interface/Panel.h index 92107c6f7..791b52384 100644 --- a/src/gui/interface/Panel.h +++ b/src/gui/interface/Panel.h @@ -5,11 +5,6 @@ #include "gui/interface/Point.h" #include "gui/interface/Component.h" -#ifdef OGLI -#include "graphics/OpenGLHeaders.h" -#endif - - class Graphics; namespace ui { @@ -27,11 +22,8 @@ class Component; public: friend class Component; -#ifdef OGLI - GLuint myVid, myVidTex; -#else pixel * myVid; -#endif + ui::Point InnerSize; ui::Point ViewportPosition; diff --git a/src/gui/interface/Slider.cpp b/src/gui/interface/Slider.cpp index 64a252210..430fe7cdf 100644 --- a/src/gui/interface/Slider.cpp +++ b/src/gui/interface/Slider.cpp @@ -109,13 +109,9 @@ void Slider::Draw(const Point& screenPos) if(bgGradient) { -#ifndef OGLI for (int j = 3; j < Size.Y-7; j++) for (int i = 3; i < Size.X-7; i++) g->blendpixel(screenPos.X+i+2, screenPos.Y+j+2, bgGradient[(i-3)*3], bgGradient[(i-3)*3+1], bgGradient[(i-3)*3+2], 255); -#else - g->gradientrect(screenPos.X+5, screenPos.Y+5, Size.X-10, Size.Y-10, col1.Red, col1.Green, col1.Blue, col1.Alpha, col2.Red, col2.Green, col2.Blue, col2.Alpha); -#endif } g->drawrect(screenPos.X+3, screenPos.Y+3, Size.X-6, Size.Y-6, 255, 255, 255, 255); diff --git a/src/gui/render/RenderView.cpp b/src/gui/render/RenderView.cpp index db0de985c..dad5c81f0 100644 --- a/src/gui/render/RenderView.cpp +++ b/src/gui/render/RenderView.cpp @@ -246,11 +246,7 @@ RenderView::RenderView(): tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_WARP)); AddComponent(tCheckbox); -#ifdef OGLR - tCheckbox = new ui::Checkbox(ui::Point(checkboxOffset, YRES+4), ui::Point(30, 16), "Effect", "Some type of OpenGL effect ... maybe"); //I would remove the whole checkbox, but then there's a large empty space -#else tCheckbox = new ui::Checkbox(ui::Point(checkboxOffset, YRES+4), ui::Point(30, 16), "Effect", "Enables moving solids, stickmen guns, and premium(tm) graphics"); -#endif displayModes.push_back(tCheckbox); tCheckbox->SetIcon(IconEffect); tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_EFFE)); diff --git a/src/simulation/SaveRenderer.cpp b/src/simulation/SaveRenderer.cpp index c6e7e07b4..b7a4612ac 100644 --- a/src/simulation/SaveRenderer.cpp +++ b/src/simulation/SaveRenderer.cpp @@ -13,24 +13,6 @@ SaveRenderer::SaveRenderer(){ ren = new Renderer(g, sim); ren->decorations_enable = true; ren->blackDecorations = true; - -#if defined(OGLR) || defined(OGLI) - glEnable(GL_TEXTURE_2D); - glGenTextures(1, &fboTex); - glBindTexture(GL_TEXTURE_2D, fboTex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, XRES, YRES, 0, GL_RGBA, GL_FLOAT, NULL); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); - - //FBO - glGenFramebuffers(1, &fbo); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); - glEnable(GL_BLEND); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fboTex, 0); - glBindTexture(GL_TEXTURE_2D, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); // Reset framebuffer binding - glDisable(GL_TEXTURE_2D); -#endif } VideoBuffer * SaveRenderer::Render(GameSave * save, bool decorations, bool fire) @@ -50,67 +32,7 @@ VideoBuffer * SaveRenderer::Render(GameSave * save, bool decorations, bool fire) { ren->decorations_enable = true; ren->blackDecorations = !decorations; -#if defined(OGLR) || defined(OGLI) - pixel * pData = NULL; - unsigned char * texData = NULL; - glTranslated(0, MENUSIZE, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - - ren->clearScreen(1.0f); - ren->ClearAccumulation(); - -#ifdef OGLR - ren->RenderBegin(); - ren->RenderEnd(); -#else - if (fire) - { - int frame = 15; - while(frame) - { - frame--; - ren->render_parts(); - ren->render_fire(); - ren->clearScreen(1.0f); - } - } - - ren->RenderBegin(); - ren->RenderEnd(); -#endif - - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - glTranslated(0, -MENUSIZE, 0); - - glEnable( GL_TEXTURE_2D ); - glBindTexture(GL_TEXTURE_2D, fboTex); - - pData = new pixel[XRES*YRES]; - texData = new unsigned char[(XRES*YRES)*PIXELSIZE]; - std::fill(texData, texData+(XRES*YRES)*PIXELSIZE, 0xDD); - glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, texData); - glDisable(GL_TEXTURE_2D); - - for(int x = 0; x < width*CELL; x++) - { - for(int y = 0; y < height*CELL; y++) - { - unsigned char red = texData[((((YRES-1-y)*XRES)+x)*4)]; - unsigned char green = texData[((((YRES-1-y)*XRES)+x)*4)+1]; - unsigned char blue = texData[((((YRES-1-y)*XRES)+x)*4)+2]; - - pData[(y*(width*CELL))+x] = PIXRGBA(red, green, blue, 255); - } - } - - tempThumb = new VideoBuffer(pData, width*CELL, height*CELL); - delete[] pData; - delete[] texData; - pData = NULL; -#else pixel * pData = NULL; pixel * dst; pixel * src = g->vid; @@ -143,7 +65,6 @@ VideoBuffer * SaveRenderer::Render(GameSave * save, bool decorations, bool fire) } tempThumb = new VideoBuffer(pData, width*CELL, height*CELL); free(pData); -#endif } if(doCollapse) save->Collapse(); diff --git a/src/simulation/SaveRenderer.h b/src/simulation/SaveRenderer.h index b5fbc38d5..0bb74b052 100644 --- a/src/simulation/SaveRenderer.h +++ b/src/simulation/SaveRenderer.h @@ -1,8 +1,5 @@ #ifndef SAVERENDERER_H_ #define SAVERENDERER_H_ -#ifdef OGLI -#include "graphics/OpenGLHeaders.h" -#endif #include "common/Singleton.h" #include @@ -24,11 +21,6 @@ public: void CopyModes(Renderer *source); void ResetModes(); virtual ~SaveRenderer(); - -private: -#if defined(OGLR) || defined(OGLI) - GLuint fboTex, fbo; -#endif }; #endif /* SAVERENDERER_H_ */