Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygengld_driver.c
Go to the documentation of this file.
00001 /**************************************************************************** 00002 * 00003 * Mesa 3-D graphics library 00004 * Direct3D Driver Interface 00005 * 00006 * ======================================================================== 00007 * 00008 * Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved. 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining a 00011 * copy of this software and associated documentation files (the "Software"), 00012 * to deal in the Software without restriction, including without limitation 00013 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00014 * and/or sell copies of the Software, and to permit persons to whom the 00015 * Software is furnished to do so, subject to the following conditions: 00016 * 00017 * The above copyright notice and this permission notice shall be included 00018 * in all copies or substantial portions of the Software. 00019 * 00020 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00021 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00022 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00023 * SCITECH SOFTWARE INC BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 00024 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 00025 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00026 * SOFTWARE. 00027 * 00028 * ====================================================================== 00029 * 00030 * Language: ANSI C 00031 * Environment: Windows 9x/2000/XP/XBox (Win32) 00032 * 00033 * Description: Driver functions and interfaces 00034 * 00035 ****************************************************************************/ 00036 00037 #define STRICT 00038 #define WIN32_LEAN_AND_MEAN 00039 #include <windows.h> 00040 00041 #include "gld_driver.h" 00042 #include "ddlog.h" 00043 #include "glheader.h" 00044 00045 // For glGetString(). 00046 #include "common_x86_asm.h" 00047 00048 //--------------------------------------------------------------------------- 00049 00050 static char *szDriverError = "Driver used before initialisation!"; 00051 00052 // This holds our dynamically created OpenGL renderer string. 00053 // 256 chars should be plenty - remember that some apps display this. 00054 static char _gldRendererString[256]; 00055 00056 static char *szVendor = "SciTech Software, Inc."; 00057 00058 //--------------------------------------------------------------------------- 00059 00060 extern BOOL gldGetDXErrorString_DX(HRESULT hr, char *buf, int nBufSize); 00061 00062 extern BOOL gldCreateDrawable_MesaSW(DGL_ctx *ctx, BOOL bPersistantInterface, BOOL bPersistantBuffers); 00063 extern BOOL gldResizeDrawable_MesaSW(DGL_ctx *ctx, BOOL bDefaultDriver, BOOL bPersistantInterface, BOOL bPersistantBuffers); 00064 extern BOOL gldDestroyDrawable_MesaSW(DGL_ctx *ctx); 00065 extern BOOL gldCreatePrivateGlobals_MesaSW(void); 00066 extern BOOL gldDestroyPrivateGlobals_MesaSW(void); 00067 extern BOOL gldBuildPixelformatList_MesaSW(void); 00068 extern BOOL gldInitialiseMesa_MesaSW(DGL_ctx *ctx); 00069 extern BOOL gldSwapBuffers_MesaSW(DGL_ctx *ctx, HDC hDC, HWND hWnd); 00070 extern PROC gldGetProcAddress_MesaSW(LPCSTR a); 00071 extern BOOL gldGetDisplayMode_MesaSW(DGL_ctx *ctx, GLD_displayMode *glddm); 00072 00073 extern BOOL gldCreateDrawable_DX(DGL_ctx *ctx, BOOL bPersistantInterface, BOOL bPersistantBuffers); 00074 extern BOOL gldResizeDrawable_DX(DGL_ctx *ctx, BOOL bDefaultDriver, BOOL bPersistantInterface, BOOL bPersistantBuffers); 00075 extern BOOL gldDestroyDrawable_DX(DGL_ctx *ctx); 00076 extern BOOL gldCreatePrivateGlobals_DX(void); 00077 extern BOOL gldDestroyPrivateGlobals_DX(void); 00078 extern BOOL gldBuildPixelformatList_DX(void); 00079 extern BOOL gldInitialiseMesa_DX(DGL_ctx *ctx); 00080 extern BOOL gldSwapBuffers_DX(DGL_ctx *ctx, HDC hDC, HWND hWnd); 00081 extern PROC gldGetProcAddress_DX(LPCSTR a); 00082 extern BOOL gldGetDisplayMode_DX(DGL_ctx *ctx, GLD_displayMode *glddm); 00083 00084 //--------------------------------------------------------------------------- 00085 // NOP functions. Called if proper driver functions are not set. 00086 //--------------------------------------------------------------------------- 00087 00088 static BOOL _gldDriverError(void) 00089 { 00090 ddlogMessage(DDLOG_CRITICAL, szDriverError); 00091 return FALSE; 00092 } 00093 00094 //--------------------------------------------------------------------------- 00095 00096 static BOOL _GetDXErrorString_ERROR( 00097 HRESULT hr, 00098 char *buf, 00099 int nBufSize) 00100 { 00101 return _gldDriverError(); 00102 } 00103 00104 //--------------------------------------------------------------------------- 00105 00106 static BOOL _CreateDrawable_ERROR( 00107 DGL_ctx *ctx, 00108 BOOL bPersistantInterface, 00109 BOOL bPersistantBuffers) 00110 { 00111 return _gldDriverError(); 00112 } 00113 00114 //--------------------------------------------------------------------------- 00115 00116 static BOOL _ResizeDrawable_ERROR( 00117 DGL_ctx *ctx, 00118 BOOL bDefaultDriver, 00119 BOOL bPersistantInterface, 00120 BOOL bPersistantBuffers) 00121 { 00122 return _gldDriverError(); 00123 } 00124 00125 //--------------------------------------------------------------------------- 00126 00127 static BOOL _DestroyDrawable_ERROR( 00128 DGL_ctx *ctx) 00129 { 00130 return _gldDriverError(); 00131 } 00132 00133 //--------------------------------------------------------------------------- 00134 00135 static BOOL _CreatePrivateGlobals_ERROR(void) 00136 { 00137 return _gldDriverError(); 00138 } 00139 00140 //--------------------------------------------------------------------------- 00141 00142 static BOOL _DestroyPrivateGlobals_ERROR(void) 00143 { 00144 return _gldDriverError(); 00145 } 00146 00147 //--------------------------------------------------------------------------- 00148 00149 static BOOL _BuildPixelformatList_ERROR(void) 00150 { 00151 return _gldDriverError(); 00152 } 00153 00154 //--------------------------------------------------------------------------- 00155 00156 00157 static BOOL _InitialiseMesa_ERROR( 00158 DGL_ctx *ctx) 00159 { 00160 return _gldDriverError(); 00161 } 00162 00163 //--------------------------------------------------------------------------- 00164 00165 static BOOL _SwapBuffers_ERROR( 00166 DGL_ctx *ctx, 00167 HDC hDC, 00168 HWND hWnd) 00169 { 00170 return _gldDriverError(); 00171 } 00172 00173 //--------------------------------------------------------------------------- 00174 00175 static PROC _GetProcAddress_ERROR( 00176 LPCSTR a) 00177 { 00178 _gldDriverError(); 00179 return NULL; 00180 } 00181 00182 //--------------------------------------------------------------------------- 00183 00184 static BOOL _GetDisplayMode_ERROR( 00185 DGL_ctx *ctx, 00186 GLD_displayMode *glddm) 00187 { 00188 return _gldDriverError(); 00189 } 00190 00191 //--------------------------------------------------------------------------- 00192 // Functions useful to all drivers 00193 //--------------------------------------------------------------------------- 00194 00195 const GLubyte* _gldGetStringGeneric( 00196 GLcontext *ctx, 00197 GLenum name) 00198 { 00199 if (!ctx) 00200 return NULL; 00201 00202 switch (name) { 00203 case GL_RENDERER: 00204 sprintf(_gldRendererString, "GLDirect 4.0 %s%s%s%s (%s %s)", 00205 _mesa_x86_cpu_features ? "/x86" : "", 00206 cpu_has_mmx ? "/MMX" : "", 00207 cpu_has_3dnow ? "/3DNow!" : "", 00208 cpu_has_xmm ? "/SSE" : "", 00209 __DATE__, __TIME__); 00210 return (const GLubyte *) _gldRendererString; 00211 case GL_VENDOR: 00212 return (const GLubyte *) szVendor; 00213 default: 00214 return NULL; 00215 } 00216 } 00217 00218 //--------------------------------------------------------------------------- 00219 // Global driver function pointers, initially set to functions that 00220 // will report an error when called. 00221 //--------------------------------------------------------------------------- 00222 00223 GLD_driver _gldDriver = { 00224 _GetDXErrorString_ERROR, 00225 _CreateDrawable_ERROR, 00226 _ResizeDrawable_ERROR, 00227 _DestroyDrawable_ERROR, 00228 _CreatePrivateGlobals_ERROR, 00229 _DestroyPrivateGlobals_ERROR, 00230 _BuildPixelformatList_ERROR, 00231 _InitialiseMesa_ERROR, 00232 _SwapBuffers_ERROR, 00233 _GetProcAddress_ERROR, 00234 _GetDisplayMode_ERROR 00235 }; 00236 00237 //--------------------------------------------------------------------------- 00238 // Init function. Should be called as soon as regkeys/ini-settings are read. 00239 //--------------------------------------------------------------------------- 00240 00241 BOOL gldInitDriverPointers( 00242 DWORD dwDriver) 00243 { 00244 _gldDriver.GetDXErrorString = gldGetDXErrorString_DX; 00245 00246 if (dwDriver == GLDS_DRIVER_MESA_SW) { 00247 // Mesa Software driver 00248 _gldDriver.CreateDrawable = gldCreateDrawable_MesaSW; 00249 _gldDriver.ResizeDrawable = gldResizeDrawable_MesaSW; 00250 _gldDriver.DestroyDrawable = gldDestroyDrawable_MesaSW; 00251 _gldDriver.CreatePrivateGlobals = gldCreatePrivateGlobals_MesaSW; 00252 _gldDriver.DestroyPrivateGlobals = gldDestroyPrivateGlobals_MesaSW; 00253 _gldDriver.BuildPixelformatList = gldBuildPixelformatList_MesaSW; 00254 _gldDriver.InitialiseMesa = gldInitialiseMesa_MesaSW; 00255 _gldDriver.SwapBuffers = gldSwapBuffers_MesaSW; 00256 _gldDriver.wglGetProcAddress = gldGetProcAddress_MesaSW; 00257 _gldDriver.GetDisplayMode = gldGetDisplayMode_MesaSW; 00258 return TRUE; 00259 } 00260 00261 if ((dwDriver == GLDS_DRIVER_REF) || (dwDriver == GLDS_DRIVER_HAL)) { 00262 // Direct3D driver, either HW or SW 00263 _gldDriver.CreateDrawable = gldCreateDrawable_DX; 00264 _gldDriver.ResizeDrawable = gldResizeDrawable_DX; 00265 _gldDriver.DestroyDrawable = gldDestroyDrawable_DX; 00266 _gldDriver.CreatePrivateGlobals = gldCreatePrivateGlobals_DX; 00267 _gldDriver.DestroyPrivateGlobals = gldDestroyPrivateGlobals_DX; 00268 _gldDriver.BuildPixelformatList = gldBuildPixelformatList_DX; 00269 _gldDriver.InitialiseMesa = gldInitialiseMesa_DX; 00270 _gldDriver.SwapBuffers = gldSwapBuffers_DX; 00271 _gldDriver.wglGetProcAddress = gldGetProcAddress_DX; 00272 _gldDriver.GetDisplayMode = gldGetDisplayMode_DX; 00273 return TRUE; 00274 }; 00275 00276 return FALSE; 00277 } 00278 00279 //--------------------------------------------------------------------------- Generated on Sat May 26 2012 04:18:45 for ReactOS by
1.7.6.1
|