summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test.cc247
1 files changed, 160 insertions, 87 deletions
diff --git a/src/test.cc b/src/test.cc
index 16f6ed4..6884790 100644
--- a/src/test.cc
+++ b/src/test.cc
@@ -28,13 +28,26 @@
#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 SPIN .50
#define TILT .20
-#define NBSTARS 10000
+#define NBSTARS 300
#define STARSRATE 300.0
-#define LUA
+#define SPHERE
int zoom = 1;
@@ -304,13 +317,13 @@ void checkluastack(lua_State * L) {
break;
case LUA_TTABLE:
printm(M_INFO, String(i) + ": (Table) Exploring:\n");
- lua_pushnil(L); /* first key */
- j = 0;
- while (lua_next(L, -2) != 0) {
- /* `key' is at index -2 and `value' at index -1 */
- printm(M_INFO, " %s - %s\n", lua_typename(L, lua_type(L, -2)),
- lua_typename(L, lua_type(L, -1)));
- lua_pop(L, 1); /* removes `value'; keeps `key' for next iteration */
+ lua_pushnil(L); /* first key */
+ j = 0;
+ while (lua_next(L, -2) != 0) {
+ /* `key' is at index -2 and `value' at index -1 */
+ printm(M_INFO, " %s - %s\n", lua_typename(L, lua_type(L, -2)),
+ lua_typename(L, lua_type(L, -1)));
+ lua_pop(L, 1); /* removes `value'; keeps `key' for next iteration */
}
t = "";
break;
@@ -514,64 +527,37 @@ virtual int startup() throw (GeneralException) {
verbosity = M_INFO;
String str;
- Buffer * b = new Buffer(true);
- (*b) << "Blah! (1)\n";
- (*b) << "Blah! (2)\n";
- (*b) << "Blah! (3)\n";
-
- (*b) >> str;
- printm(M_INFO, "Read `" + str + "'\n");
-
- (*b) << "Blah! (4)\n";
-
- (*b) >> str;
- printm(M_INFO, "Read `" + str + "'\n");
- (*b) >> str;
- printm(M_INFO, "Read `" + str + "'\n");
- (*b) >> str;
- printm(M_INFO, "Read `" + str + "'\n");
-
- (*b)[10000] = 32;
-
- printm(M_INFO, "Size = %i\n", b->GetSize());
-
- b->seek(10000);
- printm(M_INFO, "Read %i\n", b->readU8());
+ mogltk::engine::setmouseZ(50);
+#if 0
Lua * l = new Lua();
LuaInput::pushconstruct(l);
LuaOutput::pushconstruct(l);
LuaBuffer::pushconstruct(l);
l->open_math();
l->declarefunc("print", myprint);
-#if 1
+#if 0
l->load(&Input("particules.lua"), false);
l->dump(&Output("particules.out"));
l->call();
#else
l->load(&Input("particules.out"));
#endif
- l->call("testing");
+// l->call("testing");
delete l;
-
+#endif
+
new Archive("datas.paq");
// bdlload("cl.bdl");
- Input * t1;
- Output * t2;
-
- t1 = new Input("font.bin");
- t2 = new Output("dump/font.bin");
- copy(t1, t2);
- delete(t1);
- delete(t2);
-
#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::Sprite * s = new mogltk::glSprite(&Input("cursor.rgba"), 25, 25);
+ mogltk::glSprite * s = new mogltk::glSprite(&Input("cursor.rgba"), 25, 25);
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::widget * w = new mogltk::Root(sh);
#else
mogltk::base * gl = new mogltk::base();
@@ -579,77 +565,106 @@ virtual int startup() throw (GeneralException) {
mogltk::font * font = new mogltk::font(&Input("font-2.bin"));
mogltk::Sprite * s = new mogltk::Sprite(&Input("cursor.rgba"), 25, 25);
mogltk::Sprite * p = new mogltk::Sprite(&Input("particule.rgba"), 16, 16);
+ mogltk::Sprite * spr = new mogltk::Sprite(&Input("015_Over-Mind.raw"), 347, 328);
mogltk::widget * w = new mogltk::Root(sh);
#endif
+#if 1
+ font->setcolor(WHITE);
+ font->setshadow(1);
+ mogltk::rect textrect;
+ mogltk::texture * text = font->printtex(&textrect,
+ "PixelPawa!\n"
+ "It works!!\n"
+ "I can't believe it!\n"
+ );
+ SDL_SaveBMP(text->GetSurface(), "test-font.bmp");
+ textrect.x = 10;
+ textrect.y = 30;
+#endif
+
mogltk::engine::setcursorvisible(true);
mogltk::engine::setappactive(true);
+
+ mogltk::engine::setkeyevent(&keyhandler);
mogltk::texture * mytex = new mogltk::texture(&Input("pattern6.tex"), true);
Color AlphaBlue(AQUA);
AlphaBlue.A = 50;
-// mogltk::fill * f = sh->fcircle(320, 240, 50);
+ mogltk::fill * f = sh->fcircle(320, 240, 50);
initstars();
while (!mogltk::engine::quitrequested()) {
-// 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);
+ 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);
gl->Enter2DMode();
w->fulldraw();
-/* sh->tbox(mytex, 50, 50, 561, 561, BLACK, RED, LIME, BLUE); */
-// sh->box(400, 100, 450, 150, BLACK, RED, LIME, BLUE);
-
-// sh->box(5, 5, 150, 80, CORNFLOWERBLUE, DEEPSKYBLUE, MIDNIGHTBLUE, NAVY);
-/* mogltk::ColorP::Max.A = 100;
- sh->box(5, 5, 400, 300, CORNFLOWERBLUE, DEEPSKYBLUE, MIDNIGHTBLUE, NAVY);
- mogltk::ColorP::Max.A = 255; */
-// font->setshadow(1);
-// font->putcursor(10, 30);
-// font->setcolor(WHITE);
-// font->printf(
-// "PixelPawa!\n"
-// "It works!!\n"
-// "I can't believe it!\n"
-// );
+ sh->tbox(mytex, 50, 50, 561, 561, BLACK, RED, LIME, BLUE);
+ //sh->box(400, 100, 450, 150, BLACK, RED, LIME, BLUE);
+
+ sh->box(5, 5, 150, 80, CORNFLOWERBLUE, DEEPSKYBLUE, MIDNIGHTBLUE, NAVY);
+ mogltk::ColorP::Max.A = 100;
+ //sh->box(5, 5, 400, 300, CORNFLOWERBLUE, DEEPSKYBLUE, MIDNIGHTBLUE, NAVY);
+ mogltk::ColorP::Max.A = 255;
+#if 1
+ font->setshadow(1);
+ font->putcursor(10, 30);
+ mogltk::ColorP::Max.A = sy1 / 2;
+ font->setcolor(Color(sy1 / 2, sy1 / 2, sy1 / 2, sy1 / 2));
+ font->printf(
+ "PixelPawa!\n"
+ "It works!!\n"
+ "I can't believe it!\n"
+ );
+ mogltk::ColorP::Max.A = 255;
+ font->setcolor(WHITE);
+#else
+ sh->tbox(text, textrect.x, textrect.y, textrect.x + textrect.w, textrect.y + textrect.h);
+#endif
-// sh->box3d(50, 150, 150, 200);
-// sh->obox3d(50, 250, 150, 300);
-// sh->window(50, 350, 150, 400, "Titre plus beau ;)");
-// sh->box3d(180, 130, 320, 220);
-// sh->button(200, 150, 300, 200, "Bouton");
-
-// sh->fdraw(f, BLUE);
-// sh->sdraw(f);
+ sh->box3d(50, 150, 150, 200);
+ sh->obox3d(50, 250, 150, 300);
+ sh->window(50, 350, 150, 400, "Titre plus beau ;)");
+ sh->box3d(180, 130, 320, 220);
+ sh->button(200, 150, 300, 200, "Bouton");
+
+ sh->fdraw(f, BLUE);
+ sh->sdraw(f);
+
+ spr->drawrotate(500, 400, sx1);
-// sh->box(MIN(sx1, sx2), MIN(sy1, sy2), MAX(sx1, sx2), MAX(sy1, sy2), AlphaBlue);
-// mogltk::ColorP::Min.A = 200;
-// sh->obox(MIN(sx1, sx2), MIN(sy1, sy2), MAX(sx1, sx2), MAX(sy1, sy2), AlphaBlue);
-// mogltk::ColorP::Min.A = 0;
+ sh->box(MIN(sx1, sx2), MIN(sy1, sy2), MAX(sx1, sx2), MAX(sy1, sy2), AlphaBlue);
+ mogltk::ColorP::Min.A = 200;
+ sh->obox(MIN(sx1, sx2), MIN(sy1, sy2), MAX(sx1, sx2), MAX(sy1, sy2), AlphaBlue);
+ mogltk::ColorP::Min.A = 0;
+
+ p->draw(mogltk::engine::mouseX() - 8, mogltk::engine::mouseY() - 8);
+ sh->line(320, 240, mogltk::engine::mouseX(), mogltk::engine::mouseY());
+
+ mogltk::ColorP::Min.A = 200;
+ p->draw(sx1 - 8, sy1 - 8, AlphaBlue);
+ p->draw(sx2 - 8, sy2 - 8, AlphaBlue);
+
+ displaystars(p);
+ incrementstars(t);
font->putcursor(550, 400);
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);
-
-/* p->draw(mogltk::engine::mouseX() - 8, mogltk::engine::mouseY() - 8); */
+ 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);
-// sh->line(320, 240, mogltk::engine::mouseX(), mogltk::engine::mouseY());
-
-/* mogltk::ColorP::Min.A = 200; */
-// p->draw(sx1, sy1, AlphaBlue);
-// p->draw(sx2, sy2, AlphaBlue);
-
- displaystars(p);
- incrementstars(t);
gl->Leave2DMode();
@@ -662,3 +677,61 @@ virtual int startup() throw (GeneralException) {
return 0;
}
CODE_ENDS
+
+#else
+
+CODE_BEGINS
+virtual int startup() throw (GeneralException) {
+ unsigned char palette[256][3], * 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);
+ width = i.readU16();
+ height = i.readU16();
+ i.seek(12, SEEK_CUR);
+ SDL_Surface * s = SDL_SetVideoMode(width, height, 24, 0);
+ pixels = (unsigned char *) s->pixels;
+ for (x = 0; x < 256; x++) {
+ for (y = 0; y < 3; y++) {
+ palette[x][y] = i.readU8();
+ }
+ i.seek(1, SEEK_CUR);
+ }
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ c = i.readU8();
+ pixels[(y * width + x) * 3 + 0] = palette[c][2];
+ pixels[(y * width + x) * 3 + 1] = palette[c][1];
+ pixels[(y * width + x) * 3 + 2] = palette[c][0];
+ }
+ }
+
+ *strchr(argv[1], '.') = 0;
+
+ sprintf(outname, "%s.bmp", argv[1]);
+
+ SDL_SaveBMP(s, outname);
+
+ SDL_Flip(s);
+
+ SDL_Event event;
+
+ while(true) {
+ SDL_PollEvent(&event);
+ switch (event.type) {
+ case SDL_QUIT:
+ exit(0);
+ }
+ }
+
+ return 0;
+}
+CODE_ENDS
+
+
+#endif \ No newline at end of file