Stub out some of the ARB_framebuffer_object extension
This commit is contained in:
parent
1c6bb24b86
commit
51d02ae489
|
@ -1,11 +1,14 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
#include "../include/glkos.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GLuint index;
|
GLuint index;
|
||||||
GLuint texture_id;
|
GLuint texture_id;
|
||||||
GLboolean is_complete;
|
GLboolean is_complete;
|
||||||
|
|
||||||
|
/* FIXME: Add OP, TR and PT lists per framebuffer */
|
||||||
|
|
||||||
} FrameBuffer;
|
} FrameBuffer;
|
||||||
|
|
||||||
static FrameBuffer* ACTIVE_FRAMEBUFFER = NULL;
|
static FrameBuffer* ACTIVE_FRAMEBUFFER = NULL;
|
||||||
|
@ -16,6 +19,14 @@ void initFramebuffers() {
|
||||||
named_array_init(&FRAMEBUFFERS, sizeof(FrameBuffer), 32);
|
named_array_init(&FRAMEBUFFERS, sizeof(FrameBuffer), 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wipeTextureOnFramebuffers(GLuint texture) {
|
||||||
|
/* Spec says we don't update inactive framebuffers, they'll presumably just cause
|
||||||
|
* a GL_INVALID_OPERATION if we try to render to them */
|
||||||
|
if(ACTIVE_FRAMEBUFFER && ACTIVE_FRAMEBUFFER->texture_id == texture) {
|
||||||
|
ACTIVE_FRAMEBUFFER->texture_id = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void APIENTRY glGenFramebuffersEXT(GLsizei n, GLuint* framebuffers) {
|
void APIENTRY glGenFramebuffersEXT(GLsizei n, GLuint* framebuffers) {
|
||||||
TRACE();
|
TRACE();
|
||||||
|
|
||||||
|
@ -52,11 +63,26 @@ void APIENTRY glBindFramebufferEXT(GLenum target, GLuint framebuffer) {
|
||||||
ACTIVE_FRAMEBUFFER = (FrameBuffer*) named_array_get(&FRAMEBUFFERS, framebuffer);
|
ACTIVE_FRAMEBUFFER = (FrameBuffer*) named_array_get(&FRAMEBUFFERS, framebuffer);
|
||||||
} else {
|
} else {
|
||||||
ACTIVE_FRAMEBUFFER = NULL;
|
ACTIVE_FRAMEBUFFER = NULL;
|
||||||
|
|
||||||
|
/* FIXME: This is where we need to submit the lists and then clear them. Binding zero means returning to the
|
||||||
|
* default framebuffer so we need to render a frame to the texture at that point */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void APIENTRY glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
|
void APIENTRY glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
|
||||||
|
if(texture != 0 && !glIsTexture(texture)) {
|
||||||
|
_glKosThrowError(GL_INVALID_OPERATION, __func__);
|
||||||
|
_glKosPrintError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!ACTIVE_FRAMEBUFFER) {
|
||||||
|
_glKosThrowError(GL_INVALID_OPERATION, __func__);
|
||||||
|
_glKosPrintError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ACTIVE_FRAMEBUFFER->texture_id = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void APIENTRY glGenerateMipmapEXT(GLenum target) {
|
void APIENTRY glGenerateMipmapEXT(GLenum target) {
|
||||||
|
@ -64,9 +90,23 @@ void APIENTRY glGenerateMipmapEXT(GLenum target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum APIENTRY glCheckFramebufferStatusEXT(GLenum target) {
|
GLenum APIENTRY glCheckFramebufferStatusEXT(GLenum target) {
|
||||||
|
if(target != GL_FRAMEBUFFER_EXT) {
|
||||||
|
_glKosThrowError(GL_INVALID_ENUM, __func__);
|
||||||
|
_glKosPrintError();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!ACTIVE_FRAMEBUFFER) {
|
||||||
|
return GL_FRAMEBUFFER_COMPLETE_EXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!ACTIVE_FRAMEBUFFER->texture_id) {
|
||||||
|
return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GL_FRAMEBUFFER_COMPLETE_EXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLboolean APIENTRY glIsFramebufferEXT(GLuint framebuffer) {
|
GLboolean APIENTRY glIsFramebufferEXT(GLuint framebuffer) {
|
||||||
|
return (named_array_used(&FRAMEBUFFERS, framebuffer)) ? GL_TRUE : GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ void _matrixLoadTexture();
|
||||||
void _matrixLoadRender();
|
void _matrixLoadRender();
|
||||||
void _applyRenderMatrix();
|
void _applyRenderMatrix();
|
||||||
|
|
||||||
|
void wipeTextureOnFramebuffers(GLuint texture);
|
||||||
GLubyte checkImmediateModeInactive(const char* func);
|
GLubyte checkImmediateModeInactive(const char* func);
|
||||||
|
|
||||||
pvr_poly_cxt_t* getPVRContext();
|
pvr_poly_cxt_t* getPVRContext();
|
||||||
|
|
|
@ -62,6 +62,10 @@ void APIENTRY glActiveTextureARB(GLenum texture) {
|
||||||
ACTIVE_TEXTURE = texture & 0xF;
|
ACTIVE_TEXTURE = texture & 0xF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLboolean APIENTRY glIsTexture(GLuint texture) {
|
||||||
|
return (named_array_used(&TEXTURE_OBJECTS, texture)) ? GL_TRUE : GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void APIENTRY glGenTextures(GLsizei n, GLuint *textures) {
|
void APIENTRY glGenTextures(GLsizei n, GLuint *textures) {
|
||||||
TRACE();
|
TRACE();
|
||||||
|
|
||||||
|
@ -88,6 +92,9 @@ void APIENTRY glDeleteTextures(GLsizei n, GLuint *textures) {
|
||||||
while(n--) {
|
while(n--) {
|
||||||
TextureObject* txr = (TextureObject*) named_array_get(&TEXTURE_OBJECTS, *textures);
|
TextureObject* txr = (TextureObject*) named_array_get(&TEXTURE_OBJECTS, *textures);
|
||||||
|
|
||||||
|
/* Make sure we update framebuffer objects that have this texture attached */
|
||||||
|
wipeTextureOnFramebuffers(*textures);
|
||||||
|
|
||||||
if(txr == TEXTURE_UNITS[ACTIVE_TEXTURE]) {
|
if(txr == TEXTURE_UNITS[ACTIVE_TEXTURE]) {
|
||||||
TEXTURE_UNITS[ACTIVE_TEXTURE] = NULL;
|
TEXTURE_UNITS[ACTIVE_TEXTURE] = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -495,6 +495,7 @@ GLAPI void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param);
|
||||||
GLAPI void APIENTRY glTexEnvi(GLenum target, GLenum pname, GLint param);
|
GLAPI void APIENTRY glTexEnvi(GLenum target, GLenum pname, GLint param);
|
||||||
GLAPI void APIENTRY glTexEnvf(GLenum target, GLenum pname, GLfloat param);
|
GLAPI void APIENTRY glTexEnvf(GLenum target, GLenum pname, GLfloat param);
|
||||||
|
|
||||||
|
GLAPI GLboolean APIENTRY glIsTexture(GLuint texture);
|
||||||
GLAPI void APIENTRY glGenTextures(GLsizei n, GLuint *textures);
|
GLAPI void APIENTRY glGenTextures(GLsizei n, GLuint *textures);
|
||||||
GLAPI void APIENTRY glDeleteTextures(GLsizei n, GLuint *textures);
|
GLAPI void APIENTRY glDeleteTextures(GLsizei n, GLuint *textures);
|
||||||
GLAPI void APIENTRY glBindTexture(GLenum target, GLuint texture);
|
GLAPI void APIENTRY glBindTexture(GLenum target, GLuint texture);
|
||||||
|
|
|
@ -11,37 +11,6 @@
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
#define GL_COLOR_ATTACHMENT0 0x8CE0
|
|
||||||
#define GL_COLOR_ATTACHMENT1 0x8CE1
|
|
||||||
#define GL_COLOR_ATTACHMENT2 0x8CE2
|
|
||||||
#define GL_COLOR_ATTACHMENT3 0x8CE3
|
|
||||||
#define GL_COLOR_ATTACHMENT4 0x8CE4
|
|
||||||
#define GL_COLOR_ATTACHMENT5 0x8CE5
|
|
||||||
#define GL_COLOR_ATTACHMENT6 0x8CE6
|
|
||||||
#define GL_COLOR_ATTACHMENT7 0x8CE7
|
|
||||||
#define GL_COLOR_ATTACHMENT8 0x8CE8
|
|
||||||
#define GL_COLOR_ATTACHMENT9 0x8CE9
|
|
||||||
#define GL_COLOR_ATTACHMENT10 0x8CEA
|
|
||||||
#define GL_COLOR_ATTACHMENT11 0x8CEB
|
|
||||||
#define GL_COLOR_ATTACHMENT12 0x8CEC
|
|
||||||
#define GL_COLOR_ATTACHMENT13 0x8CED
|
|
||||||
#define GL_COLOR_ATTACHMENT14 0x8CEE
|
|
||||||
#define GL_COLOR_ATTACHMENT15 0x8CEF
|
|
||||||
#define GL_DEPTH_ATTACHMENT 0x8D00
|
|
||||||
#define GL_STENCIL_ATTACHMENT 0x8D20
|
|
||||||
#define GL_FRAMEBUFFER 0x8D40
|
|
||||||
#define GL_RENDERBUFFER 0x8D41
|
|
||||||
#define GL_RENDERBUFFER_WIDTH 0x8D42
|
|
||||||
#define GL_RENDERBUFFER_HEIGHT 0x8D43
|
|
||||||
#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
|
|
||||||
|
|
||||||
#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
|
|
||||||
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
|
|
||||||
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
|
|
||||||
#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
|
|
||||||
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
|
|
||||||
#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
|
|
||||||
|
|
||||||
#define GL_TEXTURE0_ARB 0x84C0
|
#define GL_TEXTURE0_ARB 0x84C0
|
||||||
#define GL_TEXTURE1_ARB 0x84C1
|
#define GL_TEXTURE1_ARB 0x84C1
|
||||||
#define GL_TEXTURE2_ARB 0x84C2
|
#define GL_TEXTURE2_ARB 0x84C2
|
||||||
|
|
|
@ -5,6 +5,37 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
|
||||||
|
#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
|
||||||
|
#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
|
||||||
|
#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
|
||||||
|
#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
|
||||||
|
#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
|
||||||
|
#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
|
||||||
|
#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
|
||||||
|
#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
|
||||||
|
#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
|
||||||
|
#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
|
||||||
|
#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
|
||||||
|
#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
|
||||||
|
#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
|
||||||
|
#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
|
||||||
|
#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
|
||||||
|
#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
|
||||||
|
#define GL_STENCIL_ATTACHMENT_EXT 0x8D20
|
||||||
|
#define GL_FRAMEBUFFER_EXT 0x8D40
|
||||||
|
#define GL_RENDERBUFFER_EXT 0x8D41
|
||||||
|
#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
|
||||||
|
#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
|
||||||
|
#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
|
||||||
|
|
||||||
|
#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
|
||||||
|
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
|
||||||
|
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
|
||||||
|
#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
|
||||||
|
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
|
||||||
|
#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
|
||||||
|
|
||||||
GLAPI void APIENTRY glKosSwapBuffers();
|
GLAPI void APIENTRY glKosSwapBuffers();
|
||||||
|
|
||||||
GLAPI void APIENTRY glGenFramebuffersEXT(GLsizei n, GLuint* framebuffers);
|
GLAPI void APIENTRY glGenFramebuffersEXT(GLsizei n, GLuint* framebuffers);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user