Start making OpenGL 1.1 fallback 64 bit compatible

This commit is contained in:
UnknownShadow200 2022-04-10 21:38:01 +10:00
parent aa793891cc
commit 771da4cd6e
2 changed files with 18 additions and 32 deletions

View File

@ -200,16 +200,19 @@ static void LoadCoreFuncs(void) {
*-------------------------------------------------------Index buffers-----------------------------------------------------* *-------------------------------------------------------Index buffers-----------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
#ifndef CC_BUILD_GL11 #ifndef CC_BUILD_GL11
static GLuint GL_GenAndBind(GLenum target) { static GfxResourceID GL_GenBuffer(void) {
GLuint id; GLuint id;
_glGenBuffers(1, &id); _glGenBuffers(1, &id);
_glBindBuffer(target, id);
return id; return id;
} }
static GfxResourceID (*_genBuffer)(void) = GL_GenBuffer;
GfxResourceID Gfx_CreateIb(void* indices, int indicesCount) { GfxResourceID Gfx_CreateIb(void* indices, int indicesCount) {
GLuint id = GL_GenAndBind(GL_ELEMENT_ARRAY_BUFFER); GfxResourceID id = _genBuffer();
cc_uint32 size = indicesCount * 2; cc_uint32 size = indicesCount * 2;
_glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id);
_glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, indices, GL_STATIC_DRAW); _glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, indices, GL_STATIC_DRAW);
return id; return id;
} }
@ -234,7 +237,9 @@ void Gfx_DeleteIb(GfxResourceID* ib) { }
*#########################################################################################################################*/ *#########################################################################################################################*/
#ifndef CC_BUILD_GL11 #ifndef CC_BUILD_GL11
GfxResourceID Gfx_CreateVb(VertexFormat fmt, int count) { GfxResourceID Gfx_CreateVb(VertexFormat fmt, int count) {
return GL_GenAndBind(GL_ARRAY_BUFFER); GfxResourceID id = _genBuffer();
_glBindBuffer(GL_ARRAY_BUFFER, id);
return id;
} }
void Gfx_BindVb(GfxResourceID vb) { _glBindBuffer(GL_ARRAY_BUFFER, (GLuint)vb); } void Gfx_BindVb(GfxResourceID vb) { _glBindBuffer(GL_ARRAY_BUFFER, (GLuint)vb); }
@ -306,12 +311,14 @@ GfxResourceID Gfx_CreateVb2(void* vertices, VertexFormat fmt, int count) {
*#########################################################################################################################*/ *#########################################################################################################################*/
#ifndef CC_BUILD_GL11 #ifndef CC_BUILD_GL11
GfxResourceID Gfx_CreateDynamicVb(VertexFormat fmt, int maxVertices) { GfxResourceID Gfx_CreateDynamicVb(VertexFormat fmt, int maxVertices) {
GLuint id; GfxResourceID id;
cc_uint32 size; cc_uint32 size;
if (Gfx.LostContext) return 0; if (Gfx.LostContext) return 0;
id = GL_GenAndBind(GL_ARRAY_BUFFER); id = _genBuffer();
size = maxVertices * strideSizes[fmt]; size = maxVertices * strideSizes[fmt];
_glBindBuffer(GL_ARRAY_BUFFER, id);
_glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW); _glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
return id; return id;
} }
@ -509,10 +516,8 @@ static void APIENTRY fake_deleteBuffers(GLsizei n, const GLuint *buffers) {
Mem_Free((void*)buffers[0]); Mem_Free((void*)buffers[0]);
} }
static void APIENTRY fake_genBuffers(GLsizei n, GLuint *buffers) { static GfxResourceID GenFakeBuffer(void) {
fake_buffer* buffer = (fake_buffer*)Mem_TryAlloc(1, sizeof(fake_buffer)); return (GfxResourceID)Mem_TryAllocCleared(1, sizeof(fake_buffer));
buffer->data = NULL;
buffers[0] = (GLuint)buffer;
} }
static void APIENTRY fake_bufferData(GLenum target, cc_uintptr size, const GLvoid* data, GLenum usage) { static void APIENTRY fake_bufferData(GLenum target, cc_uintptr size, const GLvoid* data, GLenum usage) {
@ -549,7 +554,7 @@ static void OpenGL11Fallback(void) {
customMipmapsLevels = false; customMipmapsLevels = false;
_glBindBuffer = fake_bindBuffer; _glDeleteBuffers = fake_deleteBuffers; _glBindBuffer = fake_bindBuffer; _glDeleteBuffers = fake_deleteBuffers;
_glGenBuffers = fake_genBuffers; _glBufferData = fake_bufferData; _genBuffer = GenFakeBuffer; _glBufferData = fake_bufferData;
_glBufferSubData = fake_bufferSubData; _glBufferSubData = fake_bufferSubData;
_glDrawElements = fake_drawElements; _glColorPointer = fake_colorPointer; _glDrawElements = fake_drawElements; _glColorPointer = fake_colorPointer;

View File

@ -300,7 +300,7 @@ void Window_DrawFramebuffer(Rect2D r) {
rect.origin.y = WindowInfo.Height - r.Y - r.Height; rect.origin.y = WindowInfo.Height - r.Y - r.Height;
rect.size.width = r.Width; rect.size.width = r.Width;
rect.size.height = r.Height; rect.size.height = r.Height;
view_handle.layer.contents = CFBridgingRelease(CGBitmapContextCreateImage(win_ctx)); win_handle.layer.contents = CFBridgingRelease(CGBitmapContextCreateImage(win_ctx));
// TODO always redraws entire launcher which is quite terrible performance wise // TODO always redraws entire launcher which is quite terrible performance wise
//[win_handle setNeedsDisplayInRect:rect]; //[win_handle setNeedsDisplayInRect:rect];
} }
@ -621,8 +621,6 @@ static NSString* cellID = @"CC_Cell";
btn->OnClick(btn); btn->OnClick(btn);
} }
<<<<<<< HEAD
=======
- (void)handleTextChanged:(id)sender { - (void)handleTextChanged:(id)sender {
struct LWidget* w = FindWidgetForView(sender); struct LWidget* w = FindWidgetForView(sender);
if (w == NULL) return; if (w == NULL) return;
@ -669,7 +667,6 @@ void LBackend_Init(void) {
/*########################################################################################################################* /*########################################################################################################################*
*------------------------------------------------------ButtonWidget-------------------------------------------------------* *------------------------------------------------------ButtonWidget-------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
>>>>>>> b2e96605 (ios: WIP on native table widget)
void LBackend_ButtonInit(struct LButton* w, int width, int height) { void LBackend_ButtonInit(struct LButton* w, int width, int height) {
UIButton* btn = [[UIButton alloc] init]; UIButton* btn = [[UIButton alloc] init];
btn.frame = CGRectMake(0, 0, width, height); btn.frame = CGRectMake(0, 0, width, height);
@ -720,22 +717,6 @@ void LBackend_CheckboxDraw(struct LCheckbox* w) {
/*########################################################################################################################* /*########################################################################################################################*
*------------------------------------------------------InputWidget--------------------------------------------------------* *------------------------------------------------------InputWidget--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
<<<<<<< HEAD
static void LBackend_HandleInput(id ipt_obj) {
struct LWidget* w = FindWidgetForView(ipt_obj);
if (w == NULL) return;
UITextField* src = (UITextField*)ipt_obj;
const char* str = [[src text] UTF8String];
struct LInput* ipt = (struct LInput*)w;
ipt->text.length = 0;
String_AppendUtf8(&ipt->text, str, String_Length(str));
if (ipt->TextChanged) ipt->TextChanged(ipt);
}
=======
>>>>>>> b2e96605 (ios: WIP on native table widget)
void LBackend_InputInit(struct LInput* w, int width) { void LBackend_InputInit(struct LInput* w, int width) {
UITextField* fld = [[UITextField alloc] init]; UITextField* fld = [[UITextField alloc] init];
fld.frame = CGRectMake(0, 0, width, 30); fld.frame = CGRectMake(0, 0, width, 30);