mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
OpenGL 1.0 fallback attempt
This commit is contained in:
parent
14f3b610e8
commit
343bd7413a
@ -654,6 +654,51 @@ static void APIENTRY legacy_bufferSubData(GLenum target, cc_uintptr offset, cc_u
|
||||
}
|
||||
|
||||
|
||||
static void APIENTRY gl10_bindTexture(GLenum target, GLuint texture) {
|
||||
|
||||
}
|
||||
static void APIENTRY gl10_deleteTexture(GLsizei n, const GLuint* textures) {
|
||||
|
||||
}
|
||||
static void APIENTRY gl10_genTexture(GLsizei n, GLuint* textures) {
|
||||
|
||||
}
|
||||
static void APIENTRY gl10_texImage(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) {
|
||||
|
||||
}
|
||||
static void APIENTRY gl10_texSubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) {
|
||||
|
||||
}
|
||||
|
||||
static cc_uint8* gl10_vb;
|
||||
static void APIENTRY gl10_drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) {
|
||||
/* TODO */
|
||||
int i;
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
if (gfx_format == VERTEX_FORMAT_TEXTURED) {
|
||||
struct VertexTextured* src = (struct VertexTextured*)gl10_vb;
|
||||
for (i = 0; i < count; i++, src++) {
|
||||
glVertex3f(src->x, src->y, src->z);
|
||||
}
|
||||
} else {
|
||||
struct VertexColoured* src = (struct VertexColoured*)gl10_vb;
|
||||
for (i = 0; i < count; i++, src++) {
|
||||
glVertex3f(src->x, src->y, src->z);
|
||||
}
|
||||
}
|
||||
|
||||
glEnd();
|
||||
}
|
||||
static void APIENTRY gl10_colorPointer(GLint size, GLenum type, GLsizei stride, GLpointer offset) {
|
||||
}
|
||||
static void APIENTRY gl10_texCoordPointer(GLint size, GLenum type, GLsizei stride, GLpointer offset) {
|
||||
}
|
||||
static void APIENTRY gl10_vertexPointer(GLint size, GLenum type, GLsizei stride, GLpointer offset) {
|
||||
gl10_vb = cur_vb->data + offset;
|
||||
}
|
||||
|
||||
|
||||
static void APIENTRY gl11_drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) {
|
||||
_realDrawElements(mode, count, type, (cc_uintptr)indices + cur_ib->data);
|
||||
}
|
||||
@ -686,6 +731,19 @@ static void FallbackOpenGL(void) {
|
||||
|
||||
_glDrawElements = gl11_drawElements; _glColorPointer = gl11_colorPointer;
|
||||
_glTexCoordPointer = gl11_texCoordPointer; _glVertexPointer = gl11_vertexPointer;
|
||||
|
||||
/* OpenGL 1.0 fallback support */
|
||||
if (_realDrawElements) return;
|
||||
Window_ShowDialog("Performance warning", "OpenGL 1.0 only support, expect awful performance");
|
||||
|
||||
_glDrawElements = gl10_drawElements; _glColorPointer = gl10_colorPointer;
|
||||
_glTexCoordPointer = gl10_texCoordPointer; _glVertexPointer = gl10_vertexPointer;
|
||||
|
||||
_glBindTexture = gl10_bindTexture;
|
||||
_glGenTextures = gl10_genTexture;
|
||||
_glDeleteTextures = gl10_deleteTexture;
|
||||
_glTexImage2D = gl10_texImage;
|
||||
_glTexSubImage2D = gl10_texSubImage;
|
||||
}
|
||||
#else
|
||||
/* No point in even trying for other systems */
|
||||
|
@ -48,9 +48,14 @@ GL_FUNC(void, glGetFloatv)(GLenum pname, GLfloat* params);
|
||||
GL_FUNC(void, glGetIntegerv)(GLenum pname, GLint* params);
|
||||
GL_FUNC(const GLubyte*, glGetString)(GLenum name);
|
||||
|
||||
/* Display list functions */
|
||||
/* Legacy display list functions */
|
||||
GL_FUNC(void, glCallList)(GLuint list);
|
||||
GL_FUNC(void, glDeleteLists)(GLuint list, GLsizei range);
|
||||
GL_FUNC(GLuint, glGenLists)(GLsizei range);
|
||||
GL_FUNC(void, glNewList)(GLuint list, GLenum mode);
|
||||
GL_FUNC(void, glEndList)(void);
|
||||
GL_FUNC(void, glEndList)(void);
|
||||
|
||||
/* Legacy vertex draw functions */
|
||||
GL_FUNC(void, glBegin)(GLenum mode);
|
||||
GL_FUNC(void, glEnd)(void);
|
||||
GL_FUNC(void, glVertex3f)(float x, float y, float z);
|
@ -113,17 +113,17 @@ static CC_NOINLINE void UpdateTextureSlow(int x, int y, struct Bitmap* part, int
|
||||
CopyTextureData(ptr, part->width << 2, part, rowWidth << 2);
|
||||
|
||||
if (full) {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, part->width, part->height, 0, PIXEL_FORMAT, TRANSFER_FORMAT, ptr);
|
||||
_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, part->width, part->height, 0, PIXEL_FORMAT, TRANSFER_FORMAT, ptr);
|
||||
} else {
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, part->width, part->height, PIXEL_FORMAT, TRANSFER_FORMAT, ptr);
|
||||
_glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, part->width, part->height, PIXEL_FORMAT, TRANSFER_FORMAT, ptr);
|
||||
}
|
||||
if (count > UPDATE_FAST_SIZE) Mem_Free(ptr);
|
||||
}
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GLuint texId;
|
||||
glGenTextures(1, &texId);
|
||||
glBindTexture(GL_TEXTURE_2D, texId);
|
||||
GfxResourceID texId = NULL;
|
||||
_glGenTextures(1, (GLuint*)&texId);
|
||||
_glBindTexture(GL_TEXTURE_2D, ptr_to_uint(texId));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
if (mipmaps) {
|
||||
@ -143,11 +143,11 @@ static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8
|
||||
}
|
||||
|
||||
if (mipmaps) Gfx_DoMipmaps(0, 0, bmp, rowWidth, false);
|
||||
return uint_to_ptr(texId);
|
||||
return texId;
|
||||
}
|
||||
|
||||
void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, int rowWidth, cc_bool mipmaps) {
|
||||
glBindTexture(GL_TEXTURE_2D, ptr_to_uint(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);
|
||||
@ -160,7 +160,7 @@ void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, i
|
||||
|
||||
void Gfx_DeleteTexture(GfxResourceID* texId) {
|
||||
GLuint id = ptr_to_uint(*texId);
|
||||
if (id) glDeleteTextures(1, &id);
|
||||
if (id) _glDeleteTextures(1, &id);
|
||||
*texId = 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user