Remove long defunct OpenGL code paths

This commit is contained in:
Tamás Bálint Misius 2022-10-11 20:11:14 +02:00
parent f378b3ac1d
commit f18bd6553f
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
22 changed files with 31 additions and 2125 deletions

View File

@ -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'))

View File

@ -16,9 +16,6 @@
#mesondefine LIN
#mesondefine AND
#mesondefine NO_INSTALL_CHECK
#mesondefine OGLI
#mesondefine OGLR
#mesondefine PIX32OGL
#mesondefine SNAPSHOT
#mesondefine WIN
#mesondefine MACOSX

View File

@ -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;

View File

@ -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
{

View File

@ -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
}

View File

@ -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);

View File

@ -1,416 +0,0 @@
#include "../data/font.bz2.h"
#include <cmath>
#include <cstring>
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);
}

View File

@ -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

View File

@ -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 <OpenGL/glu.h>
# ifndef GL_RGBA32F
# define GL_RGBA32F GL_RGBA32F_ARB
# endif
# elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
# include <OpenGL/gl3.h>
# include <OpenGL/glu.h>
# else
//#include <GL/glew.h>
# include <OpenGL/gl.h>
# include <OpenGL/glu.h>
# define GL_RGBA32F 0x8814
# endif
#elif defined(WIN)
# include <GL/glew.h>
# include <GL/gl.h>
# include <GL/glu.h>
#else
# include <GL/glew.h>
# include <GL/gl.h>
# include <GL/glu.h>
#endif
#endif // OPENGLHEADERS_H_

View File

@ -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

View File

@ -3,8 +3,6 @@
#include <cstdlib>
#include <cstring>
#ifndef OGLI
Graphics::Graphics():
sdl_scale(1)
{
@ -34,5 +32,3 @@ void Graphics::Finalise()
#undef VIDYRES
#undef VIDXRES
#undef PIXELMETHODS_CLASS
#endif

File diff suppressed because it is too large Load Diff

View File

@ -3,9 +3,6 @@
#include "Config.h"
#include <vector>
#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

View File

@ -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)
{

View File

@ -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)

View File

@ -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
{

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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();

View File

@ -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 <mutex>
@ -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_ */