Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pixellight #559

Closed
wants to merge 103 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
155b5b7
blendtry1
qndel Jan 27, 2020
9058f22
static lights attempt1
qndel Jan 28, 2020
05c79f6
static lights attempt1
qndel Jan 28, 2020
fe456a7
before trying to use textures
qndel Jan 28, 2020
38a3651
light PR
qndel Jan 28, 2020
c026c81
code cleanup
qndel Jan 28, 2020
be9629d
code cleanup
qndel Jan 28, 2020
3fd803e
code cleanup
qndel Jan 28, 2020
971c589
code cleanup
qndel Jan 28, 2020
e971145
code cleanup
qndel Jan 28, 2020
e58085a
code cleanup
qndel Jan 28, 2020
8ae7504
fixed memory leak
qndel Jan 28, 2020
8a3c04b
cut fps hole only if fps displayed
qndel Jan 28, 2020
93a3838
static lights
qndel Jan 28, 2020
c5dcad8
fix travis error
qndel Jan 28, 2020
44f4e0e
fix SDL1 build
qndel Jan 28, 2020
be6af23
fix static light jumping
qndel Jan 28, 2020
ac2459c
separate ui test
qndel Jan 28, 2020
03cdc9f
separate ui test
qndel Jan 28, 2020
bb78514
separate ui test
qndel Jan 28, 2020
33ee6f7
ui work in progress
qndel Jan 28, 2020
a744ccb
still doesnt work
qndel Jan 28, 2020
b3ae81e
almost works
qndel Jan 29, 2020
b7a2c9d
everything works except missiles
qndel Jan 29, 2020
8ae1a05
fix shadows
qndel Jan 29, 2020
f1071ff
fix missiles jumping around
qndel Jan 29, 2020
94e715f
fix light affecting black ui elements
qndel Jan 29, 2020
eff2605
add some spell colors
qndel Jan 29, 2020
25074a6
use TILE_SIZE
qndel Jan 29, 2020
e54348f
fixed light being cut off
qndel Jan 29, 2020
ac38cf9
improve light formula
qndel Jan 29, 2020
b4efd54
blue color tweak
qndel Jan 29, 2020
5e5950c
partially fix ui and stuff staying in main menu
qndel Jan 29, 2020
8512ece
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Jan 29, 2020
0463732
get rid of the fps stuff
qndel Jan 29, 2020
ecec16a
some cleanup
qndel Jan 29, 2020
3453733
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Jan 29, 2020
9e5e19c
Hackity hack hack
glebm Jan 29, 2020
9ec77c1
Merge pull request #1 from glebm/pixellight
qndel Jan 29, 2020
1bb6082
Merge branch 'pixellight' of https://github.com/qndel/devilutionX int…
qndel Jan 29, 2020
fe6d0a0
some code cleanup, fix compiling
qndel Jan 30, 2020
5304c54
fix static lights on first load
qndel Jan 30, 2020
ab91502
remove SDL_Logs
qndel Jan 30, 2020
bb09beb
crappy fix, cant do better
qndel Jan 30, 2020
986c2b1
everything fully works! - except cursor
qndel Jan 31, 2020
04499d6
use unused variable to avoid modifying saves
qndel Jan 31, 2020
9eae567
small fix
qndel Jan 31, 2020
1db3a59
remove unused extern
qndel Jan 31, 2020
9171d12
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Jan 31, 2020
1b79376
merge
qndel Feb 1, 2020
596036d
working shitcode
qndel Feb 1, 2020
afec01d
working shitcode
qndel Feb 1, 2020
a9c3c3d
everything works again
qndel Feb 1, 2020
8e1fb0f
fix conflicts
qndel Feb 1, 2020
8df54cc
fix build - define POINT
qndel Feb 1, 2020
974bb74
cursor fully works
qndel Feb 1, 2020
055d40b
rewrite red on pause/death
qndel Feb 1, 2020
bb9b998
fix light on lags
qndel Feb 1, 2020
bb54e16
rewrite light color map, apply to all missiles
qndel Feb 2, 2020
b6a0067
handle different arrows properly
qndel Feb 2, 2020
a5af9d4
staticLights into vector
qndel Feb 2, 2020
f17ba0e
fix some warnings
qndel Feb 2, 2020
e797a45
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 2, 2020
b9ad301
revert at, doesnt work lol
qndel Feb 3, 2020
927c569
saving to character - careful, might break char
qndel Feb 3, 2020
ca62251
restore formatting
qndel Feb 3, 2020
3388741
restore formatting
qndel Feb 3, 2020
82353d0
minor tweaks
qndel Feb 3, 2020
c7402b9
im done with this shit
qndel Feb 4, 2020
25b9ab3
build fix
qndel Feb 4, 2020
64ee8cf
fix monster light
qndel Feb 5, 2020
e9f789a
small tweaks
qndel Feb 5, 2020
be17cdd
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 8, 2020
f6a442e
memory optimizations
qndel Feb 8, 2020
721d2b6
formatting
qndel Feb 8, 2020
3a37c18
adjust light position
qndel Feb 8, 2020
27928c6
even less memory
qndel Feb 8, 2020
8e52b39
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 8, 2020
7dbec08
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 9, 2020
f2920ca
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 9, 2020
0750dda
fix merge conflict
qndel Feb 9, 2020
bfd7770
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 11, 2020
8663102
fix conflict
qndel Feb 17, 2020
8c1e6d5
everything broke
qndel Feb 19, 2020
d9a17ec
restoring includes
qndel Feb 19, 2020
534cb50
Merge branch 'pixellight' of https://github.com/qndel/devilutionX int…
qndel Feb 19, 2020
1092c01
disable light if upscale 0
qndel Feb 19, 2020
e7bef88
disable light during screenshots
qndel Feb 19, 2020
353e705
minor cleanup
qndel Feb 19, 2020
83c5dff
poisoned water color / change light to lighten_only
qndel Feb 19, 2020
e93f166
enable light in town (WIP)
qndel Feb 22, 2020
dd32574
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 22, 2020
8be4d0c
light in town
qndel Feb 23, 2020
ead0adc
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 23, 2020
5b68cbf
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Mar 17, 2020
fee9c54
fix conflict
qndel Mar 29, 2020
28fa025
fixed conflicts
qndel Apr 11, 2020
83650e9
fixed conflicts2
qndel Apr 11, 2020
a572009
update enums
qndel Apr 11, 2020
d43a212
fix light
qndel Apr 11, 2020
ccecde6
fix space
qndel Apr 12, 2020
a25689c
move town light to new mpq in save
qndel Apr 12, 2020
939c049
fix size
qndel Apr 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Source/scrollrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,15 @@ extern void DrawControllerModifierHints();
*/
void DrawView(int StartX, int StartY)
{
#ifdef PIXEL_LIGHT
gpBuffer = (BYTE *)pal_surface->pixels;
memset(gpBuffer, 0, sizeof(gpBuffer));
AJenbo marked this conversation as resolved.
Show resolved Hide resolved
#endif
DrawGame(StartX, StartY);
#ifdef PIXEL_LIGHT
gpBuffer = (BYTE *)ui_surface->pixels;
memset(gpBuffer, 0, sizeof(gpBuffer));
#endif
if (automapflag) {
DrawAutomap();
}
Expand Down
4 changes: 4 additions & 0 deletions Source/scrollrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ void DrawAndBlit();
extern char *szMonModeAssert[18];
extern char *szPlrModeAssert[12];

#ifdef PIXEL_LIGHT
extern SDL_Surface *pal_surface;
extern SDL_Surface *ui_surface;
#endif
#endif /* __SCROLLRT_H__ */
65 changes: 46 additions & 19 deletions SourceX/dx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ SDL_Surface *renderer_texture_surface = nullptr;
/** 8-bit surface wrapper around #gpBuffer */
SDL_Surface *pal_surface;

#ifdef PIXEL_LIGHT
SDL_Surface *ui_surface;
SDL_Surface *ui_surface_24;
SDL_Texture *ui_texture;
#endif

static void dx_create_back_buffer()
{
pal_surface = SDL_CreateRGBSurfaceWithFormat(0, BUFFER_WIDTH, BUFFER_HEIGHT, 8, SDL_PIXELFORMAT_INDEX8);
Expand Down Expand Up @@ -216,10 +222,6 @@ void LimitFrameRate()
}

#ifdef PIXEL_LIGHT
SDL_Surface *lightSurf;
SDL_Texture *lightTex;

SDL_Surface *fpsVision;
SDL_Texture *fpsTex;

SDL_Surface *predrawnEllipses[20];
Expand Down Expand Up @@ -294,7 +296,6 @@ void drawRadius(int lid, int row, int col, int radius, int color)
}
sx += xoff;
sy += yoff;
SDL_Rect rect;

