llwindowmesaheadless.cpp

Go to the documentation of this file.
00001 
00032 #if LL_MESA_HEADLESS
00033 
00034 #include "linden_common.h"
00035 #include "indra_constants.h"
00036 
00037 #include "llwindowmesaheadless.h"
00038 #include "llgl.h"
00039 #include "llglheaders.h"
00040 
00041 #define MESA_CHANNEL_TYPE GL_UNSIGNED_SHORT
00042 #define MESA_CHANNEL_SIZE 2
00043 
00044 U16 *gMesaBuffer = NULL;
00045 
00046 //
00047 // LLWindowMesaHeadless
00048 //
00049 LLWindowMesaHeadless::LLWindowMesaHeadless(char *title, char *name, S32 x, S32 y, S32 width, S32 height,
00050                                                          U32 flags,  BOOL fullscreen, BOOL clearBg,
00051                                                          BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth, S32 stereo_mode)
00052         : LLWindow(fullscreen, flags)
00053 {
00054         if (use_gl)
00055         {
00056                 llinfos << "MESA Init" << llendl;
00057                 mMesaContext = OSMesaCreateContextExt( GL_RGBA, 32, 0, 0, NULL );
00058 
00059                 /* Allocate the image buffer */
00060                 mMesaBuffer = new unsigned char [width * height * 4 * MESA_CHANNEL_SIZE];
00061                 llassert(mMesaBuffer);
00062 
00063                 gMesaBuffer = (U16*)mMesaBuffer;
00064 
00065                 /* Bind the buffer to the context and make it current */
00066                 if (!OSMesaMakeCurrent( mMesaContext, mMesaBuffer, MESA_CHANNEL_TYPE, width, height ))
00067                 {
00068                         llerrs << "MESA: OSMesaMakeCurrent failed!" << llendl;
00069                 }
00070 
00071                 llverify(gGLManager.initGL());
00072         }
00073 }
00074 
00075 
00076 LLWindowMesaHeadless::~LLWindowMesaHeadless()
00077 {
00078         delete mMesaBuffer;
00079         OSMesaDestroyContext( mMesaContext );
00080 }
00081 
00082 void LLWindowMesaHeadless::swapBuffers()
00083 {
00084         glFinish();
00085 }
00086 
00087 #endif

Generated on Thu Jul 1 06:09:46 2010 for Second Life Viewer by  doxygen 1.4.7