summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2011-07-18 09:00:19 -0500
committerKamil Kaminski <kamilkss@gmail.com>2011-07-18 09:00:19 -0500
commita40d0cdbb0dff7cf2b65a18be7b7085f0eca3408 (patch)
tree1f31d1367e0392d726c93b6db115d337ef9d1a93
parentf2190d3118dc1c58891793c934ae224d3d355e3c (diff)
downloadGLPyramid-a40d0cdbb0dff7cf2b65a18be7b7085f0eca3408.tar.gz
GLPyramid-a40d0cdbb0dff7cf2b65a18be7b7085f0eca3408.tar.bz2
GLPyramid-a40d0cdbb0dff7cf2b65a18be7b7085f0eca3408.zip
sdl: handle anisotropic filtering
-rw-r--r--sdl/platform.c44
-rw-r--r--sdl/pyramid.c8
2 files changed, 42 insertions, 10 deletions
diff --git a/sdl/platform.c b/sdl/platform.c
index 677b5b8..aba5789 100644
--- a/sdl/platform.c
+++ b/sdl/platform.c
@@ -9,6 +9,7 @@
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <GL/glew.h>
+#include "gltools.h"
#include "platform.h"
/* few light arrays */
@@ -25,6 +26,7 @@ const GLfloat lightPos[] = { -10.f, 5.0f, 5.0f, 1.0f };
extern const unsigned int xres_w;
extern const unsigned int yres_w;
extern const unsigned int bpp_w;
+extern const unsigned int af_w;
extern const unsigned int sdl_video_flags;
extern const char *window_caption;
extern const char *window_icon_path;
@@ -94,18 +96,43 @@ void setup_opengl(void)
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
#endif
+#if 0
+ /* screws up snowman, this has been replaced by superior multisampling */
+ glEnable(GL_POLYGON_SMOOTH);
+ glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
+#endif
+
/* we will keep the blending function and hints though */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
- /* XXX: anisotropic filtering */
+ /* anisotropic filtering */
+ if (gltQueryExtension("GL_EXT_texture_filter_anisotropic") == GL_TRUE)
+ {
+ GLint af_amount;
+ glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &af_amount);
+ printf("platform: anisotropic filtering is supported, with max amount "
+ "of: %d\n", af_amount);
+
+ if (af_amount < af_w)
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, af_amount);
+ else
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, af_w);
+
+ /* see what value was set */
+ glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, &af_amount);
+ printf("platform: set anisotropic filtering to %d\n", af_amount);
+ }
+ else
+ printf("platform: anisotropic filtering is not supported\n");
-#if 0
- /* screws up snowman, this has been replaced by superior multisampling */
- glEnable(GL_POLYGON_SMOOTH);
- glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
-#endif
+ /* texture compression */
+ if (gltQueryExtension("GL_ARB_texture_compression") == GL_TRUE)
+ {
+ printf("platform: host gfx device supports texture compression\n");
+ /* ToDo */
+ }
/* how OpenGL combines the colors from texels with the color of the underlying
* geometry is controlled by the texture environment mode */
@@ -121,6 +148,11 @@ void setup_opengl(void)
/* only if lighting is disabled */
/* glEnable(GL_COLOR_SUM); */
+ /* draw fragments that pass this test, fragments with lower than 0.2f
+ * alpha are discarded, this is just for the kicks */
+ glAlphaFunc(GL_GREATER, 0.2f);
+ glEnable(GL_ALPHA_TEST);
+
/* gray background */
glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
}
diff --git a/sdl/pyramid.c b/sdl/pyramid.c
index 42c7a22..bc0fd7a 100644
--- a/sdl/pyramid.c
+++ b/sdl/pyramid.c
@@ -38,14 +38,14 @@ static void render(void);
/* global */
int program_running = 1;
-const int xres_w = 640;
-const int yres_w = 480;
-const int bpp_w = 32;
+const unsigned int xres_w = 640;
+const unsigned int yres_w = 480;
+const unsigned int bpp_w = 32;
+const unsigned int af_w = 8;
const char *window_caption = "Textured Pyramid";
const char *window_icon_path = "tux.png";
const unsigned int sdl_video_flags = SDL_OPENGL | SDL_RESIZABLE;
-
/* platform struct */
static struct
{