int srcx = width / 2;
int srcy = height / 2;
Expand All @@ -303,6 +304,7 @@ void drawRadius(int lid, int row, int col, int radius, int color)
int offsetx = targetx - srcx;
int offsety = targety - srcy;

SDL_Rect rect;
rect.x = offsetx;
rect.y = offsety;
rect.w = width;
Expand Down Expand Up @@ -362,7 +364,7 @@ void predrawEllipse(int radius)
void prepareFPS(){
if (!frameflag)
return;
fpsVision = SDL_CreateRGBSurfaceWithFormat(0, 50, 50, SDL_BITSPERPIXEL(format), format);
SDL_Surface *fpsVision = SDL_CreateRGBSurfaceWithFormat(0, 50, 50, SDL_BITSPERPIXEL(format), format);
if (fpsVision == NULL)
ErrSdl();
if(SDL_SetSurfaceBlendMode(fpsVision, SDL_BLENDMODE_ADD) < 0)
Expand All @@ -372,6 +374,7 @@ void prepareFPS(){
fpsTex = SDL_CreateTextureFromSurface(renderer, fpsVision);
if (fpsTex == NULL)
ErrSdl();
SDL_FreeSurface(fpsVision);
if(SDL_SetTextureBlendMode(fpsTex, SDL_BLENDMODE_ADD) < 0)
ErrSdl();
}
Expand Down Expand Up @@ -399,9 +402,6 @@ void prepareLight()
SDL_RenderGetLogicalSize(renderer, &width, &height);
if (SDL_QueryTexture(texture, &format, nullptr, nullptr, nullptr) < 0)
ErrSdl();
lightSurf = SDL_CreateRGBSurfaceWithFormat(0, width, height, SDL_BITSPERPIXEL(format), format);
if (lightSurf == NULL)
ErrSdl();
for (int i = 1; i <= 15; i++) {
predrawnEllipses[i] = SDL_CreateRGBSurfaceWithFormat(0, width, height, SDL_BITSPERPIXEL(format), format);
if (predrawnEllipses[i] == NULL)
Expand All @@ -417,6 +417,24 @@ void prepareLight()
if (SDL_SetTextureBlendMode(ellipsesTextures[i], SDL_BLENDMODE_ADD) < 0)
ErrSdl();
}

ui_surface = SDL_CreateRGBSurfaceWithFormat(0, BUFFER_WIDTH, BUFFER_HEIGHT, 8, SDL_PIXELFORMAT_INDEX8);
//ui_surface = SDL_CreateRGBSurfaceWithFormat(0, width, height, SDL_BITSPERPIXEL(format), format);
if (ui_surface == NULL)
ErrSdl();
if (SDLC_SetSurfaceColors(ui_surface, palette) < 0)
ErrSdl();
if (SDL_FillRect(ui_surface, NULL, SDL_MapRGB(ui_surface->format, 0, 125, 0)) < 0)
ErrSdl();

ui_surface_24 = SDL_CreateRGBSurfaceWithFormat(0, width, height, SDL_BITSPERPIXEL(format), format);
if (ui_surface_24 == NULL)
ErrSdl();
ui_texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, width, height);
if (ui_texture == NULL)
ErrSdl();
if (SDL_SetTextureBlendMode(ui_texture, SDL_BLENDMODE_ADD) < 0)
ErrSdl();
}

