Merge 87a8e04a7b
into 2be18e2c54
This commit is contained in:
commit
1f2ffe5953
8 changed files with 5403 additions and 83 deletions
|
@ -8,7 +8,7 @@ if(EMSCRIPTEN)
|
||||||
endif()
|
endif()
|
||||||
enum_option(PLATFORM "Desktop;Web;Android;Raspberry Pi;DRM;SDL" "Platform to build for.")
|
enum_option(PLATFORM "Desktop;Web;Android;Raspberry Pi;DRM;SDL" "Platform to build for.")
|
||||||
|
|
||||||
enum_option(OPENGL_VERSION "OFF;4.3;3.3;2.1;1.1;ES 2.0;ES 3.0" "Force a specific OpenGL Version?")
|
enum_option(OPENGL_VERSION "OFF;4.3;3.3;2.1;1.1;ES 2.0;ES 3.0;Software" "Force a specific OpenGL Version?")
|
||||||
|
|
||||||
# Configuration options
|
# Configuration options
|
||||||
option(BUILD_EXAMPLES "Build the examples." ${PROJECT_IS_TOP_LEVEL})
|
option(BUILD_EXAMPLES "Build the examples." ${PROJECT_IS_TOP_LEVEL})
|
||||||
|
|
|
@ -122,6 +122,8 @@ if (NOT ${OPENGL_VERSION} MATCHES "OFF")
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
||||||
elseif (${OPENGL_VERSION} MATCHES "ES 3.0")
|
elseif (${OPENGL_VERSION} MATCHES "ES 3.0")
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES3")
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES3")
|
||||||
|
elseif (${OPENGL_VERSION} MATCHES "Software")
|
||||||
|
set(GRAPHICS "GRAPHICS_API_OPENGL_11_SOFTWARE")
|
||||||
endif ()
|
endif ()
|
||||||
if (NOT "${SUGGESTED_GRAPHICS}" STREQUAL "" AND NOT "${SUGGESTED_GRAPHICS}" STREQUAL "${GRAPHICS}")
|
if (NOT "${SUGGESTED_GRAPHICS}" STREQUAL "" AND NOT "${SUGGESTED_GRAPHICS}" STREQUAL "${GRAPHICS}")
|
||||||
message(WARNING "You are overriding the suggested GRAPHICS=${SUGGESTED_GRAPHICS} with ${GRAPHICS}! This may fail.")
|
message(WARNING "You are overriding the suggested GRAPHICS=${SUGGESTED_GRAPHICS} with ${GRAPHICS}! This may fail.")
|
||||||
|
|
|
@ -113,6 +113,10 @@ elseif ("${PLATFORM}" STREQUAL "DRM")
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c)
|
||||||
|
|
||||||
|
elseif ("${OPENGL_VERSION}" STREQUAL "Software")
|
||||||
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
|
||||||
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c)
|
||||||
|
|
||||||
elseif (NOT SUPPORT_GESTURES_SYSTEM)
|
elseif (NOT SUPPORT_GESTURES_SYSTEM)
|
||||||
# Items requiring gestures system
|
# Items requiring gestures system
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/textures/textures_mouse_painting.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/textures/textures_mouse_painting.c)
|
||||||
|
|
18
src/Makefile
18
src/Makefile
|
@ -235,20 +235,22 @@ endif
|
||||||
# NOTE: By default use OpenGL 3.3 on desktop platforms
|
# NOTE: By default use OpenGL 3.3 on desktop platforms
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
||||||
GRAPHICS ?= GRAPHICS_API_OPENGL_33
|
GRAPHICS ?= GRAPHICS_API_OPENGL_33
|
||||||
#GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
|
#GRAPHICS = GRAPHICS_API_OPENGL_11_SOFTWARE # Uncomment to use software rendering
|
||||||
#GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
|
#GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
|
||||||
#GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3
|
#GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
|
||||||
#GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE)
|
#GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3
|
||||||
|
#GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE)
|
||||||
endif
|
endif
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
|
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
|
||||||
GRAPHICS ?= GRAPHICS_API_OPENGL_33
|
GRAPHICS ?= GRAPHICS_API_OPENGL_33
|
||||||
endif
|
endif
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
|
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
|
||||||
GRAPHICS ?= GRAPHICS_API_OPENGL_33
|
GRAPHICS ?= GRAPHICS_API_OPENGL_33
|
||||||
#GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
|
#GRAPHICS = GRAPHICS_API_OPENGL_11_SOFTWARE # Uncomment to use software rendering
|
||||||
#GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
|
#GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
|
||||||
#GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3
|
#GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
|
||||||
#GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE)
|
#GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3
|
||||||
|
#GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE)
|
||||||
endif
|
endif
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
||||||
# On DRM OpenGL ES 2.0 must be used
|
# On DRM OpenGL ES 2.0 must be used
|
||||||
|
|
5246
src/external/rlsw.h
vendored
Normal file
5246
src/external/rlsw.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -54,11 +54,13 @@
|
||||||
#endif
|
#endif
|
||||||
#include "SDL.h" // SDL base library (window/rendered, input, timing... functionality)
|
#include "SDL.h" // SDL base library (window/rendered, input, timing... functionality)
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
#if !defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||||
// It seems it does not need to be included to work
|
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
//#include "SDL_opengles2.h"
|
// It seems it does not need to be included to work
|
||||||
#else
|
//#include "SDL_opengles2.h"
|
||||||
#include "SDL_opengl.h" // SDL OpenGL functionality (if required, instead of internal renderer)
|
#else
|
||||||
|
#include "SDL_opengl.h" // SDL OpenGL functionality (if required, instead of internal renderer)
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -1215,7 +1217,14 @@ void DisableCursor(void)
|
||||||
// Swap back buffer with front buffer (screen drawing)
|
// Swap back buffer with front buffer (screen drawing)
|
||||||
void SwapScreenBuffer(void)
|
void SwapScreenBuffer(void)
|
||||||
{
|
{
|
||||||
|
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||||
|
// NOTE: We use a preprocessor condition here because `rlCopyFramebuffer` is only declared for software rendering
|
||||||
|
SDL_Surface* surface = SDL_GetWindowSurface(platform.window);
|
||||||
|
rlCopyFramebuffer(0, 0, CORE.Window.render.width, CORE.Window.render.height, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, surface->pixels);
|
||||||
|
SDL_UpdateWindowSurface(platform.window);
|
||||||
|
#else
|
||||||
SDL_GL_SwapWindow(platform.window);
|
SDL_GL_SwapWindow(platform.window);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -1895,7 +1904,6 @@ int InitPlatform(void)
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
flags |= SDL_WINDOW_SHOWN;
|
flags |= SDL_WINDOW_SHOWN;
|
||||||
flags |= SDL_WINDOW_OPENGL;
|
|
||||||
flags |= SDL_WINDOW_INPUT_FOCUS;
|
flags |= SDL_WINDOW_INPUT_FOCUS;
|
||||||
flags |= SDL_WINDOW_MOUSE_FOCUS;
|
flags |= SDL_WINDOW_MOUSE_FOCUS;
|
||||||
flags |= SDL_WINDOW_MOUSE_CAPTURE; // Window has mouse captured
|
flags |= SDL_WINDOW_MOUSE_CAPTURE; // Window has mouse captured
|
||||||
|
@ -1930,44 +1938,50 @@ int InitPlatform(void)
|
||||||
|
|
||||||
// NOTE: Some OpenGL context attributes must be set before window creation
|
// NOTE: Some OpenGL context attributes must be set before window creation
|
||||||
|
|
||||||
// Check selection OpenGL version
|
if (rlGetVersion() != RL_OPENGL_11_SOFTWARE)
|
||||||
if (rlGetVersion() == RL_OPENGL_21)
|
|
||||||
{
|
{
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
// Add the flag telling the window to use an OpenGL context
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
flags |= SDL_WINDOW_OPENGL;
|
||||||
}
|
|
||||||
else if (rlGetVersion() == RL_OPENGL_33)
|
|
||||||
{
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
|
||||||
}
|
|
||||||
else if (rlGetVersion() == RL_OPENGL_43)
|
|
||||||
{
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
|
||||||
#if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT)
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); // Enable OpenGL Debug Context
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (rlGetVersion() == RL_OPENGL_ES_20) // Request OpenGL ES 2.0 context
|
|
||||||
{
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
|
||||||
}
|
|
||||||
else if (rlGetVersion() == RL_OPENGL_ES_30) // Request OpenGL ES 3.0 context
|
|
||||||
{
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CORE.Window.flags & FLAG_MSAA_4X_HINT)
|
// Check selection OpenGL version
|
||||||
{
|
if (rlGetVersion() == RL_OPENGL_21)
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
{
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
||||||
|
}
|
||||||
|
else if (rlGetVersion() == RL_OPENGL_33)
|
||||||
|
{
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||||
|
}
|
||||||
|
else if (rlGetVersion() == RL_OPENGL_43)
|
||||||
|
{
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||||
|
#if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT)
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); // Enable OpenGL Debug Context
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (rlGetVersion() == RL_OPENGL_ES_20) // Request OpenGL ES 2.0 context
|
||||||
|
{
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||||
|
}
|
||||||
|
else if (rlGetVersion() == RL_OPENGL_ES_30) // Request OpenGL ES 3.0 context
|
||||||
|
{
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CORE.Window.flags & FLAG_MSAA_4X_HINT)
|
||||||
|
{
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init window
|
// Init window
|
||||||
|
@ -1978,10 +1992,12 @@ int InitPlatform(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Init OpenGL context
|
// Init OpenGL context
|
||||||
platform.glContext = SDL_GL_CreateContext(platform.window);
|
if (rlGetVersion() != RL_OPENGL_11_SOFTWARE)
|
||||||
|
{
|
||||||
|
platform.glContext = SDL_GL_CreateContext(platform.window);
|
||||||
|
}
|
||||||
|
|
||||||
// Check window and glContext have been initialized successfully
|
if ((platform.window != NULL) && ((rlGetVersion() == RL_OPENGL_11_SOFTWARE) || (platform.glContext != NULL)))
|
||||||
if ((platform.window != NULL) && (platform.glContext != NULL))
|
|
||||||
{
|
{
|
||||||
CORE.Window.ready = true;
|
CORE.Window.ready = true;
|
||||||
|
|
||||||
|
@ -2002,8 +2018,14 @@ int InitPlatform(void)
|
||||||
TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height);
|
TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height);
|
||||||
TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y);
|
TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y);
|
||||||
|
|
||||||
if (CORE.Window.flags & FLAG_VSYNC_HINT) SDL_GL_SetSwapInterval(1);
|
if (platform.glContext != NULL)
|
||||||
else SDL_GL_SetSwapInterval(0);
|
{
|
||||||
|
SDL_GL_SetSwapInterval((CORE.Window.flags & FLAG_VSYNC_HINT)? 1 : 0);
|
||||||
|
|
||||||
|
// Load OpenGL extensions
|
||||||
|
// NOTE: GL procedures address loader is required to load extensions
|
||||||
|
rlLoadExtensions(SDL_GL_GetProcAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2011,9 +2033,6 @@ int InitPlatform(void)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load OpenGL extensions
|
|
||||||
// NOTE: GL procedures address loader is required to load extensions
|
|
||||||
rlLoadExtensions(SDL_GL_GetProcAddress);
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Initialize input events system
|
// Initialize input events system
|
||||||
|
@ -2078,7 +2097,7 @@ int InitPlatform(void)
|
||||||
void ClosePlatform(void)
|
void ClosePlatform(void)
|
||||||
{
|
{
|
||||||
SDL_FreeCursor(platform.cursor); // Free cursor
|
SDL_FreeCursor(platform.cursor); // Free cursor
|
||||||
SDL_GL_DeleteContext(platform.glContext); // Deinitialize OpenGL context
|
if (platform.glContext != NULL) SDL_GL_DeleteContext(platform.glContext); // Deinitialize OpenGL context
|
||||||
SDL_DestroyWindow(platform.window);
|
SDL_DestroyWindow(platform.window);
|
||||||
SDL_Quit(); // Deinitialize SDL internal global state
|
SDL_Quit(); // Deinitialize SDL internal global state
|
||||||
}
|
}
|
||||||
|
|
85
src/rlgl.h
85
src/rlgl.h
|
@ -149,7 +149,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Security check in case no GRAPHICS_API_OPENGL_* defined
|
// Security check in case no GRAPHICS_API_OPENGL_* defined
|
||||||
#if !defined(GRAPHICS_API_OPENGL_11) && \
|
#if !defined(GRAPHICS_API_OPENGL_11_SOFTWARE) && \
|
||||||
|
!defined(GRAPHICS_API_OPENGL_11) && \
|
||||||
!defined(GRAPHICS_API_OPENGL_21) && \
|
!defined(GRAPHICS_API_OPENGL_21) && \
|
||||||
!defined(GRAPHICS_API_OPENGL_33) && \
|
!defined(GRAPHICS_API_OPENGL_33) && \
|
||||||
!defined(GRAPHICS_API_OPENGL_43) && \
|
!defined(GRAPHICS_API_OPENGL_43) && \
|
||||||
|
@ -159,7 +160,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Security check in case multiple GRAPHICS_API_OPENGL_* defined
|
// Security check in case multiple GRAPHICS_API_OPENGL_* defined
|
||||||
#if defined(GRAPHICS_API_OPENGL_11)
|
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||||
#if defined(GRAPHICS_API_OPENGL_21)
|
#if defined(GRAPHICS_API_OPENGL_21)
|
||||||
#undef GRAPHICS_API_OPENGL_21
|
#undef GRAPHICS_API_OPENGL_21
|
||||||
#endif
|
#endif
|
||||||
|
@ -174,6 +175,11 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Software implementation uses OpenGL 1.1 functionality
|
||||||
|
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||||
|
#define GRAPHICS_API_OPENGL_11
|
||||||
|
#endif
|
||||||
|
|
||||||
// OpenGL 2.1 uses most of OpenGL 3.3 Core functionality
|
// OpenGL 2.1 uses most of OpenGL 3.3 Core functionality
|
||||||
// WARNING: Specific parts are checked with #if defines
|
// WARNING: Specific parts are checked with #if defines
|
||||||
#if defined(GRAPHICS_API_OPENGL_21)
|
#if defined(GRAPHICS_API_OPENGL_21)
|
||||||
|
@ -427,7 +433,8 @@ typedef struct rlRenderBatch {
|
||||||
|
|
||||||
// OpenGL version
|
// OpenGL version
|
||||||
typedef enum {
|
typedef enum {
|
||||||
RL_OPENGL_11 = 1, // OpenGL 1.1
|
RL_OPENGL_11_SOFTWARE = 0, // Software rendering
|
||||||
|
RL_OPENGL_11, // OpenGL 1.1
|
||||||
RL_OPENGL_21, // OpenGL 2.1 (GLSL 120)
|
RL_OPENGL_21, // OpenGL 2.1 (GLSL 120)
|
||||||
RL_OPENGL_33, // OpenGL 3.3 (GLSL 330)
|
RL_OPENGL_33, // OpenGL 3.3 (GLSL 330)
|
||||||
RL_OPENGL_43, // OpenGL 4.3 (using GLSL 330)
|
RL_OPENGL_43, // OpenGL 4.3 (using GLSL 330)
|
||||||
|
@ -767,6 +774,10 @@ RLAPI unsigned int rlLoadFramebuffer(void); // Loa
|
||||||
RLAPI void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel); // Attach texture/renderbuffer to a framebuffer
|
RLAPI void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel); // Attach texture/renderbuffer to a framebuffer
|
||||||
RLAPI bool rlFramebufferComplete(unsigned int id); // Verify framebuffer is complete
|
RLAPI bool rlFramebufferComplete(unsigned int id); // Verify framebuffer is complete
|
||||||
RLAPI void rlUnloadFramebuffer(unsigned int id); // Delete framebuffer from GPU
|
RLAPI void rlUnloadFramebuffer(unsigned int id); // Delete framebuffer from GPU
|
||||||
|
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||||
|
RLAPI void rlCopyFramebuffer(int x, int y, int w, int h, int format, void* pixels);
|
||||||
|
RLAPI void rlResizeFramebuffer(int width, int height);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Shaders management
|
// Shaders management
|
||||||
RLAPI unsigned int rlLoadShaderCode(const char *vsCode, const char *fsCode); // Load shader from code strings
|
RLAPI unsigned int rlLoadShaderCode(const char *vsCode, const char *fsCode); // Load shader from code strings
|
||||||
|
@ -833,24 +844,32 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_11)
|
#if defined(GRAPHICS_API_OPENGL_11)
|
||||||
#if defined(__APPLE__)
|
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||||
#include <OpenGL/gl.h> // OpenGL 1.1 library for OSX
|
#define RLSW_IMPL
|
||||||
#include <OpenGL/glext.h> // OpenGL extensions library
|
#define SW_MALLOC(sz) RL_MALLOC(sz)
|
||||||
|
#define SW_REALLOC(ptr, newSz) RL_REALLOC(ptr, newSz)
|
||||||
|
#define SW_FREE(ptr) RL_FREE(ptr)
|
||||||
|
#include "external/rlsw.h" // OpenGL 1.1 software implementation
|
||||||
#else
|
#else
|
||||||
// APIENTRY for OpenGL function pointer declarations is required
|
#if defined(__APPLE__)
|
||||||
#if !defined(APIENTRY)
|
#include <OpenGL/gl.h> // OpenGL 1.1 library for OSX
|
||||||
#if defined(_WIN32)
|
#include <OpenGL/glext.h> // OpenGL extensions library
|
||||||
#define APIENTRY __stdcall
|
#else
|
||||||
#else
|
// APIENTRY for OpenGL function pointer declarations is required
|
||||||
#define APIENTRY
|
#if !defined(APIENTRY)
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#define APIENTRY __stdcall
|
||||||
|
#else
|
||||||
|
#define APIENTRY
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
// WINGDIAPI definition. Some Windows OpenGL headers need it
|
||||||
|
#if !defined(WINGDIAPI) && defined(_WIN32)
|
||||||
|
#define WINGDIAPI __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
// WINGDIAPI definition. Some Windows OpenGL headers need it
|
|
||||||
#if !defined(WINGDIAPI) && defined(_WIN32)
|
|
||||||
#define WINGDIAPI __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <GL/gl.h> // OpenGL 1.1 library
|
#include <GL/gl.h> // OpenGL 1.1 library
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2310,6 +2329,14 @@ void rlglInit(int width, int height)
|
||||||
glShadeModel(GL_SMOOTH); // Smooth shading between vertex (vertex colors interpolation)
|
glShadeModel(GL_SMOOTH); // Smooth shading between vertex (vertex colors interpolation)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||||
|
if (!swInit(width, height))
|
||||||
|
{
|
||||||
|
TRACELOG(RL_LOG_ERROR, "RLGL: Software renderer initialization failed!");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
// Store screen size into global variables
|
// Store screen size into global variables
|
||||||
RLGL.State.framebufferWidth = width;
|
RLGL.State.framebufferWidth = width;
|
||||||
|
@ -2336,6 +2363,10 @@ void rlglClose(void)
|
||||||
glDeleteTextures(1, &RLGL.State.defaultTextureId); // Unload default texture
|
glDeleteTextures(1, &RLGL.State.defaultTextureId); // Unload default texture
|
||||||
TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Default texture unloaded successfully", RLGL.State.defaultTextureId);
|
TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Default texture unloaded successfully", RLGL.State.defaultTextureId);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||||
|
swClose();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load OpenGL extensions
|
// Load OpenGL extensions
|
||||||
|
@ -2633,7 +2664,9 @@ void rlLoadExtensions(void *loader)
|
||||||
int rlGetVersion(void)
|
int rlGetVersion(void)
|
||||||
{
|
{
|
||||||
int glVersion = 0;
|
int glVersion = 0;
|
||||||
#if defined(GRAPHICS_API_OPENGL_11)
|
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||||
|
glVersion = RL_OPENGL_11_SOFTWARE;
|
||||||
|
#elif defined(GRAPHICS_API_OPENGL_11)
|
||||||
glVersion = RL_OPENGL_11;
|
glVersion = RL_OPENGL_11;
|
||||||
#endif
|
#endif
|
||||||
#if defined(GRAPHICS_API_OPENGL_21)
|
#if defined(GRAPHICS_API_OPENGL_21)
|
||||||
|
@ -3673,6 +3706,20 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format)
|
||||||
return pixels;
|
return pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||||
|
void rlCopyFramebuffer(int x, int y, int w, int h, int format, void* pixels)
|
||||||
|
{
|
||||||
|
unsigned int glInternalFormat, glFormat, glType;
|
||||||
|
rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType);
|
||||||
|
swCopyFramebuffer(x, y, w, h, glFormat, glType, pixels);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rlResizeFramebuffer(int width, int height)
|
||||||
|
{
|
||||||
|
swResizeFramebuffer(width, height);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Read screen pixel data (color buffer)
|
// Read screen pixel data (color buffer)
|
||||||
unsigned char *rlReadScreenPixels(int width, int height)
|
unsigned char *rlReadScreenPixels(int width, int height)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1421,7 +1421,7 @@ void UpdateMeshBuffer(Mesh mesh, int index, const void *data, int dataSize, int
|
||||||
// Draw a 3d mesh with material and transform
|
// Draw a 3d mesh with material and transform
|
||||||
void DrawMesh(Mesh mesh, Material material, Matrix transform)
|
void DrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS_API_OPENGL_11)
|
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||||
#define GL_VERTEX_ARRAY 0x8074
|
#define GL_VERTEX_ARRAY 0x8074
|
||||||
#define GL_NORMAL_ARRAY 0x8075
|
#define GL_NORMAL_ARRAY 0x8075
|
||||||
#define GL_COLOR_ARRAY 0x8076
|
#define GL_COLOR_ARRAY 0x8076
|
||||||
|
@ -1432,10 +1432,10 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
if (mesh.animVertices) rlEnableStatePointer(GL_VERTEX_ARRAY, mesh.animVertices);
|
if (mesh.animVertices) rlEnableStatePointer(GL_VERTEX_ARRAY, mesh.animVertices);
|
||||||
else rlEnableStatePointer(GL_VERTEX_ARRAY, mesh.vertices);
|
else rlEnableStatePointer(GL_VERTEX_ARRAY, mesh.vertices);
|
||||||
|
|
||||||
rlEnableStatePointer(GL_TEXTURE_COORD_ARRAY, mesh.texcoords);
|
if (mesh.animNormals) rlEnableStatePointer(GL_NORMAL_ARRAY, mesh.animNormals);
|
||||||
if (mesh.normals) rlEnableStatePointer(GL_VERTEX_ARRAY, mesh.animNormalss);
|
|
||||||
else rlEnableStatePointer(GL_NORMAL_ARRAY, mesh.normals);
|
else rlEnableStatePointer(GL_NORMAL_ARRAY, mesh.normals);
|
||||||
|
|
||||||
|
rlEnableStatePointer(GL_TEXTURE_COORD_ARRAY, mesh.texcoords);
|
||||||
rlEnableStatePointer(GL_COLOR_ARRAY, mesh.colors);
|
rlEnableStatePointer(GL_COLOR_ARRAY, mesh.colors);
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue