00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <windows.h>
00021 #include <gl/gl.h>
00022
00023 #include "DCommon.h"
00024 #include "OglMisc.h"
00025
00026
00027
00028
00029 void InitMatrices(int width, int height)
00030 {
00031 glMatrixMode(GL_PROJECTION);
00032 glLoadIdentity();
00033 glOrtho(0.0f, (GLfloat)width, 0.0f, (GLfloat)height, 0.0f, 1.0f);
00034 glMatrixMode(GL_MODELVIEW);
00035 glLoadIdentity();
00036 glViewport(0, 0, width, height);
00037
00038 glScalef(1.0f, -1.0f, 1.0f);
00039 glTranslatef(0, 0 - (GLfloat)height, 0.0);
00040 }
00041
00042
00043
00044
00045 geBoolean ExtensionExists(const char *extension)
00046 {
00047 const GLubyte *extensions = NULL;
00048 const GLubyte *begin;
00049 GLubyte *cursor, *end;
00050
00051 cursor = (GLubyte *) strchr(extension, ' ');
00052
00053 if(cursor || *extension == '\0')
00054 {
00055 return GE_FALSE;
00056 }
00057
00058 extensions = glGetString(GL_EXTENSIONS);
00059
00060 begin = extensions;
00061
00062 while(GE_TRUE)
00063 {
00064 cursor = (GLubyte *) strstr((const char *) begin, extension);
00065
00066 if(!cursor)
00067 {
00068 break;
00069 }
00070
00071 end = cursor + strlen(extension);
00072
00073 if(cursor == begin || *(cursor - 1) == ' ')
00074 {
00075 if (*end == ' ' || *end == '\0')
00076 {
00077 return GE_TRUE;
00078 }
00079 }
00080
00081 begin = end;
00082 }
00083
00084 return GE_FALSE;
00085 }
00086
00087
00088
00089
00090 void CkBlit24_32(GLubyte *dstPtr, GLint dstWidth, GLint dstHeight, GLubyte *srcPtr, GLint srcWidth,
00091 GLint srcHeight)
00092 {
00093 GLint width, height;
00094 GLubyte *nextLine;
00095
00096 memset(dstPtr, 0x00, dstWidth * dstHeight * 4);
00097
00098
00099 for(height = 0; height < srcHeight; height++)
00100 {
00101 nextLine = (dstPtr + (dstWidth * 4));
00102
00103 for(width = 0; width < srcWidth; width++)
00104 {
00105 if(!(*srcPtr == 0x00 && *(srcPtr + 1) == 0x00 && *(srcPtr + 2) == 0x01))
00106 {
00107 *dstPtr = *srcPtr;
00108 *(dstPtr + 1) = *(srcPtr + 1);
00109 *(dstPtr + 2) = *(srcPtr + 2);
00110 *(dstPtr + 3) = 0xFF;
00111 }
00112
00113 srcPtr += 3;
00114 dstPtr += 4;
00115 }
00116
00117 dstPtr = nextLine;
00118 }
00119 }
00120
00121
00122 void Blit32(GLubyte *dstPtr, GLint dstPitch, GLubyte *srcPtr, GLint srcWidth, GLint srcHeight,
00123 GLint srcPitch)
00124 {
00125 GLint count;
00126
00127 for(count = 0; count < srcHeight; count++)
00128 {
00129 memcpy(dstPtr, srcPtr, srcWidth * 4);
00130 srcPtr += srcPitch * 4;
00131 dstPtr += dstPitch * 4;
00132 }
00133 }