mirror of
https://github.com/raysan5/raylib.git
synced 2026-04-11 09:39:09 -04:00
REVIEWED: Software renderer flag, renamed to GRAPHICS_API_OPENGL_SOFTWARE
Dropped the `11` relative to OpenGL 1.1 because latest `rlsw 1.5` also includes support for FBOs and could potentially implemented other higher level features in the feature, discerning from OpenGL 1.1 limitations
This commit is contained in:
42
src/rlgl.h
42
src/rlgl.h
@ -21,7 +21,7 @@
|
||||
* Internal buffer (and resources) must be manually unloaded calling rlglClose()
|
||||
*
|
||||
* CONFIGURATION:
|
||||
* #define GRAPHICS_API_OPENGL_11_SOFTWARE
|
||||
* #define GRAPHICS_API_OPENGL_SOFTWARE
|
||||
* #define GRAPHICS_API_OPENGL_11
|
||||
* #define GRAPHICS_API_OPENGL_21
|
||||
* #define GRAPHICS_API_OPENGL_33
|
||||
@ -145,7 +145,7 @@
|
||||
#endif
|
||||
|
||||
// Security check in case no GRAPHICS_API_OPENGL_* defined
|
||||
#if !defined(GRAPHICS_API_OPENGL_11_SOFTWARE) && \
|
||||
#if !defined(GRAPHICS_API_OPENGL_SOFTWARE) && \
|
||||
!defined(GRAPHICS_API_OPENGL_11) && \
|
||||
!defined(GRAPHICS_API_OPENGL_21) && \
|
||||
!defined(GRAPHICS_API_OPENGL_33) && \
|
||||
@ -156,7 +156,7 @@
|
||||
#endif
|
||||
|
||||
// Security check in case multiple GRAPHICS_API_OPENGL_* defined
|
||||
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_SOFTWARE)
|
||||
#if defined(GRAPHICS_API_OPENGL_21)
|
||||
#undef GRAPHICS_API_OPENGL_21
|
||||
#endif
|
||||
@ -172,7 +172,7 @@
|
||||
#endif
|
||||
|
||||
// Software implementation uses OpenGL 1.1 functionality
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
#if defined(GRAPHICS_API_OPENGL_SOFTWARE)
|
||||
#define GRAPHICS_API_OPENGL_11
|
||||
#endif
|
||||
|
||||
@ -423,7 +423,7 @@ typedef struct rlRenderBatch {
|
||||
|
||||
// OpenGL version
|
||||
typedef enum {
|
||||
RL_OPENGL_11_SOFTWARE = 0, // Software rendering
|
||||
RL_OPENGL_SOFTWARE = 0, // Software rendering
|
||||
RL_OPENGL_11, // OpenGL 1.1
|
||||
RL_OPENGL_21, // OpenGL 2.1 (GLSL 120)
|
||||
RL_OPENGL_33, // OpenGL 3.3 (GLSL 330)
|
||||
@ -835,7 +835,7 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
#if defined(GRAPHICS_API_OPENGL_SOFTWARE)
|
||||
#define RLSW_IMPLEMENTATION
|
||||
#define SW_MALLOC(sz) RL_MALLOC(sz)
|
||||
#define SW_CALLOC(n,sz) RL_CALLOC(n, sz)
|
||||
@ -1858,7 +1858,7 @@ void rlDisableShader(void)
|
||||
// Enable rendering to texture (fbo)
|
||||
void rlEnableFramebuffer(unsigned int id)
|
||||
{
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_11_SOFTWARE))
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, id);
|
||||
#endif
|
||||
}
|
||||
@ -1867,7 +1867,7 @@ void rlEnableFramebuffer(unsigned int id)
|
||||
unsigned int rlGetActiveFramebuffer(void)
|
||||
{
|
||||
GLint fboId = 0;
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3) || defined(GRAPHICS_API_OPENGL_11_SOFTWARE))
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
|
||||
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &fboId);
|
||||
#endif
|
||||
return fboId;
|
||||
@ -1876,7 +1876,7 @@ unsigned int rlGetActiveFramebuffer(void)
|
||||
// Disable rendering to texture
|
||||
void rlDisableFramebuffer(void)
|
||||
{
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_11_SOFTWARE))
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
#endif
|
||||
}
|
||||
@ -1892,7 +1892,7 @@ void rlBlitFramebuffer(int srcX, int srcY, int srcWidth, int srcHeight, int dstX
|
||||
// Bind framebuffer object (fbo)
|
||||
void rlBindFramebuffer(unsigned int target, unsigned int framebuffer)
|
||||
{
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_11_SOFTWARE))
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
|
||||
glBindFramebuffer(target, framebuffer);
|
||||
#endif
|
||||
}
|
||||
@ -2325,7 +2325,7 @@ void rlglInit(int width, int height)
|
||||
RLGL.State.currentMatrix = &RLGL.State.modelview;
|
||||
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
#if defined(GRAPHICS_API_OPENGL_SOFTWARE)
|
||||
// Initialize software renderer backend
|
||||
int result = swInit(width, height);
|
||||
if (result == 0)
|
||||
@ -2387,7 +2387,7 @@ void rlglClose(void)
|
||||
TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Default texture unloaded successfully", RLGL.State.defaultTextureId);
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
#if defined(GRAPHICS_API_OPENGL_SOFTWARE)
|
||||
swClose(); // Unload sofware renderer resources
|
||||
#endif
|
||||
isGpuReady = false;
|
||||
@ -2702,8 +2702,8 @@ int rlGetVersion(void)
|
||||
{
|
||||
int glVersion = 0;
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
glVersion = RL_OPENGL_11_SOFTWARE;
|
||||
#if defined(GRAPHICS_API_OPENGL_SOFTWARE)
|
||||
glVersion = RL_OPENGL_SOFTWARE;
|
||||
#elif defined(GRAPHICS_API_OPENGL_11)
|
||||
glVersion = RL_OPENGL_11;
|
||||
#endif
|
||||
@ -3472,7 +3472,7 @@ unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer)
|
||||
|
||||
TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Depth renderbuffer loaded successfully (%i bits)", id, (RLGL.ExtSupported.maxDepthBits >= 24)? RLGL.ExtSupported.maxDepthBits : 16);
|
||||
}
|
||||
#elif defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
#elif defined(GRAPHICS_API_OPENGL_SOFTWARE)
|
||||
// NOTE: Renderbuffers are the same type of object as textures in rlsw
|
||||
// WARNING: Ensure that the depth format is the one specified at rlsw compilation
|
||||
glGenRenderbuffers(1, &id);
|
||||
@ -3776,7 +3776,7 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format)
|
||||
// Copy framebuffer pixel data to internal buffer
|
||||
void rlCopyFramebuffer(int x, int y, int width, int height, int format, void *pixels)
|
||||
{
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
#if defined(GRAPHICS_API_OPENGL_SOFTWARE)
|
||||
unsigned int glInternalFormat, glFormat, glType;
|
||||
rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); // Get OpenGL texture format
|
||||
swReadPixels(x, y, width, height, glFormat, glType, pixels);
|
||||
@ -3786,7 +3786,7 @@ void rlCopyFramebuffer(int x, int y, int width, int height, int format, void *pi
|
||||
// Resize internal framebuffer
|
||||
void rlResizeFramebuffer(int width, int height)
|
||||
{
|
||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||
#if defined(GRAPHICS_API_OPENGL_SOFTWARE)
|
||||
swResize(width, height);
|
||||
#endif
|
||||
}
|
||||
@ -3837,7 +3837,7 @@ unsigned int rlLoadFramebuffer(void)
|
||||
unsigned int fboId = 0;
|
||||
if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return fboId; }
|
||||
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_11_SOFTWARE))
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
|
||||
glGenFramebuffers(1, &fboId); // Create the framebuffer object
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0); // Unbind any framebuffer
|
||||
#endif
|
||||
@ -3849,7 +3849,7 @@ unsigned int rlLoadFramebuffer(void)
|
||||
// NOTE: Attach type: 0-Color, 1-Depth renderbuffer, 2-Depth texture
|
||||
void rlFramebufferAttach(unsigned int id, unsigned int texId, int attachType, int texType, int mipLevel)
|
||||
{
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_11_SOFTWARE))
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, id);
|
||||
|
||||
switch (attachType)
|
||||
@ -3889,7 +3889,7 @@ bool rlFramebufferComplete(unsigned int id)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_11_SOFTWARE))
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, id);
|
||||
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
@ -3920,7 +3920,7 @@ bool rlFramebufferComplete(unsigned int id)
|
||||
// NOTE: All attached textures/cubemaps/renderbuffers are also deleted
|
||||
void rlUnloadFramebuffer(unsigned int id)
|
||||
{
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_11_SOFTWARE))
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_SOFTWARE))
|
||||
// Query depth attachment to automatically delete texture/renderbuffer
|
||||
int depthType = 0;
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, id); // Bind framebuffer to query depth texture type
|
||||
|
||||
Reference in New Issue
Block a user