Gravity lensing

This commit is contained in:
Simon Robertshaw
2012-08-09 01:17:01 +01:00
parent bb99efdedf
commit 3bdfd510b2
2 changed files with 26 additions and 4 deletions

View File

@@ -42,6 +42,13 @@ void Renderer::RenderBegin()
{ {
std::copy(persistentVid, persistentVid+(VIDXRES*YRES), vid); 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);
}
#endif #endif
draw_air(); draw_air();
draw_grav(); draw_grav();
@@ -69,6 +76,12 @@ void Renderer::RenderBegin()
DrawWalls(); DrawWalls();
draw_grav_zones(); draw_grav_zones();
DrawSigns(); DrawSigns();
#ifndef OGLR
if(display_mode & DISPLAY_WARP)
{
vid = oldVid;
}
#endif
#ifndef OGLR #ifndef OGLR
FinaliseParts(); FinaliseParts();
#endif #endif
@@ -292,9 +305,16 @@ void Renderer::FinaliseParts()
} }
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable( GL_TEXTURE_2D ); glDisable( GL_TEXTURE_2D );
#elif defined(OGLI) #endif
#if defined(OGLI) && !defined(OGLR)
render_gravlensing(warpVid);
g->draw_image(vid, 0, 0, VIDXRES, VIDYRES, 255); g->draw_image(vid, 0, 0, VIDXRES, VIDYRES, 255);
#endif #endif
#if !defined(OGLR) && !defined(OGLI)
render_gravlensing(warpVid);
#endif
} }
void Renderer::RenderZoom() void Renderer::RenderZoom()
@@ -775,13 +795,13 @@ void Renderer::DrawSigns()
#endif #endif
} }
void Renderer::render_gravlensing() void Renderer::render_gravlensing(pixel * source)
{ {
#ifndef OGLR #ifndef OGLR
int nx, ny, rx, ry, gx, gy, bx, by, co; int nx, ny, rx, ry, gx, gy, bx, by, co;
int r, g, b; int r, g, b;
pixel t; pixel t;
pixel *src = vid; pixel *src = source;
pixel *dst = vid; pixel *dst = vid;
for(nx = 0; nx < XRES; nx++) for(nx = 0; nx < XRES; nx++)
{ {
@@ -2171,6 +2191,7 @@ Renderer::Renderer(Graphics * g, Simulation * sim):
vid = g->vid; vid = g->vid;
#endif #endif
persistentVid = new pixel[VIDXRES*YRES]; persistentVid = new pixel[VIDXRES*YRES];
warpVid = new pixel[VIDXRES*VIDYRES];
#endif #endif
memset(fire_r, 0, sizeof(fire_r)); memset(fire_r, 0, sizeof(fire_r));

View File

@@ -66,7 +66,7 @@ public:
void RenderZoom(); void RenderZoom();
void DrawWalls(); void DrawWalls();
void DrawSigns(); void DrawSigns();
void render_gravlensing(); void render_gravlensing(pixel * source);
void render_fire(); void render_fire();
void prepare_alpha(int size, float intensity); void prepare_alpha(int size, float intensity);
void render_parts(); void render_parts();
@@ -88,6 +88,7 @@ public:
#else #else
pixel * vid; pixel * vid;
pixel * persistentVid; pixel * persistentVid;
pixel * warpVid;
void blendpixel(int x, int y, int r, int g, int b, int a); void blendpixel(int x, int y, int r, int g, int b, int a);
void addpixel(int x, int y, int r, int g, int b, int a); void addpixel(int x, int y, int r, int g, int b, int a);