00001 /* 00002 * Copyright (c) 1998 by Tech Soft 3D, LLC. 00003 * The information contained herein is confidential and proprietary to 00004 * Tech Soft 3D, LLC., and considered a trade secret as defined under 00005 * civil and criminal statutes. Tech Soft 3D shall pursue its civil 00006 * and criminal remedies in the event of unauthorized use or misappropriation 00007 * of its trade secrets. Use of this information by anyone other than 00008 * authorized employees of Tech Soft 3D, LLC. is granted only under a 00009 * written non-disclosure agreement, expressly prescribing the scope and 00010 * manner of such use. 00011 * 00012 * $Id: ogl2_8h-source.html,v 1.29 2008-03-10 07:09:28 stage Exp $ 00013 */ 00014 00015 #ifndef OGL2_H_DEFINED 00016 #define OGL2_H_DEFINED 00017 00018 00019 #include <stdio.h> 00020 #include <stdlib.h> 00021 00022 #include "database.h" 00023 #include "driver.h" 00024 #include "hpserror.h" 00025 #include "patterns.h" 00026 #include "phedron.h" 00027 #include "please.h" 00028 #include "searchh.h" 00029 #include "tandt.h" 00030 #include "hversion.h" 00031 #include "adt.h" 00032 00033 #include "3d_common.cpp" 00034 00035 #ifdef GLX_DRIVER 00036 # include <GL/glx.h> 00037 # include "x11data.h" 00038 00039 # ifdef LINUX_SYSTEM 00040 # define caddr_t char* 00041 # ifndef __cplusplus 00042 typedef struct GLUquadric GLUquadric; 00043 # endif 00044 # endif 00045 # ifdef IRIX_SYSTEM 00046 # undef SGI_TIMINGx 00047 # undef DEBUGx 00048 # endif 00049 # if defined(NUTCRACKER) 00050 /* for machine missing pbuffers */ 00051 typedef Window GLXPbuffer; 00052 #ifndef EXCEED_BUILD 00053 typedef void *GLXFBConfig; 00054 #endif 00055 #define glXChooseFBConfig(x1,x2,x3,x4) null 00056 #define glXGetVisualFromFBConfig(x1,x2) null 00057 #define glXCreatePbuffer(x1,x2,x3) null 00058 #endif 00059 # define MAX_SOLARIS_OVERLAY_COLORS 256 00060 # define SOLARIS_RESERVED_COLORS 65 00061 #endif 00062 00063 #ifdef WGL2_DRIVER 00064 # include <windows.h> 00065 # include "msw.h" 00066 #endif 00067 00068 #ifdef OSX_SYSTEM 00069 # undef local 00070 # undef OS_INLINE 00071 # define OS_INLINE static __inline__ /* workaround for a problem in agl headers */ 00072 # include <AGL/agl.h> 00073 # undef local 00074 # define local static 00075 # include <OpenGL/gl.h> 00076 # include <OpenGL/glu.h> 00077 # include <Carbon/Carbon.h> 00078 #else 00079 //# include <GL/gl.h> 00080 //# include <GL/glu.h> 00081 #define GLEW_STATIC 00082 #include "glew/glew.c" 00083 #endif 00084 00085 #ifndef AGLM 00086 # define AGLM(x) 00087 #endif 00088 00089 00090 00091 00092 /* Debug_NO_TWO_SIDED_LIGHTING is a way of indicating that it is okay for the 00093 * back face of objects to appear dark, even if they are not culled away. This 00094 * will improve performance significantly on some systems. */ 00095 #define Debug_NO_TWO_SIDED_LIGHTING 0x00000001 00096 #define DEBUG_GLX_INDIRECT 0x00000002 00097 #define Debug_OSX_UNDERLAY 0x00000004 00098 #define Debug_PUNT_BIG_TEXTURE 0x00000008 00099 #define DEBUG_MARKER_SIZE_CLAMP_TO_HW_MAX 0x00000010 00100 #define DEBUG_MARKER_POINTSMOOTH_CIRCLES 0x00000020 00101 /* Debug_NO_WINDOWS_HOOK is provided so that users can tell us not to hook into 00102 * the message queue for a window - this means that the user must process 00103 * ALL messages and call HC_Update_Display when they want hoops to draw 00104 * into the provided window is unused on unix*/ 00105 #define Debug_NO_WINDOWS_HOOK 0x00000040 00106 #define Debug_USE_QGL_CONTEXT 0x00000080 00107 #define Debug_WGL_NO_SHARELISTS 0x00000100 00108 #define Debug_QMOVES_NO_ZDAMAGE 0x00000200 00109 #define Debug_ENVIRONMENT_MAP_FORCE_MULTIPASS 0x00000400 00110 #define Debug_UNUSED12 0x00000800 00111 #define DEBUG_MITRE_TO_DEFAULT 0x00001000 00112 /*default clear is white*/ 00113 #define DEBUG_STARTUP_NO_CLEAR 0x00002000 00114 #define DEBUG_STARTUP_CLEAR_BLACK 0x00004000 00115 #define DEBUG_FORCE_XOR_OVERLAY 0x00008000 00116 #define DEBUG_NO_VERTEX_ARRAYS 0x00010000 00117 #define Debug_FLUSH_INTERVAL 0x00020000 00118 #define Debug_UNUSED19 0x00040000 00119 #define Debug_UNUSED20 0x00080000 00120 #define Debug_USE_WINDOW_IS_IMAGE 0x00100000 00121 #define Debug_16BIT_ZBUFFER 0x00200000 00122 #define Debug_HLR_ACTIVE 0x00400000 00123 #define Debug_NO_OGL_OVERLAY_PLANES 0x00800000 00124 #define Debug_FORCE_SOFTWARE 0x01000000 00125 #define DEBUG_FORCE_REAL_OVERLAY 0x02000000 00126 #define DEBUG_DISABLE_OCTANE2_HACK 0x04000000 00127 #define DEBUG_OGL_STUB 0x08000000 00128 00129 00130 00131 #define ACTION_NAME(a,b) 00132 00133 00134 00135 /* XBIT STUFF */ 00136 00137 #define XBIT_NONE 0L 00138 #define XBIT_UNDRAW_OVERLAY_FRONT_AND_BACK 1L 00139 #define XBIT_BAD_KTX 2L 00140 #define XBIT_DOUBLE_BUFFER_SWAP_ONLY 3L 00141 #define XBIT_BAD_VERTEX_ARRAYS 4L 00142 #define XBIT_BAD_SCISSORING 5L 00143 #define XBIT_EYE_SPACE_DEPTH 6L 00144 #define XBIT_FORCE_DEFAULT_SOFTWARE 7L 00145 #define XBIT_BAD_OVERLAY 8L 00146 #define XBIT_BAD_STENCIL 9L 00147 #define XBIT_BAD_TRANSPARENT_POINT 10L 00148 #define XBIT_RESTORE_REGION_ZBUFFER_OFF 11L 00149 #define XBIT_BAD_MULTILIGHT 12L 00150 #define XBIT_BAD_DISPLAY_LIST 13L 00151 #define XBIT_FORCE_OLD_CHOOSE_PIXEL_FORMAT 14L 00152 #define XBIT_BAD_PIXEL_STORE 15L 00153 #define XBIT_RASTERS_AS_VERTICES 16L 00154 #define XBIT_ALLOW_DRAWPIXEL_RESTORE 17L 00155 #define XBIT_DOUBLE_BUFFER_COPY_ONLY 18L 00156 #define XBIT_LIES_ABOUT_SWAP 19L 00157 #define XBIT_PIXEL_OPERATIONS_EXPENSIVE 20L /* currently used only in direct-to-ogl HStencilProbe from mvo */ 00158 #define XBIT_BAD_PHONG 21L 00159 #define XBIT_BAD_PATTERNED_LINES 22L 00160 #define XBIT_BAD_PBUFFER 23L 00161 #define XBIT_BAD_SPOTLIGHT_TEXTURE 24L 00162 #define XBIT_4142_WORKAROUND 25L 00163 #define XBIT_BAD_TWO_SIDED_LIGHTING 26L 00164 #define XBIT_BAD_FLAT_VERTEX_ARRAYS 27L 00165 #define XBIT_WGL_ARB_BUFFER_1024_LIMIT 28L 00166 #define XBIT_FLAT_TRISTRIP_MISMATCH 29L 00167 #define XBIT_BAD_NONDL_VERTEX_ARRAYS 30L 00168 #define XBIT_BAD_SINGLE_BUFFERING 31L 00169 #define XBIT_BAD_ACCUMULATION_BUFFER 32L 00170 #define XBIT_BAD_16BIT_ACCUMULATION_BUFFER 33L 00171 #define XBIT_LINE_PATTERN_NEEDS_BLENDING 34L 00172 #define XBIT_SLOW_MSAA_DEPTH_TEXTURE 35L 00173 #define XBIT_BAD_MSAA_ACCUMULATION_BUFFER 36L 00174 #define XBIT_BAD_MSAA_WGL_ARB_BUFFER 37L 00175 00176 00177 00178 /* Forward Declarations */ 00179 bool start_device (HT_Display_Context alter * dc); 00180 void stop_device (HT_Display_Context alter * dc); 00181 00182 void get_physical_info (HT_Display_Context alter * dc); 00183 POINTER_SIZED_INT get_outer_window (HT_Display_Context const * const_dc); 00184 void get_current_info (HT_Display_Context alter * dc); 00185 00186 void finish_update (HT_Display_Context const * dc); 00187 void init_update (HT_Display_Context const * dc); 00188 00189 bool request_keyboard (HT_Display_Context const * dc, 00190 int alter * button, int alter * status); 00191 00192 bool request_location (HT_Display_Context const * dc, 00193 int alter * button, 00194 int alter * x, int alter * y); 00195 00196 00197 void init_picture (HT_Net_Rendition const * nr); 00198 void finish_picture (HT_Net_Rendition const * nr, 00199 bool swap_buffers); 00200 00201 void free_outer_window (HT_Display_Context const * dc); 00202 void retitle_outer_window (HT_Display_Context const *dc); 00203 void resize_outer_window (HT_Display_Context const * dc); 00204 00205 00206 00207 00208 void update_physical_info (HT_Display_Context alter * dc); 00209 00210 00211 #ifdef WGL2_DRIVER 00212 /* these are used by the REGION_ACTIONS */ 00213 typedef void * H3DPBUFFERARB; 00214 #endif 00215 00216 00217 00218 00219 /***************************************************************************** 00220 ***************************************************************************** 00221 Category: H3D -> OGL conversion functions 00222 ***************************************************************************** 00223 *****************************************************************************/ 00224 GLenum oglprimitive(H3DPRIMITIVETYPE type) 00225 { 00226 switch (type) { 00227 case H3DPT_POINTLIST: return GL_POINTS; 00228 case H3DPT_LINELIST: return GL_LINES; 00229 case H3DPT_LINESTRIP: return GL_LINE_STRIP; 00230 case H3DPT_TRIANGLELIST: return GL_TRIANGLES; 00231 case H3DPT_TRIANGLESTRIP: return GL_TRIANGLE_STRIP; 00232 case H3DPT_TRIANGLEFAN: return GL_TRIANGLE_FAN; 00233 default: 00234 HE_ERROR(HEC_INTERNAL_ERROR, HEC_INTERNAL_ERROR, 00235 "Internal error: Unhandled primitive type mapping."); 00236 return GL_POINTS; 00237 } 00238 } 00239 00240 00241 GLenum oglcull(H3DCULL type) 00242 { 00243 switch (type) { 00244 case H3DCULL_NONE: return GL_NONE; 00245 case H3DCULL_CW: return GL_FRONT; 00246 case H3DCULL_CCW: return GL_BACK; 00247 default: 00248 HE_ERROR(HEC_INTERNAL_ERROR, HEC_INTERNAL_ERROR, 00249 "Internal error: Unhandled cull type mapping."); 00250 return GL_NONE; 00251 } 00252 } 00253 00254 00255 /***************************************************************************** 00256 ***************************************************************************** 00257 Category: Force/Ensure Macros 00258 ***************************************************************************** 00259 *****************************************************************************/ 00260 #define FORCE_VERTEX_ARRAY(ogldata,mode) SEMI_PROTECT(\ 00261 ogldata->oglcache.vertex_array = mode; \ 00262 if (mode) \ 00263 glEnableClientState(GL_VERTEX_ARRAY); \ 00264 else \ 00265 glDisableClientState(GL_VERTEX_ARRAY); \ 00266 ) 00267 00268 #define ENSURE_VERTEX_ARRAY(ogldata,mode) SEMI_PROTECT(\ 00269 if (mode != ogldata->oglcache.vertex_array) \ 00270 FORCE_VERTEX_ARRAY(ogldata,mode); \ 00271 ) 00272 00273 00274 #define FORCE_COLOR_ARRAY(ogldata,mode) SEMI_PROTECT(\ 00275 ogldata->oglcache.color_array = mode; \ 00276 if (mode) \ 00277 glEnableClientState(GL_COLOR_ARRAY); \ 00278 else \ 00279 glDisableClientState(GL_COLOR_ARRAY); \ 00280 ) 00281 00282 #define ENSURE_COLOR_ARRAY(ogldata,mode) SEMI_PROTECT(\ 00283 if (mode != ogldata->oglcache.color_array) \ 00284 FORCE_COLOR_ARRAY(ogldata,mode); \ 00285 ) 00286 00287 00288 #define FORCE_NORMAL_ARRAY(ogldata,mode) SEMI_PROTECT(\ 00289 ogldata->oglcache.normal_array = mode; \ 00290 if (mode) \ 00291 glEnableClientState(GL_NORMAL_ARRAY); \ 00292 else \ 00293 glDisableClientState(GL_NORMAL_ARRAY); \ 00294 ) 00295 00296 #define ENSURE_NORMAL_ARRAY(ogldata,mode) SEMI_PROTECT(\ 00297 if (mode != ogldata->oglcache.normal_array) \ 00298 FORCE_NORMAL_ARRAY(ogldata,mode); \ 00299 ) 00300 00301 00302 #define FORCE_TEXTURE_COORD_ARRAY(ogldata,mode) SEMI_PROTECT(\ 00303 ogldata->oglcache.param_array = mode; \ 00304 if (mode) \ 00305 glEnableClientState(GL_TEXTURE_COORD_ARRAY); \ 00306 else \ 00307 glDisableClientState(GL_TEXTURE_COORD_ARRAY); \ 00308 ) 00309 00310 #define ENSURE_TEXTURE_COORD_ARRAY(ogldata,mode) SEMI_PROTECT(\ 00311 if (mode != ogldata->oglcache.param_array) \ 00312 FORCE_TEXTURE_COORD_ARRAY(ogldata,mode); \ 00313 ) 00314 00315 00316 #define INVALIDATE_SCISSOR_SET(ogldata) SEMI_PROTECT(\ 00317 ogldata->cache.scissor_rect.left = INVALID_CACHE; \ 00318 ogldata->cache.scissor_rect.top = INVALID_CACHE; \ 00319 ogldata->cache.scissor_rect.right = INVALID_CACHE; \ 00320 ogldata->cache.scissor_rect.bottom = INVALID_CACHE; \ 00321 ) 00322 00323 00324 /***************************************************************************** 00325 ***************************************************************************** 00326 Category: OGLData 00327 ***************************************************************************** 00328 *****************************************************************************/ 00329 typedef struct ogldata_s : h3ddata_s 00330 { 00331 H3DPBUFFERARB pbuffer; /* if we are rendering as a pbuffer image */ 00332 00333 HGLRC hGLRC; 00334 HDC prevDC; 00335 HGLRC prevGLRC; 00336 HGLRC overlayGLRC; 00337 00338 /*for software hack*/ 00339 bool use_memory_buffer; 00340 HDC hMemDC; 00341 HBITMAP hBitmap; 00342 HBITMAP old_hBitmap; 00343 00344 int window_width; 00345 int window_height; 00346 00347 00348 int font_transformability; 00349 00350 bool is_high_color; 00351 00352 int accumulation_bits; 00353 00354 bool can_stencil; 00355 GLint stencil_planes; 00356 00357 bool fog_on; 00358 00359 bool can_anti_alias; 00360 int anti_alias_samples; 00361 00362 int max_texture_size; 00363 int max_line_weight; 00364 00365 00366 struct { 00367 bool vertex_array; 00368 bool normal_array; 00369 bool param_array; 00370 bool color_array; 00371 } oglcache; 00372 } OGLData; 00373 00374 #define OGLD(dc) ((OGLData alter *)((dc)->data2)) 00375 #define OGLNRD(nr) (OGLD((nr)->display_context)) 00376 00377 00378 00379 00380 00381 /***************************************************************************** 00382 ***************************************************************************** 00383 Category: HOGLVertexBufferCache Class 00384 ***************************************************************************** 00385 *****************************************************************************/ 00386 #define HOGL_PER_OBJECT_PENALTY 128 00387 00388 00389 // this is the global vertex buffer cache, being used for view dependent geometry 00390 class HOGLVertexBufferCache : public H3DVertexBufferCache 00391 { 00392 public: 00393 HOGLVertexBufferCache() 00394 { 00395 OUR(display_list_vram_usage) += HOGL_PER_OBJECT_PENALTY; 00396 m_pVertexBuffer = 0; 00397 m_nMaxPoints = 0; 00398 m_nNextVertexData = 0; 00399 m_nCurVertexData = 0; 00400 } 00401 00402 ~HOGLVertexBufferCache() 00403 { 00404 OUR(display_list_vram_usage) -= HOGL_PER_OBJECT_PENALTY; 00405 OUR(display_list_vram_usage) -= (m_nMaxPoints * m_nVertexStride); 00406 } 00407 00408 bool CreateVertexBuffer(H3DData *h3ddata, unsigned int max_points, 00409 H3DVertexFormat VF) 00410 { 00411 UNREFERENCED(h3ddata); 00412 m_nMaxPoints = max_points; 00413 m_nVertexStride = VF.get_size(); 00414 m_VF = VF; 00415 00416 glGenBuffersARB(1, &m_pVertexBuffer); 00417 OUR(display_list_vram_usage) += (m_nMaxPoints * m_nVertexStride); 00418 return true; 00419 } 00420 00421 bool Reset() 00422 { 00423 //TODO: H_SAFE_RELEASE(m_pVertexBuffer); 00424 OUR(display_list_vram_usage) -= (m_nMaxPoints * m_nVertexStride); 00425 00426 m_nMaxPoints = 0; 00427 m_nNextVertexData = 0; 00428 m_nCurVertexData = 0; 00429 return true; 00430 } 00431 00432 bool Discard() 00433 { 00434 return true; 00435 } 00436 00437 bool Lock(unsigned int count, H3DVertexBuffer *pv) 00438 { 00439 float *pvbuf = null; 00440 00441 // Determine the size of data to be moved into the vertex buffer. 00442 unsigned int data_size = count * m_nVertexStride; 00443 00444 // Check to see if the entire vertex buffer has been used up yet. 00445 if (m_nNextVertexData > (m_nMaxPoints*m_nVertexStride - data_size)) 00446 { 00447 // No space remains. Start over from the beginning 00448 // of the vertex buffer. 00449 m_nCurVertexData = 0; 00450 m_nNextVertexData = 0; 00451 } 00452 00453 // Lock the vertex buffer. 00454 glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_pVertexBuffer); 00455 glBufferDataARB(GL_ARRAY_BUFFER_ARB, data_size, NULL, GL_DYNAMIC_DRAW); 00456 pvbuf = (float *)glMapBufferARB(GL_ARRAY_BUFFER_ARB, (enum access) GL_WRITE_ONLY_ARB); 00457 00458 pv->Init(pvbuf, m_VF); 00459 normals_offset = pv->get_normals_offset() * sizeof(float); 00460 colors_offset = pv->get_color_offset() * sizeof(float); 00461 params_offset = pv->get_texture_offset() * sizeof(float); 00462 00463 // Advance to the next position in the vertex buffer. 00464 m_nNextVertexData += data_size; 00465 00466 return (pvbuf != null); 00467 } 00468 00469 bool Unlock() 00470 { 00471 GLboolean result = glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); 00472 return (result == GL_NO_ERROR); 00473 } 00474 00475 bool Draw(H3DData *h3ddata , H3DPRIMITIVETYPE PrimitiveType, unsigned int PrimitiveCount) 00476 { 00477 bool result = DrawRepeatable(h3ddata, PrimitiveType, PrimitiveCount); 00478 DrawComplete(); 00479 return result; 00480 } 00481 00482 bool DrawRepeatable(H3DData *h3ddata , H3DPRIMITIVETYPE PrimitiveType, unsigned int PrimitiveCount) 00483 { 00484 OGLData *ogldata = (OGLData *) h3ddata; 00485 00486 glBindBufferARB (GL_ARRAY_BUFFER_ARB, m_pVertexBuffer); 00487 if (m_VF.get_normals()) { 00488 ENSURE_NORMAL_ARRAY(ogldata,true); 00489 glNormalPointer (GL_FLOAT, m_nVertexStride, (char *) NULL + normals_offset); 00490 } 00491 00492 if (m_VF.get_tex_count() > 0) { 00493 ENSURE_TEXTURE_COORD_ARRAY(ogldata,true); 00494 glTexCoordPointer (m_VF.get_tex_size(0), GL_FLOAT, m_nVertexStride, (char *) NULL + params_offset); 00495 } 00496 00497 if (m_VF.get_diffuse()) { 00498 ENSURE_COLOR_ARRAY(ogldata,true); 00499 glColorPointer (4, GL_UNSIGNED_BYTE, m_nVertexStride, (char *) NULL + colors_offset); 00500 } 00501 00502 ENSURE_VERTEX_ARRAY(ogldata, true); 00503 glVertexPointer (3, GL_FLOAT, m_nVertexStride, (char *) NULL); 00504 00505 00506 //glDrawArrays(oglprimitive(PrimitiveType), m_nCurVertexData/m_nVertexStride, PrimitiveCount); 00507 glDrawArrays(oglprimitive(PrimitiveType), 0, PrimitiveCount); 00508 return true; 00509 } 00510 00511 void DrawComplete() 00512 { 00513 m_nCurVertexData = m_nNextVertexData; 00514 } 00515 00516 GLuint m_pVertexBuffer; 00517 int normals_offset; 00518 int colors_offset; 00519 int params_offset; 00520 }; 00521 00522 00523 /***************************************************************************** 00524 ***************************************************************************** 00525 Category: HOGLShader class 00526 ***************************************************************************** 00527 *****************************************************************************/ 00528 #define SHADER_SCRATCH_SIZE 65536 00529 00530 class HOGLShader : public H3DShader 00531 { 00532 protected: 00533 char alter *ComposePreamble (H3DShaderID &id, char alter *ptr, char const *end, int model, char const *dump_filename); 00534 00535 public: 00536 GLuint m_pProgram; 00537 GLuint m_pVS; 00538 GLuint m_pPS; 00539 00540 public: 00541 HOGLShader (const H3DShaderID& id); 00542 ~HOGLShader (); 00543 00544 bool Create(H3DData *h3ddata); 00545 bool Activate(); 00546 00547 void Force2DTransform (float *matrix); 00548 void Ensure3DTransform (HT_Net_Rendition const *nr); 00549 void EnsureDCTransform (HT_Net_Rendition const *nr); 00550 void EnsureColor (HT_Direct_RGB const *color); 00551 void EnsureLights ( 00552 HT_Net_Rendition const *nr, 00553 HT_Light_Rendition const *lr, 00554 HT_Material_Rendition const *mr, 00555 HT_Driver_Color const *color); 00556 void EnsureLineStyle ( 00557 HT_Net_Rendition const *nr, 00558 HT_Line_Rendition const *er); 00559 void EnsureCuttingPlanes (HT_Net_Rendition const *nr, HT_Cutting_Plane_Set const *cutset); 00560 void EnsureDCCuttingPlanes (HT_Cutting_Plane_Set const *cutset); 00561 void EnsureReflectionPlane (H3DData::ReflectionPlaneConstants const & constants); 00562 void EnsureDepthPeeling(H3DTexture *texture, H3DData *h3ddata); 00563 00564 // Shader's key is used to identify it. 00565 inline const H3DShaderID Key() const { return m_key; } 00566 }; 00567 00568 00569 /***************************************************************************** 00570 ***************************************************************************** 00571 Category: HOGLActions Class 00572 ***************************************************************************** 00573 *****************************************************************************/ 00574 class HOGLActions : public H3DActions 00575 { 00576 private: 00577 OGLData *m_ogldata; 00578 00579 public: 00580 HOGLActions(){}; 00581 HOGLActions(OGLData *ogldata) : 00582 H3DActions(ogldata), 00583 m_ogldata(ogldata) {}; 00584 ~HOGLActions(){}; 00585 00586 void Begin_Trace(WCHAR *string){} 00587 void End_Trace(){} 00588 H3DVertexBufferCache *CreateVertexBufferCache() {return new HOGLVertexBufferCache();} 00589 00590 void SetViewport(H3DVIEWPORT const *hvp) 00591 { 00592 glViewport(hvp->X, hvp->Y, hvp->Width, hvp->Height); 00593 } 00594 00595 /*******************/ 00596 /* Shader Creation */ 00597 /*******************/ 00598 H3DShader *CreateShader(H3DShaderID id) 00599 { 00600 return new HOGLShader(id); 00601 }; 00602 00603 00604 /************************/ 00605 /* Device state "force" */ 00606 /************************/ 00607 void force_anti_alias(bool mode) 00608 { 00609 m_ogldata->cache.antialias = mode; 00610 if (mode) 00611 glEnable (GL_MULTISAMPLE_ARB); 00612 else 00613 glDisable (GL_MULTISAMPLE_ARB); 00614 } 00615 00616 void force_zbuffering(bool mode) 00617 { 00618 m_ogldata->cache.zbuffering = mode; 00619 if (!mode) 00620 glDepthFunc(GL_ALWAYS); 00621 else { 00622 if (m_ogldata->cache.depth_test_reversed) 00623 glDepthFunc(GL_GREATER); 00624 else 00625 glDepthFunc(GL_LEQUAL); 00626 } 00627 } 00628 00629 void force_color_mask(bool mode) 00630 { 00631 m_ogldata->cache.color_mask = mode; 00632 if (!mode) 00633 glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 00634 else 00635 glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 00636 } 00637 00638 void force_depth_mask(bool mode) 00639 { 00640 m_ogldata->cache.depth_mask = mode; 00641 glDepthMask ((GLboolean)mode); 00642 } 00643 00644 void force_depth_range_set(float zmin, float zmax) 00645 { 00646 m_ogldata->cache.z_range[0] = zmin; 00647 m_ogldata->cache.z_range[1] = zmax; 00648 glDepthRange(zmin,zmax); 00649 } 00650 00651 void force_transparency(bool mode) 00652 { 00653 m_ogldata->cache.transparency_on = mode; 00654 if (mode) 00655 glEnable (GL_BLEND); 00656 else 00657 glDisable (GL_BLEND); 00658 } 00659 00660 void force_culling(H3DCULL mode) 00661 { 00662 if (mode == H3DCULL_NONE) 00663 m_ogldata->culling = false; 00664 else 00665 m_ogldata->culling = true; 00666 m_ogldata->cache.cull_mode = mode; 00667 00668 if (m_ogldata->culling) { 00669 glCullFace (oglcull(mode)); 00670 glEnable (GL_CULL_FACE); 00671 } 00672 else 00673 glDisable (GL_CULL_FACE); 00674 } 00675 00676 void force_scissor(bool mode) 00677 { 00678 if (m_ogldata->can_scissor) { 00679 INVALIDATE_SCISSOR_SET(m_ogldata); 00680 m_ogldata->cache.scissoring = mode; 00681 if (mode) 00682 glEnable(GL_SCISSOR_TEST); 00683 else 00684 glDisable(GL_SCISSOR_TEST); 00685 } 00686 } 00687 00688 void set_dc_xform (HT_Net_Rendition const * nr); 00689 00690 }; // HOGLActions 00691 00692 00693 #endif 00694 /*OGL2_H_DEFINED*/