usata-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Usata-commits] Changes to usata2/src/system.cpp


From: Chong Kai Xiong
Subject: [Usata-commits] Changes to usata2/src/system.cpp
Date: Sun, 16 Jan 2005 15:02:38 -0500

Index: usata2/src/system.cpp
diff -u usata2/src/system.cpp:1.15 usata2/src/system.cpp:1.16
--- usata2/src/system.cpp:1.15  Sun Jan  9 08:57:22 2005
+++ usata2/src/system.cpp       Sun Jan 16 20:02:38 2005
@@ -10,14 +10,16 @@
 // included in the software distribution, or visit
 // http://www.fsf.org/licenses/gpl.html.
 //
-// $Id: system.cpp,v 1.15 2005/01/09 08:57:22 skunix Exp $
+// $Id: system.cpp,v 1.16 2005/01/16 20:02:38 Descender Exp $
 
 #include "system.hpp"
 #include <SDL.h>
 #include <stdexcept>
 #include <algorithm>
+#include <boost/format.hpp>
 #include <GL/glew.h>
 #include "log.hpp"
+
 namespace usata
 {
 
@@ -59,6 +61,86 @@
                initialized = false;
        }
 
+       // FIXME: Placed here for now. Refactor this into a property list
+       // which the graphics engine can lookup capabilties with and
+       // degrade (scale) rendering quality when necessary. - descender
+
+       void print_gl_capabilities()
+       {
+               log::BufferedStream log;
+
+               log << "OpenGL capabilities:\n";
+
+               // Version
+               {
+                       const GLubyte *version = glGetString(GL_VERSION);
+                       log << boost::format("GL version string: %1%\n") % 
version;
+               }
+
+               // Framebuffer
+               {
+                       GLint r, g, b, depth;
+
+                       glGetIntegerv(GL_RED_BITS, &r);
+                       glGetIntegerv(GL_GREEN_BITS, &g);
+                       glGetIntegerv(GL_BLUE_BITS, &b);
+                       glGetIntegerv(GL_DEPTH_BITS, &depth);
+
+                       log << boost::format("Color bits: %1% %2% %3%\n") % r % 
g % b;
+                       log << boost::format("Depth bits: %1%\n") % depth;
+               }
+
+               // Matrix stack
+               {
+                       GLint modelview, projection, texture, color;
+
+                       glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &modelview);
+                       glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH, 
&projection);
+                       glGetIntegerv(GL_MAX_TEXTURE_STACK_DEPTH, &texture);
+                       glGetIntegerv(GL_MAX_COLOR_MATRIX_STACK_DEPTH, &color);
+
+                       log << boost::format("Matrix stack max. depths: %1% %2% 
%3% %4%\n") 
+                               % modelview % projection % texture % color;
+               }
+
+               // Texturing
+               {
+                       GLint texture_units;
+                       
+                       glGetIntegerv(GL_MAX_TEXTURE_UNITS, &texture_units);
+
+                       log << boost::format("Number of texture units: %1%\n") 
% texture_units;
+
+                       if (GLEW_ARB_texture_non_power_of_two)
+                               log << "Non power-of-2 texture sizes\n";
+
+                       if (GLEW_ARB_texture_compression)
+                               log << "ARB texture compression\n";
+
+                       if (GLEW_EXT_texture_compression_s3tc)
+                               log << "S3TC texture compression\n";
+               }
+
+               // GLSL
+               {
+                       if (GLEW_ARB_shading_language_100)
+                               log << "OpenGL Shading Language 1.0\n";
+
+                       if (GLEW_ARB_shader_objects)
+                               log << "ARB shader objects\n";
+
+                       if (GLEW_ARB_vertex_shader)
+                               log << "ARB vertex shader\n";
+
+                       if (GLEW_ARB_fragment_shader)
+                               log << "ARB fragment shader\n";
+               }
+
+               // Point sprites
+               if (GLEW_ARB_point_sprite)
+                       log << "Point sprites\n";
+       }
+
        VideoMode
        scan_modes(const VideoMode& requested)
        {
@@ -119,14 +201,16 @@
 
                int depth = vi->vfmt->BitsPerPixel;
 
-               SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);     
+               SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+
                bool success = (SDL_SetVideoMode(vm.width, vm.height, depth, 
Flags ) != 0);
+
                if (success)
                {
-                       SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE,&depth);
-                       logstream << "set video mode ok, GL_DEPTH_SIZE (" << 
depth <<")" << log::commit;
                        init_glew();
-                       glViewport(0,0,(GLsizei)vm.width, (GLsizei) vm.height);
+                       print_gl_capabilities();
+
+                       glViewport(0,0,(GLsizei)vm.width, (GLsizei) vm.height); 
           
                }
                else
                {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]