add glRenderbufferStorage binding
+ tweaks and fixes
This commit is contained in:
parent
e89c8a4440
commit
dc9d2c90bc
109
src/external/rlsw.h
vendored
109
src/external/rlsw.h
vendored
|
|
@ -314,6 +314,53 @@ typedef double GLclampd;
|
||||||
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
|
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
|
||||||
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
|
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
|
||||||
|
|
||||||
|
// OpenGL internal formats (not all are supported; see SWinternalformat)
|
||||||
|
#define GL_ALPHA4 0x803B
|
||||||
|
#define GL_ALPHA8 0x803C
|
||||||
|
#define GL_ALPHA12 0x803D
|
||||||
|
#define GL_ALPHA16 0x803E
|
||||||
|
#define GL_LUMINANCE4 0x803F
|
||||||
|
#define GL_LUMINANCE8 0x8040
|
||||||
|
#define GL_LUMINANCE12 0x8041
|
||||||
|
#define GL_LUMINANCE16 0x8042
|
||||||
|
#define GL_LUMINANCE4_ALPHA4 0x8043
|
||||||
|
#define GL_LUMINANCE6_ALPHA2 0x8044
|
||||||
|
#define GL_LUMINANCE8_ALPHA8 0x8045
|
||||||
|
#define GL_LUMINANCE12_ALPHA4 0x8046
|
||||||
|
#define GL_LUMINANCE12_ALPHA12 0x8047
|
||||||
|
#define GL_LUMINANCE16_ALPHA16 0x8048
|
||||||
|
#define GL_INTENSITY 0x8049
|
||||||
|
#define GL_INTENSITY4 0x804A
|
||||||
|
#define GL_INTENSITY8 0x804B
|
||||||
|
#define GL_INTENSITY12 0x804C
|
||||||
|
#define GL_INTENSITY16 0x804D
|
||||||
|
#define GL_R3_G3_B2 0x2A10
|
||||||
|
#define GL_RGB4 0x804F
|
||||||
|
#define GL_RGB5 0x8050
|
||||||
|
#define GL_RGB8 0x8051
|
||||||
|
#define GL_RGB10 0x8052
|
||||||
|
#define GL_RGB12 0x8053
|
||||||
|
#define GL_RGB16 0x8054
|
||||||
|
#define GL_RGBA2 0x8055
|
||||||
|
#define GL_RGBA4 0x8056
|
||||||
|
#define GL_RGB5_A1 0x8057
|
||||||
|
#define GL_RGBA8 0x8058
|
||||||
|
#define GL_RGB10_A2 0x8059
|
||||||
|
#define GL_RGBA12 0x805A
|
||||||
|
#define GL_RGBA16 0x805B
|
||||||
|
|
||||||
|
// OpenGL internal formats extension
|
||||||
|
#define GL_DEPTH_COMPONENT16 0x81A5
|
||||||
|
#define GL_DEPTH_COMPONENT24 0x81A6
|
||||||
|
#define GL_DEPTH_COMPONENT32 0x81A7
|
||||||
|
#define GL_DEPTH_COMPONENT32F 0x8CAC
|
||||||
|
#define GL_R16F 0x822D
|
||||||
|
#define GL_RGB16F 0x881B
|
||||||
|
#define GL_RGBA16F 0x881A
|
||||||
|
#define GL_R32F 0x822E
|
||||||
|
#define GL_RGB32F 0x8815
|
||||||
|
#define GL_RGBA32F 0x8814
|
||||||
|
|
||||||
// OpenGL GL_EXT_framebuffer_object
|
// OpenGL GL_EXT_framebuffer_object
|
||||||
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
|
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
|
||||||
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
|
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
|
||||||
|
|
@ -426,6 +473,8 @@ typedef double GLclampd;
|
||||||
#define glGetFramebufferAttachmentParameteriv(tr, a, p, v) swGetFramebufferAttachmentParameteriv((a), (p), (v))
|
#define glGetFramebufferAttachmentParameteriv(tr, a, p, v) swGetFramebufferAttachmentParameteriv((a), (p), (v))
|
||||||
#define glGenRenderbuffers(c, v) swGenTextures((c), (v))
|
#define glGenRenderbuffers(c, v) swGenTextures((c), (v))
|
||||||
#define glDeleteRenderbuffers(c, v) swDeleteTextures((c), (v))
|
#define glDeleteRenderbuffers(c, v) swDeleteTextures((c), (v))
|
||||||
|
#define glBindRenderbuffer(tr, rb) swBindTexture((rb))
|
||||||
|
#define glRenderbufferStorage(tr, f, w, h) swTexStorage2D((w), (h), (f))
|
||||||
|
|
||||||
// OpenGL functions NOT IMPLEMENTED by rlsw
|
// OpenGL functions NOT IMPLEMENTED by rlsw
|
||||||
#define glDepthMask(X) ((void)(X))
|
#define glDepthMask(X) ((void)(X))
|
||||||
|
|
@ -543,6 +592,27 @@ typedef enum {
|
||||||
SW_FLOAT = GL_FLOAT
|
SW_FLOAT = GL_FLOAT
|
||||||
} SWtype;
|
} SWtype;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SW_LUMINANCE8 = GL_LUMINANCE8,
|
||||||
|
SW_LUMINANCE8_ALPHA8 = GL_LUMINANCE8_ALPHA8,
|
||||||
|
SW_R3_G3_B2 = GL_R3_G3_B2,
|
||||||
|
SW_RGB8 = GL_RGB8,
|
||||||
|
SW_RGBA4 = GL_RGBA4,
|
||||||
|
SW_RGB5_A1 = GL_RGB5_A1,
|
||||||
|
SW_RGBA8 = GL_RGBA8,
|
||||||
|
SW_R16F = GL_R16F,
|
||||||
|
SW_RGB16F = GL_RGB16F,
|
||||||
|
SW_RGBA16F = GL_RGBA16F,
|
||||||
|
SW_R32F = GL_R32F,
|
||||||
|
SW_RGB32F = GL_RGB32F,
|
||||||
|
SW_RGBA32F = GL_RGBA32F,
|
||||||
|
SW_DEPTH_COMPONENT16 = GL_DEPTH_COMPONENT16,
|
||||||
|
SW_DEPTH_COMPONENT24 = GL_DEPTH_COMPONENT24,
|
||||||
|
SW_DEPTH_COMPONENT32 = GL_DEPTH_COMPONENT32,
|
||||||
|
SW_DEPTH_COMPONENT32F = GL_DEPTH_COMPONENT32F,
|
||||||
|
//SW_R5_G6_B5, // Not defined by OpenGL
|
||||||
|
} SWinternalformat;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SW_NEAREST = GL_NEAREST,
|
SW_NEAREST = GL_NEAREST,
|
||||||
SW_LINEAR = GL_LINEAR
|
SW_LINEAR = GL_LINEAR
|
||||||
|
|
@ -4146,6 +4216,8 @@ void swClearDepth(float depth)
|
||||||
|
|
||||||
void swClear(uint32_t bitmask)
|
void swClear(uint32_t bitmask)
|
||||||
{
|
{
|
||||||
|
if (!sw_is_ready_to_render()) return;
|
||||||
|
|
||||||
if ((bitmask & (SW_COLOR_BUFFER_BIT)) && (RLSW.colorBuffer != NULL) && (RLSW.colorBuffer->pixels != NULL))
|
if ((bitmask & (SW_COLOR_BUFFER_BIT)) && (RLSW.colorBuffer != NULL) && (RLSW.colorBuffer->pixels != NULL))
|
||||||
{
|
{
|
||||||
int size = RLSW.colorBuffer->width*RLSW.colorBuffer->height;
|
int size = RLSW.colorBuffer->width*RLSW.colorBuffer->height;
|
||||||
|
|
@ -4887,8 +4959,12 @@ void swDeleteTextures(int count, sw_handle_t *textures)
|
||||||
sw_texture_t *tex = sw_pool_get(&RLSW.texturePool, textures[i]);
|
sw_texture_t *tex = sw_pool_get(&RLSW.texturePool, textures[i]);
|
||||||
if (!tex) { RLSW.errCode = SW_INVALID_VALUE; continue; }
|
if (!tex) { RLSW.errCode = SW_INVALID_VALUE; continue; }
|
||||||
if (tex == RLSW.boundTexture) RLSW.boundTexture = NULL;
|
if (tex == RLSW.boundTexture) RLSW.boundTexture = NULL;
|
||||||
|
if (tex == RLSW.colorBuffer) RLSW.colorBuffer = NULL;
|
||||||
|
if (tex == RLSW.depthBuffer) RLSW.depthBuffer = NULL;
|
||||||
|
|
||||||
sw_texture_free(tex);
|
sw_texture_free(tex);
|
||||||
|
*tex = (sw_texture_t) { 0 };
|
||||||
|
|
||||||
sw_pool_free(&RLSW.texturePool, textures[i]);
|
sw_pool_free(&RLSW.texturePool, textures[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4901,6 +4977,38 @@ void swBindTexture(sw_handle_t id)
|
||||||
RLSW.boundTexture = sw_pool_get(&RLSW.texturePool, id);
|
RLSW.boundTexture = sw_pool_get(&RLSW.texturePool, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void swTexStorage2D(int width, int height, SWinternalformat format)
|
||||||
|
{
|
||||||
|
if (RLSW.boundTexture == NULL) return;
|
||||||
|
|
||||||
|
int pixelFormat = SW_PIXELFORMAT_UNKNOWN;
|
||||||
|
switch (format)
|
||||||
|
{
|
||||||
|
case SW_LUMINANCE8: pixelFormat = SW_PIXELFORMAT_COLOR_GRAYSCALE; break;
|
||||||
|
case SW_LUMINANCE8_ALPHA8: pixelFormat = SW_PIXELFORMAT_COLOR_GRAYALPHA; break;
|
||||||
|
case SW_R3_G3_B2: pixelFormat = SW_PIXELFORMAT_COLOR_R3G3B2; break;
|
||||||
|
case SW_RGB8: pixelFormat = SW_PIXELFORMAT_COLOR_R8G8B8; break;
|
||||||
|
case SW_RGBA4: pixelFormat = SW_PIXELFORMAT_COLOR_R4G4B4A4; break;
|
||||||
|
case SW_RGB5_A1: pixelFormat = SW_PIXELFORMAT_COLOR_R5G5B5A1; break;
|
||||||
|
case SW_RGBA8: pixelFormat = SW_PIXELFORMAT_COLOR_R8G8B8A8; break;
|
||||||
|
case SW_R16F: pixelFormat = SW_PIXELFORMAT_COLOR_R16; break;
|
||||||
|
case SW_RGB16F: pixelFormat = SW_PIXELFORMAT_COLOR_R16G16B16; break;
|
||||||
|
case SW_RGBA16F: pixelFormat = SW_PIXELFORMAT_COLOR_R16G16B16A16; break;
|
||||||
|
case SW_R32F: pixelFormat = SW_PIXELFORMAT_COLOR_R32; break;
|
||||||
|
case SW_RGB32F: pixelFormat = SW_PIXELFORMAT_COLOR_R32G32B32; break;
|
||||||
|
case SW_RGBA32F: pixelFormat = SW_PIXELFORMAT_COLOR_R32G32B32A32; break;
|
||||||
|
case SW_DEPTH_COMPONENT16: pixelFormat = SW_PIXELFORMAT_DEPTH_D16; break;
|
||||||
|
case SW_DEPTH_COMPONENT24: pixelFormat = SW_PIXELFORMAT_DEPTH_D32; break;
|
||||||
|
case SW_DEPTH_COMPONENT32: pixelFormat = SW_PIXELFORMAT_DEPTH_D32; break;
|
||||||
|
case SW_DEPTH_COMPONENT32F: pixelFormat = SW_PIXELFORMAT_DEPTH_D32; break;
|
||||||
|
default:
|
||||||
|
RLSW.errCode = SW_INVALID_ENUM;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)sw_texture_alloc(RLSW.boundTexture, NULL, width, height, pixelFormat);
|
||||||
|
}
|
||||||
|
|
||||||
void swTexImage2D(int width, int height, SWformat format, SWtype type, const void *data)
|
void swTexImage2D(int width, int height, SWformat format, SWtype type, const void *data)
|
||||||
{
|
{
|
||||||
if (RLSW.boundTexture == NULL) return;
|
if (RLSW.boundTexture == NULL) return;
|
||||||
|
|
@ -4908,7 +5016,6 @@ void swTexImage2D(int width, int height, SWformat format, SWtype type, const voi
|
||||||
int pixelFormat = sw_pixel_get_format(format, type);
|
int pixelFormat = sw_pixel_get_format(format, type);
|
||||||
if (pixelFormat <= SW_PIXELFORMAT_UNKNOWN) { RLSW.errCode = SW_INVALID_ENUM; return; }
|
if (pixelFormat <= SW_PIXELFORMAT_UNKNOWN) { RLSW.errCode = SW_INVALID_ENUM; return; }
|
||||||
|
|
||||||
*RLSW.boundTexture = (sw_texture_t){ 0 };
|
|
||||||
(void)sw_texture_alloc(RLSW.boundTexture, data, width, height, pixelFormat);
|
(void)sw_texture_alloc(RLSW.boundTexture, data, width, height, pixelFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user