taisei/src/stagedraw.c

1233 lines
33 KiB
C
Raw Normal View History

/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
2018-01-04 18:14:31 +01:00
* Copyright (c) 2011-2018, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2018, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "global.h"
#include "stagedraw.h"
#include "stagetext.h"
#include "video.h"
#include "resource/postprocess.h"
#include "entity.h"
#ifdef DEBUG
#define GRAPHS_DEFAULT 1
2017-12-13 20:05:12 +01:00
#define OBJPOOLSTATS_DEFAULT 1
#else
#define GRAPHS_DEFAULT 0
2017-12-13 20:05:12 +01:00
#define OBJPOOLSTATS_DEFAULT 0
#endif
Add Reimu Hakurei as a playable character (#106) * Reimu (#101) * add the reimu * Add Reimu story * account for various blunders * add reimu dialog picture * Reimu: WIP yin-yang orbs * reimu: fix up indents * Reimu: swap the shotmode names to match the kanji order in her Japanese name * Reimu: compatibility with the latest system * WIP ReimuA crap * ReimuA homing trails * more ReimuA stuff * more ReimuA adjustments + enhanced DPS stats * Reimu: stubs for new player animation sequences * Reimu: occupy the 0th character slot * Reimu: tweak needle sprite * Reimu: buff movement speed to better match Touhou * Reimu: fixup for the recent projectile changes * ReimuA: make homing shots a bit smaller; give them custom effect on collision * Reimu: add intermediate frames; move some loose sprites to the atlas * Reimu: fix compile errors * replace DBL_MAX by INFINITY * Don’t draw reimu orbs twice fixes #127 * add new reimu dialog pic * ReimuA adjustments (mostly homing); it's still OP * wip ReimuB gaps * still not sure where i'm going with these gaps * meh * Reimu: premultiplied alpha fixups after rebase * reimuB shot pattern with basic power scaling (not balanced at all) * reimuB: some lame-ass particle effects * ReimuB bomb effect prototype * reimuA bomb prototype * fix reimu shots for the new damage system * Reimu: use the new player_is_bomb_active() function, add placeholder BG for ReimuB * some reimuB bomb projectiles * ReimuB bomb bg and some framebuffer utils required to support it. Might reuse this at least in part for ReimuA unless we come up with something better. * hack to fix ReimuB bomb fade; refactoring needed * reimuA damaging bombs * fix ub * prevent nan when reimuA bombs without enemies present * add a bomb_bg to reimuA * ... * various fantasy seal tweaks * Reimu: placeholder bomb sounds; slight fantasy seal buff * fix null pointer dereference * Reimu "balance" adjustments; minor fixes * putting bandaids over gunshot wounds * Add aoe damage and bullet cancel to ReimuB's bomb * more exorcism porn * make reimu bomb bg runes better visible on dark backgrounds * More ReimuA shot changes
2018-08-11 21:13:48 +02:00
typedef struct CustomFramebuffer {
LIST_INTERFACE(struct CustomFramebuffer);
Framebuffer *fb;
Add Reimu Hakurei as a playable character (#106) * Reimu (#101) * add the reimu * Add Reimu story * account for various blunders * add reimu dialog picture * Reimu: WIP yin-yang orbs * reimu: fix up indents * Reimu: swap the shotmode names to match the kanji order in her Japanese name * Reimu: compatibility with the latest system * WIP ReimuA crap * ReimuA homing trails * more ReimuA stuff * more ReimuA adjustments + enhanced DPS stats * Reimu: stubs for new player animation sequences * Reimu: occupy the 0th character slot * Reimu: tweak needle sprite * Reimu: buff movement speed to better match Touhou * Reimu: fixup for the recent projectile changes * ReimuA: make homing shots a bit smaller; give them custom effect on collision * Reimu: add intermediate frames; move some loose sprites to the atlas * Reimu: fix compile errors * replace DBL_MAX by INFINITY * Don’t draw reimu orbs twice fixes #127 * add new reimu dialog pic * ReimuA adjustments (mostly homing); it's still OP * wip ReimuB gaps * still not sure where i'm going with these gaps * meh * Reimu: premultiplied alpha fixups after rebase * reimuB shot pattern with basic power scaling (not balanced at all) * reimuB: some lame-ass particle effects * ReimuB bomb effect prototype * reimuA bomb prototype * fix reimu shots for the new damage system * Reimu: use the new player_is_bomb_active() function, add placeholder BG for ReimuB * some reimuB bomb projectiles * ReimuB bomb bg and some framebuffer utils required to support it. Might reuse this at least in part for ReimuA unless we come up with something better. * hack to fix ReimuB bomb fade; refactoring needed * reimuA damaging bombs * fix ub * prevent nan when reimuA bombs without enemies present * add a bomb_bg to reimuA * ... * various fantasy seal tweaks * Reimu: placeholder bomb sounds; slight fantasy seal buff * fix null pointer dereference * Reimu "balance" adjustments; minor fixes * putting bandaids over gunshot wounds * Add aoe damage and bullet cancel to ReimuB's bomb * more exorcism porn * make reimu bomb bg runes better visible on dark backgrounds * More ReimuA shot changes
2018-08-11 21:13:48 +02:00
float scale;
StageFBPair scaling_base;
} CustomFramebuffer;
2017-11-23 03:25:53 +01:00
static struct {
struct {
ShaderProgram *shader;
Font *font;
struct {
Color active;
Color inactive;
Color label;
} color;
2017-11-23 03:25:53 +01:00
} hud_text;
struct {
ShaderProgram *fxaa;
ShaderProgram *copy_depth;
} shaders;
PostprocessShader *viewport_pp;
FBPair fb_pairs[NUM_FBPAIRS];
Add Reimu Hakurei as a playable character (#106) * Reimu (#101) * add the reimu * Add Reimu story * account for various blunders * add reimu dialog picture * Reimu: WIP yin-yang orbs * reimu: fix up indents * Reimu: swap the shotmode names to match the kanji order in her Japanese name * Reimu: compatibility with the latest system * WIP ReimuA crap * ReimuA homing trails * more ReimuA stuff * more ReimuA adjustments + enhanced DPS stats * Reimu: stubs for new player animation sequences * Reimu: occupy the 0th character slot * Reimu: tweak needle sprite * Reimu: buff movement speed to better match Touhou * Reimu: fixup for the recent projectile changes * ReimuA: make homing shots a bit smaller; give them custom effect on collision * Reimu: add intermediate frames; move some loose sprites to the atlas * Reimu: fix compile errors * replace DBL_MAX by INFINITY * Don’t draw reimu orbs twice fixes #127 * add new reimu dialog pic * ReimuA adjustments (mostly homing); it's still OP * wip ReimuB gaps * still not sure where i'm going with these gaps * meh * Reimu: premultiplied alpha fixups after rebase * reimuB shot pattern with basic power scaling (not balanced at all) * reimuB: some lame-ass particle effects * ReimuB bomb effect prototype * reimuA bomb prototype * fix reimu shots for the new damage system * Reimu: use the new player_is_bomb_active() function, add placeholder BG for ReimuB * some reimuB bomb projectiles * ReimuB bomb bg and some framebuffer utils required to support it. Might reuse this at least in part for ReimuA unless we come up with something better. * hack to fix ReimuB bomb fade; refactoring needed * reimuA damaging bombs * fix ub * prevent nan when reimuA bombs without enemies present * add a bomb_bg to reimuA * ... * various fantasy seal tweaks * Reimu: placeholder bomb sounds; slight fantasy seal buff * fix null pointer dereference * Reimu "balance" adjustments; minor fixes * putting bandaids over gunshot wounds * Add aoe damage and bullet cancel to ReimuB's bomb * more exorcism porn * make reimu bomb bg runes better visible on dark backgrounds * More ReimuA shot changes
2018-08-11 21:13:48 +02:00
CustomFramebuffer *custom_fbs;
bool framerate_graphs;
2017-12-13 20:05:12 +01:00
bool objpool_stats;
#ifdef DEBUG
Sprite dummy;
#endif
} stagedraw = {
.hud_text.color = {
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
// NOTE: premultiplied alpha
.active = { 1.00, 1.00, 1.00, 1.00 },
.inactive = { 0.49, 0.49, 0.49, 0.70 },
.label = { 0.49, 0.49, 0.49, 0.70 },
}
};
2017-11-23 03:25:53 +01:00
static double fb_scale(void) {
int vp_width, vp_height;
video_get_viewport_size(&vp_width, &vp_height);
return (double)vp_height / SCREEN_H;
}
static void set_fb_size(StageFBPair fb_id, int *w, int *h) {
double scale = fb_scale();
switch(fb_id) {
case FBPAIR_BG:
scale *= config_get_float(CONFIG_BG_QUALITY);
break;
default:
scale *= config_get_float(CONFIG_FG_QUALITY);
break;
}
scale = sanitize_scale(scale);
*w = round(VIEWPORT_W * scale);
*h = round(VIEWPORT_H * scale);
}
static void update_fb_size(StageFBPair fb_id) {
int w, h;
set_fb_size(fb_id, &w, &h);
fbpair_resize_all(stagedraw.fb_pairs + fb_id, w, h);
fbpair_viewport(stagedraw.fb_pairs + fb_id, 0, 0, w, h);
Add Reimu Hakurei as a playable character (#106) * Reimu (#101) * add the reimu * Add Reimu story * account for various blunders * add reimu dialog picture * Reimu: WIP yin-yang orbs * reimu: fix up indents * Reimu: swap the shotmode names to match the kanji order in her Japanese name * Reimu: compatibility with the latest system * WIP ReimuA crap * ReimuA homing trails * more ReimuA stuff * more ReimuA adjustments + enhanced DPS stats * Reimu: stubs for new player animation sequences * Reimu: occupy the 0th character slot * Reimu: tweak needle sprite * Reimu: buff movement speed to better match Touhou * Reimu: fixup for the recent projectile changes * ReimuA: make homing shots a bit smaller; give them custom effect on collision * Reimu: add intermediate frames; move some loose sprites to the atlas * Reimu: fix compile errors * replace DBL_MAX by INFINITY * Don’t draw reimu orbs twice fixes #127 * add new reimu dialog pic * ReimuA adjustments (mostly homing); it's still OP * wip ReimuB gaps * still not sure where i'm going with these gaps * meh * Reimu: premultiplied alpha fixups after rebase * reimuB shot pattern with basic power scaling (not balanced at all) * reimuB: some lame-ass particle effects * ReimuB bomb effect prototype * reimuA bomb prototype * fix reimu shots for the new damage system * Reimu: use the new player_is_bomb_active() function, add placeholder BG for ReimuB * some reimuB bomb projectiles * ReimuB bomb bg and some framebuffer utils required to support it. Might reuse this at least in part for ReimuA unless we come up with something better. * hack to fix ReimuB bomb fade; refactoring needed * reimuA damaging bombs * fix ub * prevent nan when reimuA bombs without enemies present * add a bomb_bg to reimuA * ... * various fantasy seal tweaks * Reimu: placeholder bomb sounds; slight fantasy seal buff * fix null pointer dereference * Reimu "balance" adjustments; minor fixes * putting bandaids over gunshot wounds * Add aoe damage and bullet cancel to ReimuB's bomb * more exorcism porn * make reimu bomb bg runes better visible on dark backgrounds * More ReimuA shot changes
2018-08-11 21:13:48 +02:00
if(fb_id != FBPAIR_FG_AUX) {
for(CustomFramebuffer *cfb = stagedraw.custom_fbs; cfb; cfb = cfb->next) {
if(cfb->scaling_base == fb_id) {
int sw = w * cfb->scale;
int sh = h * cfb->scale;
for(uint i = 0; i < FRAMEBUFFER_MAX_ATTACHMENTS; ++i) {
fbutil_resize_attachment(cfb->fb, i, sw, sh);
Add Reimu Hakurei as a playable character (#106) * Reimu (#101) * add the reimu * Add Reimu story * account for various blunders * add reimu dialog picture * Reimu: WIP yin-yang orbs * reimu: fix up indents * Reimu: swap the shotmode names to match the kanji order in her Japanese name * Reimu: compatibility with the latest system * WIP ReimuA crap * ReimuA homing trails * more ReimuA stuff * more ReimuA adjustments + enhanced DPS stats * Reimu: stubs for new player animation sequences * Reimu: occupy the 0th character slot * Reimu: tweak needle sprite * Reimu: buff movement speed to better match Touhou * Reimu: fixup for the recent projectile changes * ReimuA: make homing shots a bit smaller; give them custom effect on collision * Reimu: add intermediate frames; move some loose sprites to the atlas * Reimu: fix compile errors * replace DBL_MAX by INFINITY * Don’t draw reimu orbs twice fixes #127 * add new reimu dialog pic * ReimuA adjustments (mostly homing); it's still OP * wip ReimuB gaps * still not sure where i'm going with these gaps * meh * Reimu: premultiplied alpha fixups after rebase * reimuB shot pattern with basic power scaling (not balanced at all) * reimuB: some lame-ass particle effects * ReimuB bomb effect prototype * reimuA bomb prototype * fix reimu shots for the new damage system * Reimu: use the new player_is_bomb_active() function, add placeholder BG for ReimuB * some reimuB bomb projectiles * ReimuB bomb bg and some framebuffer utils required to support it. Might reuse this at least in part for ReimuA unless we come up with something better. * hack to fix ReimuB bomb fade; refactoring needed * reimuA damaging bombs * fix ub * prevent nan when reimuA bombs without enemies present * add a bomb_bg to reimuA * ... * various fantasy seal tweaks * Reimu: placeholder bomb sounds; slight fantasy seal buff * fix null pointer dereference * Reimu "balance" adjustments; minor fixes * putting bandaids over gunshot wounds * Add aoe damage and bullet cancel to ReimuB's bomb * more exorcism porn * make reimu bomb bg runes better visible on dark backgrounds * More ReimuA shot changes
2018-08-11 21:13:48 +02:00
}
r_framebuffer_viewport(cfb->fb, 0, 0, sw, sh);
Add Reimu Hakurei as a playable character (#106) * Reimu (#101) * add the reimu * Add Reimu story * account for various blunders * add reimu dialog picture * Reimu: WIP yin-yang orbs * reimu: fix up indents * Reimu: swap the shotmode names to match the kanji order in her Japanese name * Reimu: compatibility with the latest system * WIP ReimuA crap * ReimuA homing trails * more ReimuA stuff * more ReimuA adjustments + enhanced DPS stats * Reimu: stubs for new player animation sequences * Reimu: occupy the 0th character slot * Reimu: tweak needle sprite * Reimu: buff movement speed to better match Touhou * Reimu: fixup for the recent projectile changes * ReimuA: make homing shots a bit smaller; give them custom effect on collision * Reimu: add intermediate frames; move some loose sprites to the atlas * Reimu: fix compile errors * replace DBL_MAX by INFINITY * Don’t draw reimu orbs twice fixes #127 * add new reimu dialog pic * ReimuA adjustments (mostly homing); it's still OP * wip ReimuB gaps * still not sure where i'm going with these gaps * meh * Reimu: premultiplied alpha fixups after rebase * reimuB shot pattern with basic power scaling (not balanced at all) * reimuB: some lame-ass particle effects * ReimuB bomb effect prototype * reimuA bomb prototype * fix reimu shots for the new damage system * Reimu: use the new player_is_bomb_active() function, add placeholder BG for ReimuB * some reimuB bomb projectiles * ReimuB bomb bg and some framebuffer utils required to support it. Might reuse this at least in part for ReimuA unless we come up with something better. * hack to fix ReimuB bomb fade; refactoring needed * reimuA damaging bombs * fix ub * prevent nan when reimuA bombs without enemies present * add a bomb_bg to reimuA * ... * various fantasy seal tweaks * Reimu: placeholder bomb sounds; slight fantasy seal buff * fix null pointer dereference * Reimu "balance" adjustments; minor fixes * putting bandaids over gunshot wounds * Add aoe damage and bullet cancel to ReimuB's bomb * more exorcism porn * make reimu bomb bg runes better visible on dark backgrounds * More ReimuA shot changes
2018-08-11 21:13:48 +02:00
}
}
}
}
static bool stage_draw_event(SDL_Event *e, void *arg) {
if(!IS_TAISEI_EVENT(e->type)) {
return false;
}
switch(TAISEI_EVENT(e->type)) {
case TE_VIDEO_MODE_CHANGED: {
for(uint i = 0; i < NUM_FBPAIRS; ++i) {
update_fb_size(i);
}
break;
}
case TE_CONFIG_UPDATED: {
switch(e->user.code) {
case CONFIG_FG_QUALITY: {
update_fb_size(FBPAIR_FG);
update_fb_size(FBPAIR_FG_AUX);
break;
}
case CONFIG_BG_QUALITY: {
update_fb_size(FBPAIR_BG);
break;
}
}
break;
}
}
return false;
}
static void stage_draw_setup_framebuffers(void) {
int fg_width, fg_height, bg_width, bg_height;
FBAttachmentConfig a[2], *a_color, *a_depth;
memset(a, 0, sizeof(a));
a_color = &a[0];
a_depth = &a[1];
a_color->attachment = FRAMEBUFFER_ATTACH_COLOR0;
a_depth->attachment = FRAMEBUFFER_ATTACH_DEPTH;
set_fb_size(FBPAIR_FG, &fg_width, &fg_height);
set_fb_size(FBPAIR_BG, &bg_width, &bg_height);
// Set up some parameters shared by all attachments
TextureParams tex_common = {
.filter.min = TEX_FILTER_LINEAR,
.filter.mag = TEX_FILTER_LINEAR,
.wrap.s = TEX_WRAP_MIRROR,
.wrap.t = TEX_WRAP_MIRROR,
};
memcpy(&a_color->tex_params, &tex_common, sizeof(tex_common));
memcpy(&a_depth->tex_params, &tex_common, sizeof(tex_common));
// Foreground: 1 RGB texture per FB
a_color->tex_params.type = TEX_TYPE_RGB;
a_color->tex_params.width = fg_width;
a_color->tex_params.height = fg_height;
fbpair_create(stagedraw.fb_pairs + FBPAIR_FG, 1, a);
fbpair_viewport(stagedraw.fb_pairs + FBPAIR_FG, 0, 0, fg_width, fg_height);
// Foreground auxiliary: 1 RGBA texture per FB
a_color->tex_params.type = TEX_TYPE_RGBA;
fbpair_create(stagedraw.fb_pairs + FBPAIR_FG_AUX, 1, a);
fbpair_viewport(stagedraw.fb_pairs + FBPAIR_FG_AUX, 0, 0, fg_width, fg_height);
// Background: 1 RGB texture + depth per FB
a_color->tex_params.type = TEX_TYPE_RGB;
a_color->tex_params.width = bg_width;
a_color->tex_params.height = bg_height;
a_depth->tex_params.type = TEX_TYPE_DEPTH;
a_depth->tex_params.width = bg_width;
a_depth->tex_params.height = bg_height;
fbpair_create(stagedraw.fb_pairs + FBPAIR_BG, 2, a);
fbpair_viewport(stagedraw.fb_pairs + FBPAIR_BG, 0, 0, bg_width, bg_height);
}
Add Reimu Hakurei as a playable character (#106) * Reimu (#101) * add the reimu * Add Reimu story * account for various blunders * add reimu dialog picture * Reimu: WIP yin-yang orbs * reimu: fix up indents * Reimu: swap the shotmode names to match the kanji order in her Japanese name * Reimu: compatibility with the latest system * WIP ReimuA crap * ReimuA homing trails * more ReimuA stuff * more ReimuA adjustments + enhanced DPS stats * Reimu: stubs for new player animation sequences * Reimu: occupy the 0th character slot * Reimu: tweak needle sprite * Reimu: buff movement speed to better match Touhou * Reimu: fixup for the recent projectile changes * ReimuA: make homing shots a bit smaller; give them custom effect on collision * Reimu: add intermediate frames; move some loose sprites to the atlas * Reimu: fix compile errors * replace DBL_MAX by INFINITY * Don’t draw reimu orbs twice fixes #127 * add new reimu dialog pic * ReimuA adjustments (mostly homing); it's still OP * wip ReimuB gaps * still not sure where i'm going with these gaps * meh * Reimu: premultiplied alpha fixups after rebase * reimuB shot pattern with basic power scaling (not balanced at all) * reimuB: some lame-ass particle effects * ReimuB bomb effect prototype * reimuA bomb prototype * fix reimu shots for the new damage system * Reimu: use the new player_is_bomb_active() function, add placeholder BG for ReimuB * some reimuB bomb projectiles * ReimuB bomb bg and some framebuffer utils required to support it. Might reuse this at least in part for ReimuA unless we come up with something better. * hack to fix ReimuB bomb fade; refactoring needed * reimuA damaging bombs * fix ub * prevent nan when reimuA bombs without enemies present * add a bomb_bg to reimuA * ... * various fantasy seal tweaks * Reimu: placeholder bomb sounds; slight fantasy seal buff * fix null pointer dereference * Reimu "balance" adjustments; minor fixes * putting bandaids over gunshot wounds * Add aoe damage and bullet cancel to ReimuB's bomb * more exorcism porn * make reimu bomb bg runes better visible on dark backgrounds * More ReimuA shot changes
2018-08-11 21:13:48 +02:00
static Framebuffer* add_custom_framebuffer(StageFBPair fbtype, float scale_factor, uint num_attachments, FBAttachmentConfig attachments[num_attachments]) {
CustomFramebuffer *cfb = calloc(1, sizeof(*cfb));
list_push(&stagedraw.custom_fbs, cfb);
FBAttachmentConfig cfg[num_attachments];
memcpy(cfg, attachments, sizeof(cfg));
int width, height;
set_fb_size(fbtype, &width, &height);
cfb->scale = scale_factor;
width *= scale_factor;
height *= scale_factor;
for(uint i = 0; i < num_attachments; ++i) {
cfg[i].tex_params.width = width;
cfg[i].tex_params.height = height;
}
cfb->fb = r_framebuffer_create();
fbutil_create_attachments(cfb->fb, num_attachments, cfg);
r_framebuffer_viewport(cfb->fb, 0, 0, width, height);
r_framebuffer_clear(cfb->fb, CLEAR_ALL, RGBA(0, 0, 0, 0), 1);
Add Reimu Hakurei as a playable character (#106) * Reimu (#101) * add the reimu * Add Reimu story * account for various blunders * add reimu dialog picture * Reimu: WIP yin-yang orbs * reimu: fix up indents * Reimu: swap the shotmode names to match the kanji order in her Japanese name * Reimu: compatibility with the latest system * WIP ReimuA crap * ReimuA homing trails * more ReimuA stuff * more ReimuA adjustments + enhanced DPS stats * Reimu: stubs for new player animation sequences * Reimu: occupy the 0th character slot * Reimu: tweak needle sprite * Reimu: buff movement speed to better match Touhou * Reimu: fixup for the recent projectile changes * ReimuA: make homing shots a bit smaller; give them custom effect on collision * Reimu: add intermediate frames; move some loose sprites to the atlas * Reimu: fix compile errors * replace DBL_MAX by INFINITY * Don’t draw reimu orbs twice fixes #127 * add new reimu dialog pic * ReimuA adjustments (mostly homing); it's still OP * wip ReimuB gaps * still not sure where i'm going with these gaps * meh * Reimu: premultiplied alpha fixups after rebase * reimuB shot pattern with basic power scaling (not balanced at all) * reimuB: some lame-ass particle effects * ReimuB bomb effect prototype * reimuA bomb prototype * fix reimu shots for the new damage system * Reimu: use the new player_is_bomb_active() function, add placeholder BG for ReimuB * some reimuB bomb projectiles * ReimuB bomb bg and some framebuffer utils required to support it. Might reuse this at least in part for ReimuA unless we come up with something better. * hack to fix ReimuB bomb fade; refactoring needed * reimuA damaging bombs * fix ub * prevent nan when reimuA bombs without enemies present * add a bomb_bg to reimuA * ... * various fantasy seal tweaks * Reimu: placeholder bomb sounds; slight fantasy seal buff * fix null pointer dereference * Reimu "balance" adjustments; minor fixes * putting bandaids over gunshot wounds * Add aoe damage and bullet cancel to ReimuB's bomb * more exorcism porn * make reimu bomb bg runes better visible on dark backgrounds * More ReimuA shot changes
2018-08-11 21:13:48 +02:00
return cfb->fb;
Add Reimu Hakurei as a playable character (#106) * Reimu (#101) * add the reimu * Add Reimu story * account for various blunders * add reimu dialog picture * Reimu: WIP yin-yang orbs * reimu: fix up indents * Reimu: swap the shotmode names to match the kanji order in her Japanese name * Reimu: compatibility with the latest system * WIP ReimuA crap * ReimuA homing trails * more ReimuA stuff * more ReimuA adjustments + enhanced DPS stats * Reimu: stubs for new player animation sequences * Reimu: occupy the 0th character slot * Reimu: tweak needle sprite * Reimu: buff movement speed to better match Touhou * Reimu: fixup for the recent projectile changes * ReimuA: make homing shots a bit smaller; give them custom effect on collision * Reimu: add intermediate frames; move some loose sprites to the atlas * Reimu: fix compile errors * replace DBL_MAX by INFINITY * Don’t draw reimu orbs twice fixes #127 * add new reimu dialog pic * ReimuA adjustments (mostly homing); it's still OP * wip ReimuB gaps * still not sure where i'm going with these gaps * meh * Reimu: premultiplied alpha fixups after rebase * reimuB shot pattern with basic power scaling (not balanced at all) * reimuB: some lame-ass particle effects * ReimuB bomb effect prototype * reimuA bomb prototype * fix reimu shots for the new damage system * Reimu: use the new player_is_bomb_active() function, add placeholder BG for ReimuB * some reimuB bomb projectiles * ReimuB bomb bg and some framebuffer utils required to support it. Might reuse this at least in part for ReimuA unless we come up with something better. * hack to fix ReimuB bomb fade; refactoring needed * reimuA damaging bombs * fix ub * prevent nan when reimuA bombs without enemies present * add a bomb_bg to reimuA * ... * various fantasy seal tweaks * Reimu: placeholder bomb sounds; slight fantasy seal buff * fix null pointer dereference * Reimu "balance" adjustments; minor fixes * putting bandaids over gunshot wounds * Add aoe damage and bullet cancel to ReimuB's bomb * more exorcism porn * make reimu bomb bg runes better visible on dark backgrounds * More ReimuA shot changes
2018-08-11 21:13:48 +02:00
}
Framebuffer* stage_add_foreground_framebuffer(float scale_factor, uint num_attachments, FBAttachmentConfig attachments[num_attachments]) {
return add_custom_framebuffer(FBPAIR_FG, scale_factor, num_attachments, attachments);
}
Framebuffer* stage_add_background_framebuffer(float scale_factor, uint num_attachments, FBAttachmentConfig attachments[num_attachments]) {
return add_custom_framebuffer(FBPAIR_BG, scale_factor, num_attachments, attachments);
}
static void stage_draw_destroy_framebuffers(void) {
for(uint i = 0; i < NUM_FBPAIRS; ++i) {
fbpair_destroy(stagedraw.fb_pairs + i);
}
for(CustomFramebuffer *cfb = stagedraw.custom_fbs, *next; cfb; cfb = next) {
next = cfb->next;
fbutil_destroy_attachments(cfb->fb);
r_framebuffer_destroy(cfb->fb);
Add Reimu Hakurei as a playable character (#106) * Reimu (#101) * add the reimu * Add Reimu story * account for various blunders * add reimu dialog picture * Reimu: WIP yin-yang orbs * reimu: fix up indents * Reimu: swap the shotmode names to match the kanji order in her Japanese name * Reimu: compatibility with the latest system * WIP ReimuA crap * ReimuA homing trails * more ReimuA stuff * more ReimuA adjustments + enhanced DPS stats * Reimu: stubs for new player animation sequences * Reimu: occupy the 0th character slot * Reimu: tweak needle sprite * Reimu: buff movement speed to better match Touhou * Reimu: fixup for the recent projectile changes * ReimuA: make homing shots a bit smaller; give them custom effect on collision * Reimu: add intermediate frames; move some loose sprites to the atlas * Reimu: fix compile errors * replace DBL_MAX by INFINITY * Don’t draw reimu orbs twice fixes #127 * add new reimu dialog pic * ReimuA adjustments (mostly homing); it's still OP * wip ReimuB gaps * still not sure where i'm going with these gaps * meh * Reimu: premultiplied alpha fixups after rebase * reimuB shot pattern with basic power scaling (not balanced at all) * reimuB: some lame-ass particle effects * ReimuB bomb effect prototype * reimuA bomb prototype * fix reimu shots for the new damage system * Reimu: use the new player_is_bomb_active() function, add placeholder BG for ReimuB * some reimuB bomb projectiles * ReimuB bomb bg and some framebuffer utils required to support it. Might reuse this at least in part for ReimuA unless we come up with something better. * hack to fix ReimuB bomb fade; refactoring needed * reimuA damaging bombs * fix ub * prevent nan when reimuA bombs without enemies present * add a bomb_bg to reimuA * ... * various fantasy seal tweaks * Reimu: placeholder bomb sounds; slight fantasy seal buff * fix null pointer dereference * Reimu "balance" adjustments; minor fixes * putting bandaids over gunshot wounds * Add aoe damage and bullet cancel to ReimuB's bomb * more exorcism porn * make reimu bomb bg runes better visible on dark backgrounds * More ReimuA shot changes
2018-08-11 21:13:48 +02:00
free(list_unlink(&stagedraw.custom_fbs, cfb));
}
}
void stage_draw_init(void) {
preload_resources(RES_POSTPROCESS, RESF_OPTIONAL,
"viewport",
NULL);
preload_resources(RES_SPRITE, RESF_PERMANENT,
2017-11-23 03:25:53 +01:00
"star",
"hud",
NULL);
preload_resources(RES_TEXTURE, RESF_PERMANENT,
2017-11-23 03:25:53 +01:00
"titletransition",
NULL);
preload_resources(RES_SHADER_PROGRAM, RESF_PERMANENT,
"text_hud",
"text_stagetext",
2017-11-23 03:25:53 +01:00
"ingame_menu",
"sprite_circleclipped_indicator",
"copy_depth",
// TODO: Maybe don't preload this if FXAA is disabled.
// But then we also have to handle the edge case of it being enabled later mid-game.
"fxaa",
#ifdef DEBUG
"sprite_filled_circle",
#endif
2017-11-23 03:25:53 +01:00
NULL);
preload_resources(RES_FONT, RESF_PERMANENT,
"hud",
"mono",
"small",
"monosmall",
NULL);
2017-11-23 03:25:53 +01:00
stagedraw.framerate_graphs = env_get("TAISEI_FRAMERATE_GRAPHS", GRAPHS_DEFAULT);
stagedraw.objpool_stats = env_get("TAISEI_OBJPOOL_STATS", OBJPOOLSTATS_DEFAULT);
2017-12-14 16:07:24 +01:00
if(stagedraw.framerate_graphs) {
preload_resources(RES_SHADER_PROGRAM, RESF_PERMANENT,
2017-12-14 16:07:24 +01:00
"graph",
NULL);
}
if(stagedraw.objpool_stats) {
preload_resources(RES_FONT, RESF_PERMANENT,
"monotiny",
NULL);
}
stagedraw.viewport_pp = get_resource_data(RES_POSTPROCESS, "viewport", RESF_OPTIONAL);
stagedraw.hud_text.shader = r_shader_get("text_hud");
stagedraw.hud_text.font = get_font("hud");
stagedraw.shaders.fxaa = r_shader_get("fxaa");
stagedraw.shaders.copy_depth = r_shader_get("copy_depth");
r_shader_standard();
#ifdef DEBUG
stagedraw.dummy.tex = get_sprite("star")->tex;
stagedraw.dummy.w = 1;
stagedraw.dummy.h = 1;
#endif
stage_draw_setup_framebuffers();
events_register_handler(&(EventHandler) {
stage_draw_event, NULL, EPRIO_SYSTEM,
});
}
void stage_draw_shutdown(void) {
events_unregister_handler(stage_draw_event);
Add Reimu Hakurei as a playable character (#106) * Reimu (#101) * add the reimu * Add Reimu story * account for various blunders * add reimu dialog picture * Reimu: WIP yin-yang orbs * reimu: fix up indents * Reimu: swap the shotmode names to match the kanji order in her Japanese name * Reimu: compatibility with the latest system * WIP ReimuA crap * ReimuA homing trails * more ReimuA stuff * more ReimuA adjustments + enhanced DPS stats * Reimu: stubs for new player animation sequences * Reimu: occupy the 0th character slot * Reimu: tweak needle sprite * Reimu: buff movement speed to better match Touhou * Reimu: fixup for the recent projectile changes * ReimuA: make homing shots a bit smaller; give them custom effect on collision * Reimu: add intermediate frames; move some loose sprites to the atlas * Reimu: fix compile errors * replace DBL_MAX by INFINITY * Don’t draw reimu orbs twice fixes #127 * add new reimu dialog pic * ReimuA adjustments (mostly homing); it's still OP * wip ReimuB gaps * still not sure where i'm going with these gaps * meh * Reimu: premultiplied alpha fixups after rebase * reimuB shot pattern with basic power scaling (not balanced at all) * reimuB: some lame-ass particle effects * ReimuB bomb effect prototype * reimuA bomb prototype * fix reimu shots for the new damage system * Reimu: use the new player_is_bomb_active() function, add placeholder BG for ReimuB * some reimuB bomb projectiles * ReimuB bomb bg and some framebuffer utils required to support it. Might reuse this at least in part for ReimuA unless we come up with something better. * hack to fix ReimuB bomb fade; refactoring needed * reimuA damaging bombs * fix ub * prevent nan when reimuA bombs without enemies present * add a bomb_bg to reimuA * ... * various fantasy seal tweaks * Reimu: placeholder bomb sounds; slight fantasy seal buff * fix null pointer dereference * Reimu "balance" adjustments; minor fixes * putting bandaids over gunshot wounds * Add aoe damage and bullet cancel to ReimuB's bomb * more exorcism porn * make reimu bomb bg runes better visible on dark backgrounds * More ReimuA shot changes
2018-08-11 21:13:48 +02:00
stage_draw_destroy_framebuffers();
}
FBPair* stage_get_fbpair(StageFBPair id) {
assert(id >= 0 && id < NUM_FBPAIRS);
return stagedraw.fb_pairs + id;
}
static void stage_draw_collision_areas(void) {
#ifdef DEBUG
static bool enabled, keystate_saved;
bool keystate = gamekeypressed(KEY_HITAREAS);
if(keystate ^ keystate_saved) {
if(keystate) {
enabled = !enabled;
}
keystate_saved = keystate;
}
if(!enabled) {
return;
}
r_shader("sprite_filled_circle");
r_uniform_vec4("color_inner", 0, 0, 0, 1);
r_uniform_vec4("color_outer", 1, 1, 1, 0.1);
for(Projectile *p = global.projs.first; p; p = p->next) {
complex gsize = projectile_graze_size(p);
if(creal(gsize)) {
r_draw_sprite(&(SpriteParams) {
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
.color = RGB(0, 0.5, 0.5),
.sprite_ptr = &stagedraw.dummy,
.pos = { creal(p->pos), cimag(p->pos) },
.rotation.angle = p->angle + M_PI/2,
.scale = { .x = creal(gsize), .y = cimag(gsize) },
.blend = BLEND_SUB,
});
}
}
r_flush_sprites();
r_uniform_vec4("color_inner", 0.0, 1.0, 0.0, 0.75);
r_uniform_vec4("color_outer", 0.0, 0.5, 0.5, 0.75);
for(Projectile *p = global.projs.first; p; p = p->next) {
r_draw_sprite(&(SpriteParams) {
.sprite_ptr = &stagedraw.dummy,
.pos = { creal(p->pos), cimag(p->pos) },
.rotation.angle = p->angle + M_PI/2,
.scale = { .x = creal(p->collision_size), .y = cimag(p->collision_size) },
.blend = BLEND_ALPHA,
});
}
r_draw_sprite(&(SpriteParams) {
.sprite_ptr = &stagedraw.dummy,
.pos = { creal(global.plr.pos), cimag(global.plr.pos) },
.scale.both = 2, // NOTE: actual player is a singular point
});
// TODO: handle other objects the player may collide with (enemies, bosses...)
r_flush_sprites();
#endif
2017-11-23 03:25:53 +01:00
}
static void apply_shader_rules(ShaderRule *shaderrules, FBPair *fbos) {
2017-10-01 10:58:45 +02:00
if(!shaderrules) {
return;
}
for(ShaderRule *rule = shaderrules; *rule; ++rule) {
r_framebuffer(fbos->back);
2018-01-03 15:38:42 +01:00
(*rule)(fbos->front);
fbpair_swap(fbos);
}
2017-10-01 10:58:45 +02:00
return;
}
static void draw_wall_of_text(float f, const char *txt) {
Sprite spr;
BBox bbox;
char buf[strlen(txt) + 4];
memcpy(buf, txt, sizeof(buf) - 4);
memcpy(buf + sizeof(buf) - 4, " ~ ", 4);
text_render(buf, get_font("standard"), &spr, &bbox);
// FIXME: The shader currently assumes that the sprite takes up the entire texture.
// If it could handle any arbitrary sprite, then text_render wouldn't have to resize // the texture per every new string of text.
2017-04-14 10:42:09 +02:00
float w = VIEWPORT_W;
float h = VIEWPORT_H;
r_mat_push();
r_mat_translate(w/2, h/2, 0);
r_mat_scale(w, h, 1.0);
uint tw, th;
r_texture_get_size(spr.tex, 0, &tw, &th);
r_shader("spellcard_walloftext");
r_uniform_float("w", spr.tex_area.w / tw);
r_uniform_float("h", spr.tex_area.h / th);
r_uniform_float("ratio", h/w);
r_uniform_vec2("origin", creal(global.boss->pos)/h, cimag(global.boss->pos)/w); // what the fuck?
r_uniform_float("t", f);
r_uniform_sampler("tex", spr.tex);
r_draw_quad();
r_shader_standard();
r_mat_pop();
}
static void draw_spellbg(int t) {
r_mat_push();
Boss *b = global.boss;
b->current->draw_rule(b, t);
if(b->current->type == AT_ExtraSpell)
draw_extraspell_bg(b, t);
r_mat_push();
r_mat_translate(creal(b->pos), cimag(b->pos), 0);
r_mat_rotate_deg(global.frames*7.0, 0, 0, -1);
if(t < 0) {
float f = 1.0 - t/(float)ATTACK_START_DELAY;
r_mat_scale(f,f,f);
}
draw_sprite(0, 0, "boss_spellcircle0");
r_mat_pop();
2017-04-19 19:44:49 +02:00
float delay = ATTACK_START_DELAY;
if(b->current->type == AT_ExtraSpell)
2017-04-19 19:44:49 +02:00
delay = ATTACK_START_DELAY_EXTRA;
float f = (-t+ATTACK_START_DELAY)/(delay+ATTACK_START_DELAY);
if(f > 0)
draw_wall_of_text(f, b->current->name);
if(t < ATTACK_START_DELAY && b->dialog) {
r_mat_push();
float f = -0.5*t/(float)ATTACK_START_DELAY+0.5;
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
r_color(RGBA_MUL_ALPHA(1,1,1,-f*f+2*f));
draw_sprite_p(VIEWPORT_W*3/4-10*f*f,VIEWPORT_H*2/3-10*f*f,b->dialog);
r_color4(1,1,1,1);
r_mat_pop();
}
r_mat_pop();
}
static inline bool should_draw_stage_bg(void) {
return (
!global.boss
|| !global.boss->current
|| !global.boss->current->draw_rule
|| global.boss->current->endtime
|| (global.frames - global.boss->current->starttime) < 1.25*ATTACK_START_DELAY
);
}
static void fxaa_rule(Framebuffer *fb) {
r_state_push();
r_enable(RCAP_DEPTH_TEST);
r_depth_func(DEPTH_ALWAYS);
r_shader_ptr(stagedraw.shaders.fxaa);
r_uniform_sampler("depth", r_framebuffer_get_attachment(fb, FRAMEBUFFER_ATTACH_DEPTH));
draw_framebuffer_tex(fb, VIEWPORT_W, VIEWPORT_H);
r_state_pop();
}
static void copydepth_rule(Framebuffer *fb) {
r_state_push();
r_enable(RCAP_DEPTH_TEST);
r_depth_func(DEPTH_ALWAYS);
r_shader_ptr(stagedraw.shaders.copy_depth);
draw_framebuffer_attachment(fb, VIEWPORT_W, VIEWPORT_H, FRAMEBUFFER_ATTACH_DEPTH);
r_state_pop();
}
static void finish_3d_scene(FBPair *fbpair) {
// Here we synchronize the depth buffers of both framebuffers in the pair.
// The FXAA shader has this built-in, so we don't need to do the copy_depth
// pass in that case.
// The reason for this is that, normally, depth testing is disabled during
// the stage-specific post-processing ping-pong. This applies to depth writes
// as well. Therefore, only one of the framebuffers will get a depth write in
// a given frame. In the worst case, this will be the same framebuffer every
// time, leaving the other one's depth buffer undefined. In the best case,
// they will alternate. If a shader down the post-processing pipeline happens
// to sample the "unlucky" buffer, it'll probably either completely destroy
// the background rendering, or the sample will lag 1 frame behind.
// This flew past the radar for a long time. Now that I actually had to waste
// my evening debugging this peculiarity, I figured I might as well document
// it here. It is possible to solve this problem without an additional pass,
// but that would require a bit of refactoring. This is the simplest solution
// as far as I can tell.
if(config_get_int(CONFIG_FXAA)) {
apply_shader_rules((ShaderRule[]) { fxaa_rule, NULL }, fbpair);
} else {
apply_shader_rules((ShaderRule[]) { copydepth_rule, NULL }, fbpair);
// Swap because we didn't touch the color buffer.
fbpair_swap(fbpair);
}
}
static void apply_bg_shaders(ShaderRule *shaderrules, FBPair *fbos) {
Boss *b = global.boss;
if(b && b->current && b->current->draw_rule) {
int t = global.frames - b->current->starttime;
set_ortho(VIEWPORT_W, VIEWPORT_H);
if(should_draw_stage_bg()) {
finish_3d_scene(fbos);
2018-01-03 15:38:42 +01:00
apply_shader_rules(shaderrules, fbos);
}
r_framebuffer(fbos->back);
draw_framebuffer_tex(fbos->front, VIEWPORT_W, VIEWPORT_H);
draw_spellbg(t);
fbpair_swap(fbos);
r_framebuffer(fbos->back);
2017-04-14 10:42:09 +02:00
complex pos = b->pos;
float ratio = (float)VIEWPORT_H/VIEWPORT_W;
if(t<ATTACK_START_DELAY) {
r_shader("spellcard_intro");
r_uniform_float("ratio", ratio);
r_uniform_vec2("origin", creal(pos)/VIEWPORT_W, 1-cimag(pos)/VIEWPORT_H);
float delay = ATTACK_START_DELAY;
if(b->current->type == AT_ExtraSpell)
delay = ATTACK_START_DELAY_EXTRA;
float duration = ATTACK_START_DELAY_EXTRA;
r_uniform_float("t", (t+delay)/duration);
} else if(b->current->endtime) {
int tn = global.frames - b->current->endtime;
ShaderProgram *shader = r_shader_get("spellcard_outro");
r_shader_ptr(shader);
float delay = ATTACK_END_DELAY;
if(boss_is_dying(b)) {
delay = BOSS_DEATH_DELAY;
} else if(b->current->type == AT_ExtraSpell) {
delay = ATTACK_END_DELAY_EXTRA;
}
r_uniform_float("ratio", ratio);
r_uniform_vec2("origin", creal(pos)/VIEWPORT_W, 1-cimag(pos)/VIEWPORT_H);
r_uniform_float("t", max(0,tn/delay+1));
} else {
r_shader_standard();
}
draw_framebuffer_tex(fbos->front, VIEWPORT_W, VIEWPORT_H);
fbpair_swap(fbos);
r_framebuffer(NULL);
r_shader_standard();
} else if(should_draw_stage_bg()) {
set_ortho(VIEWPORT_W, VIEWPORT_H);
finish_3d_scene(fbos);
2018-01-03 15:38:42 +01:00
apply_shader_rules(shaderrules, fbos);
2017-10-01 10:58:45 +02:00
}
}
static void apply_zoom_shader(void) {
r_shader("boss_zoom");
2017-04-14 10:42:09 +02:00
complex fpos = global.boss->pos;
complex pos = fpos + 15*cexp(I*global.frames/4.5);
r_uniform_vec2("blur_orig", creal(pos) / VIEWPORT_W, 1-cimag(pos) / VIEWPORT_H);
r_uniform_vec2("fix_orig", creal(fpos) / VIEWPORT_W, 1-cimag(fpos) / VIEWPORT_H);
float spellcard_sup = 1;
// This factor is used to surpress the effect near the start of spell cards.
// This is necessary so it doesnt distort the awesome spinning background effect.
if(global.boss->current && global.boss->current->draw_rule) {
float t = (global.frames - global.boss->current->starttime + ATTACK_START_DELAY)/(float)ATTACK_START_DELAY;
spellcard_sup = 1-1/(0.1*t*t+1);
}
if(boss_is_dying(global.boss)) {
float t = (global.frames - global.boss->current->endtime)/(float)BOSS_DEATH_DELAY + 1;
spellcard_sup = 1-t*t;
}
r_uniform_float("blur_rad", 1.5*spellcard_sup*(0.2+0.025*sin(global.frames/15.0)));
r_uniform_float("rad", 0.24);
r_uniform_float("ratio", (float)VIEWPORT_H/VIEWPORT_W);
r_uniform_vec4_rgba("color", &global.boss->zoomcolor);
}
2018-01-03 15:38:42 +01:00
static void stage_render_bg(StageInfo *stage) {
FBPair *background = stage_get_fbpair(FBPAIR_BG);
r_framebuffer(background->back);
r_clear(CLEAR_ALL, RGBA(0, 0, 0, 1), 1);
if(should_draw_stage_bg()) {
r_mat_push();
r_mat_translate(-(VIEWPORT_X+VIEWPORT_W/2), -(VIEWPORT_Y+VIEWPORT_H/2),0);
r_enable(RCAP_DEPTH_TEST);
stage->procs->draw();
r_mat_pop();
fbpair_swap(background);
}
apply_bg_shaders(stage->procs->shader_rules, background);
2018-01-03 15:38:42 +01:00
return;
}
bool stage_should_draw_particle(Projectile *p) {
return (p->flags & PFLAG_REQUIREDPARTICLE) || config_get_int(CONFIG_PARTICLES);
}
static bool stage_draw_predicate(EntityInterface *ent) {
if(ent->type == ENT_PROJECTILE) {
Projectile *p = ENT_CAST(ent, Projectile);
if(p->type == Particle) {
return stage_should_draw_particle(p);
}
}
return true;
}
static void stage_draw_objects(void) {
r_shader("sprite_default");
if(global.boss) {
draw_boss_background(global.boss);
}
ent_draw(
config_get_int(CONFIG_PARTICLES)
? NULL
: stage_draw_predicate
);
if(global.boss) {
draw_boss_hud(global.boss);
}
if(global.dialog) {
draw_dialog(global.dialog);
}
stage_draw_collision_areas();
r_shader_standard();
stagetext_draw();
}
static void postprocess_prepare(Framebuffer *fb, ShaderProgram *s) {
r_uniform_int("frames", global.frames);
2018-05-18 20:15:11 +02:00
r_uniform_vec2("viewport", VIEWPORT_W, VIEWPORT_H);
r_uniform_vec2("player", creal(global.plr.pos), VIEWPORT_H - cimag(global.plr.pos));
}
void stage_draw_foreground(void) {
int vw, vh;
video_get_viewport_size(&vw, &vh);
// CAUTION: Very intricate pixel perfect scaling that will ruin your day.
float facw = (float)vw/SCREEN_W;
float fach = (float)vh/SCREEN_H;
2017-04-19 10:06:39 +02:00
// confer video_update_quality to understand why this is fach. fach is equal to facw up to roundoff error.
float scale = fach;
// draw the foreground Framebuffer
r_mat_push();
r_mat_scale(1/facw,1/fach,1);
r_mat_translate(floorf(facw*VIEWPORT_X), floorf(fach*VIEWPORT_Y), 0);
r_mat_scale(floorf(scale*VIEWPORT_W)/VIEWPORT_W,floorf(scale*VIEWPORT_H)/VIEWPORT_H,1);
// apply the screenshake effect
if(global.shake_view) {
r_mat_translate(global.shake_view*sin(global.frames),global.shake_view*sin(global.frames*1.1+3),0);
r_mat_scale(1+2*global.shake_view/VIEWPORT_W,1+2*global.shake_view/VIEWPORT_H,1);
r_mat_translate(-global.shake_view,-global.shake_view,0);
if(global.shake_view_fade) {
global.shake_view -= global.shake_view_fade;
if(global.shake_view <= 0)
global.shake_view = global.shake_view_fade = 0;
}
}
draw_framebuffer_tex(stage_get_fbpair(FBPAIR_FG)->front, VIEWPORT_W, VIEWPORT_H);
r_mat_pop();
}
void stage_draw_scene(StageInfo *stage) {
#ifdef DEBUG
bool key_nobg = gamekeypressed(KEY_NOBACKGROUND);
#else
bool key_nobg = false;
#endif
FBPair *background = stage_get_fbpair(FBPAIR_BG);
FBPair *foreground = stage_get_fbpair(FBPAIR_FG);
bool draw_bg = !config_get_int(CONFIG_NO_STAGEBG) && !key_nobg;
if(draw_bg) {
// render the 3D background
2018-01-03 15:38:42 +01:00
stage_render_bg(stage);
}
// prepare for 2D rendering into the game viewport framebuffer
r_framebuffer(foreground->back);
set_ortho(VIEWPORT_W, VIEWPORT_H);
r_disable(RCAP_DEPTH_TEST);
if(draw_bg) {
// enable boss background distortion
if(global.boss) {
apply_zoom_shader();
}
// draw the 3D background
draw_framebuffer_tex(background->front, VIEWPORT_W, VIEWPORT_H);
// disable boss background distortion
r_shader_standard();
2017-11-12 16:15:12 +01:00
// draw bomb background
Add Reimu Hakurei as a playable character (#106) * Reimu (#101) * add the reimu * Add Reimu story * account for various blunders * add reimu dialog picture * Reimu: WIP yin-yang orbs * reimu: fix up indents * Reimu: swap the shotmode names to match the kanji order in her Japanese name * Reimu: compatibility with the latest system * WIP ReimuA crap * ReimuA homing trails * more ReimuA stuff * more ReimuA adjustments + enhanced DPS stats * Reimu: stubs for new player animation sequences * Reimu: occupy the 0th character slot * Reimu: tweak needle sprite * Reimu: buff movement speed to better match Touhou * Reimu: fixup for the recent projectile changes * ReimuA: make homing shots a bit smaller; give them custom effect on collision * Reimu: add intermediate frames; move some loose sprites to the atlas * Reimu: fix compile errors * replace DBL_MAX by INFINITY * Don’t draw reimu orbs twice fixes #127 * add new reimu dialog pic * ReimuA adjustments (mostly homing); it's still OP * wip ReimuB gaps * still not sure where i'm going with these gaps * meh * Reimu: premultiplied alpha fixups after rebase * reimuB shot pattern with basic power scaling (not balanced at all) * reimuB: some lame-ass particle effects * ReimuB bomb effect prototype * reimuA bomb prototype * fix reimu shots for the new damage system * Reimu: use the new player_is_bomb_active() function, add placeholder BG for ReimuB * some reimuB bomb projectiles * ReimuB bomb bg and some framebuffer utils required to support it. Might reuse this at least in part for ReimuA unless we come up with something better. * hack to fix ReimuB bomb fade; refactoring needed * reimuA damaging bombs * fix ub * prevent nan when reimuA bombs without enemies present * add a bomb_bg to reimuA * ... * various fantasy seal tweaks * Reimu: placeholder bomb sounds; slight fantasy seal buff * fix null pointer dereference * Reimu "balance" adjustments; minor fixes * putting bandaids over gunshot wounds * Add aoe damage and bullet cancel to ReimuB's bomb * more exorcism porn * make reimu bomb bg runes better visible on dark backgrounds * More ReimuA shot changes
2018-08-11 21:13:48 +02:00
// FIXME: we need a more flexible and consistent way for entities to hook
// into the various stages of scene drawing code.
if(global.plr.mode->procs.bombbg /*&& player_is_bomb_active(&global.plr)*/) {
2017-11-12 16:15:12 +01:00
global.plr.mode->procs.bombbg(&global.plr);
}
} else if(!key_nobg) {
r_clear(CLEAR_COLOR, RGBA(0, 0, 0, 1), 1);
}
// draw the 2D objects
2017-04-14 10:42:09 +02:00
stage_draw_objects();
2018-01-03 15:38:42 +01:00
// everything drawn, now apply postprocessing
fbpair_swap(foreground);
2017-10-01 10:58:45 +02:00
// stage postprocessing
apply_shader_rules(global.stage->procs->postprocess_rules, foreground);
2017-10-01 10:58:45 +02:00
2017-11-26 14:06:35 +01:00
// bomb effects shader if present and player bombing
if(global.plr.mode->procs.bomb_shader && player_is_bomb_active(&global.plr)) {
ShaderRule rules[] = { global.plr.mode->procs.bomb_shader, NULL };
apply_shader_rules(rules, foreground);
2017-11-26 14:06:35 +01:00
}
2018-01-03 15:38:42 +01:00
2017-10-01 10:58:45 +02:00
// custom postprocessing
postprocess(
stagedraw.viewport_pp,
foreground,
postprocess_prepare,
draw_framebuffer_tex,
VIEWPORT_W,
VIEWPORT_H
);
// prepare for 2D rendering into the main framebuffer (actual screen)
r_framebuffer(NULL);
set_ortho(SCREEN_W, SCREEN_H);
// draw the game viewport and HUD
stage_draw_foreground();
stage_draw_hud();
}
struct glyphcb_state {
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
Color *color;
};
static void draw_powerval_callback(Font *font, charcode_t charcode, SpriteParams *spr_params, void *userdata) {
struct glyphcb_state *st = userdata;
if(charcode == '.') {
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
st->color = &stagedraw.hud_text.color.inactive;
}
spr_params->color = st->color;
2017-11-23 03:25:53 +01:00
}
static void draw_numeric_callback(Font *font, charcode_t charcode, SpriteParams *spr_params, void *userdata) {
struct glyphcb_state *st = userdata;
if(charcode != '0') {
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
st->color = &stagedraw.hud_text.color.active;
}
spr_params->color = st->color;
}
static inline void stage_draw_hud_power_value(float ypos, char *buf, size_t bufsize) {
snprintf(buf, bufsize, "%i.%02i", global.plr.power / 100, global.plr.power % 100);
text_draw(buf, &(TextParams) {
.pos = { 170, ypos },
.font = "mono",
.align = ALIGN_RIGHT,
.glyph_callback = {
draw_powerval_callback,
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
&(struct glyphcb_state) { &stagedraw.hud_text.color.active },
}
});
2017-11-23 03:25:53 +01:00
}
static void stage_draw_hud_score(Alignment a, float xpos, float ypos, char *buf, size_t bufsize, uint32_t score) {
snprintf(buf, bufsize, "%010u", score);
text_draw(buf, &(TextParams) {
.pos = { xpos, ypos },
.font = "mono",
.align = ALIGN_RIGHT,
.glyph_callback = {
draw_numeric_callback,
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
&(struct glyphcb_state) { &stagedraw.hud_text.color.inactive },
}
});
2017-11-23 03:25:53 +01:00
}
static void stage_draw_hud_scores(float ypos_hiscore, float ypos_score, char *buf, size_t bufsize) {
stage_draw_hud_score(ALIGN_RIGHT, 170, (int)ypos_hiscore, buf, bufsize, progress.hiscore);
stage_draw_hud_score(ALIGN_RIGHT, 170, (int)ypos_score, buf, bufsize, global.plr.points);
2017-11-23 03:25:53 +01:00
}
static void stage_draw_hud_objpool_stats(float x, float y, float width) {
2017-12-13 20:05:12 +01:00
ObjectPool **last = &stage_object_pools.first + (sizeof(StageObjectPools)/sizeof(ObjectPool*) - 1);
Font *font = get_font("monotiny");
2017-12-13 20:05:12 +01:00
ShaderProgram *sh_prev = r_shader_current();
r_shader("text_default");
2017-12-13 20:05:12 +01:00
for(ObjectPool **pool = &stage_object_pools.first; pool <= last; ++pool) {
ObjectPoolStats stats;
char buf[32];
objpool_get_stats(*pool, &stats);
snprintf(buf, sizeof(buf), "%zu | %5zu", stats.usage, stats.peak_usage);
// draw_text(ALIGN_LEFT | AL_Flag_NoAdjust, (int)x, (int)y, stats.tag, font);
// draw_text(ALIGN_RIGHT | AL_Flag_NoAdjust, (int)(x + width), (int)y, buf, font);
// y += stringheight(buf, font) * 1.1;
text_draw(stats.tag, &(TextParams) {
.pos = { x, y },
.font_ptr = font,
.align = ALIGN_LEFT,
});
text_draw(buf, &(TextParams) {
.pos = { x + width, y },
.font_ptr = font,
.align = ALIGN_RIGHT,
});
2017-12-13 20:05:12 +01:00
y += font_get_lineskip(font);
2017-12-13 20:05:12 +01:00
}
r_shader_ptr(sh_prev);
2017-12-13 20:05:12 +01:00
}
2017-11-23 03:25:53 +01:00
struct labels_s {
struct {
float ofs;
} x;
struct {
float mono_ofs;
float hiscore;
float score;
float lives;
float bombs;
float power;
float graze;
} y;
};
static void draw_graph(float x, float y, float w, float h) {
r_mat_push();
r_mat_translate(x + w/2, y + h/2, 0);
r_mat_scale(w, h, 1);
r_draw_quad();
r_mat_pop();
}
static void draw_label(const char *label_str, double y_ofs, struct labels_s* labels) {
text_draw(label_str, &(TextParams) {
.font_ptr = stagedraw.hud_text.font,
.shader_ptr = stagedraw.hud_text.shader,
.pos = { labels->x.ofs, y_ofs },
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
.color = &stagedraw.hud_text.color.label,
});
}
2017-11-23 03:25:53 +01:00
void stage_draw_hud_text(struct labels_s* labels) {
char buf[64];
Font *font;
2017-11-23 03:25:53 +01:00
r_shader_ptr(stagedraw.hud_text.shader);
2017-11-23 03:25:53 +01:00
// Labels
draw_label("Hi-Score:", labels->y.hiscore, labels);
draw_label("Score:", labels->y.score, labels);
draw_label("Lives:", labels->y.lives, labels);
draw_label("Spells:", labels->y.bombs, labels);
draw_label("Power:", labels->y.power, labels);
draw_label("Graze:", labels->y.graze, labels);
2017-11-23 03:25:53 +01:00
2017-12-13 20:05:12 +01:00
if(stagedraw.objpool_stats) {
stage_draw_hud_objpool_stats(labels->x.ofs, labels->y.graze + 32, 250);
2017-12-13 20:05:12 +01:00
}
2017-11-23 03:25:53 +01:00
// Score/Hi-Score values
stage_draw_hud_scores(labels->y.hiscore + labels->y.mono_ofs, labels->y.score + labels->y.mono_ofs, buf, sizeof(buf));
// Lives and Bombs (N/A)
if(global.stage->type == STAGE_SPELL) {
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
r_color4(0.7, 0.7, 0.7, 0.7);
text_draw("N/A", &(TextParams) { .pos = { -6, labels->y.lives }, .font_ptr = stagedraw.hud_text.font });
text_draw("N/A", &(TextParams) { .pos = { -6, labels->y.bombs }, .font_ptr = stagedraw.hud_text.font });
r_color4(1, 1, 1, 1.0);
2017-11-23 03:25:53 +01:00
}
// Power value
stage_draw_hud_power_value(labels->y.power + labels->y.mono_ofs, buf, sizeof(buf));
// Graze value
snprintf(buf, sizeof(buf), "%05i", global.plr.graze);
text_draw(buf, &(TextParams) {
.pos = { -6, labels->y.graze },
.shader_ptr = stagedraw.hud_text.shader,
.font = "mono",
.glyph_callback = {
draw_numeric_callback,
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
&(struct glyphcb_state) { &stagedraw.hud_text.color.inactive },
}
});
2017-11-23 03:25:53 +01:00
// Warning: pops outer matrix!
r_mat_pop();
2017-11-23 03:25:53 +01:00
#ifdef DEBUG
2017-12-26 12:07:40 +01:00
snprintf(buf, sizeof(buf), "%.2f lfps, %.2f rfps, timer: %d, frames: %d",
global.fps.logic.fps,
global.fps.render.fps,
global.timer,
global.frames
);
2017-11-23 03:25:53 +01:00
#else
2017-12-26 12:07:40 +01:00
if(get_effective_frameskip() > 1) {
snprintf(buf, sizeof(buf), "%.2f lfps, %.2f rfps",
global.fps.logic.fps,
global.fps.render.fps
);
} else {
snprintf(buf, sizeof(buf), "%.2f fps",
global.fps.logic.fps
);
}
2017-11-23 03:25:53 +01:00
#endif
// draw_text(ALIGN_RIGHT | AL_Flag_NoAdjust, SCREEN_W, rint(SCREEN_H - 0.5 * stringheight(buf, _fonts.monosmall)), buf, _fonts.monosmall);
font = get_font("monosmall");
text_draw(buf, &(TextParams) {
.align = ALIGN_RIGHT,
.pos = { SCREEN_W, SCREEN_H - 0.5 * text_height(font, buf, 0) },
.font_ptr = font,
});
2017-11-23 03:25:53 +01:00
if(global.replaymode == REPLAY_PLAY) {
r_shader("text_hud");
2017-11-23 03:25:53 +01:00
// XXX: does it make sense to use the monospace font here?
snprintf(buf, sizeof(buf), "Replay: %s (%i fps)", global.replay.playername, global.replay_stage->fps);
int x = 0, y = SCREEN_H - 0.5 * text_height(font, buf, 0);
2017-11-23 03:25:53 +01:00
x += text_draw(buf, &(TextParams) {
.pos = { x, y },
.font_ptr = font,
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
.color = &stagedraw.hud_text.color.inactive,
});
2017-11-23 03:25:53 +01:00
if(global.replay_stage->desynced) {
strlcpy(buf, " (DESYNCED)", sizeof(buf));
text_draw(buf, &(TextParams) {
.pos = { x, y },
.font_ptr = font,
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
.color = RGBA_MUL_ALPHA(1.00, 0.20, 0.20, 0.60),
});
2017-11-23 03:25:53 +01:00
}
}
#ifdef PLR_DPS_STATS
else if(global.frames) {
int totaldmg = 0;
int framespan = sizeof(global.plr.dmglog)/sizeof(*global.plr.dmglog);
int graphspan = framespan;
static int max = 0;
float graph[framespan];
if(graphspan > 120) {
// shader limitation
graphspan = 120;
}
// hack to update the graph every frame
2018-07-30 09:04:09 +02:00
player_register_damage(&global.plr, NULL, &(DamageInfo) { .amount = 0, .type = DMG_PLAYER_SHOT });
for(int i = 0; i < framespan; ++i) {
totaldmg += global.plr.dmglog[i];
if(global.plr.dmglog[i] > max) {
max = global.plr.dmglog[i];
}
}
for(int i = 0; i < graphspan; ++i) {
if(max > 0) {
graph[i] = (float)global.plr.dmglog[i] / max;
} else {
graph[i] = 0;
}
}
snprintf(buf, sizeof(buf), "%.02f", totaldmg / (framespan / (double)FPS));
double text_h = text_height(font, buf, 0);
double x = 0, y = SCREEN_H - 0.5 * text_h;
x += text_draw("Avg DPS: ", &(TextParams) {
.pos = { x, y },
.font_ptr = font,
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
.color = &stagedraw.hud_text.color.inactive,
});
text_draw(buf, &(TextParams) {
.pos = { x, y },
.font_ptr = font,
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
.color = &stagedraw.hud_text.color.active,
});
r_shader("graph");
r_uniform_vec3("color_low", 1.0, 0.0, 0.0);
r_uniform_vec3("color_mid", 1.0, 1.0, 0.0);
r_uniform_vec3("color_high", 0.0, 1.0, 0.0);
r_uniform_float_array("points[0]", 0, graphspan, graph);
draw_graph(142, SCREEN_H - text_h, graphspan, text_h);
2017-11-23 03:25:53 +01:00
}
#endif
r_shader_standard();
2017-11-23 03:25:53 +01:00
}
static void fill_graph(int num_samples, float *samples, FPSCounter *fps) {
for(int i = 0; i < num_samples; ++i) {
samples[i] = fps->frametimes[i] / (((hrtime_t)2.0)/FPS);
if(samples[i] > 1.0) {
samples[i] = 1.0;
}
}
}
static void stage_draw_framerate_graphs(void) {
#define NUM_SAMPLES (sizeof(((FPSCounter){{0}}).frametimes) / sizeof(((FPSCounter){{0}}).frametimes[0]))
static float samples[NUM_SAMPLES];
float pad = 15;
float w = 260 - pad;
float h = 30;
float x = SCREEN_W - w - pad;
float y = 100;
r_shader("graph");
2017-12-26 12:07:40 +01:00
fill_graph(NUM_SAMPLES, samples, &global.fps.logic);
r_uniform_vec3("color_low", 0.0, 1.0, 1.0);
r_uniform_vec3("color_mid", 1.0, 1.0, 0.0);
r_uniform_vec3("color_high", 1.0, 0.0, 0.0);
r_uniform_float_array("points[0]", 0, NUM_SAMPLES, samples);
draw_graph(x, y, w, h);
// x -= w * 1.1;
y += h + 1;
2017-12-26 12:07:40 +01:00
fill_graph(NUM_SAMPLES, samples, &global.fps.busy);
r_uniform_vec3("color_low", 0.0, 1.0, 0.0);
r_uniform_vec3("color_mid", 1.0, 0.0, 0.0);
r_uniform_vec3("color_high", 1.0, 0.0, 0.5);
r_uniform_float_array("points[0]", 0, NUM_SAMPLES, samples);
draw_graph(x, y, w, h);
r_shader_standard();
}
void stage_draw_hud(void) {
2017-11-23 03:25:53 +01:00
// Background
draw_sprite(SCREEN_W/2.0, SCREEN_H/2.0, "hud");
2017-11-23 03:25:53 +01:00
// Set up positions of most HUD elements
static struct labels_s labels = {
.x.ofs = -75,
// XXX: is there a more robust way to level the monospace font with the label one?
// .y.mono_ofs = 0.5,
2017-11-23 03:25:53 +01:00
};
const float label_height = 33;
float label_cur_height = 0;
int i;
label_cur_height = 49; i = 0;
labels.y.hiscore = label_cur_height+label_height*(i++);
labels.y.score = label_cur_height+label_height*(i++);
label_cur_height = 180; i = 0;
labels.y.lives = label_cur_height+label_height*(i++);
labels.y.bombs = label_cur_height+label_height*(i++);
labels.y.power = label_cur_height+label_height*(i++);
labels.y.graze = label_cur_height+label_height*(i++);
r_mat_push();
r_mat_translate(615, 0, 0);
2017-11-23 03:25:53 +01:00
// Difficulty indicator
r_mat_push();
r_mat_translate((SCREEN_W - 615) * 0.25, SCREEN_H-170, 0);
r_mat_scale(0.6, 0.6, 0);
draw_sprite(0, 0, difficulty_sprite_name(global.diff));
r_mat_pop();
2017-11-23 03:25:53 +01:00
// Set up variables for Extra Spell indicator
float a = 1, s = 0, fadein = 1, fadeout = 1, fade = 1;
if(global.boss && global.boss->current && global.boss->current->type == AT_ExtraSpell) {
fadein = min(1, -min(0, global.frames - global.boss->current->starttime) / (float)ATTACK_START_DELAY);
fadeout = global.boss->current->finished * (1 - (global.boss->current->endtime - global.frames) / (float)ATTACK_END_DELAY_EXTRA) / 0.74;
fade = max(fadein, fadeout);
s = 1 - fade;
a = 0.5 + 0.5 * fade;
}
2017-11-23 03:25:53 +01:00
// Lives and Bombs
if(global.stage->type != STAGE_SPELL) {
draw_stars(0, labels.y.lives, global.plr.lives, global.plr.life_fragments, PLR_MAX_LIVES, PLR_MAX_LIFE_FRAGMENTS, a, 20);
draw_stars(0, labels.y.bombs, global.plr.bombs, global.plr.bomb_fragments, PLR_MAX_BOMBS, PLR_MAX_BOMB_FRAGMENTS, a, 20);
}
2017-11-23 03:25:53 +01:00
// Power stars
draw_stars(0, labels.y.power, global.plr.power / 100, global.plr.power % 100, PLR_MAX_POWER / 100, 100, 1, 20);
ShaderProgram *sh_prev = r_shader_current();
r_shader("text_default");
2017-11-23 03:25:53 +01:00
// God Mode indicator
if(global.plr.iddqd) {
text_draw("GOD MODE", &(TextParams) { .pos = { -70, 475 }, .font = "big" });
2017-11-23 03:25:53 +01:00
}
// Extra Spell indicator
if(s) {
float s2 = max(0, swing(s, 3));
r_mat_push();
r_mat_translate((SCREEN_W - 615) * 0.25 - 615 * (1 - pow(2*fadein-1, 2)), 340, 0);
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
r_color(RGBA_MUL_ALPHA(0.3, 0.6, 0.7, 0.7 * s));
r_mat_rotate_deg(-25 + 360 * (1-s2), 0, 0, 1);
r_mat_scale(s2, s2, 0);
text_draw("Extra Spell!", &(TextParams) { .pos = { 1, 1 }, .font = "big", .align = ALIGN_CENTER });
text_draw("Extra Spell!", &(TextParams) { .pos = { -1, -1 }, .font = "big", .align = ALIGN_CENTER });
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
r_color4(s, s, s, s);
text_draw("Extra Spell!", &(TextParams) { .pos = { 0, 0 }, .font = "big", .align = ALIGN_CENTER });
r_color4(1, 1, 1, 1);
r_mat_pop();
}
r_shader_ptr(sh_prev);
2017-11-23 05:02:54 +01:00
// Warning: pops matrix!
stage_draw_hud_text(&labels);
if(stagedraw.framerate_graphs) {
stage_draw_framerate_graphs();
}
2017-11-23 03:25:53 +01:00
// Boss indicator ("Enemy")
2017-09-27 11:08:32 +02:00
if(global.boss) {
float red = 0.5*exp(-0.5*(global.frames-global.boss->lastdamageframe)); // hit indicator
if(red > 1)
red = 0;
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
r_color4(1 - red, 1 - red, 1 - red, 1 - red);
draw_sprite(VIEWPORT_X+creal(global.boss->pos), 590, "boss_indicator");
Premultiplied alpha (#133) * WIP premultiplied alpha * WIP color API rework (doesn't build yet; lots of things left to convert) * convert everything remaining to new Color api except stage*_event.c files * convert the stages to new Color api. builds & runs now; still many rendering errors * fix the bullet shader for premultiplied alpha * fix masterspark, graphs and stage 1 fog clouds * fix marisa_b and most of spellcards * Add deprecation warnings for BLEND_ADD and PFLAG_DRAWADD * fix a segfault in stage 6 undo accidental earlier change * fix text_hud.frag.glsl * fix scuttle bg and remaining stage3 BLEND_ADDs * fix marisa laser opacity * hacky fix for myon The old implementation relied on alpha being stored inside p->color. In premul alpha this doesn’t work and functions like color_set_opacity can’t solve this i think. So I tried messing around with it until it looked somewhat similar. * fix marisa_b stars * remove color_set_opacity i overlooked * more plrmode blending changes * fixup additive blending in stage 1 * various premultiplied alpha fixups for bosses and enemies * stage 2 premul alpha fixups * stage 4 premul alpha fixups * stage 5 premul alpha fixups * stage 6 premul alpha fixups * make lasers also use the PMA blend mode * remove PFLAG_DRAWADD and PFLAG_DRAWSUB * fix remaining PMA issues in menus * lame extraspell bg workaround * fix item alpha * make marisaA lasers look somewhat like in master * fix marisaA bomb background fadeout * fixup various r_color4 calls * fix myon * remove dead code * fix use of BLEND_ADD in player death effect * fix myon shot trails (broken on master as well) * fix myon shot fade-in * extend the sprite shaders custom parameter to a vec4 * fix youmuB stuff and make it look somewhat better. the code looks even worse though.
2018-07-23 19:07:59 +02:00
r_color4(1, 1, 1, 1);
2017-09-27 11:08:32 +02:00
}
}