Fancy motion blur for OpenGL, fix a lot of dialogues in OpenGL, fix gravity lensing in OpenGL, ensure Phot and Neut are PMODE_ADD, not FLAT

This commit is contained in:
Simon Robertshaw 2012-05-12 01:35:55 +01:00
parent d7fa0b139e
commit d69fc052fa
9 changed files with 282 additions and 26 deletions

View File

@ -269,16 +269,29 @@ uniform sampler2D tfY;\
uniform float xres;\ uniform float xres;\
uniform float yres;\ uniform float yres;\
void main () {\ void main () {\
vec4 transformX = texture2D(tfX, vec2(gl_TexCoord[0].s, -gl_TexCoord[0].t));\ vec4 transformX = texture2D(tfX, vec2(gl_TexCoord[0].s, gl_TexCoord[0].t));\
vec4 transformY = -texture2D(tfY, vec2(gl_TexCoord[0].s, -gl_TexCoord[0].t));\ vec4 transformY = texture2D(tfY, vec2(gl_TexCoord[0].s, gl_TexCoord[0].t));\
transformX.r /= xres;\ transformX.r /= xres/4.0;\
transformY.g /= yres;\ transformY.g /= yres/4.0;\
vec4 texColor = vec4(\ vec4 texColor1 = vec4(\
texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r*0.75, transformY.g*0.75)).r,\ texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r*0.90, transformY.g*0.90)).r,\
texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r*0.875, transformY.g*0.875)).g,\ texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r*0.80, transformY.g*0.80)).g,\
texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r, transformY.g)).b,\ texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r*0.70, transformY.g*0.70)).b,\
1.0\ 1.0\
);\ );\
vec4 texColor2 = vec4(\
texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r*0.95, transformY.g*0.95)).r,\
texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r*0.85, transformY.g*0.85)).g,\
texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r*0.75, transformY.g*0.75)).b,\
1.0\
);\
vec4 texColor3 = vec4(\
texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r*0.85, transformY.g*0.85)).r,\
texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r*0.75, transformY.g*0.75)).g,\
texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r*0.65, transformY.g*0.65)).b,\
1.0\
);\
vec4 texColor = texColor1*0.6 + texColor2*0.2 + texColor3*0.2;\
gl_FragColor = texColor;\ gl_FragColor = texColor;\
}"; }";
const char * lensVertex = "#version 120\n\ const char * lensVertex = "#version 120\n\

View File

@ -283,6 +283,7 @@ struct particle
int type; int type;
int life, ctype; int life, ctype;
float x, y, vx, vy; float x, y, vx, vy;
float lastX, lastY;
float temp; float temp;
float pavg[2]; float pavg[2];
int flags; int flags;

View File

@ -40,6 +40,8 @@ int create_n_parts(int n, int x, int y, float vx, float vy, float temp, int t)//
parts[i].x = (float)x; parts[i].x = (float)x;
parts[i].y = (float)y; parts[i].y = (float)y;
parts[i].lastX = (float)x;
parts[i].lastY = (float)y;
parts[i].type = t; parts[i].type = t;
parts[i].life = rand()%480+480; parts[i].life = rand()%480+480;
parts[i].vx = r*cosf(a); parts[i].vx = r*cosf(a);
@ -160,6 +162,7 @@ int graphics_NEUT(GRAPHICS_FUNC_ARGS)
*fireg = 80; *fireg = 80;
*fireb = 120; *fireb = 120;
*pixel_mode |= FIRE_ADD; *pixel_mode &= ~PMODE_FLAT;
*pixel_mode |= FIRE_ADD | PMODE_ADD;
return 1; return 1;
} }

View File

@ -94,6 +94,7 @@ int graphics_PHOT(GRAPHICS_FUNC_ARGS)
*fireg = *colg; *fireg = *colg;
*fireb = *colb; *fireb = *colb;
*pixel_mode |= FIRE_ADD; *pixel_mode &= ~PMODE_FLAT;
*pixel_mode |= FIRE_ADD | PMODE_ADD;
return 0; return 0;
} }

View File

