![]() Home Page Toolkit Overview Using GML User Input Services Finger Tracker Calibrator Frame Grabber Service protocol Obtaining GML Installing GML Licence Developer Documentation Tcl/Tk API The GML Canvas Image processing Tcl Scripts Library List of Classes List of Files C/C++ API List of Classes List of Files |
gml_GL_Base.hGo to the documentation of this file.00001 /** @file gml_GL_Base.h 00002 * 00003 * Wrapper for platform dependent creation of OpenGL rendering context, and 00004 * conversions from gml_TBitmap to OpenGL buffers. 00005 * 00006 * Copyright (c) 2003 CLIPS-IMAG 00007 * 00008 * See the file "gml_LicenseTerms.txt" for information on usage and redistribution 00009 * of this file, and for a DISCLAIMER OF ALL WARRANTIES. 00010 * 00011 * Created on March 9, 2003 (FB). 00012 */ 00013 #ifndef __GML_OPENGL__ 00014 #define __GML_OPENGL__ 00015 00016 //#include "gml/math/gml_Math.h" 00017 #include "gml/base/gml_Errors.h" 00018 #include "gml/image/gml_Drawable.h" 00019 #include "gml/image/gml_RGBColor.h" 00020 #include "gml/image/gml_Geometry.h" 00021 00022 00023 #if defined(__APPLE__) 00024 00025 #include <OpenGL/gl.h> 00026 #include <OpenGL/glu.h> 00027 #include <OpenGL/glext.h> 00028 00029 #define GL_TESSCALLBACKPARAMS ... 00030 00031 #elif defined(_WIN32) 00032 00033 #include <gl.h> 00034 #include <glu.h> 00035 #include <glext.h> 00036 #ifndef GL_TEXTURE_RECTANGLE_EXT 00037 #define GL_TEXTURE_RECTANGLE_EXT GL_TEXTURE_RECTANGLE_NV 00038 #endif 00039 00040 #define GL_TESSCALLBACKPARAMS 00041 00042 #else 00043 00044 #define GL_GLEXT_PROTOTYPES 00045 #include <GL/gl.h> 00046 #include <GL/glu.h> 00047 #include <GL/glext.h> 00048 #ifndef GL_TEXTURE_RECTANGLE_EXT 00049 #define GL_TEXTURE_RECTANGLE_EXT GL_TEXTURE_RECTANGLE_NV 00050 #endif 00051 00052 #define GL_TESSCALLBACKPARAMS 00053 00054 #endif 00055 00056 #define GMLGL_CHECK_ERROR 00057 do { 00058 GLenum err = glGetError (); 00059 if (err == GL_NO_ERROR) break; 00060 fprintf (stderr, "[gmlGL] %s:%d %s\n", 00061 __FILE__, __LINE__, 00062 gluErrorString (err)); 00063 } while (0) 00064 00065 00066 // Error numbers -- 00067 00068 extern gml_TError gmlGL_gErrCantChoosePixelFormat; 00069 extern gml_TError gmlGL_gErrCantCreateContext; 00070 extern gml_TError gmlGL_gErrCantAttachDrawable; 00071 extern gml_TError gmlGL_gErrCantSetCurrentContext; 00072 extern gml_TError gmlGL_gErrCantSwapBuffers; 00073 extern gml_TError gmlGL_gErrCantUpdateContextDrawable; 00074 extern gml_TError gmlGL_gErrWrongBMsize; 00075 extern gml_TError gmlGL_gErrUnsupportedBMencoding; 00076 extern gml_TError gmlGL_gErrUnknownContext; 00077 extern gml_TError gmlGL_gUnsupportedExtension; 00078 00079 00080 /** gmlGL_TContext -- 00081 * 00082 * A identifier for an OpenGL context. 00083 * NULL has a special meaning, the sharing context; 00084 * it is created automatically and cannot be deleted. 00085 */ 00086 struct gmlGL_TContext_; 00087 typedef struct gmlGL_TContext_* gmlGL_TContext; 00088 00089 00090 00091 00092 // PLATFORM INDEPENDANT CODE -- 00093 // 00094 // Defined in "gml_GL_Base.cc". 00095 00096 00097 /// gmlGL_Initialize -- 00098 /// 00099 /// Initialized gml_GL_Base error numbers. Users of gml_GL_Base function need not call 00100 /// this function as it will be called automatically. 00101 00102 GML_EXTERN_C 00103 gml_TError gmlGL_Initialize (); 00104 00105 00106 00107 /// gmlGL_ColorRGBAtoGL4usv -- 00108 /// 00109 /// Converts a gml_TRGBColor <color> and its transparency value <alpha> into a GL color 00110 /// encoded on an array of 4 unsigned short <glColor> (for use with glColor4usv). 00111 00112 GML_EXTERN_C 00113 void gmlGL_ColorRGBAtoGL4usv (gml_TRGBColor* color, float alpha, GLushort* glColor); 00114 00115 /// gmlGL_ColorRGBAtoGL4fv -- 00116 /// 00117 /// Converts a gml_TRGBColor <color> and its transparency value <alpha> into a GL color 00118 /// encoded on an array of 4 floats <glColor> (for use with glColor4fv). 00119 00120 GML_EXTERN_C 00121 void gmlGL_ColorRGBAtoGL4fv (gml_TRGBColor* color, float alpha, GLfloat* glColor); 00122 00123 00124 /// gmlGL_HasExtension -- 00125 /// 00126 /// Check whether the current OpenGL context supports the argument <extension>, 00127 /// e.g. "GL_EXT_texture_rectangle". 00128 00129 00130 GML_EXTERN_C 00131 gml_TBoolean gmlGL_HasExtension (char *extension); 00132 00133 00134 00135 //// gmlGL_GetTextureParamsFromEncoding -- 00136 //// 00137 //// Checks that the encoding <enc> is suitable for a GL texture. 00138 //// Select the correct <internal> <format> <type> for use with OpenGL. 00139 00140 GML_EXTERN_C 00141 gml_TError gmlGL_GetTextureParamsFromEncoding (gml_TPixelEncoding enc, 00142 GLint* internal, 00143 GLenum* format, 00144 GLenum* type); 00145 00146 00147 /// gmlGL_SaveToBitmap -- 00148 /// 00149 /// Copy the current OpenGL context draw buffer to the bitmap <bm> with "glReadPixels". 00150 /// <bm> must have compatible specifications. 00151 00152 GML_EXTERN_C 00153 gml_TError gmlGL_SaveToBitmap (gml_TBitmap* bm); 00154 00155 00156 00157 00158 00159 // PLATFORM DEPENDANT CODE -- 00160 // 00161 // Defined in "gml_OpenGL_<platform>.cc". 00162 00163 00164 /// gmlGL_PlatformInitialize -- 00165 /// 00166 /// Perform platform-specific setup. This is called automatically by gmlGL_Initialize. 00167 /// In particular, create the sharing context (context 0). 00168 00169 GML_EXTERN_C 00170 void gmlGL_PlatformInitialize (); 00171 00172 00173 /// gmlGL_FindVisual -- 00174 /// 00175 /// Find a visual appropriate for an OpenGL context 00176 00177 GML_EXTERN_C 00178 gml_TError gmlGL_FindVisual (gml_TDisplay display, gml_TVisual *visual); 00179 00180 00181 00182 /// gmlGL_CreateContext -- 00183 /// 00184 /// Creates an OpenGL rendering context and attach it to the drawable <drawable>. 00185 /// Return the context handle in <context>. 00186 /// If <drawable> is NULL, the context may still be used for off-screen rendering. 00187 /// Note that all context share data (textures, display lists, etc.) 00188 00189 GML_EXTERN_C 00190 gml_TError gmlGL_CreateContext (gml_TDisplay display, 00191 gml_TVisual visual, 00192 gml_TDrawable drawable, 00193 gmlGL_TContext* context); 00194 00195 00196 /// gmlGL_DeleteContext -- 00197 /// 00198 /// Deletes an OpenGL rendering context. 00199 /// After the call, the sharing context is active. 00200 00201 GML_EXTERN_C 00202 void gmlGL_DeleteContext (gmlGL_TContext context); 00203 00204 00205 00206 /// gmlGL_GetCurrentContext -- 00207 /// 00208 /// Return the current OpenGL rendering context. 00209 00210 GML_EXTERN_C 00211 gmlGL_TContext gmlGL_GetCurrentContext (); 00212 00213 00214 /// gmlGL_SetCurrentContext -- 00215 /// 00216 /// Sets <context> as the current OpenGL rendering context. 00217 /// If <context> is NULL, the sharing context is used. 00218 00219 GML_EXTERN_C 00220 gml_TError gmlGL_SetCurrentContext (gmlGL_TContext context); 00221 00222 00223 00224 /// gmlGL_SwapBuffers -- 00225 /// 00226 /// Swaps front and back buffer (double buffering). 00227 /// Note: <gmlGL_SwapBuffer> performs an implicit glFlush before it returns. 00228 00229 GML_EXTERN_C 00230 gml_TError gmlGL_SwapBuffers (gmlGL_TContext context); 00231 00232 00233 00234 /// gmlGL_DrawableChanged -- 00235 /// 00236 /// Update an Open GL rendering context after its drawable changed (resizing, 00237 /// window exposure...). 00238 00239 GML_EXTERN_C 00240 gml_TError gmlGL_DrawableChanged (gmlGL_TContext context); 00241 00242 00243 00244 /// gmlGL_SetDrawableRect -- 00245 /// 00246 /// Restricts OpenGL rendering in the context's drawable to a rectangle specified by its 00247 /// bottomleft corner and size. 00248 00249 GML_EXTERN_C 00250 gml_TError gmlGL_SetDrawableRect (gmlGL_TContext context, 00251 GLint top, GLint bottom, GLint width, GLint height); 00252 00253 00254 #endif
Generated on Tue Jun 12 14:03:27 2007 for gml by
Doxygen 1.5.2.
|
Contact: julien (dot) letessier (at) gmail (dot) com.
Copyright (c) 2000-2007 CLIPS-IMAG Laboratory, Grenoble, France. All rights reserved. W3CXHTML 1.0 W3CCSS 2.0 |