00001 /* 00002 File: MesaRenderer.cc 00003 00004 Function: 00005 00006 Author: Andrew Willmott 00007 00008 Notes: 00009 */ 00010 00011 #include "gcl/MesaRenderer.h" 00012 00013 #ifdef GCL_MESA 00014 00015 Void MesaRenderer::Init(RGBAImage &img) 00016 { 00017 mesaContext = OSMesaCreateContext(OSMESA_RGBA, 0); 00018 00019 glWidth = img.Width(); 00020 glHeight = img.Height(); 00021 outImage = &img; 00022 00023 MakeCurrent(); 00024 00025 GLRenderer::Init(); 00026 } 00027 00028 Void MesaRenderer::MakeCurrent() 00029 { 00030 // it seems as if calling this twice core dumps? 00031 // so... how else do we switch between it and other 00032 // contexts? I guess we don't. 00033 if (!OSMesaMakeCurrent(mesaContext, outImage->RGBAData(), 00034 GL_UNSIGNED_BYTE, outImage->Width(), outImage->Height())) 00035 _Error("Couldn't select mesa context"); 00036 } 00037 00038 MesaRenderer::~MesaRenderer() 00039 { 00040 OSMesaDestroyContext(mesaContext); 00041 } 00042 00043 #endif