@ -24,8 +24,7 @@
#if defined(OGLR) #if defined(OGLR)
#ifdef MACOSX #ifdef MACOSX
#include <GL/glew.h> #include <OpenGL/gl3.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h> #include <OpenGL/glu.h>
#elif defined(WIN32) #elif defined(WIN32)
#include <GL/glew.h> #include <GL/glew.h>
@ -458,6 +457,7 @@ void clearScreenNP(float alpha)
void ogl_blit(int x, int y, int w, int h, pixel *src, int pitch, int scale) void ogl_blit(int x, int y, int w, int h, pixel *src, int pitch, int scale)
{ {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glDrawPixels(w,h,GL_BGRA,GL_UNSIGNED_BYTE,src); //Why does this still think it's ABGR? //glDrawPixels(w,h,GL_BGRA,GL_UNSIGNED_BYTE,src); //Why does this still think it's ABGR?
glEnable( GL_TEXTURE_2D ); glEnable( GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D, vidBuf); glBindTexture(GL_TEXTURE_2D, vidBuf);
@ -475,6 +475,7 @@ void ogl_blit(int x, int y, int w, int h, pixel *src, int pitch, int scale)
glEnd(); glEnd();
glDisable( GL_TEXTURE_2D ); glDisable( GL_TEXTURE_2D );
glBlendFunc(GL_ONE, GL_ONE);
glFlush(); glFlush();
SDL_GL_SwapBuffers (); SDL_GL_SwapBuffers ();
} }
@ -1750,12 +1751,16 @@ GLuint addV[(YRES*XRES)*2];
GLfloat addC[(YRES*XRES)*4]; GLfloat addC[(YRES*XRES)*4];
GLfloat lineV[(((YRES*XRES)*2)*6)]; GLfloat lineV[(((YRES*XRES)*2)*6)];
GLfloat lineC[(((YRES*XRES)*2)*6)]; GLfloat lineC[(((YRES*XRES)*2)*6)];
GLfloat blurLineV[(((YRES*XRES)*2))];
GLfloat blurLineC[(((YRES*XRES)*2)*4)];
GLfloat ablurLineV[(((YRES*XRES)*2))];
GLfloat ablurLineC[(((YRES*XRES)*2)*4)];
#endif #endif
void render_parts(pixel *vid) void render_parts(pixel *vid)
{ {
int deca, decr, decg, decb, cola, colr, colg, colb, firea, firer, fireg, fireb, pixel_mode, q, i, t, nx, ny, x, y, caddress; int deca, decr, decg, decb, cola, colr, colg, colb, firea, firer, fireg, fireb, pixel_mode, q, i, t, nx, ny, x, y, caddress;
int orbd[4] = {0, 0, 0, 0}, orbl[4] = {0, 0, 0, 0}; int orbd[4] = {0, 0, 0, 0}, orbl[4] = {0, 0, 0, 0};
float gradv, flicker, fnx, fny; float gradv, flicker, fnx, fny, flx, fly;
#ifdef OGLR #ifdef OGLR
int cfireV = 0, cfireC = 0, cfire = 0; int cfireV = 0, cfireC = 0, cfire = 0;
int csmokeV = 0, csmokeC = 0, csmoke = 0; int csmokeV = 0, csmokeC = 0, csmoke = 0;
@ -1765,6 +1770,8 @@ void render_parts(pixel *vid)
int cflatV = 0, cflatC = 0, cflat = 0; int cflatV = 0, cflatC = 0, cflat = 0;
int caddV = 0, caddC = 0, cadd = 0; int caddV = 0, caddC = 0, cadd = 0;
int clineV = 0, clineC = 0, cline = 0; int clineV = 0, clineC = 0, cline = 0;
int cblurLineV = 0, cblurLineC = 0, cblurLine = 0;
int cablurLineV = 0, cablurLineC = 0, cablurLine = 0;
GLuint origBlendSrc, origBlendDst; GLuint origBlendSrc, origBlendDst;
glGetIntegerv(GL_BLEND_SRC, &origBlendSrc); glGetIntegerv(GL_BLEND_SRC, &origBlendSrc);
@ -1792,6 +1799,8 @@ void render_parts(pixel *vid)
ny = (int)(parts[i].y+0.5f); ny = (int)(parts[i].y+0.5f);
fnx = parts[i].x; fnx = parts[i].x;
fny = parts[i].y; fny = parts[i].y;
flx = parts[i].lastX;
fly = parts[i].lastY;
if(photons[ny][nx]&0xFF && !(ptypes[t].properties & TYPE_ENERGY)) if(photons[ny][nx]&0xFF && !(ptypes[t].properties & TYPE_ENERGY))
continue; continue;
@ -2099,6 +2108,65 @@ void render_parts(pixel *vid)
draw_line(vid , cplayer->legs[8], cplayer->legs[9], cplayer->legs[12], cplayer->legs[13], legr, legg, legb, s); draw_line(vid , cplayer->legs[8], cplayer->legs[9], cplayer->legs[12], cplayer->legs[13], legr, legg, legb, s);
#endif #endif
} }
#ifdef OGLR
if((display_mode & DISPLAY_EFFE) && (fabs(fnx-flx)>1.5f || fabs(fny-fly)>1.5f))
{
if(pixel_mode & PMODE_FLAT)
{
blurLineV[cblurLineV++] = nx;
blurLineV[cblurLineV++] = ny;
blurLineC[cblurLineC++] = ((float)colr)/255.0f;
blurLineC[cblurLineC++] = ((float)colg)/255.0f;
blurLineC[cblurLineC++] = ((float)colb)/255.0f;
blurLineC[cblurLineC++] = 1.0f;
cblurLine++;
blurLineV[cblurLineV++] = flx;
blurLineV[cblurLineV++] = fly;
blurLineC[cblurLineC++] = ((float)colr)/255.0f;
blurLineC[cblurLineC++] = ((float)colg)/255.0f;
blurLineC[cblurLineC++] = ((float)colb)/255.0f;
blurLineC[cblurLineC++] = 0.0f;
cblurLine++;
}
else if(pixel_mode & PMODE_BLEND)
{
blurLineV[cblurLineV++] = nx;
blurLineV[cblurLineV++] = ny;
blurLineC[cblurLineC++] = ((float)colr)/255.0f;
blurLineC[cblurLineC++] = ((float)colg)/255.0f;
blurLineC[cblurLineC++] = ((float)colb)/255.0f;
blurLineC[cblurLineC++] = ((float)cola)/255.0f;
cblurLine++;
blurLineV[cblurLineV++] = flx;
blurLineV[cblurLineV++] = fly;
blurLineC[cblurLineC++] = ((float)colr)/255.0f;
blurLineC[cblurLineC++] = ((float)colg)/255.0f;
blurLineC[cblurLineC++] = ((float)colb)/255.0f;
blurLineC[cblurLineC++] = 0.0f;
cblurLine++;
}
else if(pixel_mode & PMODE_ADD)
{
ablurLineV[cablurLineV++] = nx;
ablurLineV[cablurLineV++] = ny;
ablurLineC[cablurLineC++] = ((float)colr)/255.0f;
ablurLineC[cablurLineC++] = ((float)colg)/255.0f;
ablurLineC[cablurLineC++] = ((float)colb)/255.0f;
ablurLineC[cablurLineC++] = ((float)cola)/255.0f;
cablurLine++;
ablurLineV[cablurLineV++] = flx;
ablurLineV[cablurLineV++] = fly;
ablurLineC[cablurLineC++] = ((float)colr)/255.0f;
ablurLineC[cablurLineC++] = ((float)colg)/255.0f;
ablurLineC[cablurLineC++] = ((float)colb)/255.0f;
ablurLineC[cablurLineC++] = 0.0f;
cablurLine++;
}
}
#endif
if(pixel_mode & PMODE_FLAT) if(pixel_mode & PMODE_FLAT)
{ {
#ifdef OGLR #ifdef OGLR
@ -2546,6 +2614,36 @@ void render_parts(pixel *vid)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if(cablurLine)
{
// -- BEGIN LINES -- //
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable( GL_LINE_SMOOTH );
glColorPointer(4, GL_FLOAT, 0, &ablurLineC[0]);
glVertexPointer(2, GL_FLOAT, 0, &ablurLineV[0]);
glDrawArrays(GL_LINES, 0, cablurLine);
//Clear some stuff we set
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_LINE_SMOOTH);
// -- END LINES -- //
}
if(cblurLine)
{
// -- BEGIN LINES -- //
glEnable( GL_LINE_SMOOTH );
glColorPointer(4, GL_FLOAT, 0, &blurLineC[0]);
glVertexPointer(2, GL_FLOAT, 0, &blurLineV[0]);
glDrawArrays(GL_LINES, 0, cblurLine);
//Clear some stuff we set
glDisable(GL_LINE_SMOOTH);
// -- END LINES -- //
}
if(cflat) if(cflat)
{ {
// -- BEGIN FLAT -- // // -- BEGIN FLAT -- //
@ -3310,7 +3408,7 @@ void prepare_alpha(int size, float intensity)
for (x=0; x<CELL*3; x++) for (x=0; x<CELL*3; x++)
for (y=0; y<CELL*3; y++) for (y=0; y<CELL*3; y++)
{ {
fire_alphaf[y][x] = intensity*temp[y][x]/((float)(CELL*CELL)); fire_alphaf[y][x] = (intensity*temp[y][x]/((float)(CELL*CELL)))/2.0f;
} }
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, fireAlpha); glBindTexture(GL_TEXTURE_2D, fireAlpha);
@ -3322,6 +3420,7 @@ void prepare_alpha(int size, float intensity)
c = 5; c = 5;
glow_alphaf[c][c] = 0.8f;
glow_alphaf[c][c-1] = 0.4f; glow_alphaf[c][c-1] = 0.4f;
glow_alphaf[c][c+1] = 0.4f; glow_alphaf[c][c+1] = 0.4f;
glow_alphaf[c-1][c] = 0.4f; glow_alphaf[c-1][c] = 0.4f;
@ -3910,18 +4009,18 @@ int sdl_open(void)
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glGenTextures(1, &partsTFX); glGenTextures(1, &partsTFX);
glBindTexture(GL_TEXTURE_2D, partsTFX); glBindTexture(GL_TEXTURE_2D, partsTFX);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, XRES, YRES, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); 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_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
glGenTextures(1, &partsTFY); glGenTextures(1, &partsTFY);
glBindTexture(GL_TEXTURE_2D, partsTFY); glBindTexture(GL_TEXTURE_2D, partsTFY);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, XRES, YRES, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); 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_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);