#endif
Expand All @@ -439,11 +457,6 @@ void RenderPresent()
prepareLight();
prepareFPS();
}
if(SDL_FillRect(lightSurf, NULL, SDL_MapRGB(lightSurf->format, 0, 0, 0)) < 0)
ErrSdl();
lightTex = SDL_CreateTextureFromSurface(renderer, lightSurf);
if (lightTex == NULL)
ErrSdl();
SDL_BlendMode bm;
switch (testvar5) {
case 0:
Expand All @@ -459,8 +472,6 @@ void RenderPresent()
bm = SDL_BLENDMODE_MOD;
break;
}
if(SDL_SetTextureBlendMode(lightTex, bm) < 0)
ErrSdl();
if(SDL_SetTextureBlendMode(texture, bm) < 0)
ErrSdl();
} else {
Expand All @@ -484,17 +495,33 @@ void RenderPresent()

#ifdef PIXEL_LIGHT
if (testvar3 != 0 && leveltype != DTYPE_TOWN) {
if (SDL_RenderCopy(renderer, lightTex, NULL, NULL) < 0)
ErrSdl();
lightLoop();
showFPS();
SDL_DestroyTexture(lightTex);
}

#endif
if (SDL_RenderCopy(renderer, texture, NULL, NULL) <= -1) {
ErrSdl();
}
#ifdef PIXEL_LIGHT
if (testvar3 != 0 && leveltype != DTYPE_TOWN) {
//SDL_Surface *tmp = SDL_ConvertSurface(ui_surface, GetOutputSurface()->format, 0);
//if (tmp == NULL)
// ErrSdl();
SDL_Rect rect;
rect.x = 0;
rect.y = 0;
rect.w = 250;
rect.h = 250;
if(SDL_BlitSurface(ui_surface, NULL, ui_surface_24, &rect) < 0)
ErrSdl();
if (SDL_UpdateTexture(ui_texture, NULL, ui_surface_24->pixels, ui_surface_24->pitch) < 0)
ErrSdl();
//SDL_FreeSurface(tmp);
if (SDL_RenderCopy(renderer, ui_texture, NULL, NULL) < 0)
ErrSdl();
}
#endif
SDL_RenderPresent(renderer);
} else {
if (SDL_UpdateWindowSurface(window) <= -1) {
Expand Down