00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "osMesaGraphicsStateGuardian.h"
00016
00017 TypeHandle OSMesaGraphicsStateGuardian::_type_handle;
00018
00019
00020
00021
00022
00023
00024 OSMesaGraphicsStateGuardian::
00025 OSMesaGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
00026 OSMesaGraphicsStateGuardian *share_with) :
00027 MesaGraphicsStateGuardian(engine, pipe)
00028 {
00029 OSMesaContext share_context = NULL;
00030 if (share_with != (OSMesaGraphicsStateGuardian *)NULL) {
00031 share_context = share_with->_context;
00032 _prepared_objects = share_with->get_prepared_objects();
00033 }
00034
00035 _context = OSMesaCreateContext(OSMESA_RGBA, share_context);
00036
00037
00038 _is_hardware = false;
00039 }
00040
00041
00042
00043
00044
00045
00046 OSMesaGraphicsStateGuardian::
00047 ~OSMesaGraphicsStateGuardian() {
00048 if (_context != (OSMesaContext)NULL) {
00049 OSMesaDestroyContext(_context);
00050 _context = (OSMesaContext)NULL;
00051 }
00052 }
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 void *OSMesaGraphicsStateGuardian::
00065 do_get_extension_func(const char *prefix, const char *name) {
00066 #if (OSMESA_MAJOR_VERSION == 4 && OSMESA_MINOR_VERSION >= 1) || OSMESA_MAJOR_VERSION > 4
00067
00068
00069
00070
00071
00072
00073
00074 string fullname = string("gl") + string(name);
00075 void *ptr = (void *)OSMesaGetProcAddress(fullname.c_str());
00076 if (mesadisplay_cat.is_debug()) {
00077 mesadisplay_cat.debug()
00078 << "Looking for function " << fullname << ": " << ptr << "\n";
00079 }
00080 if (ptr == (void *)NULL) {
00081
00082 fullname = string(prefix) + string(name);
00083 ptr = (void *)OSMesaGetProcAddress(fullname.c_str());
00084 if (mesadisplay_cat.is_debug()) {
00085 mesadisplay_cat.debug()
00086 << "Looking for function " << fullname << ": " << ptr << "\n";
00087 }
00088 }
00089
00090 return ptr;
00091
00092 #else
00093 if (mesadisplay_cat.is_debug()) {
00094 mesadisplay_cat.debug()
00095 << "Couldn't look up extension function: compiled with Mesa version "
00096 << OSMESA_MAJOR_VERSION << "." << OSMESA_MINOR_VERSION << "\n";
00097 }
00098
00099
00100
00101
00102
00103
00104 return NULL;
00105 #endif
00106 }