Commits

Jason McKesson committed 2b423ba

Linux build functional again.

Comments (0)

Files changed (33)

 glload/*.sln
 glload/*.vcproj
 *.blend?
+*.make
+Makefile
+*.o
+*.d
+*.a
+freeglut-2.6.0/src/.libs
+freeglut-2.6.0/src/.deps
+*.lo
+freeglut-2.6.0/progs/demos
+freeglut-2.6.0/autom4te.cache
+freeglut-2.6.0/config.h
+freeglut-2.6.0/config.log
+freeglut-2.6.0/config.status
+freeglut-2.6.0/libtool
+freeglut-2.6.0/src/libglut.la
+freeglut-2.6.0/stamp-h1

Tut 07 World in Motion/World Scene.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
 	glEnable(GL_CULL_FACE);

Tut 07 World in Motion/World With UBO.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
 	glEnable(GL_CULL_FACE);

Tut 08 Getting Oriented/CameraRelative.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
 

Tut 08 Getting Oriented/GimbalLock.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
 

Tut 08 Getting Oriented/Interpolation.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
 	glEnable(GL_CULL_FACE);

Tut 08 Getting Oriented/QuaternionYPR.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
 

Tut 09 Lights on/Ambient Lighting.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
  	glutMouseFunc(MouseButton);

Tut 09 Lights on/Basic Lighting.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
 	glutMouseFunc(MouseButton);

Tut 09 Lights on/Scale and Lighting.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
 	glutMouseFunc(MouseButton);

Tut 10 Plane Lights/Fragment Attenuation.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
  	glutMouseFunc(MouseButton);

Tut 10 Plane Lights/Fragment Point Lighting.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
  	glutMouseFunc(MouseButton);

Tut 10 Plane Lights/Vertex Point Lighting.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
  	glutMouseFunc(MouseButton);

Tut 11 Shinies/Blinn vs Phong Lighting.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
 	glutMouseFunc(MouseButton);

Tut 11 Shinies/Gaussian Specular Lighting.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
  	glutMouseFunc(MouseButton);

Tut 11 Shinies/Phong Lighting.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 
  	glutMouseFunc(MouseButton);

Tut 12 Dynamic Range/Gamma Correction.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
 		throw;
 	}
 

Tut 12 Dynamic Range/HDR Lighting.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
 		throw;
 	}
 

Tut 12 Dynamic Range/Scene Lighting.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
 		throw;
 	}
 

Tut 13 Impostors/BasicImpostor.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
 		throw;
 	}
 

Tut 13 Impostors/GeomImpostor.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
 		throw;
 	}
 

Tut 14 Textures Are Not Pictures/Basic Texture.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
 		throw;
 	}
 

Tut 14 Textures Are Not Pictures/Material Texture.cpp

 #include "../framework/ObjectPole.h"
 #include "../framework/Timer.h"
 #include "../framework/UniformBlockArray.h"
+#include "../framework/directories.h"
 #include <glm/glm.hpp>
 #include <glm/gtc/type_ptr.hpp>
 
 
 	try
 	{
-		pImageSet.reset(glimg::loaders::dds::LoadFromFile("data\\main.dds"));
+	    std::string filename(LOCAL_FILE_DIR);
+	    filename.append("main.dds");
+	    
+		pImageSet.reset(glimg::loaders::dds::LoadFromFile(filename.c_str()));
 		std::auto_ptr<glimg::Image> pImage(pImageSet->GetImage(0, 0, 0));
 
 		glimg::Dimensions dims = pImage->GetDimensions();
 	}
 	catch(glimg::ImageCreationException &e)
 	{
-		printf(e.what());
+		printf("%s\n", e.what());
 		throw;
 	}
 }
 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
 		throw;
 	}
 

Tut 14 Textures Are Not Pictures/Perspective Interpolation.cpp

 	}
 	catch(std::exception &except)
 	{
-		printf(except.what());
+		printf("%s\n", except.what());
+		throw;
 	}
 }
 

framework/MousePole.cpp

 						this->BeginDragRotate(position, MousePole::RM_DUAL_AXIS_ROTATE);
 				}
 			}
+
+#ifdef LOAD_X11
+            //Linux Mouse wheel support			
+	        if(button == 3)
+		        this->MoveCloser(!(glutGetModifiers() & GLUT_ACTIVE_SHIFT));
+	        if(button == 4)
+		        this->MoveAway(!(glutGetModifiers() & GLUT_ACTIVE_SHIFT));
+#endif
 		}
 		else
 		{

framework/framework.cpp

 #include "framework.h"
 #include "directories.h"
 
+#ifdef LOAD_X11
+#define APIENTRY
+#endif
 
 namespace Framework
 {

glimg/Test/linux.cpp

+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "glload/gl_2_1.h"
+#include "glload/glx_exts.h"
+#include "glload/gll.h"
+ 
+// Helper to check for extension string presence.  Adapted from:
+//   http://www.opengl.org/resources/features/OGLextensions/
+static bool isExtensionSupported(const char *extList, const char *extension)
+{
+  const char *start;
+  const char *where, *terminator;
+ 
+  /* Extension names should not have spaces. */
+  where = strchr(extension, ' ');
+  if ( where || *extension == '\0' )
+    return false;
+ 
+  /* It takes a bit of care to be fool-proof about parsing the
+     OpenGL extensions string. Don't be fooled by sub-strings,
+     etc. */
+  for ( start = extList; ; ) {
+    where = strstr( start, extension );
+ 
+    if ( !where )
+      break;
+ 
+    terminator = where + strlen( extension );
+ 
+    if ( where == start || *(where - 1) == ' ' )
+      if ( *terminator == ' ' || *terminator == '\0' )
+        return true;
+ 
+    start = terminator;
+  }
+ 
+  return false;
+}
+
+static bool ctxErrorOccurred = false;
+static int ctxErrorHandler( Display *dpy, XErrorEvent *ev )
+{
+    ctxErrorOccurred = true;
+    return 0;
+}
+ 
+int main (int argc, char ** argv)
+{
+  Display *display = XOpenDisplay(0);
+ 
+  if ( !display )
+  {
+    printf( "Failed to open X display\n" );
+    exit(1);
+  }
+ 
+  // Get a matching FB config
+  static int visual_attribs[] =
+    {
+      GLX_X_RENDERABLE    , True,
+      GLX_DRAWABLE_TYPE   , GLX_WINDOW_BIT,
+      GLX_RENDER_TYPE     , GLX_RGBA_BIT,
+      GLX_X_VISUAL_TYPE   , GLX_TRUE_COLOR,
+      GLX_RED_SIZE        , 8,
+      GLX_GREEN_SIZE      , 8,
+      GLX_BLUE_SIZE       , 8,
+      GLX_ALPHA_SIZE      , 8,
+      GLX_DEPTH_SIZE      , 24,
+      GLX_STENCIL_SIZE    , 8,
+      GLX_DOUBLEBUFFER    , True,
+      //GLX_SAMPLE_BUFFERS  , 1,
+      //GLX_SAMPLES         , 4,
+      None
+    };
+ 
+  int glx_major, glx_minor;
+ 
+  // FBConfigs were added in GLX version 1.3.
+  if ( !glXQueryVersion( display, &glx_major, &glx_minor ) || 
+       ( ( glx_major == 1 ) && ( glx_minor < 3 ) ) || ( glx_major < 1 ) )
+  {
+    printf( "Invalid GLX version" );
+    exit(1);
+  }
+ 
+  printf( "Getting matching framebuffer configs\n" );
+  int fbcount;
+  GLXFBConfig *fbc = glXChooseFBConfig( display, DefaultScreen( display ), 
+                                        visual_attribs, &fbcount );
+  if ( !fbc )
+  {
+    printf( "Failed to retrieve a framebuffer config\n" );
+    exit(1);
+  }
+  printf( "Found %d matching FB configs.\n", fbcount );
+ 
+  // Pick the FB config/visual with the most samples per pixel
+  printf( "Getting XVisualInfos\n" );
+  int best_fbc = -1, worst_fbc = -1, best_num_samp = -1, worst_num_samp = 999;
+ 
+  int i;
+  for ( i = 0; i < fbcount; i++ )
+  {
+    XVisualInfo *vi = glXGetVisualFromFBConfig( display, fbc[i] );
+    if ( vi )
+    {
+      int samp_buf, samples;
+      glXGetFBConfigAttrib( display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf );
+      glXGetFBConfigAttrib( display, fbc[i], GLX_SAMPLES       , &samples  );
+ 
+      printf( "  Matching fbconfig %d, visual ID 0x%2x: SAMPLE_BUFFERS = %d,"
+              " SAMPLES = %d\n", 
+              i, (unsigned int)vi->visualid, samp_buf, samples );
+ 
+      if ( best_fbc < 0 || samp_buf && samples > best_num_samp )
+        best_fbc = i, best_num_samp = samples;
+      if ( worst_fbc < 0 || !samp_buf || samples < worst_num_samp )
+        worst_fbc = i, worst_num_samp = samples;
+    }
+    XFree( vi );
+  }
+ 
+  GLXFBConfig bestFbc = fbc[ best_fbc ];
+ 
+  // Be sure to free the FBConfig list allocated by glXChooseFBConfig()
+  XFree( fbc );
+ 
+  // Get a visual
+  XVisualInfo *vi = glXGetVisualFromFBConfig( display, bestFbc );
+  printf( "Chosen visual ID = 0x%x\n", (unsigned int)vi->visualid );
+ 
+  printf( "Creating colormap\n" );
+  XSetWindowAttributes swa;
+  Colormap cmap;
+  swa.colormap = cmap = XCreateColormap( display,
+                                         RootWindow( display, vi->screen ), 
+                                         vi->visual, AllocNone );
+  swa.background_pixmap = None ;
+  swa.border_pixel      = 0;
+  swa.event_mask        = StructureNotifyMask;
+ 
+  printf( "Creating window\n" );
+  Window win = XCreateWindow( display, RootWindow( display, vi->screen ), 
+                              0, 0, 100, 100, 0, vi->depth, InputOutput, 
+                              vi->visual, 
+                              CWBorderPixel|CWColormap|CWEventMask, &swa );
+  if ( !win )
+  {
+    printf( "Failed to create window.\n" );
+    exit(1);
+  }
+ 
+  // Done with the visual info data
+  XFree( vi );
+ 
+  XStoreName( display, win, "GL 3.0 Window" );
+ 
+  printf( "Mapping window\n" );
+  XMapWindow( display, win );
+ 
+  // Get the default screen's GLX extension list
+  const char *glxExts = glXQueryExtensionsString( display,
+                                                  DefaultScreen( display ) );
+ 
+  // NOTE: It is not necessary to create or make current to a context before
+  // calling glXGetProcAddressARB
+  glload::LoadGLXFunctions(display, DefaultScreen( display ));
+  /**
+  glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;
+  glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)
+           glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" );
+      **/
+ 
+  GLXContext ctx = 0;
+ 
+  // Install an X error handler so the application won't exit if GL 3.0
+  // context allocation fails.
+  //
+  // Note this error handler is global.  All display connections in all threads
+  // of a process use the same error handler, so be sure to guard against other
+  // threads issuing X commands while this code is running.
+  ctxErrorOccurred = false;
+  int (*oldHandler)(Display*, XErrorEvent*) =
+      XSetErrorHandler(&ctxErrorHandler);
+ 
+  // Check for the GLX_ARB_create_context extension string and the function.
+  // If either is not present, use GLX 1.3 context creation method.
+  if ( !isExtensionSupported( glxExts, "GLX_ARB_create_context" ) ||
+       !glXCreateContextAttribsARB )
+  {
+    printf( "glXCreateContextAttribsARB() not found"
+            " ... using old-style GLX context\n" );
+    ctx = glXCreateNewContext( display, bestFbc, GLX_RGBA_TYPE, 0, True );
+  }
+ 
+  // If it does, try to get a GL 3.0 context!
+  else
+  {
+    int context_attribs[] =
+      {
+        GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
+        GLX_CONTEXT_MINOR_VERSION_ARB, 3,
+        //GLX_CONTEXT_FLAGS_ARB        , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
+        None
+      };
+ 
+    printf( "Creating context\n" );
+    ctx = glXCreateContextAttribsARB( display, bestFbc, 0,
+                                      True, context_attribs );
+ 
+    // Sync to ensure any errors generated are processed.
+    XSync( display, False );
+    if ( !ctxErrorOccurred && ctx )
+      printf( "Created GL 3.0 context\n" );
+    else
+    {
+      // Couldn't create GL 3.0 context.  Fall back to old-style 2.x context.
+      // When a context version below 3.0 is requested, implementations will
+      // return the newest context version compatible with OpenGL versions less
+      // than version 3.0.
+      // GLX_CONTEXT_MAJOR_VERSION_ARB = 1
+      context_attribs[1] = 1;
+      // GLX_CONTEXT_MINOR_VERSION_ARB = 0
+      context_attribs[3] = 0;
+ 
+      ctxErrorOccurred = false;
+ 
+      printf( "Failed to create GL 3.0 context"
+              " ... using old-style GLX context\n" );
+      ctx = glXCreateContextAttribsARB( display, bestFbc, 0, 
+                                        True, context_attribs );
+    }
+  }
+ 
+  // Sync to ensure any errors generated are processed.
+  XSync( display, False );
+ 
+  // Restore the original error handler
+  XSetErrorHandler( oldHandler );
+ 
+  if ( ctxErrorOccurred || !ctx )
+  {
+    printf( "Failed to create an OpenGL context\n" );
+    exit(1);
+  }
+ 
+  // Verifying that context is a direct context
+  if ( ! glXIsDirect ( display, ctx ) )
+  {
+    printf( "Indirect GLX rendering context obtained\n" );
+  }
+  else
+  {
+    printf( "Direct GLX rendering context obtained\n" );
+  }
+ 
+  printf( "Making context current\n" );
+  glXMakeCurrent( display, win, ctx );
+  
+  glload::LoadFunctions();
+ 
+  glClearColor ( 0, 0.5, 1, 1 );
+  glClear ( GL_COLOR_BUFFER_BIT );
+  glXSwapBuffers ( display, win );
+  
+  printf("Vendor: %s\n", glGetString(GL_VENDOR));
+  printf("Renderer: %s\n", glGetString(GL_RENDERER));
+  printf("Version: %s\n", glGetString(GL_VERSION));
+ 
+  sleep( 1 );
+ 
+  glClearColor ( 1, 0.5, 0, 1 );
+  glClear ( GL_COLOR_BUFFER_BIT );
+  glXSwapBuffers ( display, win );
+ 
+  sleep( 1 );
+ 
+  glXMakeCurrent( display, 0, 0 );
+  glXDestroyContext( display, ctx );
+ 
+  XDestroyWindow( display, win );
+  XFreeColormap( display, cmap );
+  XCloseDisplay( display );
+}

