/[usata]/usata2/src/system.cpp
ViewVC logotype

Diff of /usata2/src/system.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by skunix, Sun Jan 9 08:57:22 2005 UTC revision 1.16 by Descender, Sun Jan 16 20:02:38 2005 UTC
# Line 16  Line 16 
16  #include <SDL.h>  #include <SDL.h>
17  #include <stdexcept>  #include <stdexcept>
18  #include <algorithm>  #include <algorithm>
19    #include <boost/format.hpp>
20  #include <GL/glew.h>  #include <GL/glew.h>
21  #include "log.hpp"  #include "log.hpp"
22    
23  namespace usata  namespace usata
24  {  {
25    
# Line 59  namespace system Line 61  namespace system
61                  initialized = false;                  initialized = false;
62          }          }
63    
64            // FIXME: Placed here for now. Refactor this into a property list
65            // which the graphics engine can lookup capabilties with and
66            // degrade (scale) rendering quality when necessary. - descender
67    
68            void print_gl_capabilities()
69            {
70                    log::BufferedStream log;
71    
72                    log << "OpenGL capabilities:\n";
73    
74                    // Version
75                    {
76                            const GLubyte *version = glGetString(GL_VERSION);
77                            log << boost::format("GL version string: %1%\n") % version;
78                    }
79    
80                    // Framebuffer
81                    {
82                            GLint r, g, b, depth;
83    
84                            glGetIntegerv(GL_RED_BITS, &r);
85                            glGetIntegerv(GL_GREEN_BITS, &g);
86                            glGetIntegerv(GL_BLUE_BITS, &b);
87                            glGetIntegerv(GL_DEPTH_BITS, &depth);
88    
89                            log << boost::format("Color bits: %1% %2% %3%\n") % r % g % b;
90                            log << boost::format("Depth bits: %1%\n") % depth;
91                    }
92    
93                    // Matrix stack
94                    {
95                            GLint modelview, projection, texture, color;
96    
97                            glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &modelview);
98                            glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH, &projection);
99                            glGetIntegerv(GL_MAX_TEXTURE_STACK_DEPTH, &texture);
100                            glGetIntegerv(GL_MAX_COLOR_MATRIX_STACK_DEPTH, &color);
101    
102                            log << boost::format("Matrix stack max. depths: %1% %2% %3% %4%\n")
103                                    % modelview % projection % texture % color;
104                    }
105    
106                    // Texturing
107                    {
108                            GLint texture_units;
109                            
110                            glGetIntegerv(GL_MAX_TEXTURE_UNITS, &texture_units);
111    
112                            log << boost::format("Number of texture units: %1%\n") % texture_units;
113    
114                            if (GLEW_ARB_texture_non_power_of_two)
115                                    log << "Non power-of-2 texture sizes\n";
116    
117                            if (GLEW_ARB_texture_compression)
118                                    log << "ARB texture compression\n";
119    
120                            if (GLEW_EXT_texture_compression_s3tc)
121                                    log << "S3TC texture compression\n";
122                    }
123    
124                    // GLSL
125                    {
126                            if (GLEW_ARB_shading_language_100)
127                                    log << "OpenGL Shading Language 1.0\n";
128    
129                            if (GLEW_ARB_shader_objects)
130                                    log << "ARB shader objects\n";
131    
132                            if (GLEW_ARB_vertex_shader)
133                                    log << "ARB vertex shader\n";
134    
135                            if (GLEW_ARB_fragment_shader)
136                                    log << "ARB fragment shader\n";
137                    }
138    
139                    // Point sprites
140                    if (GLEW_ARB_point_sprite)
141                            log << "Point sprites\n";
142            }
143    
144          VideoMode          VideoMode
145          scan_modes(const VideoMode& requested)          scan_modes(const VideoMode& requested)
146          {          {
# Line 119  namespace system Line 201  namespace system
201    
202                  int depth = vi->vfmt->BitsPerPixel;                  int depth = vi->vfmt->BitsPerPixel;
203    
204                  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);                      SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
205    
206                  bool success = (SDL_SetVideoMode(vm.width, vm.height, depth, Flags ) != 0);                  bool success = (SDL_SetVideoMode(vm.width, vm.height, depth, Flags ) != 0);
207    
208                  if (success)                  if (success)
209                  {                  {
                         SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE,&depth);  
                         logstream << "set video mode ok, GL_DEPTH_SIZE (" << depth <<")" << log::commit;  
210                          init_glew();                          init_glew();
211                          glViewport(0,0,(GLsizei)vm.width, (GLsizei) vm.height);                          print_gl_capabilities();
212    
213                            glViewport(0,0,(GLsizei)vm.width, (GLsizei) vm.height);            
214                  }                  }
215                  else                  else
216                  {                  {

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26