View File

@ -252,7 +252,9 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
drawtext(vid_buf, x0+5, y0+69, "OK", 255, 255, 255, 255); drawtext(vid_buf, x0+5, y0+69, "OK", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+64, 192, 16, 192, 192, 192, 255); drawrect(vid_buf, x0, y0+64, 192, 16, 192, 192, 192, 255);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
ui_edit_process(mx, my, b, &ed); ui_edit_process(mx, my, b, &ed);
@ -533,6 +535,9 @@ void ui_list_process(pixel * vid_buf, int mx, int my, int mb, ui_list *ed)
if(!selected && mb) if(!selected && mb)
break; break;
drawrect(vid_buf, ed->x, ystart, ed->w, ed->count*16, 255, 255, 255, 255); drawrect(vid_buf, ed->x, ystart, ed->w, ed->count*16, 255, 255, 255, 255);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
clearrect(vid_buf, ed->x-2, ystart-2, ed->w+4, (ed->count*16)+4); clearrect(vid_buf, ed->x-2, ystart-2, ed->w+4, (ed->count*16)+4);
} }
@ -955,6 +960,9 @@ void error_ui(pixel *vid_buf, int err, char *txt)
drawtextwrap(vid_buf, x0+8, y0+26, 224, msg, 255, 255, 255, 255); drawtextwrap(vid_buf, x0+8, y0+26, 224, msg, 255, 255, 255, 255);
drawtext(vid_buf, x0+5, y0+textheight+37, "Dismiss", 255, 255, 255, 255); drawtext(vid_buf, x0+5, y0+textheight+37, "Dismiss", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+textheight+32, 240, 16, 192, 192, 192, 255); drawrect(vid_buf, x0, y0+textheight+32, 240, 16, 192, 192, 192, 255);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b && !bq && mx>=x0 && mx<x0+240 && my>=y0+textheight+32 && my<=y0+textheight+48) if (b && !bq && mx>=x0 && mx<x0+240 && my>=y0+textheight+32 && my<=y0+textheight+48)
@ -1024,6 +1032,9 @@ char *input_ui(pixel *vid_buf, char *title, char *prompt, char *text, char *shad
drawtext(vid_buf, x0+5, y0+ysize-11, "OK", 255, 255, 255, 255); drawtext(vid_buf, x0+5, y0+ysize-11, "OK", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+ysize-16, xsize, 16, 192, 192, 192, 255); drawrect(vid_buf, x0, y0+ysize-16, xsize, 16, 192, 192, 192, 255);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b && !bq && mx>=x0 && mx<x0+xsize && my>=y0+ysize-16 && my<=y0+ysize) if (b && !bq && mx>=x0 && mx<x0+xsize && my>=y0+ysize-16 && my<=y0+ysize)
@ -1116,6 +1127,9 @@ void prop_edit_ui(pixel *vid_buf, int x, int y)
drawtext(vid_buf, x0+5, y0+ysize-11, "OK", 255, 255, 255, 255); drawtext(vid_buf, x0+5, y0+ysize-11, "OK", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+ysize-16, xsize, 16, 192, 192, 192, 255); drawrect(vid_buf, x0, y0+ysize-16, xsize, 16, 192, 192, 192, 255);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b && !bq && mx>=x0 && mx<x0+xsize && my>=y0+ysize-16 && my<=y0+ysize) if (b && !bq && mx>=x0 && mx<x0+xsize && my>=y0+ysize-16 && my<=y0+ysize)
@ -1258,6 +1272,9 @@ void info_ui(pixel *vid_buf, char *top, char *txt)
drawtext(vid_buf, x0+8, y0+26, txt, 255, 255, 255, 255); drawtext(vid_buf, x0+8, y0+26, txt, 255, 255, 255, 255);
drawtext(vid_buf, x0+5, y0+49, "OK", 255, 255, 255, 255); drawtext(vid_buf, x0+5, y0+49, "OK", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+44, 240, 16, 192, 192, 192, 255); drawrect(vid_buf, x0, y0+44, 240, 16, 192, 192, 192, 255);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b && !bq && mx>=x0 && mx<x0+240 && my>=y0+44 && my<=y0+60) if (b && !bq && mx>=x0 && mx<x0+240 && my>=y0+44 && my<=y0+60)
@ -1286,6 +1303,9 @@ void info_box(pixel *vid_buf, char *msg)
drawrect(vid_buf, x0, y0, w, 24, 192, 192, 192, 255); drawrect(vid_buf, x0, y0, w, 24, 192, 192, 192, 255);
drawtext(vid_buf, x0+8, y0+8, msg, 192, 192, 240, 255); drawtext(vid_buf, x0+8, y0+8, msg, 192, 192, 240, 255);
#ifndef RENDERER #ifndef RENDERER
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
#endif #endif
} }
@ -1340,6 +1360,9 @@ void copytext_ui(pixel *vid_buf, char *top, char *txt, char *copytxt)
drawtext(vid_buf, x0+5, y0+ysize-11, "OK", 255, 255, 255, 255); drawtext(vid_buf, x0+5, y0+ysize-11, "OK", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+ysize-16, xsize, 16, 192, 192, 192, 255); drawrect(vid_buf, x0, y0+ysize-16, xsize, 16, 192, 192, 192, 255);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b && !bq && mx>=x0 && mx<x0+xsize && my>=y0+ysize-16 && my<=y0+ysize) if (b && !bq && mx>=x0 && mx<x0+xsize && my>=y0+ysize-16 && my<=y0+ysize)
@ -1391,6 +1414,9 @@ int confirm_ui(pixel *vid_buf, char *top, char *msg, char *btn)
drawrect(vid_buf, x0, y0+textheight+32, 160, 16, 192, 192, 192, 255); drawrect(vid_buf, x0, y0+textheight+32, 160, 16, 192, 192, 192, 255);
drawrect(vid_buf, x0+160, y0+textheight+32, 80, 16, 192, 192, 192, 255); drawrect(vid_buf, x0+160, y0+textheight+32, 80, 16, 192, 192, 192, 255);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b && !bq && mx>=x0+160 && mx<x0+240 && my>=y0+textheight+32 && my<=y0+textheight+48) if (b && !bq && mx>=x0+160 && mx<x0+240 && my>=y0+textheight+32 && my<=y0+textheight+48)
@ -1476,6 +1502,10 @@ void login_ui(pixel *vid_buf)
drawtext(vid_buf, x0+187-textwidth("Sign in"), y0+69, "Sign in", 255, 255, 55, 255); drawtext(vid_buf, x0+187-textwidth("Sign in"), y0+69, "Sign in", 255, 255, 55, 255);
drawrect(vid_buf, x0, y0+64, 192, 16, 192, 192, 192, 255); drawrect(vid_buf, x0, y0+64, 192, 16, 192, 192, 192, 255);
drawrect(vid_buf, x0, y0+64, 96, 16, 192, 192, 192, 255); drawrect(vid_buf, x0, y0+64, 96, 16, 192, 192, 192, 255);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
ui_edit_process(mx, my, b, &ed1); ui_edit_process(mx, my, b, &ed1);
@ -1682,6 +1712,9 @@ int stamp_ui(pixel *vid_buf)
} }
} }
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b==1&&r!=-1) if (b==1&&r!=-1)
@ -1817,6 +1850,9 @@ void tag_list_ui(pixel *vid_buf)
ui_edit_draw(vid_buf, &ed); ui_edit_draw(vid_buf, &ed);
drawtext(vid_buf, x0+5, y0+245, "Close", 255, 255, 255, 255); drawtext(vid_buf, x0+5, y0+245, "Close", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+240, 192, 16, 192, 192, 192, 255); drawrect(vid_buf, x0, y0+240, 192, 16, 192, 192, 192, 255);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
ui_edit_process(mx, my, b, &ed); ui_edit_process(mx, my, b, &ed);
@ -1972,6 +2008,9 @@ int save_name_ui(pixel *vid_buf)
ui_copytext_draw(vid_buf, &ctb); ui_copytext_draw(vid_buf, &ctb);
ui_copytext_process(mx, my, b, bq, &ctb); ui_copytext_process(mx, my, b, bq, &ctb);
} }
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
@ -2968,6 +3007,9 @@ char *download_ui(pixel *vid_buf, char *uri, int *len)
drawtext(vid_buf, x0+120-textwidth("Waiting...")/2, y0+48, "Waiting...", 255, 216, 32, 255); drawtext(vid_buf, x0+120-textwidth("Waiting...")/2, y0+48, "Waiting...", 255, 216, 32, 255);
drawrect(vid_buf, x0, y0+44, 240, 16, 192, 192, 192, 255); drawrect(vid_buf, x0, y0+44, 240, 16, 192, 192, 192, 255);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
} }
@ -3819,6 +3861,9 @@ int report_ui(pixel* vid_buf, char *save_id)
return 0; return 0;
} }
ui_edit_draw(vid_buf, &ed); ui_edit_draw(vid_buf, &ed);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
ui_edit_process(mx, my, b, &ed); ui_edit_process(mx, my, b, &ed);
} }
@ -4329,6 +4374,9 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
if (!info_ready || !data_ready) { if (!info_ready || !data_ready) {
info_box(vid_buf, "Loading"); info_box(vid_buf, "Loading");
} }
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
if (info_ready && svf_login) { if (info_ready && svf_login) {
@ -5704,6 +5752,9 @@ unsigned int decorations_ui(pixel *vid_buf,int *bsx,int *bsy, unsigned int saved
if (zoom_en) if (zoom_en)
render_zoom(vid_buf); render_zoom(vid_buf);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (sdl_wheel) if (sdl_wheel)
@ -6020,7 +6071,9 @@ int save_filename_ui(pixel *vid_buf)
ui_edit_draw(vid_buf, &ed); ui_edit_draw(vid_buf, &ed);
drawtext(vid_buf, x0+12+textwidth(ed.str), y0+25, ".cps", 240, 240, 255, 180); drawtext(vid_buf, x0+12+textwidth(ed.str), y0+25, ".cps", 240, 240, 255, 180);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
@ -6308,6 +6361,9 @@ void catalogue_ui(pixel * vid_buf)
//srctemp+=(XRES+BARSIZE);//*PIXELSIZE; //srctemp+=(XRES+BARSIZE);//*PIXELSIZE;
} }
} }
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (sdl_key==SDLK_RETURN) if (sdl_key==SDLK_RETURN)
break; break;
@ -6382,6 +6438,8 @@ void drawIcon(pixel * vid_buf, int x, int y, int cmode)
void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation) void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
{ {
pixel * o_vid_buf; pixel * o_vid_buf;
pixel *part_vbuf; //Extra video buffer
pixel *part_vbuf_store;
int i, j, count, changed, temp; int i, j, count, changed, temp;
int xsize; int xsize;
int ysize; int ysize;
@ -6472,7 +6530,10 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
} }
o_vid_buf = calloc((YRES+MENUSIZE) * (XRES+BARSIZE), PIXELSIZE); o_vid_buf = calloc((YRES+MENUSIZE) * (XRES+BARSIZE), PIXELSIZE);
memcpy(o_vid_buf, vid_buf, ((YRES+MENUSIZE) * (XRES+BARSIZE)) * PIXELSIZE); //memcpy(o_vid_buf, vid_buf, ((YRES+MENUSIZE) * (XRES+BARSIZE)) * PIXELSIZE);
part_vbuf = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); //Extra video buffer
part_vbuf_store = part_vbuf;
while (!sdl_poll()) while (!sdl_poll())
{ {
@ -6487,7 +6548,64 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
b = mouse_get_state(&mx, &my); b = mouse_get_state(&mx, &my);
memcpy(vid_buf, o_vid_buf, ((YRES+MENUSIZE) * (XRES+BARSIZE)) * PIXELSIZE); memcpy(vid_buf, o_vid_buf, ((YRES+MENUSIZE) * (XRES+BARSIZE)) * PIXELSIZE);
render_parts(vid_buf);
if(ngrav_enable && display_mode & DISPLAY_WARP)
{
part_vbuf = part_vbuf_store;
memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
} else {
part_vbuf = vid_buf;
}
#ifdef OGLR
if (display_mode & DISPLAY_PERS)//save background for persistent, then clear
{
clearScreen(0.01f);
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
}
else //clear screen every frame
{
clearScreen(1.0f);
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes
{
draw_air(part_vbuf);
}
}
#else
if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes
{
draw_air(part_vbuf);
}
else if (display_mode & DISPLAY_PERS)//save background for persistent, then clear
{
memcpy(part_vbuf, pers_bg, (XRES+BARSIZE)*YRES*PIXELSIZE);
memset(part_vbuf+((XRES+BARSIZE)*YRES), 0, ((XRES+BARSIZE)*YRES*PIXELSIZE)-((XRES+BARSIZE)*YRES*PIXELSIZE));
}
else //clear screen every frame
{
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
}
#endif
if(ngrav_enable && drawgrav_enable)
draw_grav(vid_buf);
draw_walls(part_vbuf);
render_parts(part_vbuf);
draw_other(part_vbuf);
#ifndef OGLR
if (render_mode & FIREMODE)
render_fire(part_vbuf);
#endif
render_signs(part_vbuf);
#ifndef OGLR
if(ngrav_enable && display_mode & DISPLAY_WARP)
render_gravlensing(part_vbuf, vid_buf);
#endif
draw_svf_ui(vid_buf, sdl_mod & (KMOD_LCTRL|KMOD_RCTRL));
clearrect(vid_buf, xcoord-2, ycoord-2, xsize+4, ysize+4); clearrect(vid_buf, xcoord-2, ycoord-2, xsize+4, ysize+4);
drawrect(vid_buf, xcoord, ycoord, xsize, ysize, 192, 192, 192, 255); drawrect(vid_buf, xcoord, ycoord, xsize, ysize, 192, 192, 192, 255);
@ -6618,11 +6736,12 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
} }
} }
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
#ifdef OGLR #ifdef OGLR
clearScreenNP(1.0f); clearScreenNP(1.0f);
draw_parts_fbo(); draw_parts_fbo();
#endif #endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (sdl_key==SDLK_RETURN) if (sdl_key==SDLK_RETURN)
break; break;
if (sdl_key==SDLK_ESCAPE) if (sdl_key==SDLK_ESCAPE)
@ -6644,6 +6763,8 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
break; break;
} }
free(part_vbuf);
free(o_vid_buf); free(o_vid_buf);
} }
@ -6774,6 +6895,9 @@ void simulation_ui(pixel * vid_buf)
ui_checkbox_draw(vid_buf, &cb6); ui_checkbox_draw(vid_buf, &cb6);
ui_list_draw(vid_buf, &list); ui_list_draw(vid_buf, &list);
ui_list_draw(vid_buf, &list2); ui_list_draw(vid_buf, &list2);
#ifdef OGLR
clearScreen(1.0f);
#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
ui_checkbox_process(mx, my, b, bq, &cb); ui_checkbox_process(mx, my, b, bq, &cb);
ui_checkbox_process(mx, my, b, bq, &cb2); ui_checkbox_process(mx, my, b, bq, &cb2);

