Use the standard bool type instead of that stupid enum
Also removed all of the annoying trailing tabs/whitespaces
This commit is contained in:
parent
985b6d1dd6
commit
9a7a874783
110 changed files with 2300 additions and 2295 deletions
80
src/boss.c
80
src/boss.c
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
*/
|
||||
|
@ -12,14 +12,14 @@
|
|||
|
||||
Boss *create_boss(char *name, char *ani, complex pos) {
|
||||
Boss *buf = malloc(sizeof(Boss));
|
||||
memset(buf, 0, sizeof(Boss));
|
||||
|
||||
memset(buf, 0, sizeof(Boss));
|
||||
|
||||
buf->name = malloc(strlen(name) + 1);
|
||||
strcpy(buf->name, name);
|
||||
buf->pos = pos;
|
||||
|
||||
|
||||
buf->ani = get_ani(ani);
|
||||
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -37,58 +37,58 @@ void spell_opening(Boss *b, int time) {
|
|||
if(time > 100) {
|
||||
y = 35;
|
||||
}
|
||||
|
||||
|
||||
draw_boss_text(AL_Right, VIEWPORT_W, y, b->current->name);
|
||||
}
|
||||
|
||||
void draw_boss(Boss *boss) {
|
||||
draw_animation_p(creal(boss->pos), cimag(boss->pos) + 6*sin(global.frames/25.0), boss->anirow, boss->ani);
|
||||
draw_boss_text(AL_Left, 10, 20, boss->name);
|
||||
|
||||
|
||||
if(!boss->current)
|
||||
return;
|
||||
|
||||
|
||||
if(boss->current->type == AT_Spellcard || boss->current->type == AT_SurvivalSpell)
|
||||
spell_opening(boss, global.frames - boss->current->starttime);
|
||||
|
||||
|
||||
if(boss->current->type != AT_Move) {
|
||||
char buf[16];
|
||||
snprintf(buf, sizeof(buf), "%.2f", (boss->current->timeout - global.frames + boss->current->starttime)/(float)FPS);
|
||||
draw_boss_text(AL_Center, VIEWPORT_W - 20, 10, buf);
|
||||
|
||||
|
||||
int nextspell, lastspell;
|
||||
for(nextspell = 0; nextspell < boss->acount - 1; nextspell++) {
|
||||
if(boss->dmg < boss->attacks[nextspell].dmglimit && boss->attacks[nextspell].type == AT_Spellcard)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
for(lastspell = nextspell; lastspell > 0; lastspell--) {
|
||||
if(boss->dmg > boss->attacks[lastspell].dmglimit && boss->attacks[lastspell].type == AT_Spellcard)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
int dmgoffset = boss->attacks[lastspell].dmglimit;
|
||||
int dmgspan = boss->attacks[nextspell].dmglimit - boss->attacks[lastspell].dmglimit;
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(VIEWPORT_W-50, 4, 0);
|
||||
glScalef((VIEWPORT_W-60)/(float)dmgspan,1,1);
|
||||
glTranslatef(dmgoffset,0,0);
|
||||
int i;
|
||||
|
||||
|
||||
glColor4f(0,0,0,0.65);
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-(boss->attacks[nextspell].dmglimit+boss->dmg-2)*0.5, 2, 0);
|
||||
glScalef(boss->attacks[nextspell].dmglimit-boss->dmg+2, 4, 1);
|
||||
|
||||
|
||||
draw_quad();
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
for(i = nextspell; i >= 0; i--) {
|
||||
if(boss->dmg > boss->attacks[i].dmglimit)
|
||||
continue;
|
||||
|
||||
|
||||
switch(boss->attacks[i].type) {
|
||||
case AT_Normal:
|
||||
glColor3f(1,1,1);
|
||||
|
@ -100,35 +100,35 @@ void draw_boss(Boss *boss) {
|
|||
glColor3f(0.5,0.5,1);
|
||||
default:
|
||||
break; // never happens
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-(boss->attacks[i].dmglimit+boss->dmg)*0.5, 1, 0);
|
||||
glScalef(boss->attacks[i].dmglimit-boss->dmg, 2, 1);
|
||||
|
||||
|
||||
draw_quad();
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
glColor4f(1,1,1,0.7);
|
||||
|
||||
|
||||
int x = 0;
|
||||
for(i = boss->acount-1; i > nextspell; i--)
|
||||
if(boss->attacks[i].type == AT_Spellcard)
|
||||
draw_texture(x += 22, 40, "star");
|
||||
|
||||
|
||||
glColor3f(1,1,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void process_boss(Boss *boss) {
|
||||
if(boss->current) {
|
||||
if(boss->current) {
|
||||
int time = global.frames - boss->current->starttime;
|
||||
|
||||
|
||||
boss->current->rule(boss, time);
|
||||
|
||||
|
||||
if(boss->current->type != AT_Move && boss->dmg >= boss->current->dmglimit)
|
||||
time = boss->current->timeout + 1;
|
||||
if(time > boss->current->timeout) {
|
||||
|
@ -148,18 +148,18 @@ void boss_death(Boss **boss) {
|
|||
|
||||
free_boss(*boss);
|
||||
*boss = NULL;
|
||||
|
||||
|
||||
Projectile *p;
|
||||
for(p = global.projs; p; p = p->next)
|
||||
if(p->type == FairyProj)
|
||||
p->type = DeadProj;
|
||||
|
||||
|
||||
delete_lasers();
|
||||
}
|
||||
|
||||
void free_boss(Boss *boss) {
|
||||
del_ref(boss);
|
||||
|
||||
|
||||
free(boss->name);
|
||||
int i;
|
||||
for(i = 0; i < boss->acount; i++)
|
||||
|
@ -181,35 +181,35 @@ void start_attack(Boss *b, Attack *a) {
|
|||
a->rule(b, EVENT_BIRTH);
|
||||
if(a->type == AT_Spellcard || a->type == AT_SurvivalSpell)
|
||||
play_sound("charge_generic");
|
||||
|
||||
|
||||
Projectile *p;
|
||||
for(p = global.projs; p; p = p->next)
|
||||
if(p->type == FairyProj)
|
||||
p->type = DeadProj;
|
||||
|
||||
|
||||
delete_lasers();
|
||||
}
|
||||
|
||||
Attack *boss_add_attack(Boss *boss, AttackType type, char *name, float timeout, int hp, BossRule rule, BossRule draw_rule) {
|
||||
boss->attacks = realloc(boss->attacks, sizeof(Attack)*(++boss->acount));
|
||||
Attack *a = &boss->attacks[boss->acount-1];
|
||||
|
||||
|
||||
boss->current = &boss->attacks[0];
|
||||
|
||||
|
||||
a->type = type;
|
||||
a->name = malloc(strlen(name)+1);
|
||||
strcpy(a->name, name);
|
||||
a->timeout = timeout * FPS;
|
||||
|
||||
|
||||
int dmg = 0;
|
||||
if(boss->acount > 1)
|
||||
dmg = boss->attacks[boss->acount - 2].dmglimit;
|
||||
|
||||
|
||||
a->dmglimit = dmg + hp;
|
||||
a->rule = rule;
|
||||
a->draw_rule = draw_rule;
|
||||
|
||||
|
||||
a->starttime = global.frames;
|
||||
|
||||
|
||||
return a;
|
||||
}
|
||||
|
|
24
src/boss.h
24
src/boss.h
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
*/
|
||||
|
@ -25,31 +25,31 @@ typedef enum AttackType {
|
|||
|
||||
typedef struct Attack {
|
||||
char *name;
|
||||
|
||||
|
||||
AttackType type;
|
||||
|
||||
|
||||
int starttime;
|
||||
|
||||
|
||||
int timeout;
|
||||
int dmglimit;
|
||||
|
||||
|
||||
BossRule rule;
|
||||
BossRule draw_rule;
|
||||
} Attack;
|
||||
} Attack;
|
||||
|
||||
typedef struct Boss {
|
||||
typedef struct Boss {
|
||||
Attack *attacks;
|
||||
Attack *current;
|
||||
|
||||
|
||||
complex pos;
|
||||
|
||||
|
||||
char *name;
|
||||
|
||||
|
||||
int acount;
|
||||
|
||||
|
||||
Animation *ani;
|
||||
int anirow;
|
||||
|
||||
|
||||
int dmg;
|
||||
Color *zoomcolor;
|
||||
} Boss;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
* Copyright (C) 2012, Alexeyew Andrew <http://akari.thebadasschoobs.org/>
|
||||
|
@ -45,16 +45,16 @@ void credits_add(char *data, int time) {
|
|||
CreditsEntry *e;
|
||||
char *c, buf[256];
|
||||
int l = 0, i = 0;
|
||||
|
||||
|
||||
credits.entries = realloc(credits.entries, (++credits.ecount) * sizeof(CreditsEntry));
|
||||
e = &(credits.entries[credits.ecount-1]);
|
||||
e->time = time;
|
||||
e->lines = 1;
|
||||
|
||||
|
||||
for(c = data; *c; ++c)
|
||||
if(*c == '\n') e->lines++;
|
||||
e->data = malloc(e->lines * sizeof(char**));
|
||||
|
||||
|
||||
for(c = data; *c; ++c) {
|
||||
if(*c == '\n') {
|
||||
buf[i] = 0;
|
||||
|
@ -66,7 +66,7 @@ void credits_add(char *data, int time) {
|
|||
buf[i++] = *c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
buf[i] = 0;
|
||||
e->data[l] = malloc(strlen(buf) + 1);
|
||||
strcpy(e->data[l], buf);
|
||||
|
@ -80,35 +80,35 @@ void credits_skysphere_draw(Vector pos) {
|
|||
glEnable(GL_TEXTURE_2D);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glBindTexture(GL_TEXTURE_2D, get_tex("stage6/sky")->gltex);
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(pos[0], pos[1], pos[2]-30);
|
||||
float s = 370;
|
||||
glScalef(s, s, s);
|
||||
draw_model("skysphere");
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void credits_towerwall_draw(Vector pos) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, get_tex("stage6/towerwall")->gltex);
|
||||
if(!tconfig.intval[NO_SHADER]) {
|
||||
Shader *s = get_shader("tower_wall");
|
||||
glUseProgram(s->prog);
|
||||
glUniform1i(uniloc(s, "lendiv"), 2800.0 + 300.0 * sin(global.frames / 77.7));
|
||||
}
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(pos[0], pos[1], pos[2]);
|
||||
// glRotatef(90, 1,0,0);
|
||||
glScalef(30,30,30);
|
||||
draw_model("towerwall");
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
glUseProgram(0);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
@ -120,56 +120,57 @@ Vector **credits_skysphere_pos(Vector pos, float maxrange) {
|
|||
void credits_init(void) {
|
||||
memset(&credits, 0, sizeof(credits));
|
||||
init_stage3d(&bgcontext);
|
||||
|
||||
|
||||
add_model(&bgcontext, credits_skysphere_draw, credits_skysphere_pos);
|
||||
add_model(&bgcontext, credits_towerwall_draw, stage6_towerwall_pos);
|
||||
|
||||
|
||||
bgcontext.cx[0] = 0;
|
||||
bgcontext.cx[1] = 600;
|
||||
bgcontext.crot[0] = 0;
|
||||
bgcontext.crot[1] = 10;
|
||||
|
||||
|
||||
global.frames = 0;
|
||||
credits_fill();
|
||||
credits.end += 500 + CREDITS_ENTRY_FADEOUT;
|
||||
}
|
||||
|
||||
void credits_draw_entry(CreditsEntry *e) {
|
||||
int time = global.frames - 400, i, yukkuri = False;
|
||||
int time = global.frames - 400, i;
|
||||
bool yukkuri = false;
|
||||
float first, other = 0, fadein = 1, fadeout = 1;
|
||||
CreditsEntry *o;
|
||||
Texture *ytex;
|
||||
|
||||
|
||||
for(o = credits.entries; o != e; ++o)
|
||||
time -= o->time + CREDITS_ENTRY_FADEOUT;
|
||||
|
||||
|
||||
if(time < 0)
|
||||
return;
|
||||
|
||||
|
||||
if(time <= CREDITS_ENTRY_FADEIN)
|
||||
fadein = time / CREDITS_ENTRY_FADEIN;
|
||||
|
||||
|
||||
if(time - e->time - CREDITS_ENTRY_FADEIN > 0)
|
||||
fadeout = max(0, 1 - (time - e->time - CREDITS_ENTRY_FADEIN) / CREDITS_ENTRY_FADEOUT);
|
||||
|
||||
|
||||
if(!fadein || !fadeout)
|
||||
return;
|
||||
|
||||
|
||||
if(*(e->data[0]) == '*') {
|
||||
yukkuri = True;
|
||||
yukkuri = true;
|
||||
ytex = get_tex("yukkureimu");
|
||||
}
|
||||
|
||||
|
||||
first = yukkuri? ytex->trueh * CREDITS_YUKKURI_SCALE : (stringheight(e->data[0], _fonts.mainmenu) * 1.2);
|
||||
if(e->lines > 1)
|
||||
other = stringheight(e->data[1], _fonts.standard) * 1.3;
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
if(fadein < 1)
|
||||
glTranslatef(0, SCREEN_W * pow(1 - fadein, 2) * 0.5, 0);
|
||||
else if(fadeout < 1)
|
||||
glTranslatef(0, SCREEN_W * pow(1 - fadeout, 2) * -0.5, 0);
|
||||
|
||||
|
||||
glColor4f(1, 1, 1, fadein * fadeout);
|
||||
for(i = 0; i < e->lines; ++i) {
|
||||
if(yukkuri && !i) {
|
||||
|
@ -191,20 +192,20 @@ void credits_draw(void) {
|
|||
glPushMatrix();
|
||||
glTranslatef(-SCREEN_W/2, 0, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
|
||||
set_perspective_viewport(&bgcontext, 100, 9000, 0, 0, SCREEN_W, SCREEN_H);
|
||||
draw_stage3d(&bgcontext, 10000);
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
set_ortho();
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glColor4f(0, 0, 0, credits.panelalpha * 0.7);
|
||||
glTranslatef(SCREEN_W/4*3, SCREEN_H/2, 0);
|
||||
glScalef(300, SCREEN_H, 1);
|
||||
draw_quad();
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glColor4f(1, 1, 1, credits.panelalpha * 0.7);
|
||||
glTranslatef(SCREEN_W/4*3, SCREEN_H/2, 0);
|
||||
|
@ -212,25 +213,25 @@ void credits_draw(void) {
|
|||
int i; for(i = 0; i < credits.ecount; ++i)
|
||||
credits_draw_entry(&(credits.entries[i]));
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
draw_transition();
|
||||
}
|
||||
|
||||
void credits_process(void) {
|
||||
TIMER(&global.frames);
|
||||
|
||||
|
||||
bgcontext.cx[2] = 200 - global.frames * 50;
|
||||
bgcontext.cx[1] = 500 + 100 * psin(global.frames / 100.0) * psin(global.frames / 200.0 + M_PI);
|
||||
//bgcontext.cx[0] += nfrand();
|
||||
bgcontext.cx[0] = 25 * sin(global.frames / 75.7) * cos(global.frames / 99.3);
|
||||
|
||||
|
||||
FROM_TO(200, 300, 1)
|
||||
credits.panelalpha += 0.01;
|
||||
|
||||
|
||||
if(global.frames >= credits.end - CREDITS_ENTRY_FADEOUT) {
|
||||
credits.panelalpha -= 1 / 120.0;
|
||||
}
|
||||
|
||||
|
||||
if(global.frames == credits.end) {
|
||||
set_transition(TransFadeWhite, CREDITS_FADEOUT, CREDITS_FADEOUT);
|
||||
}
|
||||
|
@ -244,7 +245,7 @@ void credits_free(void) {
|
|||
free(e->data[j]);
|
||||
free(e->data);
|
||||
}
|
||||
|
||||
|
||||
free(credits.entries);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
* Copyright (C) 2012, Alexeyew Andrew <http://akari.thebadasschoobs.org/>
|
||||
|
|
44
src/dialog.c
44
src/dialog.c
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
*/
|
||||
|
@ -13,12 +13,12 @@
|
|||
Dialog *create_dialog(char *left, char *right) {
|
||||
Dialog *d = malloc(sizeof(Dialog));
|
||||
memset(d, 0, sizeof(Dialog));
|
||||
|
||||
|
||||
if(left)
|
||||
d->images[Left] = get_tex(left);
|
||||
if(right)
|
||||
d->images[Right] = get_tex(right);
|
||||
|
||||
|
||||
d->page_time = global.frames;
|
||||
d->birthtime = global.frames;
|
||||
return d;
|
||||
|
@ -27,7 +27,7 @@ Dialog *create_dialog(char *left, char *right) {
|
|||
void dset_image(Dialog *d, Side side, char *name) {
|
||||
d->images[side] = get_tex(name);
|
||||
}
|
||||
|
||||
|
||||
void dadd_msg(Dialog *d, Side side, char *msg) {
|
||||
d->messages = realloc(d->messages, (++d->count)*sizeof(DialogMessage));
|
||||
d->messages[d->count-1].side = side;
|
||||
|
@ -39,16 +39,16 @@ void delete_dialog(Dialog *d) {
|
|||
int i;
|
||||
for(i = 0; i < d->count; i++)
|
||||
free(d->messages[i].msg);
|
||||
|
||||
|
||||
free(d->messages);
|
||||
free(d);
|
||||
}
|
||||
|
||||
void draw_dialog(Dialog *dialog) {
|
||||
glPushMatrix();
|
||||
|
||||
|
||||
glTranslatef(VIEWPORT_W/2.0, VIEWPORT_H*3.0/4.0, 0);
|
||||
|
||||
|
||||
int i;
|
||||
for(i = 0; i < 2; i++) {
|
||||
glPushMatrix();
|
||||
|
@ -56,15 +56,15 @@ void draw_dialog(Dialog *dialog) {
|
|||
glCullFace(GL_FRONT);
|
||||
glScalef(-1,1,1);
|
||||
}
|
||||
|
||||
|
||||
if(global.frames - dialog->birthtime < 30)
|
||||
glTranslatef(120 - (global.frames - dialog->birthtime)*4, 0, 0);
|
||||
|
||||
|
||||
int cur = dialog->messages[dialog->pos].side;
|
||||
int pre = 2;
|
||||
if(dialog->pos > 0)
|
||||
pre = dialog->messages[dialog->pos-1].side;
|
||||
|
||||
|
||||
short dir = (1 - 2*(i == dialog->messages[dialog->pos].side));
|
||||
if(global.frames - dialog->page_time < 10 && ((i != pre && i == cur) || (i == pre && i != cur))) {
|
||||
int time = (global.frames - dialog->page_time) * dir;
|
||||
|
@ -75,46 +75,46 @@ void draw_dialog(Dialog *dialog) {
|
|||
glTranslatef(dir*10, dir*10, 0);
|
||||
glColor3f(1 - dir*0.7, 1 - dir*0.7, 1 - dir*0.7);
|
||||
}
|
||||
|
||||
|
||||
glTranslatef(VIEWPORT_W*7.0/18.0, 0, 0);
|
||||
if(dialog->images[i])
|
||||
draw_texture_p(0, 0, dialog->images[i]);
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
glColor3f(1,1,1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
if(global.frames - dialog->birthtime < 25)
|
||||
glTranslatef(0, 100-(global.frames-dialog->birthtime)*4, 0);
|
||||
glColor4f(0,0,0,0.8);
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(VIEWPORT_W/2, VIEWPORT_H-75, 0);
|
||||
glScalef(VIEWPORT_W-40, 110, 1);
|
||||
|
||||
|
||||
draw_quad();
|
||||
glPopMatrix();
|
||||
glColor4f(1,1,1,1);
|
||||
|
||||
|
||||
if(dialog->messages[dialog->pos].side == Right)
|
||||
glColor3f(0.6,0.6,1);
|
||||
draw_text(AL_Center, VIEWPORT_W/2, VIEWPORT_H-110, dialog->messages[dialog->pos].msg, _fonts.standard);
|
||||
|
||||
|
||||
if(dialog->messages[dialog->pos].side == Right)
|
||||
glColor3f(1,1,1);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
void page_dialog(Dialog **d) {
|
||||
(*d)->pos++;
|
||||
(*d)->page_time = global.frames;
|
||||
|
||||
|
||||
if((*d)->pos >= (*d)->count) {
|
||||
delete_dialog(*d);
|
||||
*d = NULL;
|
||||
|
|
13
src/dialog.h
13
src/dialog.h
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
*/
|
||||
|
@ -8,6 +8,7 @@
|
|||
#ifndef DIALOG_H
|
||||
#define DIALOG_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "resource/texture.h"
|
||||
|
||||
struct DialogMessage;
|
||||
|
@ -19,7 +20,7 @@ typedef enum {
|
|||
BGM
|
||||
} Side;
|
||||
|
||||
typedef struct DialogMessage {
|
||||
typedef struct DialogMessage {
|
||||
Side side;
|
||||
char *msg;
|
||||
} DialogMessage;
|
||||
|
@ -27,14 +28,14 @@ typedef struct DialogMessage {
|
|||
typedef struct Dialog {
|
||||
DialogMessage *messages;
|
||||
Texture *images[2];
|
||||
|
||||
|
||||
int count;
|
||||
int pos;
|
||||
|
||||
|
||||
int page_time;
|
||||
|
||||
|
||||
int birthtime;
|
||||
int skip;
|
||||
bool skip;
|
||||
} Dialog;
|
||||
|
||||
Dialog *create_dialog(char *left, char *right);
|
||||
|
|
42
src/ending.c
42
src/ending.c
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
* Copyright (C) 2012, Alexeyew Andrew <http://akari.thebadasschoobs.org/>
|
||||
|
@ -11,14 +11,14 @@
|
|||
#include "video.h"
|
||||
|
||||
void add_ending_entry(Ending *e, int dur, char *msg, char *tex) {
|
||||
EndingEntry *entry;
|
||||
EndingEntry *entry;
|
||||
e->entries = realloc(e->entries, (++e->count)*sizeof(EndingEntry));
|
||||
entry = &e->entries[e->count-1];
|
||||
|
||||
|
||||
entry->time = e->duration;
|
||||
e->duration += dur;
|
||||
entry->msg = strdup(msg);
|
||||
|
||||
|
||||
if(tex)
|
||||
entry->tex = get_tex(tex);
|
||||
else
|
||||
|
@ -59,7 +59,7 @@ void good_ending_youmu(Ending *e) {
|
|||
|
||||
void create_ending(Ending *e) {
|
||||
memset(e, 0, sizeof(Ending));
|
||||
|
||||
|
||||
if(global.plr.continues || global.diff == D_Easy) {
|
||||
switch(global.plr.cha) {
|
||||
case Marisa:
|
||||
|
@ -69,7 +69,7 @@ void create_ending(Ending *e) {
|
|||
bad_ending_youmu(e);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
add_ending_entry(e, 400, "Try a no continue run on higher difficulties. You can do it!", NULL);
|
||||
} else {
|
||||
switch(global.plr.cha) {
|
||||
|
@ -82,13 +82,13 @@ void create_ending(Ending *e) {
|
|||
}
|
||||
add_ending_entry(e, 400, "Sorry, extra stage isn't done yet. ^^", NULL);
|
||||
}
|
||||
|
||||
|
||||
if(global.diff == D_Lunatic)
|
||||
add_ending_entry(e, 400, "Lunatic? Didn't know this was even possible. Cheater.", NULL);
|
||||
|
||||
|
||||
add_ending_entry(e, 400, "", NULL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void free_ending(Ending *e) {
|
||||
int i;
|
||||
for(i = 0; i < e->count; i++)
|
||||
|
@ -100,44 +100,44 @@ void ending_draw(Ending *e) {
|
|||
float s, d;
|
||||
int t1 = global.frames-e->entries[e->pos].time;
|
||||
int t2 = e->entries[e->pos+1].time-global.frames;
|
||||
|
||||
|
||||
d = 1.0/ENDING_FADE_TIME;
|
||||
|
||||
|
||||
if(t1 < ENDING_FADE_TIME)
|
||||
s = clamp(d*t1, 0.0, 1.0);
|
||||
else
|
||||
s = clamp(d*t2, 0.0, 1.0);
|
||||
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
||||
glColor4f(1,1,1,s);
|
||||
if(e->entries[e->pos].tex)
|
||||
draw_texture_p(SCREEN_W/2, SCREEN_H/2, e->entries[e->pos].tex);
|
||||
|
||||
|
||||
draw_text(AL_Center, SCREEN_W/2, SCREEN_H/5*4, e->entries[e->pos].msg, _fonts.standard);
|
||||
glColor4f(1,1,1,1);
|
||||
|
||||
|
||||
draw_transition();
|
||||
}
|
||||
|
||||
void ending_loop(void) {
|
||||
Ending e;
|
||||
create_ending(&e);
|
||||
|
||||
|
||||
global.frames = 0;
|
||||
set_ortho();
|
||||
|
||||
|
||||
while(e.pos < e.count-1) {
|
||||
handle_events(NULL, 0, NULL);
|
||||
|
||||
|
||||
ending_draw(&e);
|
||||
global.frames++;
|
||||
SDL_GL_SwapWindow(video.window);
|
||||
frame_rate(&global.lasttime);
|
||||
|
||||
|
||||
if(global.frames >= e.entries[e.pos+1].time)
|
||||
e.pos++;
|
||||
|
||||
|
||||
if(global.frames == e.entries[e.count-1].time-ENDING_FADE_OUT)
|
||||
set_transition(TransFadeWhite, ENDING_FADE_OUT, ENDING_FADE_OUT);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
* Copyright (C) 2012, Alexeyew Andrew <http://akari.thebadasschoobs.org/>
|
||||
|
@ -20,7 +20,7 @@ typedef struct EndingEntry EndingEntry;
|
|||
struct EndingEntry {
|
||||
char *msg;
|
||||
Texture *tex;
|
||||
|
||||
|
||||
int time;
|
||||
};
|
||||
|
||||
|
@ -29,7 +29,7 @@ struct Ending {
|
|||
EndingEntry *entries;
|
||||
int count;
|
||||
int duration;
|
||||
|
||||
|
||||
int pos;
|
||||
};
|
||||
|
||||
|
|
86
src/enemy.c
86
src/enemy.c
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
*/
|
||||
|
@ -16,32 +16,32 @@
|
|||
Enemy *create_enemy_p(Enemy **enemies, complex pos, int hp, EnemyDrawRule draw_rule, EnemyLogicRule logic_rule,
|
||||
complex a1, complex a2, complex a3, complex a4) {
|
||||
Enemy *e = (Enemy *)create_element((void **)enemies, sizeof(Enemy));
|
||||
e->moving = 0;
|
||||
e->moving = false;
|
||||
e->dir = 0;
|
||||
|
||||
|
||||
e->birthtime = global.frames;
|
||||
e->pos = pos;
|
||||
e->pos0 = pos;
|
||||
|
||||
|
||||
e->hp = hp;
|
||||
e->alpha = 1.0;
|
||||
e->unbombable = 0;
|
||||
|
||||
e->unbombable = false;
|
||||
|
||||
e->logic_rule = logic_rule;
|
||||
e->draw_rule = draw_rule;
|
||||
|
||||
|
||||
e->args[0] = a1;
|
||||
e->args[1] = a2;
|
||||
e->args[2] = a3;
|
||||
e->args[3] = a4;
|
||||
|
||||
|
||||
e->logic_rule(e, EVENT_BIRTH);
|
||||
return e;
|
||||
}
|
||||
|
||||
void _delete_enemy(void **enemies, void* enemy) {
|
||||
Enemy *e = (Enemy *)enemy;
|
||||
|
||||
|
||||
if(e->hp <= 0 && e->hp > ENEMY_IMMUNE) {
|
||||
int i;
|
||||
play_sound("enemydeath");
|
||||
|
@ -55,7 +55,7 @@ void _delete_enemy(void **enemies, void* enemy) {
|
|||
}
|
||||
e->logic_rule(enemy, EVENT_DEATH);
|
||||
del_ref(enemy);
|
||||
|
||||
|
||||
delete_element((void **)enemies, enemy);
|
||||
}
|
||||
|
||||
|
@ -69,19 +69,19 @@ void delete_enemies(Enemy **enemies) {
|
|||
|
||||
void draw_enemies(Enemy *enemies) {
|
||||
Enemy *e;
|
||||
int reset = False;
|
||||
|
||||
bool reset = false;
|
||||
|
||||
for(e = enemies; e; e = e->next) {
|
||||
if(e->draw_rule) {
|
||||
if(e->alpha < 1) {
|
||||
e->alpha += 1 / 60.0;
|
||||
if(e->alpha > 1)
|
||||
e->alpha = 1;
|
||||
|
||||
|
||||
glColor4f(1,1,1,e->alpha);
|
||||
reset = True;
|
||||
reset = true;
|
||||
}
|
||||
|
||||
|
||||
e->draw_rule(e, global.frames - e->birthtime);
|
||||
if(reset)
|
||||
glColor4f(1,1,1,1);
|
||||
|
@ -90,8 +90,8 @@ void draw_enemies(Enemy *enemies) {
|
|||
}
|
||||
|
||||
void killall(Enemy *enemies) {
|
||||
Enemy *e;
|
||||
|
||||
Enemy *e;
|
||||
|
||||
for(e = enemies; e; e = e->next)
|
||||
e->hp = 0;
|
||||
}
|
||||
|
@ -105,9 +105,9 @@ int enemy_flare(Projectile *p, int t) { // a[0] timeout, a[1] velocity, a[2] ref
|
|||
} else if(t < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
p->pos += p->args[1];
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -115,28 +115,28 @@ void EnemyFlareShrink(Projectile *p, int t) {
|
|||
Enemy *e = (Enemy *)REF(p->args[2]);
|
||||
if(e == NULL)
|
||||
return;
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
float s = 2.0-t/p->args[0]*2;
|
||||
|
||||
|
||||
if(e->pos + p->pos)
|
||||
glTranslatef(creal(e->pos + p->pos), cimag(e->pos + p->pos), 0);
|
||||
|
||||
|
||||
if(p->angle != M_PI*0.5)
|
||||
glRotatef(p->angle*180/M_PI+90, 0, 0, 1);
|
||||
|
||||
|
||||
if(s != 1)
|
||||
glScalef(s, s, 1);
|
||||
|
||||
|
||||
if(p->clr)
|
||||
glColor4fv((float *)p->clr);
|
||||
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
draw_texture_p(0, 0, p->tex);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
if(p->clr)
|
||||
glColor3f(1,1,1);
|
||||
}
|
||||
|
@ -146,41 +146,41 @@ void BigFairy(Enemy *e, int t) {
|
|||
complex offset = (frand()-0.5)*30 + (frand()-0.5)*20.0I;
|
||||
create_particle3c("lasercurve", offset, rgb(0,0.2,0.3), EnemyFlareShrink, enemy_flare, 50, (-50.0I-offset)/50.0, add_ref(e));
|
||||
}
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(creal(e->pos), cimag(e->pos), 0);
|
||||
|
||||
|
||||
float s = sin((float)(global.frames-e->birthtime)/10.f)/6 + 0.8;
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(global.frames*10,0,0,1);
|
||||
glScalef(s, s, s);
|
||||
draw_texture(0,0,"fairy_circle");
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
if(e->dir) {
|
||||
glCullFace(GL_FRONT);
|
||||
glScalef(-1,1,1);
|
||||
}
|
||||
draw_animation(0, 0, e->moving, "bigfairy");
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
if(e->dir)
|
||||
glCullFace(GL_BACK);
|
||||
}
|
||||
|
||||
void Fairy(Enemy *e, int t) {
|
||||
|
||||
|
||||
float s = sin((float)(global.frames-e->birthtime)/10.f)/6 + 0.8;
|
||||
glPushMatrix();
|
||||
glTranslatef(creal(e->pos),cimag(e->pos),0);
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(global.frames*10,0,0,1);
|
||||
glScalef(s, s, s);
|
||||
draw_texture(0,0,"fairy_circle");
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
if(e->dir) {
|
||||
glCullFace(GL_FRONT);
|
||||
|
@ -188,9 +188,9 @@ void Fairy(Enemy *e, int t) {
|
|||
}
|
||||
draw_animation(0, 0, e->moving, "fairy");
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
if(e->dir) {
|
||||
glCullFace(GL_BACK);
|
||||
}
|
||||
|
@ -206,13 +206,13 @@ void Swirl(Enemy *e, int t) {
|
|||
|
||||
void process_enemies(Enemy **enemies) {
|
||||
Enemy *enemy = *enemies, *del = NULL;
|
||||
|
||||
|
||||
while(enemy != NULL) {
|
||||
int action = enemy->logic_rule(enemy, global.frames - enemy->birthtime);
|
||||
|
||||
|
||||
if(enemy->hp > ENEMY_IMMUNE && cabs(enemy->pos - global.plr.pos) < 7)
|
||||
player_death(&global.plr);
|
||||
|
||||
|
||||
if((enemy->hp > ENEMY_IMMUNE
|
||||
&& (creal(enemy->pos) < -20 || creal(enemy->pos) > VIEWPORT_W + 20
|
||||
|| cimag(enemy->pos) < -20 || cimag(enemy->pos) > VIEWPORT_H + 20
|
||||
|
@ -222,6 +222,6 @@ void process_enemies(Enemy **enemies) {
|
|||
delete_enemy(enemies, del);
|
||||
} else {
|
||||
enemy = enemy->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
21
src/enemy.h
21
src/enemy.h
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
*/
|
||||
|
@ -13,6 +13,7 @@
|
|||
#undef complex
|
||||
#define complex double _Complex
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef struct Enemy Enemy;
|
||||
|
@ -27,21 +28,21 @@ enum {
|
|||
struct Enemy {
|
||||
Enemy *next;
|
||||
Enemy *prev;
|
||||
|
||||
|
||||
complex pos;
|
||||
complex pos0;
|
||||
|
||||
long birthtime;
|
||||
|
||||
|
||||
long birthtime;
|
||||
|
||||
int dir;
|
||||
int moving;
|
||||
|
||||
bool moving;
|
||||
|
||||
EnemyLogicRule logic_rule;
|
||||
EnemyDrawRule draw_rule;
|
||||
|
||||
|
||||
int hp;
|
||||
int unbombable;
|
||||
|
||||
bool unbombable;
|
||||
|
||||
complex args[RULE_ARGC];
|
||||
float alpha;
|
||||
};
|
||||
|
|
24
src/events.c
24
src/events.c
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
* Copyright (C) 2012, Alexeyew Andrew <http://akari.thebadasschoobs.org/>
|
||||
|
@ -14,7 +14,7 @@
|
|||
|
||||
void handle_events(EventHandler handler, EventFlags flags, void *arg) {
|
||||
SDL_Event event;
|
||||
|
||||
|
||||
int kbd = flags & EF_Keyboard;
|
||||
int text = flags & EF_Text;
|
||||
int menu = flags & EF_Menu;
|
||||
|
@ -35,7 +35,7 @@ void handle_events(EventHandler handler, EventFlags flags, void *arg) {
|
|||
while(SDL_PollEvent(&event)) {
|
||||
SDL_Scancode scan = event.key.keysym.scancode;
|
||||
SDL_Keymod mod = event.key.keysym.mod;
|
||||
|
||||
|
||||
switch(event.type) {
|
||||
case SDL_KEYDOWN:
|
||||
if(scan == tconfig.intval[KEY_SCREENSHOT]) {
|
||||
|
@ -51,7 +51,7 @@ void handle_events(EventHandler handler, EventFlags flags, void *arg) {
|
|||
if(kbd) {
|
||||
handler(E_KeyDown, scan, arg);
|
||||
}
|
||||
|
||||
|
||||
if(menu) {
|
||||
if(scan == tconfig.intval[KEY_DOWN] || scan == SDL_SCANCODE_DOWN) {
|
||||
handler(E_CursorDown, 0, arg);
|
||||
|
@ -67,7 +67,7 @@ void handle_events(EventHandler handler, EventFlags flags, void *arg) {
|
|||
handler(E_MenuAbort, 0, arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(game && !event.key.repeat) {
|
||||
if(scan == SDL_SCANCODE_ESCAPE) {
|
||||
handler(E_Pause, 0, arg);
|
||||
|
@ -77,7 +77,7 @@ void handle_events(EventHandler handler, EventFlags flags, void *arg) {
|
|||
handler(E_PlrKeyDown, key, arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(text) {
|
||||
if(scan == SDL_SCANCODE_ESCAPE)
|
||||
handler(E_CancelText, 0, arg);
|
||||
|
@ -86,22 +86,22 @@ void handle_events(EventHandler handler, EventFlags flags, void *arg) {
|
|||
else if(scan == SDL_SCANCODE_BACKSPACE)
|
||||
handler(E_CharErased, 0, arg);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case SDL_KEYUP:
|
||||
if(kbd) {
|
||||
handler(E_KeyUp, scan, arg);
|
||||
}
|
||||
|
||||
|
||||
if(game && !event.key.repeat) {
|
||||
int key = config_scan2key(scan);
|
||||
if(key >= 0)
|
||||
handler(E_PlrKeyUp, key, arg);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case SDL_TEXTINPUT: {
|
||||
char *c;
|
||||
|
||||
|
@ -129,7 +129,7 @@ void handle_events(EventHandler handler, EventFlags flags, void *arg) {
|
|||
case SDL_QUIT:
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
gamepad_event(&event, handler, flags, arg);
|
||||
break;
|
||||
|
|
10
src/events.h
10
src/events.h
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
* Copyright (C) 2012, Alexeyew Andrew <http://akari.thebadasschoobs.org/>
|
||||
|
@ -21,13 +21,13 @@ typedef enum {
|
|||
// EF_Keyboard
|
||||
E_KeyDown,
|
||||
E_KeyUp,
|
||||
|
||||
|
||||
// EF_Text
|
||||
E_CharTyped,
|
||||
E_CharErased,
|
||||
E_SubmitText,
|
||||
E_CancelText,
|
||||
|
||||
|
||||
// EF_Menu
|
||||
E_CursorUp,
|
||||
E_CursorDown,
|
||||
|
@ -35,14 +35,14 @@ typedef enum {
|
|||
E_CursorRight,
|
||||
E_MenuAccept,
|
||||
E_MenuAbort,
|
||||
|
||||
|
||||
// EF_Game
|
||||
E_PlrKeyDown,
|
||||
E_PlrKeyUp,
|
||||
E_PlrAxisUD,
|
||||
E_PlrAxisLR,
|
||||
E_Pause,
|
||||
|
||||
|
||||
// EF_Gamepad
|
||||
E_GamepadKeyDown,
|
||||
E_GamepadKeyUp
|
||||
|
|
36
src/fbo.c
36
src/fbo.c
|
@ -9,39 +9,39 @@
|
|||
#include "global.h"
|
||||
#include "taisei_err.h"
|
||||
|
||||
void init_fbo(FBO *fbo) {
|
||||
void init_fbo(FBO *fbo) {
|
||||
glGenTextures(1, &fbo->tex);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo->tex);
|
||||
|
||||
|
||||
fbo->nw = 2;
|
||||
fbo->nh = 2;
|
||||
|
||||
|
||||
while(fbo->nw < VIEWPORT_W+VIEWPORT_X) fbo->nw *= 2;
|
||||
while(fbo->nh < VIEWPORT_H+VIEWPORT_Y) fbo->nh *= 2;
|
||||
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, fbo->nw, fbo->nh, 0, GL_BGR, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
|
||||
glGenFramebuffers(1,&fbo->fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo->fbo);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fbo->tex, 0);
|
||||
|
||||
|
||||
glGenTextures(1, &fbo->depth);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo->depth);
|
||||
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, fbo->nw, fbo->nh, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
|
||||
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D,fbo->depth, 0);
|
||||
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
|
@ -51,22 +51,22 @@ void delete_fbo(FBO *fbo) {
|
|||
glDeleteTextures(1, &fbo->tex);
|
||||
}
|
||||
|
||||
void draw_fbo_viewport(FBO *fbo) {
|
||||
void draw_fbo_viewport(FBO *fbo) {
|
||||
glPushMatrix();
|
||||
glTranslatef(-VIEWPORT_X,VIEWPORT_H+VIEWPORT_Y-fbo->nh,0);
|
||||
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
|
||||
glTranslatef(fbo->nw/2,fbo->nw/2,0);
|
||||
glScalef(fbo->nw, fbo->nh, 1);
|
||||
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, fbo->tex);
|
||||
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glDrawArrays(GL_QUADS, 4, 4);
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
}
|
|
@ -14,7 +14,7 @@ typedef struct {
|
|||