summaryrefslogtreecommitdiff
path: root/src/test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/test.cc')
-rw-r--r--src/test.cc557
1 files changed, 524 insertions, 33 deletions
diff --git a/src/test.cc b/src/test.cc
index 6884790..d19b5d8 100644
--- a/src/test.cc
+++ b/src/test.cc
@@ -28,19 +28,9 @@
#include "glshape.h"
#include "glwidgets.h"
-class keyhandler_t : public mogltk::engine::keyevent {
- virtual void down(SDL_keysym keysym) {
- if (keysym.sym == SDLK_ESCAPE)
- mogltk::engine::quit();
- if ((keysym.sym == SDLK_RETURN) && (keysym.mod & KMOD_ALT))
- mogltk::engine::base_o->ToggleFullscreen();
- }
- virtual void up(SDL_keysym keysym) {
- }
-} keyhandler;
-
#if 1
+#define TRTIME 1500
#define SPIN .50
#define TILT .20
@@ -521,15 +511,89 @@ void incrementstars(double nt) {
#endif
}
+class testkey_t : public mogltk::engine::keyevent {
+ public:
+ virtual void down(SDL_keysym keysym) {
+ if (keysym.sym == SDLK_SPACE && !start_transit) {
+ start_transit = true;
+ transit_time = SDL_GetTicks();
+ } else if (old_handler)
+ old_handler->down(keysym);
+ }
+ virtual void up(SDL_keysym keysym) {
+ if (old_handler)
+ old_handler->up(keysym);
+ }
+ bool start_transit;
+ Uint32 transit_time;
+} * testkey;
+
+void affiche_grille(mogltk::shape * sh, mogltk::texture * tex, int grille[41][31][2]) {
+ int x, y, tx1, tx2, ty1, ty2;
+ static mogltk::ColorP w = WHITE;
+
+ w.Bind();
+ tex->Bind();
+
+// sh->box(0, 0, 640, 480, BLACK);
+ for (y = 0; y < 30; y++) {
+ for (x = 0; x < 40; x++) {
+ tx1 = x * 20;
+ ty1 = y * 20;
+ tx2 = x * 20 + 20;
+ ty2 = y * 20 + 20;
+
+#if 1
+ glBegin(GL_TRIANGLE_STRIP);
+ glTexCoord2i(tx1, ty1); glVertex2i(grille[x ][y ][0], grille[x ][y ][1]);
+ glTexCoord2i(tx2, ty1); glVertex2i(grille[x + 1][y ][0], grille[x + 1][y ][1]);
+ glTexCoord2i(tx1, ty2); glVertex2i(grille[x ][y + 1][0], grille[x ][y + 1][1]);
+ glTexCoord2i(tx2, ty2); glVertex2i(grille[x + 1][y + 1][0], grille[x + 1][y + 1][1]);
+ glEnd();
+#else
+ sh->line(grille[x ][y ][0], grille[x ][y ][1],
+ grille[x + 1][y ][0], grille[x + 1][y ][1]);
+ sh->line(grille[x + 1][y ][0], grille[x + 1][y ][1],
+ grille[x + 1][y + 1][0], grille[x + 1][y + 1][1]);
+ sh->line(grille[x + 1][y + 1][0], grille[x + 1][y + 1][1],
+ grille[x ][y + 1][0], grille[x ][y + 1][1]);
+ sh->line(grille[x ][y + 1][0], grille[x ][y + 1][1],
+ grille[x ][y ][0], grille[x ][y ][1]);
+#endif
+ }
+ }
+}
+
virtual int startup() throw (GeneralException) {
- int sx1, sx2, sy1, sy2;
+ bool flag = false, flag2 = false;
+ mogltk::texture * sshot = 0, * plastex = new mogltk::texture(1024, 512);
+ int x, y, sx1, sx2, sy1, sy2, lastframe, curframe, px, py, lasttick = 0, curtick = 0, oldblend, seconds = 0, newseconds = 0;
double t = 0;
- verbosity = M_INFO;
+ verbosity = M_ERROR;
String str;
+ bool got_transit = false;
+ Uint8 * plasma = (Uint8 *) malloc(640 * 480), * pplasma;
+ int grille[41][31][2];
+ double seeds[41][31];
+ double speeds[41][31];
+
+#if 0
+ srand(25);
+ for (y = 0; y < 31; y++) {
+ for (x = 0; x < 41; x++) {
+ seeds[x][y] = 1.2 * (double) (rand() % 10000) / 10000;
+ speeds[x][y] = 2.6 * (double) (rand() % 10000) / 10000;
+ }
+ }
+#endif
+
+ testkey = new testkey_t();
mogltk::engine::setmouseZ(50);
#if 0
+
+#if 0
Lua * l = new Lua();
LuaInput::pushconstruct(l);
LuaOutput::pushconstruct(l);
@@ -547,18 +611,39 @@ virtual int startup() throw (GeneralException) {
delete l;
#endif
- new Archive("datas.paq");
// bdlload("cl.bdl");
+#endif
+
+ Input pl("plasma.raw");
+ pl.read(plasma, 640 * 480);
+
+ pplasma = (Uint8 *) plastex->GetPixels();
+
+ for (y = 0; y < 480; y++) {
+ for (x = 0; x < 640; x++) {
+ pplasma[((y * 1024) + x) * 4 + 3] = 255 - plasma[(y * 640) + x];
+ }
+ }
+
+ new Archive("datas.paq");
+
#if 1
mogltk::base * gl = new mogltk::glbase();
mogltk::shape * sh = new mogltk::glshape();
mogltk::font * font = new mogltk::glfont(&Input("font-2.bin"));
mogltk::glSprite * s = new mogltk::glSprite(&Input("cursor.rgba"), 25, 25);
+ mogltk::texture * sol = new mogltk::texture(&Input("sol.tex"));
+ mogltk::glSprite * logo = new mogltk::glSprite(&Input("logo.raw"), 165, 124);
+#if 0
mogltk::Sprite * p = new mogltk::glSprite(&Input("particule.rgba"), 16, 16);
-// mogltk::glSprite * spr = new mogltk::glSprite(&Input("015_Over-Mind.raw"), 347, 328);
- mogltk::glSprite * spr = new mogltk::glSprite(&Input("test.raw"), 200, 200);
+ mogltk::glSprite * spr = new mogltk::glSprite(&Input("015_Over-Mind.raw"), 347, 328);
+ mogltk::glSprite * eD1 = new mogltk::glSprite(&Input("elkyaD1.raw"), 53, 100);
+ mogltk::glSprite * eG1 = new mogltk::glSprite(&Input("elkyaG1.raw"), 53, 100);
+ mogltk::glSprite * eM1 = new mogltk::glSprite(&Input("elkyaM1.raw"), 53, 100);
+// mogltk::glSprite * spr = new mogltk::glSprite(&Input("test.raw"), 200, 200);
mogltk::widget * w = new mogltk::Root(sh);
+#endif
#else
mogltk::base * gl = new mogltk::base();
mogltk::shape * sh = new mogltk::shape();
@@ -569,9 +654,11 @@ virtual int startup() throw (GeneralException) {
mogltk::widget * w = new mogltk::Root(sh);
#endif
-#if 1
+ mogltk::texture * ttex = 0;
+
font->setcolor(WHITE);
- font->setshadow(1);
+ font->setshadow(2);
+#if 0
mogltk::rect textrect;
mogltk::texture * text = font->printtex(&textrect,
"PixelPawa!\n"
@@ -586,8 +673,7 @@ virtual int startup() throw (GeneralException) {
mogltk::engine::setcursorvisible(true);
mogltk::engine::setappactive(true);
- mogltk::engine::setkeyevent(&keyhandler);
-
+#if 0
mogltk::texture * mytex = new mogltk::texture(&Input("pattern6.tex"), true);
Color AlphaBlue(AQUA);
@@ -596,15 +682,27 @@ virtual int startup() throw (GeneralException) {
mogltk::fill * f = sh->fcircle(320, 240, 50);
initstars();
-
+
+ px = 200;
+ py = 350;
+#endif
+
while (!mogltk::engine::quitrequested()) {
- sx1 = 320 + 320 * sin(0.983 * t + 3.15);
+#if 0
+ sx1 = 320 + 320 * sin(0.983 * t + 3.15);
sx2 = 320 + 320 * sin(0.537 * t + 5.32);
sy1 = 240 + 240 * sin(0.692 * t + 8.21);
sy2 = 240 + 240 * sin(1.029 * t + 2.42);
+#endif
gl->Enter2DMode();
+#if 1
+ if (got_transit)
+ goto do_transit;
+#endif
+
+#if 0
w->fulldraw();
sh->tbox(mytex, 50, 50, 561, 561, BLACK, RED, LIME, BLUE);
@@ -639,7 +737,37 @@ virtual int startup() throw (GeneralException) {
sh->fdraw(f, BLUE);
sh->sdraw(f);
- spr->drawrotate(500, 400, sx1);
+ eM1->drawrotate(500, 400, sx1);
+
+ curtick = (SDL_GetTicks() / 250) % 4;
+
+ if (curtick != lasttick) {
+ px -= 10;
+ py += 5;
+
+ if (px < -53)
+ px = 640;
+ if (px > 640)
+ px = -53;
+ if (py > 480)
+ py = -100;
+ lasttick = curtick;
+ }
+
+ switch(curtick) {
+ case 0:
+ eM1->draw(px, py, WHITE, 1, 1);
+ break;
+ case 1:
+ eD1->draw(px, py, WHITE, 1, 1);
+ break;
+ case 2:
+ eM1->draw(px, py, WHITE, 1, 1);
+ break;
+ case 3:
+ eG1->draw(px, py, WHITE, 1, 1);
+ break;
+ }
sh->box(MIN(sx1, sx2), MIN(sy1, sy2), MAX(sx1, sx2), MAX(sy1, sy2), AlphaBlue);
mogltk::ColorP::Min.A = 200;
@@ -656,23 +784,335 @@ virtual int startup() throw (GeneralException) {
displaystars(p);
incrementstars(t);
- font->putcursor(550, 400);
+ sh->box(0, 0, 640, 480, CORNFLOWERBLUE, DEEPSKYBLUE, MIDNIGHTBLUE, NAVY);
+
+#endif
+// sh->box(0, 0, 640, 480, CORNFLOWERBLUE, DEEPSKYBLUE, MIDNIGHTBLUE, NAVY);
+
+ int x, y;
+
+#if 0
+ for (y = 0; y < 31; y++) {
+ for (x = 0; x < 41; x++) {
+ grille[x][y][0] = x * 16 + 8 * sin(t * 6 + (x + y) / 2.0);
+ grille[x][y][1] = y * 16 + 8 * cos(t * 6 + (x + y) / 2.0);
+ }
+ }
+#endif
+ double dis, xdis, ydis, xpos, ypos, norm, tt, tt1;
+
+ t += 48;
+
+ tt = t - (((int) t) / 58) * 58;
+
+ if (tt <= 20) {
+ flag = flag2 = false;
+ for (y = 0; y < 31; y++) {
+ for (x = 0; x < 41; x++) {
+ xpos = x - 20.5;
+ ypos = y - 15.5;
+ norm = sqrt(xpos * xpos + ypos * ypos);
+ xpos /= norm;
+ ypos /= norm;
+ dis = sin(t * 6 - norm);
+ xdis = dis * sin(xpos);
+ ydis = dis * sin(ypos);
+ grille[x][y][0] = (((x * 16 + 16 * xdis) - 320) * 1.08) + 320;
+ grille[x][y][1] = (((y * 16 + 16 * ydis) - 240) * 1.08) + 240;
+ }
+ }
+
+ affiche_grille(sh, sol, grille);
+ if (tt < 4)
+ sh->box(0, 0, 640, 480, Color(255, 255, 255, 255 * ((4 - tt) / 4)));
+ else if (tt > 16)
+ sh->box(0, 0, 640, 480, Color(0, 0, 0, 255 * ((tt - 16) / 4)));
+ } else if (tt <= 23) {
+ tt -= 20;
+ sh->box(0, 0, 640, 480, BLACK);
+ for (y = 0; y < 31; y++) {
+ for (x = 0; x < 41; x++) {
+ grille[x][y][0] = ((((x * 16 + 8 * sin(t * 6 + (x + y) / 2.0)) - 320) * 1.08) + 320) * tt / 3;
+ grille[x][y][1] = ((((y * 16 + 8 * cos(t * 6 + (x + y) / 2.0)) - 200) * 1.08) + 200) * tt / 3;
+ }
+ }
+ affiche_grille(sh, sol, grille);
+ } else if (tt <= 36) {
+ for (y = 0; y < 31; y++) {
+ for (x = 0; x < 41; x++) {
+ grille[x][y][0] = (((x * 16 + 8 * sin(t * 6 + (x + y) / 2.0)) - 320) * 1.08) + 320;
+ grille[x][y][1] = (((y * 16 + 8 * cos(t * 6 + (x + y) / 2.0)) - 200) * 1.08) + 200;
+ }
+ }
+ affiche_grille(sh, sol, grille);
+ } else if (tt <= 38) {
+ tt -= 36;
+ if (!flag2) {
+ sshot = gl->GrabTexture();
+ flag2 = true;
+ }
+ sh->tbox(sshot, 0, 0, 640, 480);
+ if (tt <= 0.1) {
+ sh->box(0, 0, 640, 480, Color(255, 255, 255, 255 * (tt / 0.1)));
+ } else if (tt < 0.5) {
+ tt -= 0.1;
+ sh->box(0, 0, 640, 480, Color(255, 255, 255, 255 * ((0.4 - tt) / 0.4)));
+ sh->box(0, 0, 640, 480, Color(0.3 * 255, 0.2 * 255, 0.3 * 255, 127 * (tt / 0.4)));
+ } else {
+ sh->box(0, 0, 640, 480, Color(0.3 * 255, 0.2 * 255, 0.3 * 255, 127));
+ }
+ for (y = 0; y < 15; y++) {
+ for (x = 0; x < 20; x++) {
+ sh->obox(x * 32, y * 32, x * 32 + 32, y * 32 + 32, WHITE);
+ }
+ }
+ } else if (tt <= 42) {
+ int xx, yy, tyy;
+ double ttt;
+ tt -= 38;
+ sh->box(0, 0, 640, 480, BLACK);
+ for (y = 14; y >= 0; y--) {
+ for (x = 19; x >= 0; x--) {
+ double d = (33.0 - x - y) / 16.5;
+ xx = x * 32;
+ tyy = y * 32;
+ if (tt <= d) {
+ yy = y * 32;
+ } else {
+ ttt = tt - d;
+ yy = y * 32 + ttt * ttt * ttt * 60;
+ }
+ sh->tbox(sshot, xx, yy, xx + 32, yy + 32, xx, tyy, xx + 32, tyy + 32);
+ sh->box(xx, yy, xx + 32, yy + 32, Color(0.3 * 255, 0.2 * 255, 0.3 * 255, 127));
+ sh->obox(xx, yy, xx + 32, yy + 32, WHITE);
+ }
+ }
+ } else if (tt <= 43) {
+ sh->box(0, 0, 640, 480, BLACK);
+ } else if (tt <= 48) {
+ tt -= 43;
+ sh->tbox(sol, 0, 0, 640, 480, 0, 0, 800, 600);
+ glDisable(GL_BLEND);
+ glEnable(GL_ALPHA_TEST);
+ glAlphaFunc(GL_GREATER, tt / 5);
+ sh->tbox(plastex, 0, 0, 640, 480);
+ glDisable(GL_ALPHA_TEST);
+ glEnable(GL_BLEND);
+ } else if (tt <= 56) {
+ sh->tbox(sol, 0, 0, 640, 480, 0, 0, 800, 600);
+ } else if (tt <= 58) {
+ if (!flag) {
+ if (sshot)
+ delete sshot;
+ testkey->start_transit = true;
+ testkey->transit_time = SDL_GetTicks();
+ flag = true;
+ } else {
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ sh->box(0, 0, 640, 480, Color(255, 255, 255, 1));
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+ }
+
+ logo->draw(10, 10, Color(255, 255, 255, 100));
+
+
+ font->putcursor(530, 460);
font->printf("FPS: %.2f\n", mogltk::engine::FPS());
- font->printf("mx: %i\n", mogltk::engine::mouseX());
- font->printf("my: %i\n", mogltk::engine::mouseY());
- font->printf("t: %.2fs\n", SDL_GetTicks() / 1000.0);
- mogltk::ColorP::Max.A = 50;
- s->draw(mogltk::engine::mouseX() - 6, mogltk::engine::mouseY() - 3, BLACK);
+// font->printf("mx: %i\n", mogltk::engine::mouseX());
+// font->printf("my: %i\n", mogltk::engine::mouseY());
+// font->printf("t: %.2fs\n", SDL_GetTicks() / 1000.0);
+// mogltk::ColorP::Max.A = 50;
+// s->draw(mogltk::engine::mouseX() - 6, mogltk::engine::mouseY() - 3, BLACK);
+// mogltk::ColorP::Max.A = 255;
+// s->draw(mogltk::engine::mouseX() - 8, mogltk::engine::mouseY() - 6);
+
+do_transit:
+ mogltk::ColorP::Min.A = 0;
mogltk::ColorP::Max.A = 255;
- s->draw(mogltk::engine::mouseX() - 8, mogltk::engine::mouseY() - 6);
+ if (testkey->start_transit) {
+ double t;
+ int x, y;
+ Uint8 * pixels;
+ if (!got_transit) {
+ lastframe = 0;
+ got_transit = true;
+ ttex = gl->GrabTexture();
+ pixels = (Uint8 *) ttex->GetPixels();
+ oldblend = 20;
+#if 1
+ for (y = 0; y < 480; y++) {
+ for (x = 0; x < 640; x++) {
+#if 0
+ pixels[(y * 1024 + x) * 4 + 0] ^= 255;
+ pixels[(y * 1024 + x) * 4 + 1] ^= 255;
+ pixels[(y * 1024 + x) * 4 + 2] ^= 255;
+#endif
+#if 0
+ pixels[(y * 1024 + x) * 4 + 3] = plasma[y * 640 + x];
+#endif
+#if 1
+ pixels[(y * 1024 + x) * 4 + 3] = 30;
+#endif
+#if 0
+ pixels[(y * 1024 + x) * 4 + 3] = 7;
+#endif
+#if 0
+ pixels[(y * 1024 + x) * 4 + 3] = 1;
+#endif
+ }
+ }
+#endif
+ }
+ pixels = (Uint8 *) ttex->GetPixels();
+ t = (double) (SDL_GetTicks() - testkey->transit_time) / TRTIME;
+ curframe = 45 * (SDL_GetTicks() - testkey->transit_time) / TRTIME;
+ if (t >= 1.0) {
+ testkey->start_transit = false;
+ }
+#if 0
+ mogltk::ColorP::Max.A = 255 * (TRTIME - SDL_GetTicks() + testkey->transit_time) / TRTIME;
+ mogltk::ColorP::Min.R = 255 * (SDL_GetTicks() - testkey->transit_time) / TRTIME;
+ mogltk::ColorP::Min.G = 255 * (SDL_GetTicks() - testkey->transit_time) / TRTIME;
+ mogltk::ColorP::Min.B = 255 * (SDL_GetTicks() - testkey->transit_time) / TRTIME;
+ sh->tbox(ttex, 0, 0, 640, 480);
+ mogltk::ColorP::Max.A = 255;
+ mogltk::ColorP::Min.R = 0;
+ mogltk::ColorP::Min.G = 0;
+ mogltk::ColorP::Min.B = 0;
+#endif
+#if 0
+ for (y = 0; y < 10; y++) {
+ for (x = 0; x < 10; x++) {
+ int cx, cy, tx1, ty1, tx2, ty2;
+ cx = x * 64 + 32;
+ cy = y * 48 + 24;
+ tx1 = x * 64;
+ ty1 = y * 48;
+ tx2 = x * 64 + 64;
+ ty2 = y * 48 + 48;
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glTranslated(cx, cy, 0);
+ glScaled((1 - t), (1 - t), 1);
+ glRotated((t + ((x + y) / 30)) * 400, 0, 0, 1);
+ sh->tbox(ttex, -32, -24, 32, 24, tx1, ty1, tx2, ty2);
+ glPopMatrix();
+ }
+ }
+#endif
+#if 0
+ glDisable(GL_BLEND);
+ glEnable(GL_ALPHA_TEST);
+ glAlphaFunc(GL_GREATER, t);
+ sh->tbox(ttex, 0, 0, 640, 480);
+ glDisable(GL_ALPHA_TEST);
+ glEnable(GL_BLEND);
+#endif
+#if 1
+ if (curframe > lastframe) {
+#if 1
+ sh->box(0, 0, 640, 480, Color(40, 40, 40, 12));
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glPushMatrix();
+ glTranslated(320, 240, 0);
+ glScaled(1 + 2 * t, 1 + 2 * t, 1);
+ glRotated(t * 100, 0, 0, 1);
+ sh->tbox(ttex, -320, -240, 320, 240);
+ glPopMatrix();
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+#endif
+#if 0
+ sh->box(0, 0, 640, 480, Color(25, 25, 25, 20));
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glPushMatrix();
+ glTranslated(320, 240, 0);
+ glTranslated(curframe, 0, 0); sh->tbox(ttex, -320, -240, 320, 240);
+ glTranslated(0, curframe, 0); sh->tbox(ttex, -320, -240, 320, 240);
+ glTranslated(-curframe, 0, 0); sh->tbox(ttex, -320, -240, 320, 240);
+ glTranslated(-curframe, 0, 0); sh->tbox(ttex, -320, -240, 320, 240);
+ glTranslated(0, -curframe, 0); sh->tbox(ttex, -320, -240, 320, 240);
+ glTranslated(0, -curframe, 0); sh->tbox(ttex, -320, -240, 320, 240);
+ glTranslated(curframe, 0, 0); sh->tbox(ttex, -320, -240, 320, 240);
+ glTranslated(curframe, 0, 0); sh->tbox(ttex, -320, -240, 320, 240);
+ glPopMatrix();
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+#endif
+#if 0
+ int x0 = 320, y0 = 240;
+ int x = 0;
+ int y = t * 15 - 1;
+ int d = 3 - 2 * t * 15;
+ int dI = 10 - 4 * t * 15;
+ int rI = 6;
+
+ sh->box(0, 0, 640, 480, Color(25, 25, 25, oldblend));
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ oldblend = 0;
+ while (x <= y) {
+ oldblend += 16;
+ glPushMatrix(); glTranslated(x0 + x, y0 + y, 0); sh->tbox(ttex, -320, -240, 320, 240); glPopMatrix();
+ glPushMatrix(); glTranslated(x0 - x, y0 + y, 0); sh->tbox(ttex, -320, -240, 320, 240); glPopMatrix();
+ glPushMatrix(); glTranslated(x0 + x, y0 - y, 0); sh->tbox(ttex, -320, -240, 320, 240); glPopMatrix();
+ glPushMatrix(); glTranslated(x0 - x, y0 - y, 0); sh->tbox(ttex, -320, -240, 320, 240); glPopMatrix();
+ glPushMatrix(); glTranslated(x0 + y, y0 + x, 0); sh->tbox(ttex, -320, -240, 320, 240); glPopMatrix();
+ glPushMatrix(); glTranslated(x0 - y, y0 + x, 0); sh->tbox(ttex, -320, -240, 320, 240); glPopMatrix();
+ glPushMatrix(); glTranslated(x0 + y, y0 - x, 0); sh->tbox(ttex, -320, -240, 320, 240); glPopMatrix();
+ glPushMatrix(); glTranslated(x0 - y, y0 - x, 0); sh->tbox(ttex, -320, -240, 320, 240); glPopMatrix();
+ if (d >= 0) {
+ d += dI;
+ dI += 8;
+ y -= 1;
+ } else {
+ d += rI;
+ dI += 4;
+ }
+ rI += 4;
+ x += 1;
+ }
+ printm(M_INFO, "blends = %i\n", oldblend / 2);
+ oldblend += 10;
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+#endif
+#if 0
+ sh->box(0, 0, 640, 480, Color(40, 40, 40, 12));
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glPushMatrix();
+ glTranslated(320, 240, 0);
+ glRotated(t * 25, 0, 0, 1);
+ sh->tbox(ttex, -320, -240, 320, 240);
+ glPopMatrix();
+ glPushMatrix();
+ glTranslated(320, 240, 0);
+ glRotated(-t * 25, 0, 0, 1);
+ sh->tbox(ttex, -320, -240, 320, 240);
+ glPopMatrix();
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+#endif
+ lastframe = curframe;
+ }
+#endif
+ }
+ if (!testkey->start_transit && ttex) {
+ delete ttex;
+ ttex = 0;
+ got_transit = false;
+ }
gl->Leave2DMode();
- gl->Flip();
+ //gl->Flip(got_transit ? false : true);
+ gl->Flip(false);
t = (double) SDL_GetTicks() / 1000.0;
+ newseconds = t;
+
+ if (newseconds != seconds) {
+ printm(M_INFO, "FPS: %.2f\n", mogltk::engine::FPS());
+ seconds = newseconds;
+ }
}
- delete mytex;
+// delete mytex;
return 0;
}
@@ -680,6 +1120,7 @@ CODE_ENDS
#else
+#if 0
CODE_BEGINS
virtual int startup() throw (GeneralException) {
unsigned char palette[256][3], * pixels, c;
@@ -733,5 +1174,55 @@ virtual int startup() throw (GeneralException) {
}
CODE_ENDS
+#else
+CODE_BEGINS
+virtual int startup() throw (GeneralException) {
+ unsigned char * pixels, c;
+ char outname[256];
+ int width, height, x, y;
+
+ if (argc != 2)
+ exit(-1);
+ Input i(argv[1]);
+ SDL_Init(SDL_INIT_VIDEO);
+ atexit(SDL_Quit);
+ i.seek(4, SEEK_SET);
+ i.read(&width, 4);
+ i.read(&height, 4);
+ i.seek(4, SEEK_CUR);
+ SDL_Surface * _s = SDL_SetVideoMode(width, height, 32, 0);
+ SDL_Surface * s = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
+ 0x000000ff,
+ 0x0000ff00,
+ 0x00ff0000,
+ 0xff000000);
+
+ pixels = (unsigned char *) s->pixels;
+ *strchr(argv[1], '.') = 0;
+
+ i.read(pixels, width * height * 4);
+
+ sprintf(outname, "%s.bmp", argv[1]);
+
+ SDL_SaveBMP(s, outname);
+ SDL_BlitSurface(s, 0, _s, 0);
+
+ SDL_Flip(_s);
-#endif \ No newline at end of file
+ SDL_Event event;
+
+ while(true) {
+ SDL_PollEvent(&event);
+ switch (event.type) {
+ case SDL_QUIT:
+ exit(0);
+ }
+ }
+
+ return 0;
+}
+CODE_ENDS
+
+#endif
+
+#endif