mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
use run-time dynamic linking for opengl32.dll to prevent random bugs where the game fails to start
This commit is contained in:
parent
2754da2a30
commit
35ac845688
4
Makefile
4
Makefile
@ -1,10 +1,10 @@
|
|||||||
CC=gcc
|
CC=gcc
|
||||||
WINDRES=windres
|
WINDRES=windres
|
||||||
CFLAGS=-DHAVE_LIBPNG -Iinc -Wall -Wl,--enable-stdcall-fixup -s
|
CFLAGS=-DHAVE_LIBPNG -Iinc -Wall -Wl,--enable-stdcall-fixup -s
|
||||||
LIBS=lib/libpng14.a lib/libz.a -lgdi32 -lopengl32 -lwinmm
|
LIBS=lib/libpng14.a lib/libz.a -lgdi32 -lwinmm
|
||||||
|
|
||||||
#CFLAGS=-Iinc -Wall -Wl,--enable-stdcall-fixup -O3 -s
|
#CFLAGS=-Iinc -Wall -Wl,--enable-stdcall-fixup -O3 -s
|
||||||
#LIBS=-lgdi32 -lopengl32 -lwinmm
|
#LIBS=-lgdi32 -lwinmm
|
||||||
|
|
||||||
FILES = src/debug.c \
|
FILES = src/debug.c \
|
||||||
src/main.c \
|
src/main.c \
|
||||||
|
@ -26,10 +26,11 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="inc\clipper.h" />
|
<ClInclude Include="inc\clipper.h" />
|
||||||
|
<ClInclude Include="inc\glcorearb.h" />
|
||||||
|
<ClInclude Include="inc\KHR\khrplatform.h" />
|
||||||
<ClInclude Include="inc\render_d3d9.h" />
|
<ClInclude Include="inc\render_d3d9.h" />
|
||||||
<ClInclude Include="inc\ddraw.h" />
|
<ClInclude Include="inc\ddraw.h" />
|
||||||
<ClInclude Include="inc\debug.h" />
|
<ClInclude Include="inc\debug.h" />
|
||||||
<ClInclude Include="inc\glext.h" />
|
|
||||||
<ClInclude Include="inc\main.h" />
|
<ClInclude Include="inc\main.h" />
|
||||||
<ClInclude Include="inc\opengl.h" />
|
<ClInclude Include="inc\opengl.h" />
|
||||||
<ClInclude Include="inc\palette.h" />
|
<ClInclude Include="inc\palette.h" />
|
||||||
@ -99,7 +100,7 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<AdditionalDependencies>opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<ModuleDefinitionFile>ddraw.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>ddraw.def</ModuleDefinitionFile>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
@ -126,7 +127,7 @@ if exist "$(LocalDebuggerCommand)" if exist "$(LocalDebuggerWorkingDirectory)"
|
|||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<ModuleDefinitionFile>ddraw.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>ddraw.def</ModuleDefinitionFile>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -62,9 +62,6 @@
|
|||||||
<ClInclude Include="inc\debug.h">
|
<ClInclude Include="inc\debug.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="inc\glext.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="inc\main.h">
|
<ClInclude Include="inc\main.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@ -98,6 +95,12 @@
|
|||||||
<ClInclude Include="inc\render_d3d9.h">
|
<ClInclude Include="inc\render_d3d9.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="inc\glcorearb.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="inc\KHR\khrplatform.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="ddraw.rc">
|
<ResourceCompile Include="ddraw.rc">
|
||||||
|
2
ddraw.rc
2
ddraw.rc
@ -2,7 +2,7 @@
|
|||||||
#define vxstr(a,b,c,d) str(a##.##b##.##c##.##d)
|
#define vxstr(a,b,c,d) str(a##.##b##.##c##.##d)
|
||||||
#define str(s) #s
|
#define str(s) #s
|
||||||
|
|
||||||
#define VERSION 1,2,2,0
|
#define VERSION 1,2,2,1
|
||||||
|
|
||||||
1 VERSIONINFO
|
1 VERSIONINFO
|
||||||
FILEVERSION VERSION
|
FILEVERSION VERSION
|
||||||
|
282
inc/KHR/khrplatform.h
Normal file
282
inc/KHR/khrplatform.h
Normal file
@ -0,0 +1,282 @@
|
|||||||
|
#ifndef __khrplatform_h_
|
||||||
|
#define __khrplatform_h_
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2008-2018 The Khronos Group Inc.
|
||||||
|
**
|
||||||
|
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
** copy of this software and/or associated documentation files (the
|
||||||
|
** "Materials"), to deal in the Materials without restriction, including
|
||||||
|
** without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||||
|
** permit persons to whom the Materials are furnished to do so, subject to
|
||||||
|
** the following conditions:
|
||||||
|
**
|
||||||
|
** The above copyright notice and this permission notice shall be included
|
||||||
|
** in all copies or substantial portions of the Materials.
|
||||||
|
**
|
||||||
|
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Khronos platform-specific types and definitions.
|
||||||
|
*
|
||||||
|
* The master copy of khrplatform.h is maintained in the Khronos EGL
|
||||||
|
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
|
||||||
|
* The last semantic modification to khrplatform.h was at commit ID:
|
||||||
|
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
|
||||||
|
*
|
||||||
|
* Adopters may modify this file to suit their platform. Adopters are
|
||||||
|
* encouraged to submit platform specific modifications to the Khronos
|
||||||
|
* group so that they can be included in future versions of this file.
|
||||||
|
* Please submit changes by filing pull requests or issues on
|
||||||
|
* the EGL Registry repository linked above.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* See the Implementer's Guidelines for information about where this file
|
||||||
|
* should be located on your system and for more details of its use:
|
||||||
|
* http://www.khronos.org/registry/implementers_guide.pdf
|
||||||
|
*
|
||||||
|
* This file should be included as
|
||||||
|
* #include <KHR/khrplatform.h>
|
||||||
|
* by Khronos client API header files that use its types and defines.
|
||||||
|
*
|
||||||
|
* The types in khrplatform.h should only be used to define API-specific types.
|
||||||
|
*
|
||||||
|
* Types defined in khrplatform.h:
|
||||||
|
* khronos_int8_t signed 8 bit
|
||||||
|
* khronos_uint8_t unsigned 8 bit
|
||||||
|
* khronos_int16_t signed 16 bit
|
||||||
|
* khronos_uint16_t unsigned 16 bit
|
||||||
|
* khronos_int32_t signed 32 bit
|
||||||
|
* khronos_uint32_t unsigned 32 bit
|
||||||
|
* khronos_int64_t signed 64 bit
|
||||||
|
* khronos_uint64_t unsigned 64 bit
|
||||||
|
* khronos_intptr_t signed same number of bits as a pointer
|
||||||
|
* khronos_uintptr_t unsigned same number of bits as a pointer
|
||||||
|
* khronos_ssize_t signed size
|
||||||
|
* khronos_usize_t unsigned size
|
||||||
|
* khronos_float_t signed 32 bit floating point
|
||||||
|
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
|
||||||
|
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
|
||||||
|
* nanoseconds
|
||||||
|
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
|
||||||
|
* khronos_boolean_enum_t enumerated boolean type. This should
|
||||||
|
* only be used as a base type when a client API's boolean type is
|
||||||
|
* an enum. Client APIs which use an integer or other type for
|
||||||
|
* booleans cannot use this as the base type for their boolean.
|
||||||
|
*
|
||||||
|
* Tokens defined in khrplatform.h:
|
||||||
|
*
|
||||||
|
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
|
||||||
|
*
|
||||||
|
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
|
||||||
|
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
|
||||||
|
*
|
||||||
|
* Calling convention macros defined in this file:
|
||||||
|
* KHRONOS_APICALL
|
||||||
|
* KHRONOS_APIENTRY
|
||||||
|
* KHRONOS_APIATTRIBUTES
|
||||||
|
*
|
||||||
|
* These may be used in function prototypes as:
|
||||||
|
*
|
||||||
|
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
|
||||||
|
* int arg1,
|
||||||
|
* int arg2) KHRONOS_APIATTRIBUTES;
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* Definition of KHRONOS_APICALL
|
||||||
|
*-------------------------------------------------------------------------
|
||||||
|
* This precedes the return type of the function in the function prototype.
|
||||||
|
*/
|
||||||
|
#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||||
|
# define KHRONOS_APICALL __declspec(dllimport)
|
||||||
|
#elif defined (__SYMBIAN32__)
|
||||||
|
# define KHRONOS_APICALL IMPORT_C
|
||||||
|
#elif defined(__ANDROID__)
|
||||||
|
# define KHRONOS_APICALL __attribute__((visibility("default")))
|
||||||
|
#else
|
||||||
|
# define KHRONOS_APICALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* Definition of KHRONOS_APIENTRY
|
||||||
|
*-------------------------------------------------------------------------
|
||||||
|
* This follows the return type of the function and precedes the function
|
||||||
|
* name in the function prototype.
|
||||||
|
*/
|
||||||
|
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
|
||||||
|
/* Win32 but not WinCE */
|
||||||
|
# define KHRONOS_APIENTRY __stdcall
|
||||||
|
#else
|
||||||
|
# define KHRONOS_APIENTRY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* Definition of KHRONOS_APIATTRIBUTES
|
||||||
|
*-------------------------------------------------------------------------
|
||||||
|
* This follows the closing parenthesis of the function prototype arguments.
|
||||||
|
*/
|
||||||
|
#if defined (__ARMCC_2__)
|
||||||
|
#define KHRONOS_APIATTRIBUTES __softfp
|
||||||
|
#else
|
||||||
|
#define KHRONOS_APIATTRIBUTES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* basic type definitions
|
||||||
|
*-----------------------------------------------------------------------*/
|
||||||
|
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Using <stdint.h>
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
typedef int32_t khronos_int32_t;
|
||||||
|
typedef uint32_t khronos_uint32_t;
|
||||||
|
typedef int64_t khronos_int64_t;
|
||||||
|
typedef uint64_t khronos_uint64_t;
|
||||||
|
#define KHRONOS_SUPPORT_INT64 1
|
||||||
|
#define KHRONOS_SUPPORT_FLOAT 1
|
||||||
|
|
||||||
|
#elif defined(__VMS ) || defined(__sgi)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Using <inttypes.h>
|
||||||
|
*/
|
||||||
|
#include <inttypes.h>
|
||||||
|
typedef int32_t khronos_int32_t;
|
||||||
|
typedef uint32_t khronos_uint32_t;
|
||||||
|
typedef int64_t khronos_int64_t;
|
||||||
|
typedef uint64_t khronos_uint64_t;
|
||||||
|
#define KHRONOS_SUPPORT_INT64 1
|
||||||
|
#define KHRONOS_SUPPORT_FLOAT 1
|
||||||
|
|
||||||
|
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Win32
|
||||||
|
*/
|
||||||
|
typedef __int32 khronos_int32_t;
|
||||||
|
typedef unsigned __int32 khronos_uint32_t;
|
||||||
|
typedef __int64 khronos_int64_t;
|
||||||
|
typedef unsigned __int64 khronos_uint64_t;
|
||||||
|
#define KHRONOS_SUPPORT_INT64 1
|
||||||
|
#define KHRONOS_SUPPORT_FLOAT 1
|
||||||
|
|
||||||
|
#elif defined(__sun__) || defined(__digital__)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sun or Digital
|
||||||
|
*/
|
||||||
|
typedef int khronos_int32_t;
|
||||||
|
typedef unsigned int khronos_uint32_t;
|
||||||
|
#if defined(__arch64__) || defined(_LP64)
|
||||||
|
typedef long int khronos_int64_t;
|
||||||
|
typedef unsigned long int khronos_uint64_t;
|
||||||
|
#else
|
||||||
|
typedef long long int khronos_int64_t;
|
||||||
|
typedef unsigned long long int khronos_uint64_t;
|
||||||
|
#endif /* __arch64__ */
|
||||||
|
#define KHRONOS_SUPPORT_INT64 1
|
||||||
|
#define KHRONOS_SUPPORT_FLOAT 1
|
||||||
|
|
||||||
|
#elif 0
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hypothetical platform with no float or int64 support
|
||||||
|
*/
|
||||||
|
typedef int khronos_int32_t;
|
||||||
|
typedef unsigned int khronos_uint32_t;
|
||||||
|
#define KHRONOS_SUPPORT_INT64 0
|
||||||
|
#define KHRONOS_SUPPORT_FLOAT 0
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generic fallback
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
typedef int32_t khronos_int32_t;
|
||||||
|
typedef uint32_t khronos_uint32_t;
|
||||||
|
typedef int64_t khronos_int64_t;
|
||||||
|
typedef uint64_t khronos_uint64_t;
|
||||||
|
#define KHRONOS_SUPPORT_INT64 1
|
||||||
|
#define KHRONOS_SUPPORT_FLOAT 1
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Types that are (so far) the same on all platforms
|
||||||
|
*/
|
||||||
|
typedef signed char khronos_int8_t;
|
||||||
|
typedef unsigned char khronos_uint8_t;
|
||||||
|
typedef signed short int khronos_int16_t;
|
||||||
|
typedef unsigned short int khronos_uint16_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Types that differ between LLP64 and LP64 architectures - in LLP64,
|
||||||
|
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
|
||||||
|
* to be the only LLP64 architecture in current use.
|
||||||
|
*/
|
||||||
|
#ifdef _WIN64
|
||||||
|
typedef signed long long int khronos_intptr_t;
|
||||||
|
typedef unsigned long long int khronos_uintptr_t;
|
||||||
|
typedef signed long long int khronos_ssize_t;
|
||||||
|
typedef unsigned long long int khronos_usize_t;
|
||||||
|
#else
|
||||||
|
typedef signed long int khronos_intptr_t;
|
||||||
|
typedef unsigned long int khronos_uintptr_t;
|
||||||
|
typedef signed long int khronos_ssize_t;
|
||||||
|
typedef unsigned long int khronos_usize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if KHRONOS_SUPPORT_FLOAT
|
||||||
|
/*
|
||||||
|
* Float type
|
||||||
|
*/
|
||||||
|
typedef float khronos_float_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if KHRONOS_SUPPORT_INT64
|
||||||
|
/* Time types
|
||||||
|
*
|
||||||
|
* These types can be used to represent a time interval in nanoseconds or
|
||||||
|
* an absolute Unadjusted System Time. Unadjusted System Time is the number
|
||||||
|
* of nanoseconds since some arbitrary system event (e.g. since the last
|
||||||
|
* time the system booted). The Unadjusted System Time is an unsigned
|
||||||
|
* 64 bit value that wraps back to 0 every 584 years. Time intervals
|
||||||
|
* may be either signed or unsigned.
|
||||||
|
*/
|
||||||
|
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
|
||||||
|
typedef khronos_int64_t khronos_stime_nanoseconds_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Dummy value used to pad enum types to 32 bits.
|
||||||
|
*/
|
||||||
|
#ifndef KHRONOS_MAX_ENUM
|
||||||
|
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enumerated boolean type
|
||||||
|
*
|
||||||
|
* Values other than zero should be considered to be true. Therefore
|
||||||
|
* comparisons should not be made against KHRONOS_TRUE.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
KHRONOS_FALSE = 0,
|
||||||
|
KHRONOS_TRUE = 1,
|
||||||
|
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
|
||||||
|
} khronos_boolean_enum_t;
|
||||||
|
|
||||||
|
#endif /* __khrplatform_h_ */
|
5879
inc/glcorearb.h
Normal file
5879
inc/glcorearb.h
Normal file
File diff suppressed because it is too large
Load Diff
11007
inc/glext.h
11007
inc/glext.h
File diff suppressed because it is too large
Load Diff
58
inc/opengl.h
58
inc/opengl.h
@ -1,8 +1,58 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <GL/gl.h>
|
#include "glcorearb.h"
|
||||||
#include <GL/glu.h>
|
|
||||||
#include "glext.h"
|
|
||||||
|
|
||||||
|
typedef HGLRC (APIENTRYP PFNWGLCREATECONTEXT)(HDC);
|
||||||
|
typedef BOOL (APIENTRYP PFNWGLDELETECONTEXT)(HGLRC);
|
||||||
|
typedef PROC (APIENTRYP PFNWGLGETPROCADDRESS)(LPCSTR);
|
||||||
|
typedef BOOL (APIENTRYP PFNWGLMAKECURRENT)(HDC, HGLRC);
|
||||||
|
|
||||||
|
extern PFNWGLCREATECONTEXT xwglCreateContext;
|
||||||
|
extern PFNWGLDELETECONTEXT xwglDeleteContext;
|
||||||
|
extern PFNWGLGETPROCADDRESS xwglGetProcAddress;
|
||||||
|
extern PFNWGLMAKECURRENT xwglMakeCurrent;
|
||||||
|
|
||||||
|
typedef void (APIENTRYP PFNGLVIEWPORT)(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||||
|
typedef void (APIENTRYP PFNGLBINDTEXTURE)(GLenum target, GLuint texture);
|
||||||
|
typedef void (APIENTRYP PFNGLGENTEXTURES)(GLsizei n, GLuint *textures);
|
||||||
|
typedef void (APIENTRYP PFNGLTEXPARAMETERI)(GLenum target, GLenum pname, GLint param);
|
||||||
|
typedef void (APIENTRYP PFNGLDELETETEXTURES)(GLsizei n, const GLuint *textures);
|
||||||
|
typedef void (APIENTRYP PFNGLTEXIMAGE2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
|
||||||
|
typedef void (APIENTRYP PFNGLDRAWELEMENTS)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
|
||||||
|
typedef void (APIENTRYP PFNGLTEXSUBIMAGE2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
|
||||||
|
typedef GLenum (APIENTRYP PFNGLGETERROR)(void);
|
||||||
|
typedef const GLubyte * (APIENTRYP PFNGLGETSTRING)(GLenum name);
|
||||||
|
typedef void (APIENTRYP PFNGLGETTEXIMAGE)(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
|
||||||
|
typedef void (APIENTRYP PFNGLPIXELSTOREI)(GLenum pname, GLint param);
|
||||||
|
|
||||||
|
extern PFNGLVIEWPORT glViewport;
|
||||||
|
extern PFNGLBINDTEXTURE glBindTexture;
|
||||||
|
extern PFNGLGENTEXTURES glGenTextures;
|
||||||
|
extern PFNGLTEXPARAMETERI glTexParameteri;
|
||||||
|
extern PFNGLDELETETEXTURES glDeleteTextures;
|
||||||
|
extern PFNGLTEXIMAGE2D glTexImage2D;
|
||||||
|
extern PFNGLDRAWELEMENTS glDrawElements;
|
||||||
|
extern PFNGLTEXSUBIMAGE2D glTexSubImage2D;
|
||||||
|
extern PFNGLGETERROR glGetError;
|
||||||
|
extern PFNGLGETSTRING glGetString;
|
||||||
|
extern PFNGLGETTEXIMAGE glGetTexImage;
|
||||||
|
extern PFNGLPIXELSTOREI glPixelStorei;
|
||||||
|
|
||||||
|
//compat profile only --->
|
||||||
|
#define GL_LUMINANCE 0x1909
|
||||||
|
#define GL_LUMINANCE8 0x8040
|
||||||
|
typedef void (APIENTRYP PFNGLBEGIN)(GLenum mode);
|
||||||
|
typedef void (APIENTRYP PFNGLEND)(void);
|
||||||
|
typedef void (APIENTRYP PFNGLTEXCOORD2F)(GLfloat s, GLfloat t);
|
||||||
|
typedef void (APIENTRYP PFNGLVERTEX2F)(GLfloat x, GLfloat y);
|
||||||
|
|
||||||
|
extern PFNGLBEGIN glBegin;
|
||||||
|
extern PFNGLEND glEnd;
|
||||||
|
extern PFNGLTEXCOORD2F glTexCoord2f;
|
||||||
|
extern PFNGLVERTEX2F glVertex2f;
|
||||||
|
// <--- compat profile only
|
||||||
|
|
||||||
|
|
||||||
|
BOOL OpenGL_LoadDll();
|
||||||
void OpenGL_Init();
|
void OpenGL_Init();
|
||||||
BOOL OpenGL_ExtExists(char *ext, HDC hdc);
|
BOOL OpenGL_ExtExists(char *ext, HDC hdc);
|
||||||
GLuint OpenGL_BuildProgram(const GLchar *vertSource, const GLchar *fragSource);
|
GLuint OpenGL_BuildProgram(const GLchar *vertSource, const GLchar *fragSource);
|
||||||
@ -75,6 +125,8 @@ extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB;
|
|||||||
|
|
||||||
extern PFNGLTEXBUFFERPROC glTexBuffer;
|
extern PFNGLTEXBUFFERPROC glTexBuffer;
|
||||||
|
|
||||||
|
extern HMODULE OpenGL_hModule;
|
||||||
|
|
||||||
extern BOOL OpenGL_GotVersion2;
|
extern BOOL OpenGL_GotVersion2;
|
||||||
extern BOOL OpenGL_GotVersion3;
|
extern BOOL OpenGL_GotVersion3;
|
||||||
|
|
||||||
|
34
src/main.c
34
src/main.c
@ -21,6 +21,7 @@
|
|||||||
#include <d3d9.h>
|
#include <d3d9.h>
|
||||||
#include "ddraw.h"
|
#include "ddraw.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "opengl.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "surface.h"
|
#include "surface.h"
|
||||||
#include "clipper.h"
|
#include "clipper.h"
|
||||||
@ -983,11 +984,6 @@ ULONG __stdcall ddraw_Release(IDirectDrawImpl *This)
|
|||||||
ddraw->render.ev = NULL;
|
ddraw->render.ev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(This->real_dll)
|
|
||||||
{
|
|
||||||
FreeLibrary(This->real_dll);
|
|
||||||
}
|
|
||||||
|
|
||||||
DeleteCriticalSection(&This->cs);
|
DeleteCriticalSection(&This->cs);
|
||||||
|
|
||||||
/* restore old wndproc, subsequent ddraw creation will otherwise fail */
|
/* restore old wndproc, subsequent ddraw creation will otherwise fail */
|
||||||
@ -1068,14 +1064,17 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
|
|||||||
|
|
||||||
ddraw = This;
|
ddraw = This;
|
||||||
|
|
||||||
This->real_dll = LoadLibrary("system32\\ddraw.dll");
|
if (!This->real_dll)
|
||||||
|
This->real_dll = LoadLibrary("system32\\ddraw.dll");
|
||||||
|
|
||||||
if(!This->real_dll)
|
if(!This->real_dll)
|
||||||
{
|
{
|
||||||
ddraw_Release(This);
|
ddraw_Release(This);
|
||||||
return DDERR_GENERIC;
|
return DDERR_GENERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
This->DirectDrawCreate = (HRESULT (WINAPI *)(GUID FAR*, LPDIRECTDRAW FAR*, IUnknown FAR*))GetProcAddress(This->real_dll, "DirectDrawCreate");
|
This->DirectDrawCreate =
|
||||||
|
(HRESULT (WINAPI *)(GUID FAR*, LPDIRECTDRAW FAR*, IUnknown FAR*))GetProcAddress(This->real_dll, "DirectDrawCreate");
|
||||||
|
|
||||||
if(!This->DirectDrawCreate)
|
if(!This->DirectDrawCreate)
|
||||||
{
|
{
|
||||||
@ -1301,9 +1300,18 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (d3d)
|
if (d3d)
|
||||||
|
{
|
||||||
This->renderer = render_d3d9_main;
|
This->renderer = render_d3d9_main;
|
||||||
else
|
}
|
||||||
|
else if (OpenGL_LoadDll())
|
||||||
|
{
|
||||||
This->renderer = render_main;
|
This->renderer = render_main;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowDriverWarning = TRUE;
|
||||||
|
This->renderer = render_soft_main;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (tolower(tmp[0]) == 'd')
|
else if (tolower(tmp[0]) == 'd')
|
||||||
@ -1314,7 +1322,15 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("DirectDrawCreate: Using OpenGL renderer\n");
|
printf("DirectDrawCreate: Using OpenGL renderer\n");
|
||||||
This->renderer = render_main;
|
if (OpenGL_LoadDll())
|
||||||
|
{
|
||||||
|
This->renderer = render_main;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowDriverWarning = TRUE;
|
||||||
|
This->renderer = render_soft_main;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// to do: read .glslp config file instead of the shader and apply the correct settings
|
// to do: read .glslp config file instead of the shader and apply the correct settings
|
||||||
|
285
src/opengl.c
285
src/opengl.c
@ -2,141 +2,202 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
|
|
||||||
|
PFNWGLCREATECONTEXT xwglCreateContext;
|
||||||
|
PFNWGLDELETECONTEXT xwglDeleteContext;
|
||||||
|
PFNWGLGETPROCADDRESS xwglGetProcAddress;
|
||||||
|
PFNWGLMAKECURRENT xwglMakeCurrent;
|
||||||
|
|
||||||
|
PFNGLVIEWPORT glViewport;
|
||||||
|
PFNGLBINDTEXTURE glBindTexture;
|
||||||
|
PFNGLGENTEXTURES glGenTextures;
|
||||||
|
PFNGLTEXPARAMETERI glTexParameteri;
|
||||||
|
PFNGLDELETETEXTURES glDeleteTextures;
|
||||||
|
PFNGLTEXIMAGE2D glTexImage2D;
|
||||||
|
PFNGLDRAWELEMENTS glDrawElements;
|
||||||
|
PFNGLTEXSUBIMAGE2D glTexSubImage2D;
|
||||||
|
PFNGLGETERROR glGetError;
|
||||||
|
PFNGLGETSTRING glGetString;
|
||||||
|
PFNGLGETTEXIMAGE glGetTexImage;
|
||||||
|
PFNGLPIXELSTOREI glPixelStorei;
|
||||||
|
|
||||||
|
PFNGLBEGIN glBegin;
|
||||||
|
PFNGLEND glEnd;
|
||||||
|
PFNGLTEXCOORD2F glTexCoord2f;
|
||||||
|
PFNGLVERTEX2F glVertex2f;
|
||||||
|
|
||||||
// Program
|
// Program
|
||||||
PFNGLCREATEPROGRAMPROC glCreateProgram = NULL;
|
PFNGLCREATEPROGRAMPROC glCreateProgram;
|
||||||
PFNGLDELETEPROGRAMPROC glDeleteProgram = NULL;
|
PFNGLDELETEPROGRAMPROC glDeleteProgram;
|
||||||
PFNGLUSEPROGRAMPROC glUseProgram = NULL;
|
PFNGLUSEPROGRAMPROC glUseProgram;
|
||||||
PFNGLATTACHSHADERPROC glAttachShader = NULL;
|
PFNGLATTACHSHADERPROC glAttachShader;
|
||||||
PFNGLDETACHSHADERPROC glDetachShader = NULL;
|
PFNGLDETACHSHADERPROC glDetachShader;
|
||||||
PFNGLLINKPROGRAMPROC glLinkProgram = NULL;
|
PFNGLLINKPROGRAMPROC glLinkProgram;
|
||||||
PFNGLGETPROGRAMIVPROC glGetProgramiv = NULL;
|
PFNGLGETPROGRAMIVPROC glGetProgramiv;
|
||||||
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog = NULL;
|
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
|
||||||
PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = NULL;
|
PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
||||||
PFNGLUNIFORM1IPROC glUniform1i = NULL;
|
PFNGLUNIFORM1IPROC glUniform1i;
|
||||||
PFNGLUNIFORM1IVPROC glUniform1iv = NULL;
|
PFNGLUNIFORM1IVPROC glUniform1iv;
|
||||||
PFNGLUNIFORM2IVPROC glUniform2iv = NULL;
|
PFNGLUNIFORM2IVPROC glUniform2iv;
|
||||||
PFNGLUNIFORM3IVPROC glUniform3iv = NULL;
|
PFNGLUNIFORM3IVPROC glUniform3iv;
|
||||||
PFNGLUNIFORM4IVPROC glUniform4iv = NULL;
|
PFNGLUNIFORM4IVPROC glUniform4iv;
|
||||||
PFNGLUNIFORM1FPROC glUniform1f = NULL;
|
PFNGLUNIFORM1FPROC glUniform1f;
|
||||||
PFNGLUNIFORM1FVPROC glUniform1fv = NULL;
|
PFNGLUNIFORM1FVPROC glUniform1fv;
|
||||||
PFNGLUNIFORM2FVPROC glUniform2fv = NULL;
|
PFNGLUNIFORM2FVPROC glUniform2fv;
|
||||||
PFNGLUNIFORM3FVPROC glUniform3fv = NULL;
|
PFNGLUNIFORM3FVPROC glUniform3fv;
|
||||||
PFNGLUNIFORM4FVPROC glUniform4fv = NULL;
|
PFNGLUNIFORM4FVPROC glUniform4fv;
|
||||||
PFNGLUNIFORM4FPROC glUniform4f = NULL;
|
PFNGLUNIFORM4FPROC glUniform4f;
|
||||||
PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv = NULL;
|
PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
|
||||||
PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation = NULL;
|
PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
|
||||||
PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f = NULL;
|
PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f;
|
||||||
PFNGLVERTEXATTRIB1FVPROC glVertexAttrib1fv = NULL;
|
PFNGLVERTEXATTRIB1FVPROC glVertexAttrib1fv;
|
||||||
PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv = NULL;
|
PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv;
|
||||||
PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv = NULL;
|
PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv;
|
||||||
PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv = NULL;
|
PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv;
|
||||||
PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = NULL;
|
PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
||||||
PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray = NULL;
|
PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
|
||||||
PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation = NULL;
|
PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
|
||||||
PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform = NULL;
|
PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform;
|
||||||
|
|
||||||
PFNGLCREATESHADERPROC glCreateShader = NULL;
|
PFNGLCREATESHADERPROC glCreateShader;
|
||||||
PFNGLDELETESHADERPROC glDeleteShader = NULL;
|
PFNGLDELETESHADERPROC glDeleteShader;
|
||||||
PFNGLSHADERSOURCEPROC glShaderSource = NULL;
|
PFNGLSHADERSOURCEPROC glShaderSource;
|
||||||
PFNGLCOMPILESHADERPROC glCompileShader = NULL;
|
PFNGLCOMPILESHADERPROC glCompileShader;
|
||||||
PFNGLGETSHADERIVPROC glGetShaderiv = NULL;
|
PFNGLGETSHADERIVPROC glGetShaderiv;
|
||||||
|
|
||||||
PFNGLGENBUFFERSPROC glGenBuffers = NULL;
|
PFNGLGENBUFFERSPROC glGenBuffers;
|
||||||
PFNGLBINDBUFFERPROC glBindBuffer = NULL;
|
PFNGLBINDBUFFERPROC glBindBuffer;
|
||||||
PFNGLBUFFERDATAPROC glBufferData = NULL;
|
PFNGLBUFFERDATAPROC glBufferData;
|
||||||
PFNGLMAPBUFFERPROC glMapBuffer = NULL;
|
PFNGLMAPBUFFERPROC glMapBuffer;
|
||||||
PFNGLUNMAPBUFFERPROC glUnmapBuffer = NULL;
|
PFNGLUNMAPBUFFERPROC glUnmapBuffer;
|
||||||
PFNGLBUFFERSUBDATAPROC glBufferSubData = NULL;
|
PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
||||||
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = NULL;
|
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
|
||||||
PFNGLDELETEBUFFERSPROC glDeleteBuffers = NULL;
|
PFNGLDELETEBUFFERSPROC glDeleteBuffers;
|
||||||
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays = NULL;
|
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||||
PFNGLBINDVERTEXARRAYPROC glBindVertexArray = NULL;
|
PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
||||||
PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays = NULL;
|
PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
|
||||||
|
|
||||||
PFNGLACTIVETEXTUREPROC glActiveTexture = NULL;
|
PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||||
|
|
||||||
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = NULL;
|
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||||
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = NULL;
|
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||||
PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = NULL;
|
PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
||||||
PFNGLDRAWBUFFERSPROC glDrawBuffers = NULL;
|
PFNGLDRAWBUFFERSPROC glDrawBuffers;
|
||||||
PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = NULL;
|
PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
||||||
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = NULL;
|
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
|
||||||
|
|
||||||
PFNWGLSWAPINTERVALEXT wglSwapIntervalEXT = NULL;
|
PFNWGLSWAPINTERVALEXT wglSwapIntervalEXT;
|
||||||
PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = NULL;
|
PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB;
|
||||||
|
|
||||||
PFNGLTEXBUFFERPROC glTexBuffer = NULL;
|
PFNGLTEXBUFFERPROC glTexBuffer;
|
||||||
|
|
||||||
|
HMODULE OpenGL_hModule;
|
||||||
|
|
||||||
BOOL OpenGL_GotVersion2;
|
BOOL OpenGL_GotVersion2;
|
||||||
BOOL OpenGL_GotVersion3;
|
BOOL OpenGL_GotVersion3;
|
||||||
|
|
||||||
char OpenGL_Version[128];
|
char OpenGL_Version[128];
|
||||||
|
|
||||||
|
BOOL OpenGL_LoadDll()
|
||||||
|
{
|
||||||
|
if (!OpenGL_hModule)
|
||||||
|
OpenGL_hModule = LoadLibrary("opengl32.dll");
|
||||||
|
|
||||||
|
if (OpenGL_hModule)
|
||||||
|
{
|
||||||
|
xwglCreateContext = (PFNWGLCREATECONTEXT)GetProcAddress(OpenGL_hModule, "wglCreateContext");
|
||||||
|
xwglDeleteContext = (PFNWGLDELETECONTEXT)GetProcAddress(OpenGL_hModule, "wglDeleteContext");
|
||||||
|
xwglGetProcAddress = (PFNWGLGETPROCADDRESS)GetProcAddress(OpenGL_hModule, "wglGetProcAddress");
|
||||||
|
xwglMakeCurrent = (PFNWGLMAKECURRENT)GetProcAddress(OpenGL_hModule, "wglMakeCurrent");
|
||||||
|
|
||||||
|
glViewport = (PFNGLVIEWPORT)GetProcAddress(OpenGL_hModule, "glViewport");
|
||||||
|
glBindTexture = (PFNGLBINDTEXTURE)GetProcAddress(OpenGL_hModule, "glBindTexture");
|
||||||
|
glGenTextures = (PFNGLGENTEXTURES)GetProcAddress(OpenGL_hModule, "glGenTextures");
|
||||||
|
glTexParameteri = (PFNGLTEXPARAMETERI)GetProcAddress(OpenGL_hModule, "glTexParameteri");
|
||||||
|
glDeleteTextures = (PFNGLDELETETEXTURES)GetProcAddress(OpenGL_hModule, "glDeleteTextures");
|
||||||
|
glTexImage2D = (PFNGLTEXIMAGE2D)GetProcAddress(OpenGL_hModule, "glTexImage2D");
|
||||||
|
glDrawElements = (PFNGLDRAWELEMENTS)GetProcAddress(OpenGL_hModule, "glDrawElements");
|
||||||
|
glTexSubImage2D = (PFNGLTEXSUBIMAGE2D)GetProcAddress(OpenGL_hModule, "glTexSubImage2D");
|
||||||
|
glGetError = (PFNGLGETERROR)GetProcAddress(OpenGL_hModule, "glGetError");
|
||||||
|
glGetString = (PFNGLGETSTRING)GetProcAddress(OpenGL_hModule, "glGetString");
|
||||||
|
glGetTexImage = (PFNGLGETTEXIMAGE)GetProcAddress(OpenGL_hModule, "glGetTexImage");
|
||||||
|
glPixelStorei = (PFNGLPIXELSTOREI)GetProcAddress(OpenGL_hModule, "glPixelStorei");
|
||||||
|
|
||||||
|
glBegin = (PFNGLBEGIN)GetProcAddress(OpenGL_hModule, "glBegin");
|
||||||
|
glEnd = (PFNGLEND)GetProcAddress(OpenGL_hModule, "glEnd");
|
||||||
|
glTexCoord2f = (PFNGLTEXCOORD2F)GetProcAddress(OpenGL_hModule, "glTexCoord2f");
|
||||||
|
glVertex2f = (PFNGLVERTEX2F)GetProcAddress(OpenGL_hModule, "glVertex2f");
|
||||||
|
}
|
||||||
|
|
||||||
|
return xwglCreateContext && xwglDeleteContext && xwglGetProcAddress && xwglMakeCurrent && glViewport &&
|
||||||
|
glBindTexture && glGenTextures && glTexParameteri && glDeleteTextures && glTexImage2D &&
|
||||||
|
glDrawElements && glTexSubImage2D && glGetError && glGetString && glGetTexImage && glPixelStorei &&
|
||||||
|
glBegin && glEnd && glTexCoord2f && glVertex2f;
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGL_Init()
|
void OpenGL_Init()
|
||||||
{
|
{
|
||||||
// Program
|
// Program
|
||||||
glCreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram");
|
glCreateProgram = (PFNGLCREATEPROGRAMPROC)xwglGetProcAddress("glCreateProgram");
|
||||||
glDeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram");
|
glDeleteProgram = (PFNGLDELETEPROGRAMPROC)xwglGetProcAddress("glDeleteProgram");
|
||||||
glUseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram");
|
glUseProgram = (PFNGLUSEPROGRAMPROC)xwglGetProcAddress("glUseProgram");
|
||||||
glAttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader");
|
glAttachShader = (PFNGLATTACHSHADERPROC)xwglGetProcAddress("glAttachShader");
|
||||||
glDetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader");
|
glDetachShader = (PFNGLDETACHSHADERPROC)xwglGetProcAddress("glDetachShader");
|
||||||
glLinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram");
|
glLinkProgram = (PFNGLLINKPROGRAMPROC)xwglGetProcAddress("glLinkProgram");
|
||||||
glGetProgramiv = (PFNGLGETPROGRAMIVPROC)wglGetProcAddress("glGetProgramiv");
|
glGetProgramiv = (PFNGLGETPROGRAMIVPROC)xwglGetProcAddress("glGetProgramiv");
|
||||||
glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog");
|
glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)xwglGetProcAddress("glGetShaderInfoLog");
|
||||||
glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation");
|
glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)xwglGetProcAddress("glGetUniformLocation");
|
||||||
glUniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i");
|
glUniform1i = (PFNGLUNIFORM1IPROC)xwglGetProcAddress("glUniform1i");
|
||||||
glUniform1iv = (PFNGLUNIFORM1IVPROC)wglGetProcAddress("glUniform1iv");
|
glUniform1iv = (PFNGLUNIFORM1IVPROC)xwglGetProcAddress("glUniform1iv");
|
||||||
glUniform2iv = (PFNGLUNIFORM2IVPROC)wglGetProcAddress("glUniform2iv");
|
glUniform2iv = (PFNGLUNIFORM2IVPROC)xwglGetProcAddress("glUniform2iv");
|
||||||
glUniform3iv = (PFNGLUNIFORM3IVPROC)wglGetProcAddress("glUniform3iv");
|
glUniform3iv = (PFNGLUNIFORM3IVPROC)xwglGetProcAddress("glUniform3iv");
|
||||||
glUniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv");
|
glUniform4iv = (PFNGLUNIFORM4IVPROC)xwglGetProcAddress("glUniform4iv");
|
||||||
glUniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f");
|
glUniform1f = (PFNGLUNIFORM1FPROC)xwglGetProcAddress("glUniform1f");
|
||||||
glUniform1fv = (PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv");
|
glUniform1fv = (PFNGLUNIFORM1FVPROC)xwglGetProcAddress("glUniform1fv");
|
||||||
glUniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress("glUniform2fv");
|
glUniform2fv = (PFNGLUNIFORM2FVPROC)xwglGetProcAddress("glUniform2fv");
|
||||||
glUniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv");
|
glUniform3fv = (PFNGLUNIFORM3FVPROC)xwglGetProcAddress("glUniform3fv");
|
||||||
glUniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv");
|
glUniform4fv = (PFNGLUNIFORM4FVPROC)xwglGetProcAddress("glUniform4fv");
|
||||||
glUniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f");
|
glUniform4f = (PFNGLUNIFORM4FPROC)xwglGetProcAddress("glUniform4f");
|
||||||
glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv");
|
glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)xwglGetProcAddress("glUniformMatrix4fv");
|
||||||
glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation");
|
glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)xwglGetProcAddress("glGetAttribLocation");
|
||||||
glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)wglGetProcAddress("glVertexAttrib1f");
|
glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)xwglGetProcAddress("glVertexAttrib1f");
|
||||||
glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)wglGetProcAddress("glVertexAttrib1fv");
|
glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)xwglGetProcAddress("glVertexAttrib1fv");
|
||||||
glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)wglGetProcAddress("glVertexAttrib2fv");
|
glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)xwglGetProcAddress("glVertexAttrib2fv");
|
||||||
glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)wglGetProcAddress("glVertexAttrib3fv");
|
glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)xwglGetProcAddress("glVertexAttrib3fv");
|
||||||
glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv");
|
glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)xwglGetProcAddress("glVertexAttrib4fv");
|
||||||
glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray");
|
glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)xwglGetProcAddress("glEnableVertexAttribArray");
|
||||||
glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation");
|
glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)xwglGetProcAddress("glBindAttribLocation");
|
||||||
|
|
||||||
glCreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader");
|
glCreateShader = (PFNGLCREATESHADERPROC)xwglGetProcAddress("glCreateShader");
|
||||||
glDeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader");
|
glDeleteShader = (PFNGLDELETESHADERPROC)xwglGetProcAddress("glDeleteShader");
|
||||||
glShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource");
|
glShaderSource = (PFNGLSHADERSOURCEPROC)xwglGetProcAddress("glShaderSource");
|
||||||
glCompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader");
|
glCompileShader = (PFNGLCOMPILESHADERPROC)xwglGetProcAddress("glCompileShader");
|
||||||
glGetShaderiv = (PFNGLGETSHADERIVPROC)wglGetProcAddress("glGetShaderiv");
|
glGetShaderiv = (PFNGLGETSHADERIVPROC)xwglGetProcAddress("glGetShaderiv");
|
||||||
|
|
||||||
glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers");
|
glGenBuffers = (PFNGLGENBUFFERSPROC)xwglGetProcAddress("glGenBuffers");
|
||||||
glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer");
|
glBindBuffer = (PFNGLBINDBUFFERPROC)xwglGetProcAddress("glBindBuffer");
|
||||||
glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData");
|
glBufferData = (PFNGLBUFFERDATAPROC)xwglGetProcAddress("glBufferData");
|
||||||
glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer");
|
glMapBuffer = (PFNGLMAPBUFFERPROC)xwglGetProcAddress("glMapBuffer");
|
||||||
glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer");
|
glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)xwglGetProcAddress("glUnmapBuffer");
|
||||||
glBufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubData");
|
glBufferSubData = (PFNGLBUFFERSUBDATAPROC)xwglGetProcAddress("glBufferSubData");
|
||||||
glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer");
|
glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)xwglGetProcAddress("glVertexAttribPointer");
|
||||||
glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers");
|
glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)xwglGetProcAddress("glDeleteBuffers");
|
||||||
glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)wglGetProcAddress("glGenVertexArrays");
|
glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)xwglGetProcAddress("glGenVertexArrays");
|
||||||
glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)wglGetProcAddress("glBindVertexArray");
|
glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)xwglGetProcAddress("glBindVertexArray");
|
||||||
glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)wglGetProcAddress("glDeleteVertexArrays");
|
glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)xwglGetProcAddress("glDeleteVertexArrays");
|
||||||
|
|
||||||
glActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTexture");
|
glActiveTexture = (PFNGLACTIVETEXTUREPROC)xwglGetProcAddress("glActiveTexture");
|
||||||
|
|
||||||
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers");
|
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)xwglGetProcAddress("glGenFramebuffers");
|
||||||
glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer");
|
glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)xwglGetProcAddress("glBindFramebuffer");
|
||||||
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D");
|
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)xwglGetProcAddress("glFramebufferTexture2D");
|
||||||
glDrawBuffers = (PFNGLDRAWBUFFERSPROC)wglGetProcAddress("glDrawBuffers");
|
glDrawBuffers = (PFNGLDRAWBUFFERSPROC)xwglGetProcAddress("glDrawBuffers");
|
||||||
glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)wglGetProcAddress("glCheckFramebufferStatus");
|
glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)xwglGetProcAddress("glCheckFramebufferStatus");
|
||||||
glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers");
|
glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)xwglGetProcAddress("glDeleteFramebuffers");
|
||||||
|
|
||||||
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXT)wglGetProcAddress("wglSwapIntervalEXT");
|
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXT)xwglGetProcAddress("wglSwapIntervalEXT");
|
||||||
wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
|
wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)xwglGetProcAddress("wglGetExtensionsStringARB");
|
||||||
|
|
||||||
glTexBuffer = (PFNGLTEXBUFFERPROC)wglGetProcAddress("glTexBuffer");
|
glTexBuffer = (PFNGLTEXBUFFERPROC)xwglGetProcAddress("glTexBuffer");
|
||||||
|
|
||||||
char *glversion = (char *)glGetString(GL_VERSION);
|
char *glversion = (char *)glGetString(GL_VERSION);
|
||||||
if (glversion)
|
if (glversion)
|
||||||
|
22
src/render.c
22
src/render.c
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
static HGLRC OpenGLContext;
|
static HGLRC OpenGLContext;
|
||||||
static int MaxFPS;
|
static int MaxFPS;
|
||||||
static BOOL VSyncEnabled;
|
|
||||||
static DWORD FrameLength;
|
static DWORD FrameLength;
|
||||||
static GLuint PaletteProgram;
|
static GLuint PaletteProgram;
|
||||||
static GLuint ScaleProgram;
|
static GLuint ScaleProgram;
|
||||||
@ -100,15 +99,15 @@ DWORD WINAPI render_main(void)
|
|||||||
|
|
||||||
static HGLRC CreateContext(HDC hdc)
|
static HGLRC CreateContext(HDC hdc)
|
||||||
{
|
{
|
||||||
HGLRC context = wglCreateContext(hdc);
|
HGLRC context = xwglCreateContext(hdc);
|
||||||
BOOL madeCurrent = context && wglMakeCurrent(hdc, context);
|
BOOL madeCurrent = context && xwglMakeCurrent(hdc, context);
|
||||||
|
|
||||||
if (!madeCurrent || glGetError() != GL_NO_ERROR)
|
if (!madeCurrent || glGetError() != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
if (madeCurrent)
|
if (madeCurrent)
|
||||||
{
|
{
|
||||||
wglMakeCurrent(NULL, NULL);
|
xwglMakeCurrent(NULL, NULL);
|
||||||
wglDeleteContext(context);
|
xwglDeleteContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
context = 0;
|
context = 0;
|
||||||
@ -120,7 +119,6 @@ static HGLRC CreateContext(HDC hdc)
|
|||||||
static void SetMaxFPS(int baseMaxFPS)
|
static void SetMaxFPS(int baseMaxFPS)
|
||||||
{
|
{
|
||||||
MaxFPS = baseMaxFPS;
|
MaxFPS = baseMaxFPS;
|
||||||
VSyncEnabled = FALSE;
|
|
||||||
|
|
||||||
if (OpenGL_ExtExists("WGL_EXT_swap_control_tear", ddraw->render.hDC))
|
if (OpenGL_ExtExists("WGL_EXT_swap_control_tear", ddraw->render.hDC))
|
||||||
{
|
{
|
||||||
@ -130,7 +128,6 @@ static void SetMaxFPS(int baseMaxFPS)
|
|||||||
{
|
{
|
||||||
wglSwapIntervalEXT(-1);
|
wglSwapIntervalEXT(-1);
|
||||||
MaxFPS = 1000;
|
MaxFPS = 1000;
|
||||||
VSyncEnabled = TRUE;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
wglSwapIntervalEXT(0);
|
wglSwapIntervalEXT(0);
|
||||||
@ -144,7 +141,6 @@ static void SetMaxFPS(int baseMaxFPS)
|
|||||||
{
|
{
|
||||||
wglSwapIntervalEXT(1);
|
wglSwapIntervalEXT(1);
|
||||||
MaxFPS = 1000;
|
MaxFPS = 1000;
|
||||||
VSyncEnabled = TRUE;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
wglSwapIntervalEXT(0);
|
wglSwapIntervalEXT(0);
|
||||||
@ -602,10 +598,9 @@ static void Render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int errorCheckCount = 0;
|
static int errorCheckCount = 0;
|
||||||
if (errorCheckCount < 3)
|
if (errorCheckCount < 20)
|
||||||
{
|
{
|
||||||
errorCheckCount++;
|
errorCheckCount++;
|
||||||
glFinish();
|
|
||||||
|
|
||||||
if (glGetError() != GL_NO_ERROR)
|
if (glGetError() != GL_NO_ERROR)
|
||||||
UseOpenGL = FALSE;
|
UseOpenGL = FALSE;
|
||||||
@ -712,9 +707,6 @@ static void Render()
|
|||||||
|
|
||||||
SwapBuffers(ddraw->render.hDC);
|
SwapBuffers(ddraw->render.hDC);
|
||||||
|
|
||||||
if (VSyncEnabled)
|
|
||||||
glFinish();
|
|
||||||
|
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
DrawFrameInfoEnd();
|
DrawFrameInfoEnd();
|
||||||
#endif
|
#endif
|
||||||
@ -773,8 +765,8 @@ static void DeleteContext(HGLRC context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wglMakeCurrent(NULL, NULL);
|
xwglMakeCurrent(NULL, NULL);
|
||||||
wglDeleteContext(context);
|
xwglDeleteContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL TextureUploadTest()
|
static BOOL TextureUploadTest()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user