GLdc/GL/flush.c

120 lines
3.1 KiB
C
Raw Normal View History

2018-05-05 19:38:55 +00:00
#include "../containers/aligned_vector.h"
#include "private.h"
2021-05-08 13:38:55 +00:00
PolyList OP_LIST;
PolyList PT_LIST;
PolyList TR_LIST;
2018-05-05 19:38:55 +00:00
2022-04-26 17:15:08 +00:00
/**
* FAST_MODE will use invW for all Z coordinates sent to the
* GPU.
*
2021-05-23 12:06:11 +00:00
* This will break orthographic mode so default is FALSE
**/
2021-05-23 12:06:11 +00:00
#define FAST_MODE GL_FALSE
2018-05-05 19:38:55 +00:00
GLboolean AUTOSORT_ENABLED = GL_FALSE;
2021-04-14 20:38:33 +00:00
PolyList* _glOpaquePolyList() {
return &OP_LIST;
}
PolyList* _glPunchThruPolyList() {
return &PT_LIST;
}
PolyList *_glTransparentPolyList() {
2018-08-04 20:00:26 +00:00
return &TR_LIST;
}
2019-03-10 12:19:41 +00:00
void APIENTRY glFlush() {
}
void APIENTRY glFinish() {
}
void APIENTRY glKosInitConfig(GLdcConfig* config) {
config->autosort_enabled = GL_FALSE;
config->fsaa_enabled = GL_FALSE;
2021-04-26 15:14:33 +00:00
config->initial_op_capacity = 1024 * 3;
config->initial_pt_capacity = 512 * 3;
config->initial_tr_capacity = 1024 * 3;
config->initial_immediate_capacity = 1024 * 3;
config->internal_palette_format = GL_RGBA8;
}
void APIENTRY glKosInitEx(GLdcConfig* config) {
TRACE();
printf("\nWelcome to GLdc! Git revision: %s\n\n", GLDC_VERSION);
2021-04-09 15:24:47 +00:00
InitGPU(config->autosort_enabled, config->fsaa_enabled);
AUTOSORT_ENABLED = config->autosort_enabled;
_glInitSubmissionTarget();
_glInitMatrices();
_glInitAttributePointers();
2018-09-15 10:45:38 +00:00
_glInitContext();
_glInitLights();
2019-03-13 15:43:50 +00:00
_glInitImmediateMode(config->initial_immediate_capacity);
_glInitFramebuffers();
_glSetInternalPaletteFormat(config->internal_palette_format);
_glInitTextures();
2018-05-05 19:38:55 +00:00
2021-04-09 15:24:47 +00:00
OP_LIST.list_type = GPU_LIST_OP_POLY;
PT_LIST.list_type = GPU_LIST_PT_POLY;
TR_LIST.list_type = GPU_LIST_TR_POLY;
2019-03-25 09:44:59 +00:00
aligned_vector_init(&OP_LIST.vector, sizeof(Vertex));
aligned_vector_init(&PT_LIST.vector, sizeof(Vertex));
aligned_vector_init(&TR_LIST.vector, sizeof(Vertex));
2019-03-13 15:43:50 +00:00
aligned_vector_reserve(&OP_LIST.vector, config->initial_op_capacity);
aligned_vector_reserve(&PT_LIST.vector, config->initial_pt_capacity);
aligned_vector_reserve(&TR_LIST.vector, config->initial_tr_capacity);
}
void APIENTRY glKosInit() {
GLdcConfig config;
glKosInitConfig(&config);
glKosInitEx(&config);
2018-05-05 19:38:55 +00:00
}
void APIENTRY glKosSwapBuffers() {
TRACE();
2021-04-09 15:24:47 +00:00
SceneBegin();
2023-05-12 19:51:36 +00:00
if(aligned_vector_header(&OP_LIST.vector)->size > 2) {
2022-08-24 19:31:55 +00:00
SceneListBegin(GPU_LIST_OP_POLY);
2023-05-12 19:51:36 +00:00
SceneListSubmit((Vertex*) aligned_vector_front(&OP_LIST.vector), aligned_vector_size(&OP_LIST.vector));
2022-08-24 19:31:55 +00:00
SceneListFinish();
}
2023-05-12 19:51:36 +00:00
if(aligned_vector_header(&PT_LIST.vector)->size > 2) {
2022-08-24 19:31:55 +00:00
SceneListBegin(GPU_LIST_PT_POLY);
2023-05-12 19:51:36 +00:00
SceneListSubmit((Vertex*) aligned_vector_front(&PT_LIST.vector), aligned_vector_size(&PT_LIST.vector));
2022-08-24 19:31:55 +00:00
SceneListFinish();
}
2023-05-12 19:51:36 +00:00
if(aligned_vector_header(&TR_LIST.vector)->size > 2) {
2022-08-24 19:31:55 +00:00
SceneListBegin(GPU_LIST_TR_POLY);
2023-05-12 19:51:36 +00:00
SceneListSubmit((Vertex*) aligned_vector_front(&TR_LIST.vector), aligned_vector_size(&TR_LIST.vector));
2022-08-24 19:31:55 +00:00
SceneListFinish();
}
2021-04-09 15:24:47 +00:00
SceneFinish();
aligned_vector_clear(&OP_LIST.vector);
aligned_vector_clear(&PT_LIST.vector);
aligned_vector_clear(&TR_LIST.vector);
2018-08-19 20:10:42 +00:00
2021-04-14 20:38:33 +00:00
_glApplyScissor(true);
2022-06-09 12:07:51 +00:00
}