From: Brian Date: Tue, 14 Aug 2007 21:19:37 +0000 (-0600) Subject: vars to test 1D/2D textures with linear/nearest filtering X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bfcc337e386902712de49d43308167bc79c9e709;p=mesa.git vars to test 1D/2D textures with linear/nearest filtering --- diff --git a/progs/trivial/quad-tex-2d.c b/progs/trivial/quad-tex-2d.c index 98f538eda32..cb0b9202a25 100644 --- a/progs/trivial/quad-tex-2d.c +++ b/progs/trivial/quad-tex-2d.c @@ -27,10 +27,8 @@ #include #include - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - +static GLenum Target = GL_TEXTURE_2D; +static GLenum Filter = GL_NEAREST; GLenum doubleBuffer; static void Init(void) @@ -60,42 +58,42 @@ static void Init(void) } } + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + if (Target == GL_TEXTURE_1D) + glTexImage1D(Target, 0, 3, SIZE, 0, GL_RGB, GL_UNSIGNED_BYTE, tex2d); + else + glTexImage2D(Target, 0, 3, SIZE, SIZE, 0, + GL_RGB, GL_UNSIGNED_BYTE, tex2d); + + glEnable(Target); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(Target, GL_TEXTURE_WRAP_R, GL_REPEAT); + glTexParameterf(Target, GL_TEXTURE_MIN_FILTER, Filter); + glTexParameterf(Target, GL_TEXTURE_MAG_FILTER, Filter); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0, - GL_RGB, GL_UNSIGNED_BYTE, tex2d); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glEnable(GL_TEXTURE_2D); } - } static void Reshape(int width, int height) { - - glViewport(0, 0, (GLint)width, (GLint)height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); - glMatrixMode(GL_MODELVIEW); + glViewport(0, 0, (GLint)width, (GLint)height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); } static void Key(unsigned char key, int x, int y) { - - switch (key) { - case 27: - exit(1); - default: - return; - } - - glutPostRedisplay(); + switch (key) { + case 27: + exit(0); + default: + return; + } + glutPostRedisplay(); } static void Draw(void) @@ -165,5 +163,5 @@ int main(int argc, char **argv) glutKeyboardFunc(Key); glutDisplayFunc(Draw); glutMainLoop(); - return 0; + return 0; }