#include #include #include #include #include #include "glbase.h" #include "gltexture.h" #include "glfont.h" CODE_BEGINS virtual int startup() throw (GeneralException) { Uint8 * texture; verbosity = M_INFO; mogltk::glbase::setup(); Input ffont("font-2.bin"); mogltk::font font(&ffont); verbosity = M_INFO; mogltk::texture * mytex = new mogltk::texture(256, 256, true); texture = (Uint8 *) mytex->GetSurface()->pixels; for (int y = 0; y < 256; y++) { for (int x = 0; x < 256; x++) { //int r = random() % 256; int r = 255; texture[(x + y * 256) * 4 + 0] = r; texture[(x + y * 256) * 4 + 1] = r; texture[(x + y * 256) * 4 + 2] = r; texture[(x + y * 256) * 4 + 3] = 255; } } SDL_Surface * s; if (!(s = SDL_LoadBMP("pattern6.bmp"))) { throw GeneralException("Error: could not load texture."); } SDL_BlitSurface(s, NULL, mytex->GetSurface(), NULL); /* for (int y = 0; y < 256; y += 2) { for (int x = 0; x < 256; x += 2) { texture[(x + y * 256) * 4 + 0] = 0; texture[(x + y * 256) * 4 + 1] = 0; texture[(x + y * 256) * 4 + 2] = 255; texture[(x + y * 256) * 4 + 3] = 0; } } */ mogltk::glbase::Enter2DMode(); mytex->Bind(); glBegin(GL_TRIANGLE_STRIP); glColor3d(0, 0, 0); glTexCoord2i(0, 0); glVertex2f(50, 50); glColor3d(1, 0, 0); glTexCoord2i(511, 0); glVertex2f(561, 50); glColor3d(0, 1, 0); glTexCoord2i(0, 511); glVertex2f(50, 561); glColor3d(0, 0, 1); glTexCoord2i(511, 511); glVertex2f(561, 561); glEnd(); mogltk::texture::Unbind(); glBegin(GL_TRIANGLE_STRIP); glColor3d(0, 0, 0); glVertex2f(400, 100); glColor3d(1, 0, 0); glVertex2f(450, 100); glColor3d(0, 1, 0); glVertex2f(400, 150); glColor3d(0, 0, 1); glVertex2f(450, 150); glEnd(); glBegin(GL_TRIANGLE_STRIP); CORNFLOWERBLUE.Bind(); glVertex2f( 5, 5); DEEPSKYBLUE.Bind(); glVertex2f(150, 5); MIDNIGHTBLUE.Bind(); glVertex2f( 5, 80); NAVY.Bind(); glVertex2f(150, 80); glEnd(); font.setshadow(1); font.putcursor(10, 30); font.setcolor(WHITE); font.printf("PixelPawa!\n"); font.printf("It works!!\n"); font.printf("I can't believe it!\n"); mogltk::glbase::Leave2DMode(); mogltk::glbase::Flip(); // sleep(15); getchar(); delete mytex; return 0; } CODE_ENDS