Implement gen/delete/bind framebuffers
This commit is contained in:
parent
8a4e53a9c7
commit
f3339e1868
|
@ -68,6 +68,7 @@ void APIENTRY glKosInit() {
|
|||
initContext();
|
||||
initLights();
|
||||
initImmediateMode();
|
||||
initFramebuffers();
|
||||
|
||||
_glKosInitTextures();
|
||||
|
||||
|
|
|
@ -1,19 +1,58 @@
|
|||
#include <stdio.h>
|
||||
#include "private.h"
|
||||
|
||||
static GLuint ACTIVE_FRAMEBUFFER = 0;
|
||||
|
||||
typedef struct {
|
||||
GLuint index;
|
||||
GLuint texture_id;
|
||||
GLboolean is_complete;
|
||||
} FrameBuffer;
|
||||
|
||||
static FrameBuffer* ACTIVE_FRAMEBUFFER = NULL;
|
||||
static NamedArray FRAMEBUFFERS;
|
||||
|
||||
|
||||
void APIENTRY glGenFramebuffersEXT(GLsizei n, GLuint* framebuffers) {
|
||||
void initFramebuffers() {
|
||||
named_array_init(&FRAMEBUFFERS, sizeof(FrameBuffer), 32);
|
||||
}
|
||||
|
||||
void APIENTRY glGenFramebuffersEXT(GLsizei n, GLuint* framebuffers) {
|
||||
TRACE();
|
||||
|
||||
while(n--) {
|
||||
GLuint id = 0;
|
||||
FrameBuffer* fb = (FrameBuffer*) named_array_alloc(&FRAMEBUFFERS, &id);
|
||||
fb->index = id;
|
||||
fb->is_complete = GL_FALSE;
|
||||
fb->texture_id = 0;
|
||||
|
||||
*framebuffers = id;
|
||||
framebuffers++;
|
||||
}
|
||||
}
|
||||
|
||||
void APIENTRY glDeleteFramebuffersEXT(GLsizei n, const GLuint* framebuffers) {
|
||||
TRACE();
|
||||
|
||||
while(n--) {
|
||||
FrameBuffer* fb = (FrameBuffer*) named_array_get(&FRAMEBUFFERS, *framebuffers);
|
||||
|
||||
if(fb == ACTIVE_FRAMEBUFFER) {
|
||||
ACTIVE_FRAMEBUFFER = NULL;
|
||||
}
|
||||
|
||||
named_array_release(&FRAMEBUFFERS, *framebuffers++);
|
||||
}
|
||||
}
|
||||
|
||||
void APIENTRY glBindFramebufferEXT(GLenum target, GLuint framebuffer) {
|
||||
TRACE();
|
||||
|
||||
if(framebuffer) {
|
||||
ACTIVE_FRAMEBUFFER = (FrameBuffer*) named_array_get(&FRAMEBUFFERS, framebuffer);
|
||||
} else {
|
||||
ACTIVE_FRAMEBUFFER = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void APIENTRY glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
|
||||
|
|
|
@ -69,6 +69,7 @@ void initContext();
|
|||
void initLights();
|
||||
void initImmediateMode();
|
||||
void initMatrices();
|
||||
void initFramebuffers();
|
||||
|
||||
void _matrixLoadNormal();
|
||||
void _matrixLoadModelView();
|
||||
|
|
Loading…
Reference in New Issue
Block a user