From dd1e9ef7dd0d490f9397d524e1cfde13d6314623 Mon Sep 17 00:00:00 2001 From: pixel Date: Mon, 9 Dec 2002 17:10:02 +0000 Subject: Zou --- lib/gltexture.cc | 16 +++++++++++ po/fr.po | 4 +-- src/test.cc | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 100 insertions(+), 8 deletions(-) diff --git a/lib/gltexture.cc b/lib/gltexture.cc index 2758c05..f33fe98 100644 --- a/lib/gltexture.cc +++ b/lib/gltexture.cc @@ -4,6 +4,8 @@ #include #include "gltexture.h" +#define DEBUG 1 + #ifdef TRACE_TEXTURES mogltk::texture * mogltk::texture::header = 0; mogltk::texture * mogltk::texture::footer = 0; @@ -81,12 +83,23 @@ void mogltk::texture::Generate() { } glGenTextures(1, &tex); +#ifdef DEBUG + printm(M_INFO, "Generated texture index: %i\n", tex); +#endif + + glBindTexture(GL_TEXTURE_2D, tex); if (planar) { +#ifdef DEBUG + printm(M_INFO, "Generating planar texture: %i\n", tex); +#endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels); } else { +#ifdef DEBUG + printm(M_INFO, "Generating 3D texture: %i\n", tex); +#endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); @@ -103,6 +116,9 @@ void mogltk::texture::Bind(bool expand) { if ((!texture_allocated) || tainted) Generate(); glEnable(GL_TEXTURE_2D); +#ifdef DEBUG + printm(M_INFO, "Binding texture index %i\n", tex); +#endif glBindTexture(GL_TEXTURE_2D, tex); if (expand) { glMatrixMode(GL_TEXTURE); diff --git a/po/fr.po b/po/fr.po index 7085ca9..a543167 100644 --- a/po/fr.po +++ b/po/fr.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: mogltk 1.0.1\n" -"POT-Creation-Date: 2002-12-07 01:41+0100\n" +"POT-Creation-Date: 2002-12-09 12:06+0100\n" "PO-Revision-Date: 2001-10-29 08:26GMT\n" "Last-Translator: Nicolas Noble \n" "Language-Team: French \n" @@ -14,6 +14,6 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "X-Generator: KBabel 0.8\n" -#: lib/engine.cc:12 +#: lib/engine.cc:14 msgid "Unable to start SDL base system" msgstr "" 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 +#include "generic.h" +#include "Main.h" #include "glbase.h" -#include +#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 -- cgit v1.2.3