summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpixel <pixel>2002-12-09 17:10:02 +0000
committerpixel <pixel>2002-12-09 17:10:02 +0000
commitdd1e9ef7dd0d490f9397d524e1cfde13d6314623 (patch)
tree406605e9a3515b027492d07bc28580db3ff38706 /src
parent6529df93b5c53d11ce081272d292fb6b2c9b1101 (diff)
Zou
Diffstat (limited to 'src')
-rw-r--r--src/test.cc88
1 files changed, 82 insertions, 6 deletions
diff --git a/src/test.cc b/src/test.cc
index 679c893..f82a6bd 100644
--- a/src/test.cc
+++ b/src/test.cc
@@ -1,13 +1,89 @@
+#include <SDL.h>
+#include "generic.h"
+#include "Main.h"
#include "glbase.h"
-#include <Main.h>
+#include "gltexture.h"
CODE_BEGINS
-
-virtual int startup(void) throw(GeneralException) {
+virtual int startup() throw (GeneralException) {
+ Uint8 * texture;
verbosity = M_INFO;
-
- mogltk::glbase::glVertex(3.0, 3.0);
+ mogltk::glbase::setup();
+
+ 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;
+ 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] = 255;
+ texture[(x + y * 256) * 4 + 1] = 255;
+ texture[(x + y * 256) * 4 + 2] = 255;
+ texture[(x + y * 256) * 4 + 3] = 255;
+ }
+ }
+*/
+ 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);
+// glTexCoord2i(0, 0);
+ glColor3d(0, 0, 0);
+ glVertex2f(400, 100);
+// glTexCoord2i(256, 0);
+ glColor3d(1, 0, 0);
+ glVertex2f(450, 100);
+// glTexCoord2i(0, 256);
+ glColor3d(0, 1, 0);
+ glVertex2f(400, 150);
+// glTexCoord2i(256, 256);
+ glColor3d(0, 0, 1);
+ glVertex2f(450, 150);
+ glEnd();
+ mogltk::glbase::Leave2DMode();
+
+ mogltk::glbase::Flip();
+
+// sleep(15);
+ getchar();
+
+ delete mytex;
+
return 0;
}
-
CODE_ENDS