#include <metahook.h>
#include <gl/gl.h>
#include <triangleapi.h>
#include "plugins.h"
#include "qgl.h"

void QGL_Init(void)
{
	if (g_iVideoMode != VIDEOMODE_D3D)
	{
		HMODULE hOpenGL = GetModuleHandle("opengl32.dll");

		if (hOpenGL)
		{
			*(FARPROC *)&qglAccum = GetProcAddress(hOpenGL, "glAccum");
			*(FARPROC *)&qglAlphaFunc = GetProcAddress(hOpenGL, "glAlphaFunc");
			*(FARPROC *)&qglAreTexturesResident = GetProcAddress(hOpenGL, "glAreTexturesResident");
			*(FARPROC *)&qglArrayElement = GetProcAddress(hOpenGL, "glArrayElement");
			*(FARPROC *)&qglBegin = GetProcAddress(hOpenGL, "glBegin");
			*(FARPROC *)&qglBindTexture = GetProcAddress(hOpenGL, "glBindTexture");
			*(FARPROC *)&qglBitmap = GetProcAddress(hOpenGL, "glBitmap");
			*(FARPROC *)&qglBlendFunc = GetProcAddress(hOpenGL, "glBlendFunc");
			*(FARPROC *)&qglCallList = GetProcAddress(hOpenGL, "glCallList");
			*(FARPROC *)&qglCallLists = GetProcAddress(hOpenGL, "glCallLists");
			*(FARPROC *)&qglClear = GetProcAddress(hOpenGL, "glClear");
			*(FARPROC *)&qglClearAccum = GetProcAddress(hOpenGL, "glClearAccum");
			*(FARPROC *)&qglClearColor = GetProcAddress(hOpenGL, "glClearColor");
			*(FARPROC *)&qglClearDepth = GetProcAddress(hOpenGL, "glClearDepth");
			*(FARPROC *)&qglClearIndex = GetProcAddress(hOpenGL, "glClearIndex");
			*(FARPROC *)&qglClearStencil = GetProcAddress(hOpenGL, "glClearStencil");
			*(FARPROC *)&qglClipPlane = GetProcAddress(hOpenGL, "glClipPlane");
			*(FARPROC *)&qglColor3b = GetProcAddress(hOpenGL, "glColor3b");
			*(FARPROC *)&qglColor3bv = GetProcAddress(hOpenGL, "glColor3bv");
			*(FARPROC *)&qglColor3d = GetProcAddress(hOpenGL, "glColor3d");
			*(FARPROC *)&qglColor3dv = GetProcAddress(hOpenGL, "glColor3dv");
			*(FARPROC *)&qglColor3f = GetProcAddress(hOpenGL, "glColor3f");
			*(FARPROC *)&qglColor3fv = GetProcAddress(hOpenGL, "glColor3fv");
			*(FARPROC *)&qglColor3i = GetProcAddress(hOpenGL, "glColor3i");
			*(FARPROC *)&qglColor3iv = GetProcAddress(hOpenGL, "glColor3iv");
			*(FARPROC *)&qglColor3s = GetProcAddress(hOpenGL, "glColor3s");
			*(FARPROC *)&qglColor3sv = GetProcAddress(hOpenGL, "glColor3sv");
			*(FARPROC *)&qglColor3ub = GetProcAddress(hOpenGL, "glColor3ub");
			*(FARPROC *)&qglColor3ubv = GetProcAddress(hOpenGL, "glColor3ubv");
			*(FARPROC *)&qglColor3ui = GetProcAddress(hOpenGL, "glColor3ui");
			*(FARPROC *)&qglColor3uiv = GetProcAddress(hOpenGL, "glColor3uiv");
			*(FARPROC *)&qglColor3us = GetProcAddress(hOpenGL, "glColor3us");
			*(FARPROC *)&qglColor3usv = GetProcAddress(hOpenGL, "glColor3usv");
			*(FARPROC *)&qglColor4b = GetProcAddress(hOpenGL, "glColor4b");
			*(FARPROC *)&qglColor4bv = GetProcAddress(hOpenGL, "glColor4bv");
			*(FARPROC *)&qglColor4d = GetProcAddress(hOpenGL, "glColor4d");
			*(FARPROC *)&qglColor4dv = GetProcAddress(hOpenGL, "glColor4dv");
			*(FARPROC *)&qglColor4f = GetProcAddress(hOpenGL, "glColor4f");
			*(FARPROC *)&qglColor4fv = GetProcAddress(hOpenGL, "glColor4fv");
			*(FARPROC *)&qglColor4i = GetProcAddress(hOpenGL, "glColor4i");
			*(FARPROC *)&qglColor4iv = GetProcAddress(hOpenGL, "glColor4iv");
			*(FARPROC *)&qglColor4s = GetProcAddress(hOpenGL, "glColor4s");
			*(FARPROC *)&qglColor4sv = GetProcAddress(hOpenGL, "glColor4sv");
			*(FARPROC *)&qglColor4ub = GetProcAddress(hOpenGL, "glColor4ub");
			*(FARPROC *)&qglColor4ubv = GetProcAddress(hOpenGL, "glColor4ubv");
			*(FARPROC *)&qglColor4ui = GetProcAddress(hOpenGL, "glColor4ui");
			*(FARPROC *)&qglColor4uiv = GetProcAddress(hOpenGL, "glColor4uiv");
			*(FARPROC *)&qglColor4us = GetProcAddress(hOpenGL, "glColor4us");
			*(FARPROC *)&qglColor4usv = GetProcAddress(hOpenGL, "glColor4usv");
			*(FARPROC *)&qglColorMask = GetProcAddress(hOpenGL, "glColorMask");
			*(FARPROC *)&qglColorMaterial = GetProcAddress(hOpenGL, "glColorMaterial");
			*(FARPROC *)&qglColorPointer = GetProcAddress(hOpenGL, "glColorPointer");
			*(FARPROC *)&qglCopyPixels = GetProcAddress(hOpenGL, "glCopyPixels");
			*(FARPROC *)&qglCopyTexImage1D = GetProcAddress(hOpenGL, "glCopyTexImage1D");
			*(FARPROC *)&qglCopyTexImage2D = GetProcAddress(hOpenGL, "glCopyTexImage2D");
			*(FARPROC *)&qglCopyTexSubImage1D = GetProcAddress(hOpenGL, "glCopyTexSubImage1D");
			*(FARPROC *)&qglCopyTexSubImage2D = GetProcAddress(hOpenGL, "glCopyTexSubImage2D");
			*(FARPROC *)&qglCullFace = GetProcAddress(hOpenGL, "glCullFace");
			*(FARPROC *)&qglDeleteLists = GetProcAddress(hOpenGL, "glDeleteLists");
			*(FARPROC *)&qglDeleteTextures = GetProcAddress(hOpenGL, "glDeleteTextures");
			*(FARPROC *)&qglDepthFunc = GetProcAddress(hOpenGL, "glDepthFunc");
			*(FARPROC *)&qglDepthMask = GetProcAddress(hOpenGL, "glDepthMask");
			*(FARPROC *)&qglDepthRange = GetProcAddress(hOpenGL, "glDepthRange");
			*(FARPROC *)&qglDisable = GetProcAddress(hOpenGL, "glDisable");
			*(FARPROC *)&qglDisableClientState = GetProcAddress(hOpenGL, "glDisableClientState");
			*(FARPROC *)&qglDrawArrays = GetProcAddress(hOpenGL, "glDrawArrays");
			*(FARPROC *)&qglDrawBuffer = GetProcAddress(hOpenGL, "glDrawBuffer");
			*(FARPROC *)&qglDrawElements = GetProcAddress(hOpenGL, "glDrawElements");
			*(FARPROC *)&qglDrawPixels = GetProcAddress(hOpenGL, "glDrawPixels");
			*(FARPROC *)&qglEdgeFlag = GetProcAddress(hOpenGL, "glEdgeFlag");
			*(FARPROC *)&qglEdgeFlagPointer = GetProcAddress(hOpenGL, "glEdgeFlagPointer");
			*(FARPROC *)&qglEdgeFlagv = GetProcAddress(hOpenGL, "glEdgeFlagv");
			*(FARPROC *)&qglEnable = GetProcAddress(hOpenGL, "glEnable");
			*(FARPROC *)&qglEnableClientState = GetProcAddress(hOpenGL, "glEnableClientState");
			*(FARPROC *)&qglEnd = GetProcAddress(hOpenGL, "glEnd");
			*(FARPROC *)&qglEndList = GetProcAddress(hOpenGL, "glEndList");
			*(FARPROC *)&qglEvalCoord1d = GetProcAddress(hOpenGL, "glEvalCoord1d");
			*(FARPROC *)&qglEvalCoord1dv = GetProcAddress(hOpenGL, "glEvalCoord1dv");
			*(FARPROC *)&qglEvalCoord1f = GetProcAddress(hOpenGL, "glEvalCoord1f");
			*(FARPROC *)&qglEvalCoord1fv = GetProcAddress(hOpenGL, "glEvalCoord1fv");
			*(FARPROC *)&qglEvalCoord2d = GetProcAddress(hOpenGL, "glEvalCoord2d");
			*(FARPROC *)&qglEvalCoord2dv = GetProcAddress(hOpenGL, "glEvalCoord2dv");
			*(FARPROC *)&qglEvalCoord2f = GetProcAddress(hOpenGL, "glEvalCoord2f");
			*(FARPROC *)&qglEvalCoord2fv = GetProcAddress(hOpenGL, "glEvalCoord2fv");
			*(FARPROC *)&qglEvalMesh1 = GetProcAddress(hOpenGL, "glEvalMesh1");
			*(FARPROC *)&qglEvalMesh2 = GetProcAddress(hOpenGL, "glEvalMesh2");
			*(FARPROC *)&qglEvalPoint1 = GetProcAddress(hOpenGL, "glEvalPoint1");
			*(FARPROC *)&qglEvalPoint2 = GetProcAddress(hOpenGL, "glEvalPoint2");
			*(FARPROC *)&qglFeedbackBuffer = GetProcAddress(hOpenGL, "glFeedbackBuffer");
			*(FARPROC *)&qglFinish = GetProcAddress(hOpenGL, "glFinish");
			*(FARPROC *)&qglFlush = GetProcAddress(hOpenGL, "glFlush");
			*(FARPROC *)&qglFogf = GetProcAddress(hOpenGL, "glFogf");
			*(FARPROC *)&qglFogfv = GetProcAddress(hOpenGL, "glFogfv");
			*(FARPROC *)&qglFogi = GetProcAddress(hOpenGL, "glFogi");
			*(FARPROC *)&qglFogiv = GetProcAddress(hOpenGL, "glFogiv");
			*(FARPROC *)&qglFrontFace = GetProcAddress(hOpenGL, "glFrontFace");
			*(FARPROC *)&qglFrustum = GetProcAddress(hOpenGL, "glFrustum");
			*(FARPROC *)&qglGenLists = GetProcAddress(hOpenGL, "glGenLists");
			*(FARPROC *)&qglGenTextures = GetProcAddress(hOpenGL, "glGenTextures");
			*(FARPROC *)&qglGetBooleanv = GetProcAddress(hOpenGL, "glGetBooleanv");
			*(FARPROC *)&qglGetClipPlane = GetProcAddress(hOpenGL, "glGetClipPlane");
			*(FARPROC *)&qglGetDoublev = GetProcAddress(hOpenGL, "glGetDoublev");
			*(FARPROC *)&qglGetError = GetProcAddress(hOpenGL, "glGetError");
			*(FARPROC *)&qglGetFloatv = GetProcAddress(hOpenGL, "glGetFloatv");
			*(FARPROC *)&qglGetIntegerv = GetProcAddress(hOpenGL, "glGetIntegerv");
			*(FARPROC *)&qglGetLightfv = GetProcAddress(hOpenGL, "glGetLightfv");
			*(FARPROC *)&qglGetLightiv = GetProcAddress(hOpenGL, "glGetLightiv");
			*(FARPROC *)&qglGetMapdv = GetProcAddress(hOpenGL, "glGetMapdv");
			*(FARPROC *)&qglGetMapfv = GetProcAddress(hOpenGL, "glGetMapfv");
			*(FARPROC *)&qglGetMapiv = GetProcAddress(hOpenGL, "glGetMapiv");
			*(FARPROC *)&qglGetMaterialfv = GetProcAddress(hOpenGL, "glGetMaterialfv");
			*(FARPROC *)&qglGetMaterialiv = GetProcAddress(hOpenGL, "glGetMaterialiv");
			*(FARPROC *)&qglGetPixelMapfv = GetProcAddress(hOpenGL, "glGetPixelMapfv");
			*(FARPROC *)&qglGetPixelMapuiv = GetProcAddress(hOpenGL, "glGetPixelMapuiv");
			*(FARPROC *)&qglGetPixelMapusv = GetProcAddress(hOpenGL, "glGetPixelMapusv");
			*(FARPROC *)&qglGetPointerv = GetProcAddress(hOpenGL, "glGetPointerv");
			*(FARPROC *)&qglGetPolygonStipple = GetProcAddress(hOpenGL, "glGetPolygonStipple");
			*(FARPROC *)&qglGetString = GetProcAddress(hOpenGL, "glGetString");
			*(FARPROC *)&qglGetTexEnvfv = GetProcAddress(hOpenGL, "glGetTexEnvfv");
			*(FARPROC *)&qglGetTexEnviv = GetProcAddress(hOpenGL, "glGetTexEnviv");
			*(FARPROC *)&qglGetTexGendv = GetProcAddress(hOpenGL, "glGetTexGendv");
			*(FARPROC *)&qglGetTexGenfv = GetProcAddress(hOpenGL, "glGetTexGenfv");
			*(FARPROC *)&qglGetTexGeniv = GetProcAddress(hOpenGL, "glGetTexGeniv");
			*(FARPROC *)&qglGetTexImage = GetProcAddress(hOpenGL, "glGetTexImage");
			*(FARPROC *)&qglGetTexLevelParameterfv = GetProcAddress(hOpenGL, "glGetLevelParameterfv");
			*(FARPROC *)&qglGetTexLevelParameteriv = GetProcAddress(hOpenGL, "glGetLevelParameteriv");
			*(FARPROC *)&qglGetTexParameterfv = GetProcAddress(hOpenGL, "glGetTexParameterfv");
			*(FARPROC *)&qglGetTexParameteriv = GetProcAddress(hOpenGL, "glGetTexParameteriv");
			*(FARPROC *)&qglHint = GetProcAddress(hOpenGL, "glHint");
			*(FARPROC *)&qglIndexMask = GetProcAddress(hOpenGL, "glIndexMask");
			*(FARPROC *)&qglIndexPointer = GetProcAddress(hOpenGL, "glIndexPointer");
			*(FARPROC *)&qglIndexd = GetProcAddress(hOpenGL, "glIndexd");
			*(FARPROC *)&qglIndexdv = GetProcAddress(hOpenGL, "glIndexdv");
			*(FARPROC *)&qglIndexf = GetProcAddress(hOpenGL, "glIndexf");
			*(FARPROC *)&qglIndexfv = GetProcAddress(hOpenGL, "glIndexfv");
			*(FARPROC *)&qglIndexi = GetProcAddress(hOpenGL, "glIndexi");
			*(FARPROC *)&qglIndexiv = GetProcAddress(hOpenGL, "glIndexiv");
			*(FARPROC *)&qglIndexs = GetProcAddress(hOpenGL, "glIndexs");
			*(FARPROC *)&qglIndexsv = GetProcAddress(hOpenGL, "glIndexsv");
			*(FARPROC *)&qglIndexub = GetProcAddress(hOpenGL, "glIndexub");
			*(FARPROC *)&qglIndexubv = GetProcAddress(hOpenGL, "glIndexubv");
			*(FARPROC *)&qglInitNames = GetProcAddress(hOpenGL, "glInitNames");
			*(FARPROC *)&qglInterleavedArrays = GetProcAddress(hOpenGL, "glInterleavedArrays");
			*(FARPROC *)&qglIsEnabled = GetProcAddress(hOpenGL, "glIsEnabled");
			*(FARPROC *)&qglIsList = GetProcAddress(hOpenGL, "glIsList");
			*(FARPROC *)&qglIsTexture = GetProcAddress(hOpenGL, "glIsTexture");
			*(FARPROC *)&qglLightModelf = GetProcAddress(hOpenGL, "glLightModelf");
			*(FARPROC *)&qglLightModelfv = GetProcAddress(hOpenGL, "glLightModelfv");
			*(FARPROC *)&qglLightModeli = GetProcAddress(hOpenGL, "glLightModeli");
			*(FARPROC *)&qglLightModeliv = GetProcAddress(hOpenGL, "glLightModeliv");
			*(FARPROC *)&qglLightf = GetProcAddress(hOpenGL, "glLightf");
			*(FARPROC *)&qglLightfv = GetProcAddress(hOpenGL, "glLightfv");
			*(FARPROC *)&qglLighti = GetProcAddress(hOpenGL, "glLighti");
			*(FARPROC *)&qglLightiv = GetProcAddress(hOpenGL, "glLightiv");
			*(FARPROC *)&qglLineStipple = GetProcAddress(hOpenGL, "glLineStipple");
			*(FARPROC *)&qglLineWidth = GetProcAddress(hOpenGL, "glLineWidth");
			*(FARPROC *)&qglListBase = GetProcAddress(hOpenGL, "glListBase");
			*(FARPROC *)&qglLoadIdentity = GetProcAddress(hOpenGL, "glLoadIdentity");
			*(FARPROC *)&qglLoadMatrixd = GetProcAddress(hOpenGL, "glLoadMatrixd");
			*(FARPROC *)&qglLoadMatrixf = GetProcAddress(hOpenGL, "glLoadMatrixf");
			*(FARPROC *)&qglLoadName = GetProcAddress(hOpenGL, "glLoadName");
			*(FARPROC *)&qglLogicOp = GetProcAddress(hOpenGL, "glLogicOp");
			*(FARPROC *)&qglMap1d = GetProcAddress(hOpenGL, "glMap1d");
			*(FARPROC *)&qglMap1f = GetProcAddress(hOpenGL, "glMap1f");
			*(FARPROC *)&qglMap2d = GetProcAddress(hOpenGL, "glMap2d");
			*(FARPROC *)&qglMap2f = GetProcAddress(hOpenGL, "glMap2f");
			*(FARPROC *)&qglMapGrid1d = GetProcAddress(hOpenGL, "glMapGrid1d");
			*(FARPROC *)&qglMapGrid1f = GetProcAddress(hOpenGL, "glMapGrid1f");
			*(FARPROC *)&qglMapGrid2d = GetProcAddress(hOpenGL, "glMapGrid2d");
			*(FARPROC *)&qglMapGrid2f = GetProcAddress(hOpenGL, "glMapGrid2f");
			*(FARPROC *)&qglMaterialf = GetProcAddress(hOpenGL, "glMaterialf");
			*(FARPROC *)&qglMaterialfv = GetProcAddress(hOpenGL, "glMaterialfv");
			*(FARPROC *)&qglMateriali = GetProcAddress(hOpenGL, "glMateriali");
			*(FARPROC *)&qglMaterialiv = GetProcAddress(hOpenGL, "glMaterialiv");
			*(FARPROC *)&qglMatrixMode = GetProcAddress(hOpenGL, "glMatrixMode");
			*(FARPROC *)&qglMultMatrixd = GetProcAddress(hOpenGL, "glMultMatrixd");
			*(FARPROC *)&qglMultMatrixf = GetProcAddress(hOpenGL, "glMultMatrixf");
			*(FARPROC *)&qglNewList = GetProcAddress(hOpenGL, "glNewList");
			*(FARPROC *)&qglNormal3b = GetProcAddress(hOpenGL, "glNormal3b");
			*(FARPROC *)&qglNormal3bv = GetProcAddress(hOpenGL, "glNormal3bv");
			*(FARPROC *)&qglNormal3d = GetProcAddress(hOpenGL, "glNormal3d");
			*(FARPROC *)&qglNormal3dv = GetProcAddress(hOpenGL, "glNormal3dv");
			*(FARPROC *)&qglNormal3f = GetProcAddress(hOpenGL, "glNormal3f");
			*(FARPROC *)&qglNormal3fv = GetProcAddress(hOpenGL, "glNormal3fv");
			*(FARPROC *)&qglNormal3i = GetProcAddress(hOpenGL, "glNormal3i");
			*(FARPROC *)&qglNormal3iv = GetProcAddress(hOpenGL, "glNormal3iv");
			*(FARPROC *)&qglNormal3s = GetProcAddress(hOpenGL, "glNormal3s");
			*(FARPROC *)&qglNormal3sv = GetProcAddress(hOpenGL, "glNormal3sv");
			*(FARPROC *)&qglNormalPointer = GetProcAddress(hOpenGL, "glNormalPointer");
			*(FARPROC *)&qglOrtho = GetProcAddress(hOpenGL, "glOrtho");
			*(FARPROC *)&qglPassThrough = GetProcAddress(hOpenGL, "glPassThrough");
			*(FARPROC *)&qglPixelMapfv = GetProcAddress(hOpenGL, "glPixelMapfv");
			*(FARPROC *)&qglPixelMapuiv = GetProcAddress(hOpenGL, "glPixelMapuiv");
			*(FARPROC *)&qglPixelMapusv = GetProcAddress(hOpenGL, "glPixelMapusv");
			*(FARPROC *)&qglPixelStoref = GetProcAddress(hOpenGL, "glPixelStoref");
			*(FARPROC *)&qglPixelStorei = GetProcAddress(hOpenGL, "glPixelStorei");
			*(FARPROC *)&qglPixelTransferf = GetProcAddress(hOpenGL, "glPixelTransferf");
			*(FARPROC *)&qglPixelTransferi = GetProcAddress(hOpenGL, "glPixelTransferi");
			*(FARPROC *)&qglPixelZoom = GetProcAddress(hOpenGL, "glPixelZoom");
			*(FARPROC *)&qglPointSize = GetProcAddress(hOpenGL, "glPointSize");
			*(FARPROC *)&qglPolygonMode = GetProcAddress(hOpenGL, "glPolygonMode");
			*(FARPROC *)&qglPolygonOffset = GetProcAddress(hOpenGL, "glPolygonOffset");
			*(FARPROC *)&qglPolygonStipple = GetProcAddress(hOpenGL, "glPolygonStipple");
			*(FARPROC *)&qglPopAttrib = GetProcAddress(hOpenGL, "glPopAttrib");
			*(FARPROC *)&qglPopClientAttrib = GetProcAddress(hOpenGL, "glPopClientAttrib");
			*(FARPROC *)&qglPopMatrix = GetProcAddress(hOpenGL, "glPopMatrix");
			*(FARPROC *)&qglPopName = GetProcAddress(hOpenGL, "glPopName");
			*(FARPROC *)&qglPrioritizeTextures = GetProcAddress(hOpenGL, "glPrioritizeTextures");
			*(FARPROC *)&qglPushAttrib = GetProcAddress(hOpenGL, "glPushAttrib");
			*(FARPROC *)&qglPushClientAttrib = GetProcAddress(hOpenGL, "glPushClientAttrib");
			*(FARPROC *)&qglPushMatrix = GetProcAddress(hOpenGL, "glPushMatrix");
			*(FARPROC *)&qglPushName = GetProcAddress(hOpenGL, "glPushName");
			*(FARPROC *)&qglRasterPos2d = GetProcAddress(hOpenGL, "glRasterPos2d");
			*(FARPROC *)&qglRasterPos2dv = GetProcAddress(hOpenGL, "glRasterPos2dv");
			*(FARPROC *)&qglRasterPos2f = GetProcAddress(hOpenGL, "glRasterPos2f");
			*(FARPROC *)&qglRasterPos2fv = GetProcAddress(hOpenGL, "glRasterPos2fv");
			*(FARPROC *)&qglRasterPos2i = GetProcAddress(hOpenGL, "glRasterPos2i");
			*(FARPROC *)&qglRasterPos2iv = GetProcAddress(hOpenGL, "glRasterPos2iv");
			*(FARPROC *)&qglRasterPos2s = GetProcAddress(hOpenGL, "glRasterPos2s");
			*(FARPROC *)&qglRasterPos2sv = GetProcAddress(hOpenGL, "glRasterPos2sv");
			*(FARPROC *)&qglRasterPos3d = GetProcAddress(hOpenGL, "glRasterPos3d");
			*(FARPROC *)&qglRasterPos3dv = GetProcAddress(hOpenGL, "glRasterPos3dv");
			*(FARPROC *)&qglRasterPos3f = GetProcAddress(hOpenGL, "glRasterPos3f");
			*(FARPROC *)&qglRasterPos3fv = GetProcAddress(hOpenGL, "glRasterPos3fv");
			*(FARPROC *)&qglRasterPos3i = GetProcAddress(hOpenGL, "glRasterPos3i");
			*(FARPROC *)&qglRasterPos3iv = GetProcAddress(hOpenGL, "glRasterPos3iv");
			*(FARPROC *)&qglRasterPos3s = GetProcAddress(hOpenGL, "glRasterPos3s");
			*(FARPROC *)&qglRasterPos3sv = GetProcAddress(hOpenGL, "glRasterPos3sv");
			*(FARPROC *)&qglRasterPos4d = GetProcAddress(hOpenGL, "glRasterPos4d");
			*(FARPROC *)&qglRasterPos4dv = GetProcAddress(hOpenGL, "glRasterPos4dv");
			*(FARPROC *)&qglRasterPos4f = GetProcAddress(hOpenGL, "glRasterPos4f");
			*(FARPROC *)&qglRasterPos4fv = GetProcAddress(hOpenGL, "glRasterPos4fv");
			*(FARPROC *)&qglRasterPos4i = GetProcAddress(hOpenGL, "glRasterPos4i");
			*(FARPROC *)&qglRasterPos4iv = GetProcAddress(hOpenGL, "glRasterPos4iv");
			*(FARPROC *)&qglRasterPos4s = GetProcAddress(hOpenGL, "glRasterPos4s");
			*(FARPROC *)&qglRasterPos4sv = GetProcAddress(hOpenGL, "glRasterPos4sv");
			*(FARPROC *)&qglReadBuffer = GetProcAddress(hOpenGL, "glReadBuffer");
			*(FARPROC *)&qglReadPixels = GetProcAddress(hOpenGL, "glReadPixels");
			*(FARPROC *)&qglRectd = GetProcAddress(hOpenGL, "glRectd");
			*(FARPROC *)&qglRectdv = GetProcAddress(hOpenGL, "glRectdv");
			*(FARPROC *)&qglRectf = GetProcAddress(hOpenGL, "glRectf");
			*(FARPROC *)&qglRectfv = GetProcAddress(hOpenGL, "glRectfv");
			*(FARPROC *)&qglRecti = GetProcAddress(hOpenGL, "glRecti");
			*(FARPROC *)&qglRectiv = GetProcAddress(hOpenGL, "glRectiv");
			*(FARPROC *)&qglRects = GetProcAddress(hOpenGL, "glRects");
			*(FARPROC *)&qglRectsv = GetProcAddress(hOpenGL, "glRectsv");
			*(FARPROC *)&qglRenderMode = GetProcAddress(hOpenGL, "glRenderMode");
			*(FARPROC *)&qglRotated = GetProcAddress(hOpenGL, "glRotated");
			*(FARPROC *)&qglRotatef = GetProcAddress(hOpenGL, "glRotatef");
			*(FARPROC *)&qglScaled = GetProcAddress(hOpenGL, "glScaled");
			*(FARPROC *)&qglScalef = GetProcAddress(hOpenGL, "glScalef");
			*(FARPROC *)&qglScissor = GetProcAddress(hOpenGL, "glScissor");
			*(FARPROC *)&qglSelectBuffer = GetProcAddress(hOpenGL, "glSelectBuffer");
			*(FARPROC *)&qglShadeModel = GetProcAddress(hOpenGL, "glShadeModel");
			*(FARPROC *)&qglStencilFunc = GetProcAddress(hOpenGL, "glStencilFunc");
			*(FARPROC *)&qglStencilMask = GetProcAddress(hOpenGL, "glStencilMask");
			*(FARPROC *)&qglStencilOp = GetProcAddress(hOpenGL, "glStencilOp");
			*(FARPROC *)&qglTexCoord1d = GetProcAddress(hOpenGL, "glTexCoord1d");
			*(FARPROC *)&qglTexCoord1dv = GetProcAddress(hOpenGL, "glTexCoord1dv");
			*(FARPROC *)&qglTexCoord1f = GetProcAddress(hOpenGL, "glTexCoord1f");
			*(FARPROC *)&qglTexCoord1fv = GetProcAddress(hOpenGL, "glTexCoord1fv");
			*(FARPROC *)&qglTexCoord1i = GetProcAddress(hOpenGL, "glTexCoord1i");
			*(FARPROC *)&qglTexCoord1iv = GetProcAddress(hOpenGL, "glTexCoord1iv");
			*(FARPROC *)&qglTexCoord1s = GetProcAddress(hOpenGL, "glTexCoord1s");
			*(FARPROC *)&qglTexCoord1sv = GetProcAddress(hOpenGL, "glTexCoord1sv");
			*(FARPROC *)&qglTexCoord2d = GetProcAddress(hOpenGL, "glTexCoord2d");
			*(FARPROC *)&qglTexCoord2dv = GetProcAddress(hOpenGL, "glTexCoord2dv");
			*(FARPROC *)&qglTexCoord2f = GetProcAddress(hOpenGL, "glTexCoord2f");
			*(FARPROC *)&qglTexCoord2fv = GetProcAddress(hOpenGL, "glTexCoord2fv");
			*(FARPROC *)&qglTexCoord2i = GetProcAddress(hOpenGL, "glTexCoord2i");
			*(FARPROC *)&qglTexCoord2iv = GetProcAddress(hOpenGL, "glTexCoord2iv");
			*(FARPROC *)&qglTexCoord2s = GetProcAddress(hOpenGL, "glTexCoord2s");
			*(FARPROC *)&qglTexCoord2sv = GetProcAddress(hOpenGL, "glTexCoord2sv");
			*(FARPROC *)&qglTexCoord3d = GetProcAddress(hOpenGL, "glTexCoord3d");
			*(FARPROC *)&qglTexCoord3dv = GetProcAddress(hOpenGL, "glTexCoord3dv");
			*(FARPROC *)&qglTexCoord3f = GetProcAddress(hOpenGL, "glTexCoord3f");
			*(FARPROC *)&qglTexCoord3fv = GetProcAddress(hOpenGL, "glTexCoord3fv");
			*(FARPROC *)&qglTexCoord3i = GetProcAddress(hOpenGL, "glTexCoord3i");
			*(FARPROC *)&qglTexCoord3iv = GetProcAddress(hOpenGL, "glTexCoord3iv");
			*(FARPROC *)&qglTexCoord3s = GetProcAddress(hOpenGL, "glTexCoord3s");
			*(FARPROC *)&qglTexCoord3sv = GetProcAddress(hOpenGL, "glTexCoord3sv");
			*(FARPROC *)&qglTexCoord4d = GetProcAddress(hOpenGL, "glTexCoord4d");
			*(FARPROC *)&qglTexCoord4dv = GetProcAddress(hOpenGL, "glTexCoord4dv");
			*(FARPROC *)&qglTexCoord4f = GetProcAddress(hOpenGL, "glTexCoord4f");
			*(FARPROC *)&qglTexCoord4fv = GetProcAddress(hOpenGL, "glTexCoord4fv");
			*(FARPROC *)&qglTexCoord4i = GetProcAddress(hOpenGL, "glTexCoord4i");
			*(FARPROC *)&qglTexCoord4iv = GetProcAddress(hOpenGL, "glTexCoord4iv");
			*(FARPROC *)&qglTexCoord4s = GetProcAddress(hOpenGL, "glTexCoord4s");
			*(FARPROC *)&qglTexCoord4sv = GetProcAddress(hOpenGL, "glTexCoord4sv");
			*(FARPROC *)&qglTexCoordPointer = GetProcAddress(hOpenGL, "glTexCoordPointer");
			*(FARPROC *)&qglTexEnvf = GetProcAddress(hOpenGL, "glTexEnvf");
			*(FARPROC *)&qglTexEnvfv = GetProcAddress(hOpenGL, "glTexEnvfv");
			*(FARPROC *)&qglTexEnvi = GetProcAddress(hOpenGL, "glTexEnvi");
			*(FARPROC *)&qglTexEnviv = GetProcAddress(hOpenGL, "glTexEnviv");
			*(FARPROC *)&qglTexGend = GetProcAddress(hOpenGL, "glTexGend");
			*(FARPROC *)&qglTexGendv = GetProcAddress(hOpenGL, "glTexGendv");
			*(FARPROC *)&qglTexGenf = GetProcAddress(hOpenGL, "glTexGenf");
			*(FARPROC *)&qglTexGenfv = GetProcAddress(hOpenGL, "glTexGenfv");
			*(FARPROC *)&qglTexGeni = GetProcAddress(hOpenGL, "glTexGeni");
			*(FARPROC *)&qglTexGeniv = GetProcAddress(hOpenGL, "glTexGeniv");
			*(FARPROC *)&qglTexImage1D = GetProcAddress(hOpenGL, "glTexImage1D");
			*(FARPROC *)&qglTexImage2D = GetProcAddress(hOpenGL, "glTexImage2D");
			*(FARPROC *)&qglTexParameterf = GetProcAddress(hOpenGL, "glTexParameterf");
			*(FARPROC *)&qglTexParameterfv = GetProcAddress(hOpenGL, "glTexParameterfv");
			*(FARPROC *)&qglTexParameteri = GetProcAddress(hOpenGL, "glTexParameteri");
			*(FARPROC *)&qglTexParameteriv = GetProcAddress(hOpenGL, "glTexParameteriv");
			*(FARPROC *)&qglTexSubImage1D = GetProcAddress(hOpenGL, "glTexSubImage1D");
			*(FARPROC *)&qglTexSubImage2D = GetProcAddress(hOpenGL, "glTexSubImage2D");
			*(FARPROC *)&qglTranslated = GetProcAddress(hOpenGL, "glTranslated");
			*(FARPROC *)&qglTranslatef = GetProcAddress(hOpenGL, "glTranslatef");
			*(FARPROC *)&qglVertex2d = GetProcAddress(hOpenGL, "glVertex2d");
			*(FARPROC *)&qglVertex2dv = GetProcAddress(hOpenGL, "glVertex2dv");
			*(FARPROC *)&qglVertex2f = GetProcAddress(hOpenGL, "glVertex2f");
			*(FARPROC *)&qglVertex2fv = GetProcAddress(hOpenGL, "glVertex2fv");
			*(FARPROC *)&qglVertex2i = GetProcAddress(hOpenGL, "glVertex2i");
			*(FARPROC *)&qglVertex2iv = GetProcAddress(hOpenGL, "glVertex2iv");
			*(FARPROC *)&qglVertex2s = GetProcAddress(hOpenGL, "glVertex2s");
			*(FARPROC *)&qglVertex2sv = GetProcAddress(hOpenGL, "glVertex2sv");
			*(FARPROC *)&qglVertex3d = GetProcAddress(hOpenGL, "glVertex3d");
			*(FARPROC *)&qglVertex3dv = GetProcAddress(hOpenGL, "glVertex3dv");
			*(FARPROC *)&qglVertex3f = GetProcAddress(hOpenGL, "glVertex3f");
			*(FARPROC *)&qglVertex3fv = GetProcAddress(hOpenGL, "glVertex3fv");
			*(FARPROC *)&qglVertex3i = GetProcAddress(hOpenGL, "glVertex3i");
			*(FARPROC *)&qglVertex3iv = GetProcAddress(hOpenGL, "glVertex3iv");
			*(FARPROC *)&qglVertex3s = GetProcAddress(hOpenGL, "glVertex3s");
			*(FARPROC *)&qglVertex3sv = GetProcAddress(hOpenGL, "glVertex3sv");
			*(FARPROC *)&qglVertex4d = GetProcAddress(hOpenGL, "glVertex4d");
			*(FARPROC *)&qglVertex4dv = GetProcAddress(hOpenGL, "glVertex4dv");
			*(FARPROC *)&qglVertex4f = GetProcAddress(hOpenGL, "glVertex4f");
			*(FARPROC *)&qglVertex4fv = GetProcAddress(hOpenGL, "glVertex4fv");
			*(FARPROC *)&qglVertex4i = GetProcAddress(hOpenGL, "glVertex4i");
			*(FARPROC *)&qglVertex4iv = GetProcAddress(hOpenGL, "glVertex4iv");
			*(FARPROC *)&qglVertex4s = GetProcAddress(hOpenGL, "glVertex4s");
			*(FARPROC *)&qglVertex4sv = GetProcAddress(hOpenGL, "glVertex4sv");
			*(FARPROC *)&qglVertexPointer = GetProcAddress(hOpenGL, "glVertexPointer");
			*(FARPROC *)&qglViewport = GetProcAddress(hOpenGL, "glViewport");
		}
	}
	else
	{
		DWORD base = *(DWORD *)((DWORD)gEngfuncs.pTriAPI->RenderMode + 0x47);

		qglAccum = (void (APIENTRY *)(GLenum, GLfloat))(*(DWORD *)(base - 0xB4));
		qglAlphaFunc = (void (APIENTRY *)(GLenum, GLclampf))(*(DWORD *)(base - 0x374));
		qglAreTexturesResident = (GLboolean (APIENTRY *)(GLsizei, const GLuint *, GLboolean *))(*(DWORD *)(base - 0x3A8));
		qglBlendFunc = (void (APIENTRY *)(GLenum, GLenum))(*(DWORD *)base);
		qglTexImage2D = (void (APIENTRY *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))(*(DWORD *)(base - 0x24C));
		qglGenTextures = (void (APIENTRY *)(GLsizei, GLuint *))(*(DWORD *)(base - 0x6C));
		qglBindTexture = (void (APIENTRY *)(GLenum, GLuint))(*(DWORD *)(base - 0x224));
		qglTexParameteri = (void (APIENTRY *) (GLenum, GLenum, GLint))(*(DWORD *)(base - 0x524));
		qglTexImage2D = (void (APIENTRY *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))(*(DWORD *)(base + 0x1EC));
		qglIsTexture = (GLboolean (APIENTRY *)(GLuint))(*(DWORD *)(base + 0x250));
		qglGetIntegerv = (void (APIENTRY *)(GLenum, GLint *))(*(DWORD *)(base + 0x3C0));
		qglDrawElements = (void (APIENTRY *)(GLenum, GLsizei, GLenum, const GLvoid *))(*(DWORD *)(base - 0x4C0));
		qglDrawArrays = (void (APIENTRY *)(GLenum, GLint, GLsizei))(*(DWORD *)(base + 0X270));
		qglEnable = (void (APIENTRY *) (GLenum))(*(DWORD *)(base - 0x4BC));
		qglDisable = (void (APIENTRY *) (GLenum))(*(DWORD *)(base + 0x380));
		qglPushAttrib = (void (APIENTRY *)(GLbitfield))(*(DWORD *)(base - 0x1C));
		qglPopAttrib = (void (APIENTRY *)(void))(*(DWORD *)(base + 0xF8));
		qglDeleteTextures = (void (APIENTRY *)(GLsizei, const GLuint *))(*(DWORD *)(base + 0x110));
		qglTexSubImage2D = (void (APIENTRY *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))(*(DWORD *)(base + 0x44));
		qglVertex2f = (void (APIENTRY *)(GLfloat, GLfloat))(*(DWORD *)(base + 0x36C));
		qglEnd = (void (APIENTRY *)(void))(*(DWORD *)(base - 0x428));
		qglTexEnvf = (void (APIENTRY *)(GLenum, GLenum, GLfloat))(*(DWORD *)(base - 0x564));
		qglColor4f = (void (APIENTRY *)(GLfloat, GLfloat, GLfloat, GLfloat))(*(DWORD *)(base - 0x468));
		qglColor3f = (void (APIENTRY *)(GLfloat, GLfloat, GLfloat))(*(DWORD *)(base - 0x48C));
		qglGetTexImage = (void (APIENTRY *)(GLenum, GLint, GLenum, GLenum, GLvoid *))(*(DWORD *)(base - 0x3D4));
		qglScissor = (void (APIENTRY *)(GLint, GLint, GLsizei, GLsizei))(*(DWORD *)(base + 0x294));
		qglColor4ub = (void (APIENTRY *)(GLubyte, GLubyte, GLubyte, GLubyte))(*(DWORD *)(base + 0x1E8));

		if (g_dwEngineBuildnum < 4554)
		{
			qglBegin = (void (APIENTRY *)(GLenum))(*(DWORD *)(base + 0x410));
			qglTexCoord2f = (void (APIENTRY *)(GLfloat, GLfloat))(*(DWORD *)(base + 0x46C));
		}
		else
		{
			qglBegin = (void (APIENTRY *)(GLenum))(*(DWORD *)(base + 0x414));
			qglTexCoord2f = (void (APIENTRY *)(GLfloat, GLfloat))(*(DWORD *)(base + 0x474));
		}
	}
}