[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx/demo clamptexture.cxx
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx/demo clamptexture.cxx |
Date: |
Sat, 14 Sep 2002 12:57:11 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/09/14 12:57:10
Modified files:
gfx/demo : clamptexture.cxx
Log message:
Manually built mipmaps without using the OpenGL border features work
now. On NV1X, GENERATE_MIPMAP_SGIS does not seem to work with the border
feature (I get "empty" textures); with only the first LOD, the border feature
works but very slowly (seems to be emulated)
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/clamptexture.cxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/clamptexture.cxx
diff -c gzz/gfx/demo/clamptexture.cxx:1.1 gzz/gfx/demo/clamptexture.cxx:1.2
*** gzz/gfx/demo/clamptexture.cxx:1.1 Sat Sep 14 06:22:28 2002
--- gzz/gfx/demo/clamptexture.cxx Sat Sep 14 12:57:10 2002
***************
*** 22,30 ****
<< " into texture " << t.id << "\n";
t.clamped = true;
float *data = new float[w*h*c];
-
int level = 0;
for (;;) {
glBindTexture(GL_TEXTURE_2D, id);
--- 22,30 ----
<< " into texture " << t.id << "\n";
t.clamped = true;
+ #if 1
float *data = new float[w*h*c];
int level = 0;
for (;;) {
glBindTexture(GL_TEXTURE_2D, id);
***************
*** 46,52 ****
glBindTexture(GL_TEXTURE_2D, t.id);
GLERR;
! glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGB,
w, h, 0,
GL_RGB,
--- 46,52 ----
glBindTexture(GL_TEXTURE_2D, t.id);
GLERR;
! glTexImage2D(GL_TEXTURE_2D, level,
GL_RGB,
w, h, 0,
GL_RGB,
***************
*** 56,73 ****
level++;
- // XXX: bordering the lower LOD's does not seem to work
- break;
-
if (w <= 1 && h <= 1) break;
h = h+1>>1;
w = w+1>>1;
}
-
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level - 1);
GLERR;
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
--- 56,114 ----
level++;
if (w <= 1 && h <= 1) break;
h = h+1>>1;
w = w+1>>1;
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level - 1);
GLERR;
+
+ delete[] data;
+
+ #else
+ /* This version uses the OpenGL texture border feature */
+ /* XXX: At least on NV1X, does not seem to work with
+ GENERATE_MIPMAP_SGIS and with only one LOD seems very
+ slow, probably emulated */
+
+ float *olddata = new float[w*h*c];
+ float *data = new float[(w+2)*(h+2)*c];
+
+ glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT, olddata);
+ GLERR;
+
+
+ int ind = 0;
+ for (int j = 0; j < h+2; j++)
+ for (int i = 0; i < w+2; i++)
+ for (int a = 0; a < c; a++)
+ data[(j * (w+2) + i) * c + a] =
+ (i == 0 || i == w - 1 || j == 0 || j == h - 1) ?
+ bordercolor : olddata[ind++];
+
+ glBindTexture(GL_TEXTURE_2D, t.id);
+ GLERR;
+ #if 0
+ glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
+ #else
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
+ #endif
+ GLERR;
+
+ glTexImage2D(GL_TEXTURE_2D, 0,
+ GL_RGB,
+ w+2, h+2, 1,
+ GL_RGB,
+ GL_FLOAT,
+ data);
+ GLERR;
+
+ delete[] olddata;
+ delete[] data;
+ #endif
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/gfx/demo clamptexture.cxx,
Janne V. Kujala <=