#include "texstore.h"
+static struct gl_frame_buffer_object DummyFramebuffer;
+static struct gl_render_buffer_object DummyRenderbuffer;
+
+
#define IS_CUBE_FACE(TARGET) \
((TARGET) >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && \
(TARGET) <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)
{
struct gl_render_buffer_object *rb;
- if (!id == 0)
+ if (id == 0)
return NULL;
rb = (struct gl_render_buffer_object *)
{
struct gl_frame_buffer_object *fb;
- if (!id == 0)
+ if (id == 0)
return NULL;
fb = (struct gl_frame_buffer_object *)
}
-GLboolean
+GLboolean GLAPIENTRY
_mesa_IsRenderbufferEXT(GLuint renderbuffer)
{
struct gl_render_buffer_object *rb;
}
-void
+void GLAPIENTRY
_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
{
struct gl_render_buffer_object *newRb, *oldRb;
if (renderbuffer) {
newRb = lookup_renderbuffer(ctx, renderbuffer);
+ if (newRb == &DummyRenderbuffer) {
+ /* ID was reserved, but no real renderbuffer object made yet */
+ newRb = NULL;
+ }
if (!newRb) {
/* create new renderbuffer object */
newRb = new_renderbuffer(ctx, renderbuffer);
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT");
return;
}
+ _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb);
}
newRb->RefCount++;
}
}
}
+ ASSERT(newRb != &DummyRenderbuffer);
+
ctx->CurrentRenderbuffer = newRb;
}
-void
+void GLAPIENTRY
_mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers)
{
GLint i;
/* remove from hash table immediately, to free the ID */
_mesa_HashRemove(ctx->Shared->RenderBuffers, renderbuffers[i]);
- /* But the object will not be freed until it's no longer bound in
- * any context.
- */
- rb->RefCount--;
- if (rb->RefCount == 0) {
- _mesa_free(rb); /* XXX call device driver function */
+ if (rb != &DummyRenderbuffer) {
+ /* But the object will not be freed until it's no longer
+ * bound in any context.
+ */
+ rb->RefCount--;
+ if (rb->RefCount == 0) {
+ _mesa_free(rb); /* XXX call device driver function */
+ }
}
}
}
}
-void
+void GLAPIENTRY
_mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers)
{
GET_CURRENT_CONTEXT(ctx);
first = _mesa_HashFindFreeKeyBlock(ctx->Shared->RenderBuffers, n);
for (i = 0; i < n; i++) {
- struct gl_render_buffer_object *rb;
GLuint name = first + i;
- rb = new_renderbuffer(ctx, name);
- if (!rb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenRenderbuffersEXT");
- return;
- }
- /* insert into hash table */
+ /* insert dummy placeholder into hash table */
_glthread_LOCK_MUTEX(ctx->Shared->Mutex);
- _mesa_HashInsert(ctx->Shared->RenderBuffers, name, rb);
+ _mesa_HashInsert(ctx->Shared->RenderBuffers, name, &DummyRenderbuffer);
_glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
renderbuffers[i] = name;
}
-void
+void GLAPIENTRY
_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,
GLsizei width, GLsizei height)
{
}
-void
+void GLAPIENTRY
_mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
}
-GLboolean
+GLboolean GLAPIENTRY
_mesa_IsFramebufferEXT(GLuint framebuffer)
{
struct gl_frame_buffer_object *fb;
}
-void
+void GLAPIENTRY
_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
{
struct gl_frame_buffer_object *newFb, *oldFb;
if (framebuffer) {
newFb = lookup_framebuffer(ctx, framebuffer);
+ if (newFb == &DummyFramebuffer) {
+ newFb = NULL;
+ }
if (!newFb) {
/* create new framebuffer object */
newFb = new_framebuffer(ctx, framebuffer);
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFramebufferEXT");
return;
}
+ _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb);
}
newFb->RefCount++;
}
}
}
+ ASSERT(newFb != &DummyFramebuffer);
+
ctx->CurrentFramebuffer = newFb;
}
-void
+void GLAPIENTRY
_mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers)
{
GLint i;
/* remove from hash table immediately, to free the ID */
_mesa_HashRemove(ctx->Shared->FrameBuffers, framebuffers[i]);
- /* But the object will not be freed until it's no longer bound in
- * any context.
- */
- fb->RefCount--;
- if (fb->RefCount == 0) {
- _mesa_free(fb); /* XXX call device driver function */
+ if (fb != &DummyFramebuffer) {
+ /* But the object will not be freed until it's no longer
+ * bound in any context.
+ */
+ fb->RefCount--;
+ if (fb->RefCount == 0) {
+ _mesa_free(fb); /* XXX call device driver function */
+ }
}
}
}
}
-void
+void GLAPIENTRY
_mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers)
{
GET_CURRENT_CONTEXT(ctx);
first = _mesa_HashFindFreeKeyBlock(ctx->Shared->FrameBuffers, n);
for (i = 0; i < n; i++) {
- struct gl_frame_buffer_object *fb;
GLuint name = first + i;
- fb = new_framebuffer(ctx, name);
- if (!fb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenFramebuffersEXT");
- return;
- }
/* insert into hash table */
_glthread_LOCK_MUTEX(ctx->Shared->Mutex);
- _mesa_HashInsert(ctx->Shared->FrameBuffers, name, fb);
+ _mesa_HashInsert(ctx->Shared->FrameBuffers, name, &DummyFramebuffer);
_glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
framebuffers[i] = name;
-GLenum
+GLenum GLAPIENTRY
_mesa_CheckFramebufferStatusEXT(GLenum target)
{
GET_CURRENT_CONTEXT(ctx);
}
-void
+void GLAPIENTRY
_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level)
{
}
-void
+void GLAPIENTRY
_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level)
{
}
-void
+void GLAPIENTRY
_mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture,
GLint level, GLint zoffset)
}
-
-void
+void GLAPIENTRY
_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
GLenum renderbufferTarget,
GLuint renderbuffer)
{
- struct gl_render_buffer_object *rb;
struct gl_render_buffer_attachment *att;
GET_CURRENT_CONTEXT(ctx);
return;
}
+ att = get_attachment(ctx, attachment);
+ if (att == NULL) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferRenderbufferEXT(attachment)");
+ return;
+ }
+
if (renderbuffer) {
+ struct gl_render_buffer_object *rb;
rb = lookup_renderbuffer(ctx, renderbuffer);
if (!rb) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glFramebufferRenderbufferEXT(renderbuffer)");
return;
}
+ set_renderbuffer_attachment(ctx, att, rb);
}
else {
- rb = NULL; /* default renderbuffer */
- }
-
- att = get_attachment(ctx, attachment);
- if (att == NULL) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferRenderbufferEXT(attachment)");
- return;
+ remove_attachment(ctx, att);
}
-
- remove_attachment(ctx, att);
- set_renderbuffer_attachment(ctx, att, rb);
}
-
-void
+void GLAPIENTRY
_mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
GLenum pname, GLint *params)
{
}
-
-void
+void GLAPIENTRY
_mesa_GenerateMipmapEXT(GLenum target)
{
struct gl_texture_unit *texUnit;
};
-extern GLboolean
+extern GLboolean GLAPIENTRY
_mesa_IsRenderbufferEXT(GLuint renderbuffer);
-extern void
+extern void GLAPIENTRY
_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer);
-extern void
+extern void GLAPIENTRY
_mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers);
-extern void
+extern void GLAPIENTRY
_mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers);
-extern void
+extern void GLAPIENTRY
_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalformat,
GLsizei width, GLsizei height);
-extern void
+extern void GLAPIENTRY
_mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params);
-extern GLboolean
+extern GLboolean GLAPIENTRY
_mesa_IsFramebufferEXT(GLuint framebuffer);
-extern void
+extern void GLAPIENTRY
_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer);
-extern void
+extern void GLAPIENTRY
_mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers);
-extern void
+extern void GLAPIENTRY
_mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers);
-extern GLenum
+extern GLenum GLAPIENTRY
_mesa_CheckFramebufferStatusEXT(GLenum target);
-extern void
+extern void GLAPIENTRY
_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level);
-extern void
+extern void GLAPIENTRY
_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level);
-extern void
+extern void GLAPIENTRY
_mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture,
GLint level, GLint zoffset);
-extern void
+extern void GLAPIENTRY
_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
GLenum renderbuffertarget,
GLuint renderbuffer);
-extern void
+extern void GLAPIENTRY
_mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
GLenum pname, GLint *params);
-extern void
+extern void GLAPIENTRY
_mesa_GenerateMipmapEXT(GLenum target);