diff --git a/meson.build b/meson.build index c2cc196db..d4c43d77d 100644 --- a/meson.build +++ b/meson.build @@ -296,9 +296,6 @@ conf_data.set('X86_SSE3', x86_sse_level >= 30) conf_data.set('X86_SSE2', x86_sse_level >= 20) conf_data.set('X86_SSE', x86_sse_level >= 10) conf_data.set('_64BIT', is_64bit) -conf_data.set('OGLI', false) -conf_data.set('OGLR', false) -conf_data.set('PIX32OGL', false) conf_data.set('BETA', get_option('beta')) conf_data.set('NO_INSTALL_CHECK', not get_option('install_check')) conf_data.set('IGNORE_UPDATES', get_option('ignore_updates')) diff --git a/src/Config.template.h b/src/Config.template.h index 25758528e..4c2fd278e 100644 --- a/src/Config.template.h +++ b/src/Config.template.h @@ -16,9 +16,6 @@ #mesondefine LIN #mesondefine AND #mesondefine NO_INSTALL_CHECK -#mesondefine OGLI -#mesondefine OGLR -#mesondefine PIX32OGL #mesondefine SNAPSHOT #mesondefine WIN #mesondefine MACOSX diff --git a/src/PowderToyFontEditor.cpp b/src/PowderToyFontEditor.cpp index 9149d6150..b248f8d4f 100644 --- a/src/PowderToyFontEditor.cpp +++ b/src/PowderToyFontEditor.cpp @@ -107,12 +107,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)); @@ -122,7 +116,6 @@ void blit(pixel * vid) SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL); SDL_RenderPresent(sdl_renderer); } -#endif void RecreateWindow(); int SDLOpen() @@ -421,11 +414,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; diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index 57906abfd..da6ebe2d3 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -160,12 +160,6 @@ void CalculateMousePosition(int *x, int *y) *y = (globalMy - windowY) / scale; } -#ifdef OGLI -void blit() -{ - SDL_GL_SwapWindow(sdl_window); -} -#else void blit(pixel * vid) { SDL_UpdateTexture(sdl_texture, NULL, vid, WINDOWW * sizeof (Uint32)); @@ -175,7 +169,6 @@ void blit(pixel * vid) SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL); SDL_RenderPresent(sdl_renderer); } -#endif bool RecreateWindow(); void SDLOpen() @@ -622,11 +615,7 @@ void EngineProcess() engine->GetForceIntegerScaling()); } -#ifdef OGLI - blit(); -#else blit(engine->g->vid); -#endif } int frameTime = SDL_GetTicks() - frameStart; @@ -693,11 +682,7 @@ void BlueScreen(String detailMessage) while (SDL_PollEvent(&event)) if(event.type == SDL_QUIT) exit(-1); -#ifdef OGLI - blit(); -#else blit(engine->g->vid); -#endif } } @@ -878,19 +863,6 @@ int main(int argc, char * argv[]) } } -#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 - StopTextInput(); ui::Engine::Ref().g = new Graphics(); @@ -971,11 +943,7 @@ 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 3c3fc87b5..19226b944 100644 --- a/src/graphics/Graphics.cpp +++ b/src/graphics/Graphics.cpp @@ -1077,10 +1077,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 fda575535..e2cb393c7 100644 --- a/src/graphics/Graphics.h +++ b/src/graphics/Graphics.h @@ -3,9 +3,6 @@ #include "Config.h" #include "common/String.h" -#if defined(OGLI) -#include "OpenGLHeaders.h" -#endif #include "common/tpt-inline.h" #include "Pixel.h" #include "Icons.h" @@ -26,20 +23,6 @@ public: void Crop(int width, int height, int x, int y); 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; @@ -51,18 +34,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) @@ -95,14 +73,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/OpenGLDrawMethods.inl b/src/graphics/OpenGLDrawMethods.inl deleted file mode 100644 index ae60d3e8a..000000000 --- a/src/graphics/OpenGLDrawMethods.inl +++ /dev/null @@ -1,416 +0,0 @@ -#include "../data/font.bz2.h" -#include -#include - -int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, String s, int r, int g, int b, int a) -{ - drawtext(x-1, y-1, s, 0, 0, 0, 120); - drawtext(x+1, y+1, s, 0, 0, 0, 120); - - drawtext(x-1, y+1, s, 0, 0, 0, 120); - drawtext(x+1, y-1, s, 0, 0, 0, 120); - - return drawtext(x, y, s, r, g, b, a); -} - -int PIXELMETHODS_CLASS::drawtext(int x, int y, String str, int r, int g, int b, int a) -{ - bool invert = false; - if(str.size() == 0) - return 0; - int oR = r, oG = g, oB = b; - int width, height; - Graphics::textsize(str, width, height); - VideoBuffer texture(width, height); - int characterX = 0, characterY = 0; - int startX = characterX; - const String::value_type *s = str.c_str(); - for (; *s; s++) - { - if (*s == '\n') - { - characterX = startX; - characterY += FONT_H+2; - } - else if (*s == '\x0F') - { - if(!s[1] || !s[2] || !s[3]) break; - oR = r; - oG = g; - oB = b; - r = (unsigned char)s[1]; - g = (unsigned char)s[2]; - b = (unsigned char)s[3]; - s += 3; - } - else if (*s == '\x0E') - { - r = oR; - g = oG; - b = oB; - } - else if (*s == '\x01') - { - invert = !invert; - r = 255-r; - g = 255-g; - b = 255-b; - } - else if (*s == '\b') - { - if(!s[1]) break; - switch (s[1]) - { - case 'w': - r = g = b = 255; - break; - case 'g': - r = g = b = 192; - break; - case 'o': - r = 255; - g = 216; - b = 32; - break; - case 'r': - r = 255; - g = b = 0; - break; - case 'l': - r = 255; - g = b = 75; - break; - case 'b': - r = g = 0; - b = 255; - break; - case 't': - b = 255; - g = 170; - r = 32; - break; - } - if(invert) - { - r = 255-r; - g = 255-g; - b = 255-b; - } - s++; - } - else - { - characterX = texture.SetCharacter(characterX, characterY, *s, r, g, b, a); - } - } - glEnable(GL_TEXTURE_2D); - - //Generate texture - glBindTexture(GL_TEXTURE_2D, textTexture); - - //Draw texture - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.Width, texture.Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, texture.Buffer); - - //glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture.Width, texture.Height, GL_BGRA, GL_UNSIGNED_BYTE, texture.Buffer); - glBegin(GL_QUADS); - glTexCoord2d(0, 0); - glVertex2f(x, y); - glTexCoord2d(1, 0); - glVertex2f(x+texture.Width, y); - glTexCoord2d(1, 1); - glVertex2f(x+texture.Width, y+texture.Height); - glTexCoord2d(0, 1); - glVertex2f(x, y+texture.Height); - glEnd(); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - return x; -} - -int PIXELMETHODS_CLASS::drawchar(int x, int y, String::value_type c, int r, int g, int b, int a) -{ - const unsigned char *rp = font_data + font_ptrs[c]; - int w = *(rp++); - VideoBuffer texture(w, FONT_H); - texture.SetCharacter(0, 0, c, r, g, b, a); - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, textTexture); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.Width, texture.Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, texture.Buffer); - glBegin(GL_QUADS); - glTexCoord2d(0, 0); - glVertex2f(x, y); - glTexCoord2d(1, 0); - glVertex2f(x+texture.Width, y); - glTexCoord2d(1, 1); - glVertex2f(x+texture.Width, y+texture.Height); - glTexCoord2d(0, 1); - glVertex2f(x, y+texture.Height); - glEnd(); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - return x + w; -} - -int PIXELMETHODS_CLASS::addchar(int x, int y, String::value_type c, int r, int g, int b, int a) -{ - const unsigned char *rp = font_data + font_ptrs[c]; - int w = *(rp++); - VideoBuffer texture(w, FONT_H); - texture.AddCharacter(0, 0, c, r, g, b, a); - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, textTexture); - glBlendFunc(GL_ONE, GL_ONE); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.Width, texture.Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, texture.Buffer); - glBegin(GL_QUADS); - glTexCoord2d(0, 0); - glVertex2f(x, y); - glTexCoord2d(1, 0); - glVertex2f(x+texture.Width, y); - glTexCoord2d(1, 1); - glVertex2f(x+texture.Width, y+texture.Height); - glTexCoord2d(0, 1); - glVertex2f(x, y+texture.Height); - glEnd(); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - return x + w; -} - -TPT_INLINE void PIXELMETHODS_CLASS::xor_pixel(int x, int y) -{ - //OpenGL doesn't support single pixel manipulation, there are ways around it, but with poor performance -} - -void PIXELMETHODS_CLASS::blendpixel(int x, int y, int r, int g, int b, int a) -{ - //OpenGL doesn't support single pixel manipulation, there are ways around it, but with poor performance -} - -void PIXELMETHODS_CLASS::addpixel(int x, int y, int r, int g, int b, int a) -{ - //OpenGL doesn't support single pixel manipulation, there are ways around it, but with poor performance -} - -void PIXELMETHODS_CLASS::xor_line(int x, int y, int x2, int y2) -{ - glEnable(GL_COLOR_LOGIC_OP); - //glEnable(GL_LINE_SMOOTH); - glLogicOp(GL_XOR); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_LINES); - glVertex2i(x, y); - glVertex2i(x2, y2); - glEnd(); - glDisable(GL_COLOR_LOGIC_OP); -} - -void PIXELMETHODS_CLASS::xor_rect(int x, int y, int width, int height) -{ - glEnable(GL_COLOR_LOGIC_OP); - //glEnable(GL_LINE_SMOOTH); - glLogicOp(GL_XOR); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_LINE_STRIP); - glVertex2i(x, y); - glVertex2i(x+width, y); - glVertex2i(x+width, y+height); - glVertex2i(x, y+height); - glVertex2i(x, y); - glEnd(); - glDisable(GL_COLOR_LOGIC_OP); -} - -void PIXELMETHODS_CLASS::xor_bitmap(unsigned char * bitmap, int x, int y, int w, int h) -{ - //glEnable(GL_COLOR_LOGIC_OP); - //glLogicOp(GL_XOR); - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, textTexture); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap); - - glBegin(GL_QUADS); - glTexCoord2d(0, 0); - glVertex2f(x, y); - glTexCoord2d(1, 0); - glVertex2f(x+w, y); - glTexCoord2d(1, 1); - glVertex2f(x+w, y+h); - glTexCoord2d(0, 1); - glVertex2f(x, y+h); - glEnd(); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - //glDisable(GL_COLOR_LOGIC_OP); - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); -} - -void PIXELMETHODS_CLASS::draw_line(int x, int y, int x2, int y2, int r, int g, int b, int a) -{ - a = 255; - glColor4ub(r, g, b, a); - glBegin(GL_LINES); - glVertex2i(x, y); - glVertex2i(x2, y2); - glEnd(); -} - -void PIXELMETHODS_CLASS::drawrect(int x, int y, int width, int height, int r, int g, int b, int a) -{ - float fx = float(x)+0.5f; - float fy = float(y)+0.5f; - float fwidth = width-1.0f; - float fheight = height-1.0f; - //x++; - //y++; - //height-=2; - //width-=2; - glColor4ub(r, g, b, a); - glBegin(GL_LINE_STRIP); - glVertex2f(fx, fy); - glVertex2f(fx+fwidth, fy); - glVertex2f(fx+fwidth, fy+fheight); - glVertex2f(fx, fy+fheight); //+1 is a hack to prevent squares from missing their corners, will make smoothed lines look like SHIT - glVertex2f(fx, fy); - glEnd(); -} - -void PIXELMETHODS_CLASS::fillrect(int x, int y, int width, int height, int r, int g, int b, int a) -{ - /*x++; - y++; - width-=1; - height-=1;*/ - - glColor4ub(r, g, b, a); - glBegin(GL_QUADS); - glVertex2i(x, y); - glVertex2i(x+width, y); - glVertex2i(x+width, y+height); - glVertex2i(x, y+height); - glEnd(); -} - -void PIXELMETHODS_CLASS::drawcircle(int x, int y, int rx, int ry, int r, int g, int b, int a) -{ - int yTop = ry, yBottom, i, j; - if (!rx) - { - for (j = -ry; j <= ry; j++) - blendpixel(x, y+j, r, g, b, a); - return; - } - for (i = 0; i <= rx; i++) { - yBottom = yTop; - while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0)) - yTop++; - if (yBottom != yTop) - yTop--; - for (int j = yBottom; j <= yTop; j++) - { - blendpixel(x+i-rx, y+j-ry, r, g, b, a); - if (i != rx) - blendpixel(x-i+rx, y+j-ry, r, g, b, a); - if (j != ry) - { - blendpixel(x+i-rx, y-j+ry, r, g, b, a); - if (i != rx) - blendpixel(x-i+rx, y-j+ry, r, g, b, a); - } - } - } -} - -void PIXELMETHODS_CLASS::fillcircle(int x, int y, int rx, int ry, int r, int g, int b, int a) -{ - int yTop = ry+1, yBottom, i, j; - if (!rx) - { - for (j = -ry; j <= ry; j++) - blendpixel(x, y+j, r, g, b, a); - return; - } - for (i = 0; i <= rx; i++) - { - while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0)) - yTop++; - yBottom = 2*ry - yTop; - for (int j = yBottom+1; j < yTop; j++) - { - blendpixel(x+i-rx, y+j-ry, r, g, b, a); - if (i != rx) - blendpixel(x-i+rx, y+j-ry, r, g, b, a); - } - } -} - -void PIXELMETHODS_CLASS::gradientrect(int x, int y, int width, int height, int r, int g, int b, int a, int r2, int g2, int b2, int a2) -{ - glBegin(GL_QUADS); - glColor4ub(r, g, b, a); - glVertex2i(x, y); - glColor4ub(r2, g2, b2, a2); - glVertex2i(x+width, y); - glColor4ub(r2, g2, b2, a2); - glVertex2i(x+width, y+height); - glColor4ub(r, g, b, a); - glVertex2i(x, y+height); - glEnd(); -} - -void PIXELMETHODS_CLASS::clearrect(int x, int y, int width, int height) -{ - glColor4ub(0, 0, 0, 255); - glBegin(GL_QUADS); - glVertex2i(x, y); - glVertex2i(x+width, y); - glVertex2i(x+width, y+height); - glVertex2i(x, y+height); - glEnd(); -} - -void PIXELMETHODS_CLASS::draw_image(pixel *img, int x, int y, int w, int h, int a) -{ - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, textTexture); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, img); - glBegin(GL_QUADS); - glTexCoord2d(0, 0); - glVertex2f(x, y); - glTexCoord2d(1, 0); - glVertex2f(x+w, y); - glTexCoord2d(1, 1); - glVertex2f(x+w, y+h); - glTexCoord2d(0, 1); - glVertex2f(x, y+h); - glEnd(); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); -} - -void PIXELMETHODS_CLASS::draw_image(VideoBuffer * vidBuf, int x, int y, int a) -{ - draw_image(vidBuf->Buffer, x, y, vidBuf->Width, vidBuf->Height, a); -} diff --git a/src/graphics/OpenGLGraphics.cpp b/src/graphics/OpenGLGraphics.cpp deleted file mode 100644 index a42c4c903..000000000 --- a/src/graphics/OpenGLGraphics.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include "Graphics.h" -#include "FontReader.h" -#ifdef OGLI - -Graphics::Graphics(): - sdl_scale(1) -{ - LoadDefaults(); - InitialiseTextures(); -} - -void Graphics::LoadDefaults() -{ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - //glOrtho(0, WINDOWW*sdl_scale, 0, WINDOWH*sdl_scale, -1, 1); - glOrtho(0, WINDOWW*sdl_scale, WINDOWH*sdl_scale, 0, -1, 1); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - //glRasterPos2i(0, WINDOWH); - glRasterPos2i(0, 0); - glPixelZoom(1, 1); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -} - -void Graphics::InitialiseTextures() -{ - glEnable(GL_TEXTURE_2D); - - glGenTextures(1, &vidBuf); - glBindTexture(GL_TEXTURE_2D, vidBuf); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WINDOWW, WINDOWH, 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); - - 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); -} - -void Graphics::DestroyTextures() -{ - //Todo... -} - -Graphics::~Graphics() -{ -} - -void Graphics::Reset() -{ - LoadDefaults(); - DestroyTextures(); - InitialiseTextures(); -} - -void Graphics::Clear() -{ - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); -} - -void Graphics::Finalise() -{ - glFlush(); -} - -#define VIDXRES WINDOWW -#define VIDYRES WINDOWH -#define PIXELMETHODS_CLASS Graphics -#include "OpenGLDrawMethods.inl" -#undef VIDYRES -#undef VIDXRES -#undef PIXELMETHODS_CLASS - - -#endif diff --git a/src/graphics/OpenGLHeaders.h b/src/graphics/OpenGLHeaders.h deleted file mode 100644 index 5d42449f9..000000000 --- a/src/graphics/OpenGLHeaders.h +++ /dev/null @@ -1,30 +0,0 @@ -#include "Config.h" -#ifndef OPENGLHEADERS_H_ -#define OPENGLHEADERS_H_ - -#ifdef MACOSX -# if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_OS_X_VERSION_10_9 -# include -# ifndef GL_RGBA32F -# define GL_RGBA32F GL_RGBA32F_ARB -# endif -# elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 -# include -# include -# else -//#include -# include -# include -# define GL_RGBA32F 0x8814 -# endif -#elif defined(WIN) -# include -# include -# include -#else -# include -# include -# include -#endif - -#endif // OPENGLHEADERS_H_ diff --git a/src/graphics/Pixel.h b/src/graphics/Pixel.h index bcafa762e..7bbcdfa21 100644 --- a/src/graphics/Pixel.h +++ b/src/graphics/Pixel.h @@ -3,45 +3,35 @@ #define PIXELCHANNELS 3 #ifdef PIX16 -#define PIXELSIZE 2 -#define PIXPACK(x) ((((x)>>8)&0xF800)|(((x)>>5)&0x07E0)|(((x)>>3)&0x001F)) //16bit RGB in 16bit int: ???? -#define PIXRGB(r,g,b) ((((r)<<8)&0xF800)|(((g)<<3)&0x07E0)|(((b)>>3)&0x001F)) -#define PIXR(x) (((x)>>8)&0xF8) -#define PIXG(x) (((x)>>3)&0xFC) -#define PIXB(x) (((x)<<3)&0xF8) +# define PIXELSIZE 2 +# define PIXPACK(x) ((((x)>>8)&0xF800)|(((x)>>5)&0x07E0)|(((x)>>3)&0x001F)) //16bit RGB in 16bit int: ???? +# define PIXRGB(r,g,b) ((((r)<<8)&0xF800)|(((g)<<3)&0x07E0)|(((b)>>3)&0x001F)) +# define PIXR(x) (((x)>>8)&0xF8) +# define PIXG(x) (((x)>>3)&0xFC) +# define PIXB(x) (((x)<<3)&0xF8) #else -#define PIXELSIZE 4 -#ifdef PIX32BGRA -#define PIXPACK(x) ((((x)>>16)&0x0000FF)|((x)&0x00FF00)|(((x)<<16)&0xFF0000)) //24bit BGR in 32bit int: 00BBGGRR -#define PIXRGB(r,g,b) (((b)<<16)|((g)<<8)|((r)))// (((b)<<16)|((g)<<8)|(r)) -#define PIXR(x) ((x)&0xFF) -#define PIXG(x) (((x)>>8)&0xFF) -#define PIXB(x) ((x)>>16) -#else -#ifdef PIX32BGRA -#define PIXPACK(x) ((((x)>>8)&0x0000FF00)|(((x)<<8)&0x00FF0000)|(((x)<<24)&0xFF000000)) //32bit BGRA in 32bit int: BBGGRRAA -#define PIXRGB(r,g,b) (((b)<<24)|((g)<<16)|((r)<<8)) -#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)) -#define PIXR(x) (((x)>>16)&0xFF) -#define PIXG(x) (((x)>>8)&0xFF) -#define PIXB(x) ((x)&0xFF) -#endif -#endif +# define PIXELSIZE 4 +# ifdef PIX32BGRA +# define PIXPACK(x) ((((x)>>16)&0x0000FF)|((x)&0x00FF00)|(((x)<<16)&0xFF0000)) //24bit BGR in 32bit int: 00BBGGRR +# define PIXRGB(r,g,b) (((b)<<16)|((g)<<8)|((r)))// (((b)<<16)|((g)<<8)|(r)) +# define PIXR(x) ((x)&0xFF) +# define PIXG(x) (((x)>>8)&0xFF) +# define PIXB(x) ((x)>>16) +# else +# ifdef PIX32BGRA +# define PIXPACK(x) ((((x)>>8)&0x0000FF00)|(((x)<<8)&0x00FF0000)|(((x)<<24)&0xFF000000)) //32bit BGRA in 32bit int: BBGGRRAA +# define PIXRGB(r,g,b) (((b)<<24)|((g)<<16)|((r)<<8)) +# define PIXR(x) (((x)>>8)&0xFF) +# define PIXG(x) (((x)>>16)&0xFF) +# define PIXB(x) (((x)>>24)&0xFF) +# else +# define PIXPACK(x) (x) //24bit RGB in 32bit int: 00RRGGBB. +# define PIXRGB(r,g,b) (((r)<<16)|((g)<<8)|(b)) +# define PIXR(x) (((x)>>16)&0xFF) +# define PIXG(x) (((x)>>8)&0xFF) +# define PIXB(x) ((x)&0xFF) +# endif +# endif #endif #ifdef PIX16 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 bd23b04e6..20de1d7e2 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -26,80 +26,13 @@ #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); @@ -148,24 +81,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) @@ -175,327 +95,22 @@ 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++) - { - //Across - glVertex2i(zoomWindowPosition.X, zoomWindowPosition.Y+(i*ZFACTOR)); - glVertex2i(zoomWindowPosition.X+(zoomScopeSize*ZFACTOR), zoomWindowPosition.Y+(i*ZFACTOR)); - - //Down - glVertex2i(zoomWindowPosition.X+(i*ZFACTOR), zoomWindowPosition.Y); - glVertex2i(zoomWindowPosition.X+(i*ZFACTOR), zoomWindowPosition.Y+(zoomScopeSize*ZFACTOR)); - } - glEnd(); - - //Draw zoom window border - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_LINE_LOOP); - glVertex2i(zoomWindowPosition.X, zoomWindowPosition.Y); - glVertex2i(zoomWindowPosition.X+(zoomScopeSize*ZFACTOR), zoomWindowPosition.Y); - glVertex2i(zoomWindowPosition.X+(zoomScopeSize*ZFACTOR), zoomWindowPosition.Y+(zoomScopeSize*ZFACTOR)); - glVertex2i(zoomWindowPosition.X, zoomWindowPosition.Y+(zoomScopeSize*ZFACTOR)); - glEnd(); - //glDisable(GL_LINE_SMOOTH); - - if(zoomEnabled) - { - glEnable(GL_COLOR_LOGIC_OP); - //glEnable(GL_LINE_SMOOTH); - glLogicOp(GL_XOR); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_LINE_LOOP); - glVertex2i(zoomScopePosition.X, zoomScopePosition.Y); - glVertex2i(zoomScopePosition.X+zoomScopeSize, zoomScopePosition.Y); - glVertex2i(zoomScopePosition.X+zoomScopeSize, zoomScopePosition.Y+zoomScopeSize); - glVertex2i(zoomScopePosition.X, zoomScopePosition.Y+zoomScopeSize); - /*glVertex3i((zoomScopePosition.X-1)*sdl_scale, (WINDOWH-(zoomScopePosition.Y-1))*sdl_scale, 0); - glVertex3i((zoomScopePosition.X-1)*sdl_scale, (WINDOWH-(zoomScopePosition.Y+zoomScopeSize))*sdl_scale, 0); - glVertex3i((zoomScopePosition.X+zoomScopeSize)*sdl_scale, (WINDOWH-(zoomScopePosition.Y+zoomScopeSize))*sdl_scale, 0); - glVertex3i((zoomScopePosition.X+zoomScopeSize)*sdl_scale, (WINDOWH-(zoomScopePosition.Y-1))*sdl_scale, 0); - glVertex3i((zoomScopePosition.X-1)*sdl_scale, (WINDOWH-(zoomScopePosition.Y-1))*sdl_scale, 0);*/ - glEnd(); - glDisable(GL_COLOR_LOGIC_OP); - } - glLineWidth(1); - glBlendFunc(origBlendSrc, origBlendDst); - #else + { int x, y, i, j; pixel pix; pixel * img = vid; @@ -523,7 +138,7 @@ void Renderer::RenderZoom() xor_pixel(zoomScopePosition.X+zoomScopeSize, zoomScopePosition.Y+j); } } - #endif + } } #ifndef FONTEDITOR @@ -707,33 +322,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]) @@ -976,7 +564,6 @@ void Renderer::DrawWalls() fire_b[y][x] = cb; } } -#endif } #ifndef FONTEDITOR @@ -984,12 +571,6 @@ 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()) @@ -1005,33 +586,20 @@ 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 } #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; @@ -1066,12 +634,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; @@ -1108,7 +674,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]; @@ -1131,69 +696,6 @@ void Renderer::prepare_alpha(int size, float intensity) for (y=0; y 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 } #ifndef FONTEDITOR @@ -1208,25 +710,6 @@ void Renderer::render_parts() return; parts = sim->parts; elements = sim->elements.data(); -#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) { @@ -1246,10 +728,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; @@ -1402,7 +880,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; @@ -1421,7 +898,6 @@ void Renderer::render_parts() else if(fireb<0) fireb = 0; if(firea>255) firea = 255; else if(firea<0) firea = 0; - #endif if (findingElement) { @@ -1498,49 +974,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; @@ -1616,61 +1049,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); @@ -1682,20 +1075,10 @@ 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); @@ -1716,19 +1099,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++) @@ -1741,61 +1114,10 @@ void Renderer::render_parts() blendpixel(x+nx, y+ny, colr, colg, colb, 10); } } -#endif } if(pixel_mode & PMODE_SPARK) { flicker = float(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, int(gradv)); @@ -1805,61 +1127,10 @@ void Renderer::render_parts() addpixel(nx, ny-x, colr, colg, colb, int(gradv)); gradv = gradv/1.5f; } -#endif } if(pixel_mode & PMODE_FLARE) { flicker = float(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, int((gradv*4)>255?255:(gradv*4)) ); blendpixel(nx+1, ny, colr, colg, colb,int( (gradv*2)>255?255:(gradv*2)) ); @@ -1878,61 +1149,10 @@ void Renderer::render_parts() addpixel(nx, ny-x, colr, colg, colb, int(gradv)); gradv = gradv/1.2f; } -#endif } if(pixel_mode & PMODE_LFLARE) { flicker = float(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, int((gradv*4)>255?255:(gradv*4)) ); blendpixel(nx+1, ny, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) ); @@ -1951,7 +1171,6 @@ void Renderer::render_parts() addpixel(nx, ny-x, colr, colg, colb, int(gradv)); gradv = gradv/1.01f; } -#endif } if (pixel_mode & EFFECT_GRAVIN) { @@ -2011,32 +1230,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]; @@ -2052,208 +1252,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 @@ -2266,28 +1275,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=int(emp_decor*2.5), g=int(100+emp_decor*1.5), b=255; int a=int((1.0*emp_decor/110)*255); if (r>255) r=255; @@ -2299,7 +1286,6 @@ void Renderer::draw_other() // EMP effect { blendpixel(i, j, r, g, b, a); } -#endif } } #endif @@ -2344,7 +1330,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; @@ -2414,66 +1399,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() @@ -2516,11 +1441,7 @@ 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): @@ -2547,15 +1468,9 @@ 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)); @@ -2647,149 +1562,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); } @@ -2812,9 +1584,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) @@ -2926,30 +1696,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); @@ -2957,10 +1715,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 0e84b03f0..2d30211ec 100644 --- a/src/graphics/Renderer.h +++ b/src/graphics/Renderer.h @@ -3,9 +3,6 @@ #include "Config.h" #include -#ifdef OGLR -#include "OpenGLHeaders.h" -#endif #include "Graphics.h" #include "gui/interface/Point.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 f04fe2722..f9fe275b0 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -2297,7 +2297,6 @@ void GameView::OnDraw() g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, int(alpha*0.5f)); g->drawtext(XRES-16-textWidth, 16, sampleInfo.Build(), 255, 255, 255, int(alpha*0.75f)); -#ifndef OGLI if (wavelengthGfx) { int i, cr, cg, cb, j, h = 3, x = XRES-19-textWidth, y = 10; @@ -2332,7 +2331,6 @@ void GameView::OnDraw() } } } -#endif if (showDebug) { diff --git a/src/gui/game/SignTool.cpp b/src/gui/game/SignTool.cpp index 0811a1177..9f2142c0e 100644 --- a/src/gui/game/SignTool.cpp +++ b/src/gui/game/SignTool.cpp @@ -178,20 +178,12 @@ 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 ccea443f4..af0f8178e 100644 --- a/src/gui/interface/Engine.cpp +++ b/src/gui/interface/Engine.cpp @@ -108,9 +108,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_)); @@ -216,12 +214,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, int(255-std::pow(.98, windowOpenState)*255)); -#endif } else { diff --git a/src/gui/interface/Panel.cpp b/src/gui/interface/Panel.cpp index cee6fe38d..e7cea286f 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,7 @@ Panel::~Panel() { delete children[i]; } -#ifdef OGLI - glDeleteTextures(1, &myVidTex); - glDeleteFramebuffers(1, &myVid); -#else delete[] myVid; -#endif } void Panel::AddChild(Component* c) @@ -97,17 +69,9 @@ 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 +91,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 +98,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..d4d13740b 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,7 @@ 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 c8fb0d56c..24fcdfc84 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 a7eb03954..93e68db88 100644 --- a/src/gui/render/RenderView.cpp +++ b/src/gui/render/RenderView.cpp @@ -84,13 +84,7 @@ RenderView::RenderView(): addDisplayModeCheckbox(DISPLAY_AIRH, IconHeat , ui::Point(167, 22), "Displays the temperature of the air like heat display does"); line2 = 200; addDisplayModeCheckbox(DISPLAY_WARP, IconWarp , ui::Point(205, 22), "Gravity lensing, Newtonian Gravity bends light with this on"); -#ifdef OGLR -# define TOOLTIP "Some type of OpenGL effect ... maybe" -#else -# define TOOLTIP "Enables moving solids, stickmen guns, and premium(tm) graphics" -#endif - addDisplayModeCheckbox(DISPLAY_EFFE, IconEffect , ui::Point(205, 4), TOOLTIP); -#undef TOOLTIP + addDisplayModeCheckbox(DISPLAY_EFFE, IconEffect , ui::Point(205, 4), "Enables moving solids, stickmen guns, and premium(tm) graphics"); addDisplayModeCheckbox(DISPLAY_PERS, IconPersistant, ui::Point(237, 4), "Element paths persist on the screen for a while"); line3 = 270; diff --git a/src/simulation/SaveRenderer.cpp b/src/simulation/SaveRenderer.cpp index 55bc2a7d6..8fe52153f 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 } void SaveRenderer::Flush(int begin, int end) @@ -64,67 +46,6 @@ 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; @@ -157,7 +78,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 202955139..c0ca685bb 100644 --- a/src/simulation/SaveRenderer.h +++ b/src/simulation/SaveRenderer.h @@ -1,9 +1,6 @@ #ifndef SAVERENDERER_H_ #define SAVERENDERER_H_ #include "Config.h" -#ifdef OGLI -#include "graphics/OpenGLHeaders.h" -#endif #include "common/Singleton.h" #include @@ -24,11 +21,6 @@ public: VideoBuffer * Render(unsigned char * saveData, int saveDataSize, bool decorations = true, bool fire = true); void Flush(int begin, int end); virtual ~SaveRenderer(); - -private: -#if defined(OGLR) || defined(OGLI) - GLuint fboTex, fbo; -#endif }; #endif /* SAVERENDERER_H_ */