#include <windows.h>#include <stdio.h>#include <math.h>#include <gl/gl.h>#include "OglDrv.h"#include "OglMisc.h"#include "THandle.h"#include "Render.h"#include "Win32.h"Go to the source code of this file.
|
|
|
|
|
Definition at line 263 of file OGLDrv.c. References DRV_EngineSettings::CanSupportFlags, DllExport, DRV_ERROR_NONE, DRV_SUPPORT_ALPHA, DRV_SUPPORT_COLORKEY, DRV_Driver::EngineSettings, EngineSettings, GE_TRUE, LastErrorStr, DRV_Driver::LastErrorStr, OGLDRV, DRV_EngineSettings::PreferenceFlags, and SetLastDrvError().
00264 {
00265
00266 EngineSettings.CanSupportFlags = (DRV_SUPPORT_ALPHA | DRV_SUPPORT_COLORKEY);
00267 EngineSettings.PreferenceFlags = 0;
00268
00269 OGLDRV.EngineSettings = &EngineSettings;
00270
00271 *Driver = &OGLDRV;
00272
00273 // Make sure the error string ptr is not null, or invalid!!!
00274 OGLDRV.LastErrorStr = LastErrorStr;
00275
00276 SetLastDrvError(DRV_ERROR_NONE, "OGL: No error.");
00277
00278 return GE_TRUE;
00279 }
|
|
|
Definition at line 123 of file OGLDrv.c. References tagRECT::bottom, ClientWindow, DRIVERCC, DRV_ERROR_GENERIC, ExtensionExists(), GE_FALSE, GE_TRUE, geBoolean, GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, glActiveTextureARB, glMultiTexCoord4fARB, DRV_Window::Height, DRV_DriverHook::Height, DRV_Window::hWnd, DRV_DriverHook::hWnd, InitMatrices(), tagRECT::left, maxTextureSize, multitexture, NULL, tagRECT::right, SetFogEnable(), SetFullscreen(), SetGLPixelFormat(), SetLastDrvError(), THandle_Startup(), tagRECT::top, DRV_Window::Width, DRV_DriverHook::Width, and WindowSetup().
00124 {
00125 RECT WRect;
00126
00127
00128 WindowSetup(Hook);
00129
00130 if(Hook->Width == -1 && Hook->Height == -1)
00131 {
00132 GetClientRect(Hook->hWnd, &WRect);
00133
00134 Hook->Width = (WRect.right - WRect.left);
00135 Hook->Height = (WRect.bottom - WRect.top);
00136 }
00137 else if(!SetFullscreen(Hook))
00138 {
00139 return GE_FALSE;
00140 }
00141
00142 SetGLPixelFormat(Hook);
00143
00144 ClientWindow.Width = Hook->Width;
00145 ClientWindow.Height = Hook->Height;
00146 ClientWindow.hWnd = Hook->hWnd;
00147
00148 #ifdef USE_LIGHTMAPS
00149 if(ExtensionExists("GL_ARB_multitexture"))
00150 {
00151 glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress("glActiveTextureARB");
00152 glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC)wglGetProcAddress("glMultiTexCoord4fARB");
00153
00154 if(glActiveTextureARB != NULL && glMultiTexCoord4fARB != NULL)
00155 {
00156 multitexture = GL_TRUE;
00157 }
00158 }
00159 else
00160 #endif
00161 {
00162 multitexture = GL_FALSE;
00163 }
00164
00165
00166 glPixelStorei(GL_PACK_ALIGNMENT, 1);
00167 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
00168
00169 glEnable(GL_TEXTURE_2D);
00170 glEnable(GL_DEPTH_TEST);
00171
00172 glEnable(GL_BLEND);
00173 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00174
00175 glShadeModel(GL_SMOOTH);
00176 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
00177
00178 if(multitexture)
00179 {
00180 glActiveTextureARB(GL_TEXTURE1_ARB);
00181
00182 glDisable(GL_TEXTURE_1D);
00183 glDisable(GL_TEXTURE_2D);
00184
00185 glActiveTextureARB(GL_TEXTURE0_ARB);
00186 }
00187
00188 SetFogEnable(GE_FALSE, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
00189
00190 InitMatrices(ClientWindow.Width, ClientWindow.Height);
00191
00192 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
00193
00194 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
00195
00196 if (!THandle_Startup())
00197 {
00198 SetLastDrvError(DRV_ERROR_GENERIC, "OGL_DrvInit: THandle_Startup failed...\n");
00199 return GE_FALSE;
00200 }
00201
00202 return GE_TRUE;
00203 }
|
|
|
Definition at line 225 of file OGLDrv.c. References DRIVERCC, GE_TRUE, and geBoolean.
00226 {
00227
00228 return GE_TRUE;
00229 }
|
|
|
Definition at line 206 of file OGLDrv.c. References DRIVERCC, GE_TRUE, geBoolean, and WindowCleanup().
00207 {
00208 // Tell OpenGL to finish whatever is in the pipe, because we're closing up shop.
00209 glFinish();
00210
00211 WindowCleanup();
00212
00213 return GE_TRUE;
00214 }
|
|
|
Definition at line 218 of file OGLDrv.c. References DRIVERCC, GE_TRUE, and geBoolean.
00219 {
00220
00221 return GE_TRUE;
00222 }
|
|
||||||||||||||||||||
|
Definition at line 282 of file OGLDrv.c. References DRIVERCC, EnumNativeModes(), GE_TRUE, and geBoolean.
00284 {
00285 GLint modeCount = 0;
00286
00287 modeCount = EnumNativeModes(Cb, Context);
00288
00289 return GE_TRUE;
00290 }
|
|
||||||||||||
|
Definition at line 320 of file OGLDrv.c. References DRIVERCC, GE_TRUE, geBoolean, NUM_PIXEL_FORMATS, and PixelFormats.
00321 {
00322 GLint i;
00323
00324 for(i = 0; i < NUM_PIXEL_FORMATS; i++)
00325 {
00326 if(!Cb(&PixelFormats[i], Context))
00327 {
00328 return GE_TRUE;
00329 }
00330 }
00331
00332 return GE_TRUE;
00333 }
|
|
||||||||||||
|
Definition at line 293 of file OGLDrv.c. References DRIVERCC, DRV_VMAJS, DRV_VMINS, GE_TRUE, and geBoolean.
|
|
|
Definition at line 253 of file OGLDrv.c. References CurrentGamma, DRIVERCC, geBoolean, and TRUE.
00254 {
00255 *Gamma = CurrentGamma;
00256
00257 return TRUE;
00258 }
|
|
|
Definition at line 357 of file OGLDrv.c. References ClientWindow, DRIVERCC, GE_FALSE, GE_TRUE, geBoolean, GL_BGR_EXT, DRV_Window::Height, NULL, and DRV_Window::Width.
00358 {
00359 unsigned char tgaHeader[18];
00360 GLubyte *buffer;
00361 FILE *fp;
00362 char *newName;
00363 int nameLen;
00364
00365 buffer = (GLubyte *)malloc(sizeof(GLubyte) * ClientWindow.Width * ClientWindow.Height * 3);
00366
00367 glFinish();
00368
00369 glReadPixels(0, 0, ClientWindow.Width, ClientWindow.Height,
00370 GL_BGR_EXT, GL_UNSIGNED_BYTE, buffer);
00371
00372 memset(tgaHeader, 0, sizeof(tgaHeader));
00373 tgaHeader[2] = 2;
00374 tgaHeader[12] = (unsigned char)ClientWindow.Width;
00375 tgaHeader[13] = (unsigned char)((unsigned long)ClientWindow.Width >> 8);
00376 tgaHeader[14] = (unsigned char)ClientWindow.Height;
00377 tgaHeader[15] = (unsigned char)((unsigned long)ClientWindow.Height >> 8);
00378 tgaHeader[16] = 24;
00379
00380 // Convert the extention (if one exists) to .tga. They probably expect a .bmp.
00381 newName = strdup(Name);
00382
00383 nameLen = strlen(newName);
00384
00385 if(nameLen > 3)
00386 {
00387 if(newName[nameLen - 4] == '.')
00388 {
00389 strcpy(newName + nameLen - 3, "tga");
00390 }
00391 }
00392
00393 fp = fopen(newName, "wb");
00394
00395 free(newName);
00396
00397 if(fp == NULL)
00398 {
00399 free(buffer);
00400 return GE_FALSE;
00401 }
00402
00403 fwrite(tgaHeader, 1, 18, fp);
00404 fwrite(buffer, 3, ClientWindow.Width * ClientWindow.Height, fp);
00405 fclose(fp);
00406
00407 free(buffer);
00408
00409 return GE_TRUE;
00410 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 116 of file OGLDrv.c. References DRIVERCC, GE_TRUE, and geBoolean. Referenced by DrvInit().
00117 {
00118
00119 return GE_TRUE;
00120 }
|
|
|
Definition at line 232 of file OGLDrv.c. References CurrentGamma, DRIVERCC, GE_TRUE, and geBoolean.
00233 {
00234 GLfloat lut[256];
00235 GLint i;
00236
00237 CurrentGamma = Gamma;
00238
00239 for(i = 0; i < 256; i++)
00240 {
00241 lut[i] = (GLfloat)pow(i / 255.0, 1.0 / CurrentGamma);
00242 }
00243
00244 glPixelTransferi(GL_MAP_COLOR, GL_TRUE);
00245 glPixelMapfv(GL_PIXEL_MAP_R_TO_R, 256, lut);
00246 glPixelMapfv(GL_PIXEL_MAP_G_TO_G, 256, lut);
00247 glPixelMapfv(GL_PIXEL_MAP_B_TO_B, 256, lut);
00248
00249 return GE_TRUE;
00250 }
|
|
||||||||||||
|
Definition at line 336 of file OGLDrv.c. References Error, DRV_Driver::LastError, LastError, DRV_Driver::LastErrorStr, LastErrorStr, and OGLDRV.
00337 {
00338 LastError = Error;
00339
00340 if(ErrorStr)
00341 {
00342 strcpy(LastErrorStr, ErrorStr);
00343 }
00344 else
00345 {
00346 LastErrorStr[0] = 0;
00347 }
00348
00349 OGLDRV.LastErrorStr = LastErrorStr;
00350 OGLDRV.LastError = LastError;
00351 }
|
|
|
|
|
|
|
|
|
Definition at line 35 of file OGLDrv.c. Referenced by GetGamma(), and SetGamma(). |
|
|
|
|
|
Definition at line 43 of file OGLDrv.c. Referenced by DrvInit(), and Render_WorldPolyMultitexture(). |
|
|
Definition at line 44 of file OGLDrv.c. Referenced by DrvInit(), and Render_WorldPolyMultitexture(). |
|
|
|
|
|
|
|
|
Definition at line 39 of file OGLDrv.c. Referenced by DrawDecal(), DrvInit(), THandle_Create(), and THandle_Update(). |
|
|
Definition at line 42 of file OGLDrv.c. Referenced by DrvInit(), and Render_WorldPoly(). |
|
|
Definition at line 48 of file OGLDrv.c. Referenced by BeginScene(), BeginWorld(), DriverHook(), Render_GouraudPoly(), Render_WorldPoly(), and SetLastDrvError(). |
|
|
Initial value: |
1.3.2