mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 09:01:57 -05:00
simplify overriding graphics backend
This commit is contained in:
parent
3aa1f9749f
commit
30d3fe47a8
18 changed files with 82 additions and 80 deletions
8
.github/workflows/build_win-arm.yml
vendored
8
.github/workflows/build_win-arm.yml
vendored
|
@ -26,12 +26,12 @@ jobs:
|
|||
id: compile
|
||||
env:
|
||||
COMMON_FLAGS: "-O1 -s -fno-stack-protector -fno-math-errno -Qn"
|
||||
WIN32_FLAGS: "-mwindows -nostartfiles -Wl,-emain_real -DCC_NOMAIN"
|
||||
WIN32_FLAGS: "-mwindows -nostartfiles -Wl,-emain_real -DCC_NOMAIN -DCC_GFX_BACKEND=CC_GFX_BACKEND_D3D11"
|
||||
run: |
|
||||
LATEST_FLAG=-DCC_COMMIT_SHA=\"${GITHUB_SHA::9}\"
|
||||
|
||||
cd src
|
||||
armv7-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN32_FLAGS }} -o cc-arm32-d3d11.exe $LATEST_FLAG -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_D3D11 -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_HTTPCLIENT -DCC_BUILD_SCHANNEL -lwinmm -limagehlp
|
||||
armv7-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN32_FLAGS }} -o cc-arm32-d3d11.exe $LATEST_FLAG -lwinmm -limagehlp
|
||||
|
||||
|
||||
- uses: ./.github/actions/notify_failure
|
||||
|
@ -59,12 +59,12 @@ jobs:
|
|||
id: compile
|
||||
env:
|
||||
COMMON_FLAGS: "-O1 -s -fno-stack-protector -fno-math-errno -Qn"
|
||||
WIN64_FLAGS: "-mwindows -nostartfiles -Wl,-emain_real -DCC_NOMAIN"
|
||||
WIN64_FLAGS: "-mwindows -nostartfiles -Wl,-emain_real -DCC_NOMAIN -DCC_GFX_BACKEND=CC_GFX_BACKEND_D3D11"
|
||||
run: |
|
||||
LATEST_FLAG=-DCC_COMMIT_SHA=\"${GITHUB_SHA::9}\"
|
||||
|
||||
cd src
|
||||
aarch64-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN64_FLAGS }} -o cc-arm64-d3d11.exe $LATEST_FLAG -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_D3D11 -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_HTTPCLIENT -DCC_BUILD_SCHANNEL -lwinmm -limagehlp
|
||||
aarch64-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN64_FLAGS }} -o cc-arm64-d3d11.exe $LATEST_FLAG -lwinmm -limagehlp
|
||||
|
||||
|
||||
- uses: ./.github/actions/notify_failure
|
||||
|
|
14
.github/workflows/build_windows.yml
vendored
14
.github/workflows/build_windows.yml
vendored
|
@ -32,12 +32,12 @@ jobs:
|
|||
|
||||
cp misc/windows/CCicon_32.res src/CCicon_32.res
|
||||
cd src
|
||||
i686-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN32_FLAGS }} -o cc-w32-d3d9.exe CCicon_32.res $LATEST_FLAG -lwinmm -limagehlp
|
||||
i686-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN32_FLAGS }} -o cc-w32-ogl.exe CCicon_32.res $LATEST_FLAG -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_GL -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_HTTPCLIENT -DCC_BUILD_SCHANNEL -lwinmm -limagehlp -lopengl32
|
||||
i686-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN32_FLAGS }} -o cc-w32-d3d11.exe CCicon_32.res $LATEST_FLAG -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_D3D11 -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_HTTPCLIENT -DCC_BUILD_SCHANNEL -lwinmm -limagehlp
|
||||
i686-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN32_FLAGS }} -o cc-w32-d3d9.exe CCicon_32.res $LATEST_FLAG -lwinmm -limagehlp
|
||||
i686-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN32_FLAGS }} -o cc-w32-ogl.exe CCicon_32.res $LATEST_FLAG -DCC_GFX_BACKEND=CC_GFX_BACKEND_GL -lwinmm -limagehlp -lopengl32
|
||||
i686-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN32_FLAGS }} -o cc-w32-d3d11.exe CCicon_32.res $LATEST_FLAG -DCC_GFX_BACKEND=CC_GFX_BACKEND_D3D11 -lwinmm -limagehlp
|
||||
|
||||
# mingw defaults to i686, but some really old CPUs only support i586
|
||||
i686-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN32_FLAGS }} -march=i586 -o cc-w9x-ogl.exe CCicon_32.res $LATEST_FLAG -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_GL -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_HTTPCLIENT -DCC_BUILD_SCHANNEL -lwinmm -limagehlp -lopengl32
|
||||
i686-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN32_FLAGS }} -march=i586 -o cc-w9x-ogl.exe CCicon_32.res $LATEST_FLAG -DCC_GFX_BACKEND=CC_GFX_BACKEND_GL -lwinmm -limagehlp -lopengl32
|
||||
|
||||
|
||||
- uses: ./.github/actions/notify_failure
|
||||
|
@ -98,9 +98,9 @@ jobs:
|
|||
|
||||
cp misc/windows/CCicon_64.res src/CCicon_64.res
|
||||
cd src
|
||||
x86_64-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN64_FLAGS }} -o cc-w64-d3d9.exe CCicon_64.res $LATEST_FLAG -lwinmm -limagehlp
|
||||
x86_64-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN64_FLAGS }} -o cc-w64-ogl.exe CCicon_64.res $LATEST_FLAG -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_GL -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_HTTPCLIENT -DCC_BUILD_SCHANNEL -lwinmm -limagehlp -lopengl32
|
||||
x86_64-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN64_FLAGS }} -o cc-w64-d3d11.exe CCicon_64.res $LATEST_FLAG -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_D3D11 -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_HTTPCLIENT -DCC_BUILD_SCHANNEL -lwinmm -limagehlp
|
||||
x86_64-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN64_FLAGS }} -o cc-w64-d3d9.exe CCicon_64.res $LATEST_FLAG -lwinmm -limagehlp
|
||||
x86_64-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN64_FLAGS }} -o cc-w64-ogl.exe CCicon_64.res $LATEST_FLAG -DCC_GFX_BACKEND=CC_GFX_BACKEND_D3D11 -lwinmm -limagehlp -lopengl32
|
||||
x86_64-w64-mingw32-gcc *.c ${{ env.COMMON_FLAGS }} ${{ env.WIN64_FLAGS }} -o cc-w64-d3d11.exe CCicon_64.res $LATEST_FLAG -DCC_GFX_BACKEND=CC_GFX_BACKEND_GL -lwinmm -limagehlp
|
||||
|
||||
|
||||
- uses: ./.github/actions/notify_failure
|
||||
|
|
70
src/Core.h
70
src/Core.h
|
@ -125,6 +125,11 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_WIN_BACKEND_SDL3 6
|
||||
#define CC_WIN_BACKEND_BEOS 7
|
||||
|
||||
#define CC_GFX_BACKEND_GL 1
|
||||
#define CC_GFX_BACKEND_D3D9 2
|
||||
#define CC_GFX_BACKEND_D3D11 3
|
||||
#define CC_GFX_BACKEND_SOFTGPU 4
|
||||
|
||||
#define CC_BUILD_NETWORKING
|
||||
#define CC_BUILD_FREETYPE
|
||||
#define CC_BUILD_RESOURCES
|
||||
|
@ -155,121 +160,119 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_HTTPCLIENT
|
||||
#elif defined _WIN32
|
||||
#define CC_BUILD_WIN
|
||||
#define CC_BUILD_D3D9
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_SCHANNEL
|
||||
#define CC_BUILD_WINMM
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_D3D9
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_WIN32
|
||||
#elif defined __ANDROID__
|
||||
#define CC_BUILD_ANDROID
|
||||
#define CC_BUILD_MOBILE
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_GL
|
||||
#define CC_BUILD_GLMODERN
|
||||
#define CC_BUILD_GLES
|
||||
#define CC_BUILD_EGL
|
||||
#define CC_BUILD_TOUCH
|
||||
#define CC_BUILD_OPENSLES
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL
|
||||
#elif defined __serenity__
|
||||
#define CC_BUILD_SERENITY
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_GL
|
||||
#define CC_BUILD_CURL
|
||||
#define CC_BUILD_OPENAL
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_SDL2
|
||||
#elif defined __linux__
|
||||
#define CC_BUILD_LINUX
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_GL
|
||||
#define CC_BUILD_XINPUT2
|
||||
#define CC_BUILD_CURL
|
||||
#define CC_BUILD_OPENAL
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_X11
|
||||
#if defined CC_BUILD_RPI
|
||||
#define CC_BUILD_GLMODERN
|
||||
#define CC_BUILD_GLES
|
||||
#define CC_BUILD_EGL
|
||||
#define CC_BUILD_GLMODERN
|
||||
#define CC_BUILD_GLES
|
||||
#define CC_BUILD_EGL
|
||||
#endif
|
||||
#elif defined __APPLE__
|
||||
#define CC_BUILD_DARWIN
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_GL
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL
|
||||
#if defined __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
|
||||
#define CC_BUILD_MOBILE
|
||||
#define CC_BUILD_GLES
|
||||
#define CC_BUILD_GLMODERN
|
||||
#define CC_BUILD_IOS
|
||||
#define CC_BUILD_TOUCH
|
||||
#define CC_BUILD_CFNETWORK
|
||||
#define CC_BUILD_MOBILE
|
||||
#define CC_BUILD_GLES
|
||||
#define CC_BUILD_GLMODERN
|
||||
#define CC_BUILD_IOS
|
||||
#define CC_BUILD_TOUCH
|
||||
#define CC_BUILD_CFNETWORK
|
||||
#else
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_COCOA
|
||||
#define CC_BUILD_MACOS
|
||||
#define CC_BUILD_CURL
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_COCOA
|
||||
#define CC_BUILD_MACOS
|
||||
#define CC_BUILD_CURL
|
||||
#endif
|
||||
#define CC_BUILD_OPENAL
|
||||
#elif defined __sun__
|
||||
#define CC_BUILD_SOLARIS
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_GL
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_X11
|
||||
#define CC_BUILD_XINPUT2
|
||||
#define CC_BUILD_CURL
|
||||
#define CC_BUILD_OPENAL
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_X11
|
||||
#elif defined __FreeBSD__ || defined __DragonFly__
|
||||
#define CC_BUILD_FREEBSD
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_BSD
|
||||
#define CC_BUILD_GL
|
||||
#define CC_BUILD_XINPUT2
|
||||
#define CC_BUILD_CURL
|
||||
#define CC_BUILD_OPENAL
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_X11
|
||||
#elif defined __OpenBSD__
|
||||
#define CC_BUILD_OPENBSD
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_BSD
|
||||
#define CC_BUILD_GL
|
||||
#define CC_BUILD_XINPUT2
|
||||
#define CC_BUILD_CURL
|
||||
#define CC_BUILD_OPENAL
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_X11
|
||||
#elif defined __NetBSD__
|
||||
#define CC_BUILD_NETBSD
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_BSD
|
||||
#define CC_BUILD_GL
|
||||
#define CC_BUILD_XINPUT2
|
||||
#define CC_BUILD_CURL
|
||||
#define CC_BUILD_OPENAL
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_X11
|
||||
#elif defined __HAIKU__
|
||||
#define CC_BUILD_HAIKU
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_GL
|
||||
#define CC_BUILD_CURL
|
||||
#define CC_BUILD_OPENAL
|
||||
#define CC_BACKTRACE_BUILTIN
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_BEOS
|
||||
#elif defined __BEOS__
|
||||
#define CC_BUILD_BEOS
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_GL
|
||||
#define CC_BUILD_GL11
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_OPENAL
|
||||
#define CC_BACKTRACE_BUILTIN
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_BEOS
|
||||
#elif defined __sgi
|
||||
#define CC_BUILD_IRIX
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_GL
|
||||
#define CC_BUILD_CURL
|
||||
#define CC_BUILD_OPENAL
|
||||
#define CC_BIG_ENDIAN
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_X11
|
||||
#elif defined __EMSCRIPTEN__
|
||||
#define CC_BUILD_WEB
|
||||
#define CC_BUILD_GL
|
||||
#define CC_BUILD_GLMODERN
|
||||
#define CC_BUILD_GLES
|
||||
#define CC_BUILD_TOUCH
|
||||
|
@ -280,6 +283,7 @@ typedef cc_uint8 cc_bool;
|
|||
#undef CC_BUILD_FREETYPE
|
||||
#undef CC_BUILD_RESOURCES
|
||||
#undef CC_BUILD_PLUGINS
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL
|
||||
#elif defined __psp__
|
||||
#define CC_BUILD_PSP
|
||||
#define CC_BUILD_CONSOLE
|
||||
|
@ -371,10 +375,10 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define CC_BUILD_TOUCH
|
||||
#define CC_BUILD_GL
|
||||
#define CC_BUILD_GLMODERN
|
||||
#define CC_BUILD_GLES
|
||||
#define CC_BUILD_EGL
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL
|
||||
#elif defined PLAT_PS1
|
||||
#define CC_BUILD_PS1
|
||||
#define CC_BUILD_CONSOLE
|
||||
|
@ -390,10 +394,10 @@ typedef cc_uint8 cc_bool;
|
|||
#elif defined OS2
|
||||
#define CC_BUILD_OS2
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_SOFTGPU
|
||||
#define CC_BUILD_SDL2
|
||||
#define CC_BUILD_CURL
|
||||
#define CC_BUILD_FREETYPE
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_SOFTGPU
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_SDL2
|
||||
#elif defined PLAT_SATURN
|
||||
#define CC_BUILD_SATURN
|
||||
#define CC_BUILD_CONSOLE
|
||||
|
@ -455,13 +459,7 @@ typedef struct cc_string_ {
|
|||
Thus it is **NOT SAFE** to allocate a string on the stack. */
|
||||
#define STRING_REF
|
||||
|
||||
#if defined CC_BUILD_GL
|
||||
/* NOTE: Although normally OpenGL object/resource IDs are 32 bit integers, */
|
||||
/* OpenGL 1.1 does actually use the full 64 bits for 'dynamic' vertex buffers */
|
||||
typedef cc_uintptr GfxResourceID;
|
||||
#else
|
||||
typedef void* GfxResourceID;
|
||||
#endif
|
||||
|
||||
/* Contains the information to describe a 2D textured quad. */
|
||||
struct Texture {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "Core.h"
|
||||
#if defined CC_BUILD_GL && !defined CC_BUILD_GLMODERN
|
||||
#if (CC_GFX_BACKEND == CC_GFX_BACKEND_GL) && !defined CC_BUILD_GLMODERN
|
||||
#include "_GraphicsBase.h"
|
||||
#include "Errors.h"
|
||||
#include "Window.h"
|
||||
|
@ -207,11 +207,11 @@ static void LoadCoreFuncs(void) {
|
|||
static GfxResourceID GL_GenBuffer(void) {
|
||||
GLuint id;
|
||||
_glGenBuffers(1, &id);
|
||||
return id;
|
||||
return uint_to_ptr(id);
|
||||
}
|
||||
|
||||
static void GL_DelBuffer(GfxResourceID id) {
|
||||
GLuint gl_id = (GLuint)id;
|
||||
GLuint gl_id = ptr_to_uint(id);
|
||||
_glDeleteBuffers(1, &gl_id);
|
||||
}
|
||||
|
||||
|
@ -275,10 +275,10 @@ void Gfx_UnlockVb(GfxResourceID vb) {
|
|||
static GfxResourceID Gfx_AllocStaticVb(VertexFormat fmt, int count) {
|
||||
return glGenLists(1);
|
||||
}
|
||||
void Gfx_BindVb(GfxResourceID vb) { activeList = (GLuint)vb; }
|
||||
void Gfx_BindVb(GfxResourceID vb) { activeList = ptr_to_uint(vb); }
|
||||
|
||||
void Gfx_DeleteVb(GfxResourceID* vb) {
|
||||
GLuint id = (GLuint)(*vb);
|
||||
GLuint id = ptr_to_uint(*vb);
|
||||
if (id) glDeleteLists(id, 1);
|
||||
*vb = 0;
|
||||
}
|
||||
|
@ -365,21 +365,21 @@ static GfxResourceID Gfx_AllocDynamicVb(VertexFormat fmt, int maxVertices) {
|
|||
|
||||
void Gfx_BindDynamicVb(GfxResourceID vb) {
|
||||
activeList = gl_DYNAMICLISTID;
|
||||
dynamicListData = (void*)vb;
|
||||
dynamicListData = vb;
|
||||
}
|
||||
|
||||
void Gfx_DeleteDynamicVb(GfxResourceID* vb) {
|
||||
void* addr = (void*)(*vb);
|
||||
void* addr = *vb;
|
||||
if (addr) Mem_Free(addr);
|
||||
*vb = 0;
|
||||
}
|
||||
|
||||
void* Gfx_LockDynamicVb(GfxResourceID vb, VertexFormat fmt, int count) { return (void*)vb; }
|
||||
void* Gfx_LockDynamicVb(GfxResourceID vb, VertexFormat fmt, int count) { return vb; }
|
||||
void Gfx_UnlockDynamicVb(GfxResourceID vb) { Gfx_BindDynamicVb(vb); }
|
||||
|
||||
void Gfx_SetDynamicVbData(GfxResourceID vb, void* vertices, int vCount) {
|
||||
Gfx_BindDynamicVb(vb);
|
||||
Mem_Copy((void*)vb, vertices, vCount * gfx_stride);
|
||||
Mem_Copy(vb, vertices, vCount * gfx_stride);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -479,7 +479,7 @@ void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
|
|||
*---------------------------------------------------------Textures--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Gfx_BindTexture(GfxResourceID texId) {
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)texId);
|
||||
glBindTexture(GL_TEXTURE_2D, ptr_to_uint(texId));
|
||||
}
|
||||
|
||||
|
||||
|
@ -640,7 +640,7 @@ static GfxResourceID GenFakeBuffer(void) {
|
|||
}
|
||||
|
||||
static void DelFakeBuffer(GfxResourceID id) {
|
||||
Mem_Free((void*)id);
|
||||
Mem_Free(id);
|
||||
}
|
||||
|
||||
static void APIENTRY fake_bufferData(GLenum target, cc_uintptr size, const GLvoid* data, GLenum usage) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "Core.h"
|
||||
#if defined CC_BUILD_GL && defined CC_BUILD_GLMODERN
|
||||
#if (CC_GFX_BACKEND == CC_GFX_BACKEND_GL) && defined CC_BUILD_GLMODERN
|
||||
#include "_GraphicsBase.h"
|
||||
#include "Errors.h"
|
||||
#include "Window.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "Core.h"
|
||||
#if defined CC_BUILD_SOFTGPU
|
||||
#if CC_GFX_BACKEND == CC_GFX_BACKEND_SOFTGPU
|
||||
#include "_GraphicsBase.h"
|
||||
#include "Errors.h"
|
||||
#include "Window.h"
|
||||
|
|
|
@ -1239,13 +1239,13 @@ static void CloseLogFile(void) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined CC_BUILD_D3D11
|
||||
#if CC_GFX_BACKEND == CC_GFX_BACKEND_D3D11
|
||||
#define GFX_BACKEND " (Direct3D11)"
|
||||
#elif defined CC_BUILD_D3D9
|
||||
#elif CC_GFX_BACKEND == CC_GFX_BACKEND_D3D9
|
||||
#define GFX_BACKEND " (Direct3D9)"
|
||||
#elif defined CC_BUILD_GLMODERN
|
||||
#elif (CC_GFX_BACKEND == CC_GFX_BACKEND_GL) && defined CC_BUILD_GLMODERN
|
||||
#define GFX_BACKEND " (ModernGL)"
|
||||
#elif defined CC_BUILD_GL
|
||||
#elif CC_GFX_BACKEND == CC_GFX_BACKEND_GL
|
||||
#define GFX_BACKEND " (OpenGL)"
|
||||
#else
|
||||
#define GFX_BACKEND " (Unknown)"
|
||||
|
|
|
@ -214,7 +214,7 @@ void Window_UpdateRawMouse(void);
|
|||
void Window_DisableRawMouse(void);
|
||||
|
||||
/* OpenGL contexts are heavily tied to the window, so for simplicitly are also provided here */
|
||||
#ifdef CC_BUILD_GL
|
||||
#if CC_GFX_BACKEND == CC_GFX_BACKEND_GL
|
||||
#define GLCONTEXT_DEFAULT_DEPTH 24
|
||||
/* Creates an OpenGL context, then makes it the active context. */
|
||||
/* NOTE: You MUST have created the window beforehand, as the GL context is attached to the window. */
|
||||
|
|
|
@ -439,7 +439,7 @@ void Window_DisableRawMouse(void) {
|
|||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------OpenGL context------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#if defined CC_BUILD_GL && !defined CC_BUILD_EGL
|
||||
#if (CC_GFX_BACKEND == CC_GFX_BACKEND_GL) && !defined CC_BUILD_EGL
|
||||
static SDL_GLContext win_ctx;
|
||||
|
||||
void GLContext_Create(void) {
|
||||
|
|
|
@ -469,7 +469,7 @@ void Window_DisableRawMouse(void) {
|
|||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------OpenGL context------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#if defined CC_BUILD_GL && !defined CC_BUILD_EGL
|
||||
#if (CC_GFX_BACKEND == CC_GFX_BACKEND_GL) && !defined CC_BUILD_EGL
|
||||
static SDL_GLContext win_ctx;
|
||||
|
||||
void GLContext_Create(void) {
|
||||
|
|
|
@ -742,7 +742,7 @@ void Window_DisableRawMouse(void) {
|
|||
/*########################################################################################################################*
|
||||
*------------------------------------------------Emscripten WebGL context-------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#ifdef CC_BUILD_GL
|
||||
#if CC_GFX_BACKEND == CC_GFX_BACKEND_GL
|
||||
#include "Graphics.h"
|
||||
static EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx_handle;
|
||||
|
||||
|
|
|
@ -765,7 +765,7 @@ void Window_DisableRawMouse(void) {
|
|||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------WGL OpenGL--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#if defined CC_BUILD_GL && !defined CC_BUILD_EGL
|
||||
#if (CC_GFX_BACKEND == CC_GFX_BACKEND_GL) && !defined CC_BUILD_EGL
|
||||
static HGLRC ctx_handle;
|
||||
static HDC ctx_DC;
|
||||
typedef BOOL (WINAPI *FP_SWAPINTERVAL)(int interval);
|
||||
|
|
|
@ -270,7 +270,7 @@ static void HookXErrors(void) {
|
|||
/*########################################################################################################################*
|
||||
*--------------------------------------------------Public implementation--------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#if defined CC_BUILD_EGL || !defined CC_BUILD_GL
|
||||
#if defined CC_BUILD_EGL || (CC_GFX_BACKEND != CC_GFX_BACKEND_GL)
|
||||
static XVisualInfo GLContext_SelectVisual(void) {
|
||||
XVisualInfo info;
|
||||
cc_result res;
|
||||
|
@ -1306,7 +1306,7 @@ void Window_DisableRawMouse(void) {
|
|||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------glX OpenGL--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#if defined CC_BUILD_GL && !defined CC_BUILD_EGL
|
||||
#if (CC_GFX_BACKEND == CC_GFX_BACKEND_GL) && !defined CC_BUILD_EGL
|
||||
#include <GL/glx.h>
|
||||
static GLXContext ctx_handle;
|
||||
typedef int (*FP_SWAPINTERVAL)(int interval);
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
#define TRANSFER_FORMAT GL_UNSIGNED_BYTE
|
||||
#endif
|
||||
|
||||
#define uint_to_ptr(raw) ((void*)((cc_uintptr)raw))
|
||||
#define ptr_to_uint(raw) ((GLuint)((cc_uintptr)(raw)))
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*---------------------------------------------------------General---------------------------------------------------------*
|
||||
|
@ -147,11 +150,11 @@ static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8
|
|||
}
|
||||
|
||||
if (mipmaps) Gfx_DoMipmaps(0, 0, bmp, rowWidth, false);
|
||||
return texId;
|
||||
return uint_to_ptr(texId);
|
||||
}
|
||||
|
||||
void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, int rowWidth, cc_bool mipmaps) {
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)texId);
|
||||
glBindTexture(GL_TEXTURE_2D, ptr_to_uint(texId));
|
||||
|
||||
if (part->width == rowWidth) {
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, part->width, part->height, PIXEL_FORMAT, TRANSFER_FORMAT, part->scan0);
|
||||
|
@ -163,7 +166,7 @@ void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, i
|
|||
}
|
||||
|
||||
void Gfx_DeleteTexture(GfxResourceID* texId) {
|
||||
GLuint id = (GLuint)(*texId);
|
||||
GLuint id = ptr_to_uint(*texId);
|
||||
if (id) glDeleteTextures(1, &id);
|
||||
*texId = 0;
|
||||
}
|
||||
|
|
|
@ -522,7 +522,7 @@ GfxResourceID Gfx_CreateDynamicVb(VertexFormat fmt, int maxVertices) {
|
|||
}
|
||||
}
|
||||
|
||||
#if defined CC_BUILD_GL || defined CC_BUILD_D3D9
|
||||
#if (CC_GFX_BACKEND == CC_GFX_BACKEND_GL) || (CC_GFX_BACKEND == CC_GFX_BACKEND_D3D9)
|
||||
/* Slightly more efficient implementations are defined in the backends */
|
||||
#else
|
||||
void Gfx_SetDynamicVbData(GfxResourceID vb, void* vertices, int vCount) {
|
||||
|
|
|
@ -100,7 +100,7 @@ static CC_INLINE void InitGraphicsMode(struct GraphicsMode* m) {
|
|||
}
|
||||
|
||||
/* EGL is window system agnostic, other OpenGL context backends are tied to one windowing system */
|
||||
#if defined CC_BUILD_GL && defined CC_BUILD_EGL
|
||||
#if (CC_GFX_BACKEND == CC_GFX_BACKEND_GL) && defined CC_BUILD_EGL
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------EGL OpenGL--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
|
|
|
@ -785,7 +785,7 @@ void Window_DisableRawMouse(void) {
|
|||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------OpenGL context------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#if defined CC_BUILD_GL && !defined CC_BUILD_EGL
|
||||
#if (CC_GFX_BACKEND == CC_GFX_BACKEND_GL) && !defined CC_BUILD_EGL
|
||||
static cc_bool win_vsync;
|
||||
|
||||
void GLContext_Create(void) {
|
||||
|
@ -823,6 +823,7 @@ void GLContext_SetFpsLimit(cc_bool vsync, float minFrameMs) {
|
|||
win_vsync = vsync;
|
||||
}
|
||||
void GLContext_GetApiInfo(cc_string* info) { }
|
||||
#endif // CC_BUILD_GL && !CC_BUILD_EGL
|
||||
#endif // CC_GFX_BACKEND == CC_GFX_BACKEND_GL && !CC_BUILD_EGL
|
||||
|
||||
#endif // !CC_BUILD_SDL
|
||||
#endif
|
||||
|
|
|
@ -246,7 +246,7 @@ static void RefreshWindowBounds(void) {
|
|||
|
||||
- (void)windowDidMove:(NSNotification *)notification {
|
||||
RefreshWindowBounds();
|
||||
#ifdef CC_BUILD_GL
|
||||
#if CC_GFX_BACKEND == CC_GFX_BACKEND_GL
|
||||
GLContext_Update();
|
||||
#endif
|
||||
}
|
||||
|
@ -736,7 +736,7 @@ void OnscreenKeyboard_Close(void) { }
|
|||
/*########################################################################################################################*
|
||||
*--------------------------------------------------------NSOpenGL---------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#if defined CC_BUILD_GL && !defined CC_BUILD_EGL
|
||||
#if (CC_GFX_BACKEND == CC_GFX_BACKEND_GL) && !defined CC_BUILD_EGL
|
||||
static NSOpenGLContext* ctxHandle;
|
||||
#include <OpenGL/OpenGL.h>
|
||||
|
||||
|
|
Loading…
Reference in a new issue