glimg/Test/windows.cpp

 	TestImageFormats();
 
 //	glimg::ImageSet *pImgSet = glimg::loaders::test::TestImage2D();
-	glimg::ImageSet *pImgSet = glimg::loaders::dds::LoadFromFile("main.dds");
+	glimg::ImageSet *pImgSet = glimg::loaders::dds::LoadFromFile("bitmap565.dds");
 //	glimg::ImageSet *pImgSet = glimg::loaders::stb::LoadFromFile("bitmap.png");
 
 	texture = glimg::CreateTexture(pImgSet, 0);

glimg/include/glimg/DdsLoader.h

 			class DdsLoaderException : public std::exception
 			{
 			public:
+			
+			    virtual ~DdsLoaderException() throw() {}
 
 				virtual const char *what() {return message.c_str();}
 
 	}
 }
 
-#endif //GLIMG_DIRECT_DRAW_SURFACE_LOADER_H
+#endif //GLIMG_DIRECT_DRAW_SURFACE_LOADER_H

glimg/include/glimg/ImageCreatorExceptions.h

 	class ImageCreationException : public std::exception
 	{
 	public:
+	    virtual ~ImageCreationException() throw() {}
 
 		virtual const char *what() {return message.c_str();}
 

glimg/include/glimg/StbLoader.h

 			class StbLoaderException : public std::exception
 			{
 			public:
+			    
+			    virtual ~StbLoaderException() throw() {}
 
 				virtual const char *what() {return message.c_str();}
 

glimg/include/glimg/TextureGeneratorExceptions.h

 	class TextureGenerationException : public std::exception
 	{
 	public:
+	    virtual ~TextureGenerationException() throw() {}
 
 		virtual const char *what() {return message.c_str();}
 

glimg/source/DdsLoader.cpp

 
 #include <vector>
 #include <stdio.h>
+#include <string.h>
 #include "glimg/ImageSet.h"
 #include "ImageSetImpl.h"
 #include "glimg/ImageCreator.h"
 		}
 	}
 
-	ImageSet * loaders::dds::LoadFromFile( const std::string &filename )
+	ImageSet * LoadFromFile( const std::string &filename )
 	{
 		//Load the file.
 		FILE *pFile = fopen(filename.c_str(),"rb");
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.