View File

@ -2255,7 +2255,7 @@ int main(int argc, char *argv[])
} }
if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq) if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq)
{ {
render_ui(vid_buf, XRES+BARSIZE-(510-491), YRES-2, 3); render_ui(vid_buf, XRES+BARSIZE-(510-491)+1, YRES+22, 3);
} }
if (x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq) if (x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq)
sys_pause = !sys_pause; sys_pause = !sys_pause;

View File

@ -888,6 +888,8 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
{ {
parts[i].x = (float)x; parts[i].x = (float)x;
parts[i].y = (float)y; parts[i].y = (float)y;
parts[i].lastX = (float)x;
parts[i].lastY = (float)y;
parts[i].type = t; parts[i].type = t;
parts[i].vx = 0; parts[i].vx = 0;
parts[i].vy = 0; parts[i].vy = 0;
@ -1031,6 +1033,8 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
{ {
parts[i].x = (float)x; parts[i].x = (float)x;
parts[i].y = (float)y; parts[i].y = (float)y;
parts[i].lastX = (float)x;
parts[i].lastY = (float)y;
parts[i].type = PT_STKM; parts[i].type = PT_STKM;
parts[i].vx = 0; parts[i].vx = 0;
parts[i].vy = 0; parts[i].vy = 0;
@ -1053,6 +1057,8 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
{ {
parts[i].x = (float)x; parts[i].x = (float)x;
parts[i].y = (float)y; parts[i].y = (float)y;
parts[i].lastX = (float)x;
parts[i].lastY = (float)y;
parts[i].type = PT_STKM2; parts[i].type = PT_STKM2;
parts[i].vx = 0; parts[i].vx = 0;
parts[i].vy = 0; parts[i].vy = 0;
@ -1077,6 +1083,8 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
{ {
parts[i].x = (float)x; parts[i].x = (float)x;
parts[i].y = (float)y; parts[i].y = (float)y;
parts[i].lastX = (float)x;
parts[i].lastY = (float)y;
parts[i].type = PT_FIGH; parts[i].type = PT_FIGH;
parts[i].vx = 0; parts[i].vx = 0;
parts[i].vy = 0; parts[i].vy = 0;
@ -1721,6 +1729,8 @@ void update_particles_i(pixel *vid, int start, int inc)
if (parts[i].type) if (parts[i].type)
{ {
t = parts[i].type; t = parts[i].type;
parts[i].lastX = parts[i].x;
parts[i].lastY = parts[i].y;
if (t<0 || t>=PT_NUM) if (t<0 || t>=PT_NUM)
{ {
kill_part(i); kill_part(i);

View File

@ -1346,6 +1346,9 @@ int parse_save_OPS(void *save, int size, int replace, int x0, int y0, unsigned c
partsptr[newIndex].tmp2 = partsData[i++]; partsptr[newIndex].tmp2 = partsData[i++];
} }
partsptr[newIndex].lastX = partsptr[newIndex].x - partsptr[newIndex].vx;
partsptr[newIndex].lastY = partsptr[newIndex].y - partsptr[newIndex].vy;
if ((player.spwn == 1 && partsptr[newIndex].type==PT_STKM) || (player2.spwn == 1 && partsptr[newIndex].type==PT_STKM2)) if ((player.spwn == 1 && partsptr[newIndex].type==PT_STKM) || (player2.spwn == 1 && partsptr[newIndex].type==PT_STKM2))
{ {
partsptr[newIndex].type = PT_NONE; partsptr[newIndex].type = PT_NONE;
@ -2023,6 +2026,8 @@ int parse_save_PSv(void *save, int size, int replace, int x0, int y0, unsigned c
{ {
parts[i].vx = (d[p++]-127.0f)/16.0f; parts[i].vx = (d[p++]-127.0f)/16.0f;
parts[i].vy = (d[p++]-127.0f)/16.0f; parts[i].vy = (d[p++]-127.0f)/16.0f;
parts[i].lastX = parts[i].x - parts[i].vx;
parts[i].lastY = parts[i].y - parts[i].vy;
} }
else else
p += 2; p += 2;