Beispiel #1
0
/**
 * Allocate a new renderbuffer to describe the user-provided color buffer.
 */
static struct gl_renderbuffer *
new_osmesa_renderbuffer(GLcontext *ctx, GLenum format, GLenum type)
{
   const GLuint name = 0;
   struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name);
   if (rb) {
      rb->RefCount = 1;
      rb->Delete = osmesa_delete_renderbuffer;
      rb->AllocStorage = osmesa_renderbuffer_storage;

      if (format == OSMESA_COLOR_INDEX) {
         rb->InternalFormat = GL_COLOR_INDEX;
         rb->_ActualFormat = GL_COLOR_INDEX8_EXT;
         rb->_BaseFormat = GL_COLOR_INDEX;
         rb->DataType = GL_UNSIGNED_BYTE;
      }
      else {
         rb->InternalFormat = GL_RGBA;
         rb->_ActualFormat = GL_RGBA;
         rb->_BaseFormat = GL_RGBA;
         rb->DataType = type;
      }
   }
   return rb;
}
Beispiel #2
0
/**
 * Allocate a new renderbuffer to describe the user-provided color buffer.
 */
static struct gl_renderbuffer *
new_osmesa_renderbuffer(GLcontext *ctx, GLenum format, GLenum type)
{
   const GLuint name = 0;
   struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name);
   if (rb) {
      rb->RefCount = 1;
      rb->Delete = osmesa_delete_renderbuffer;
      rb->AllocStorage = osmesa_renderbuffer_storage;

      rb->InternalFormat = GL_RGBA;
      switch (type) {
      case GL_UNSIGNED_BYTE:
         rb->Format = MESA_FORMAT_RGBA8888;
         break;
      case GL_UNSIGNED_SHORT:
         rb->Format = MESA_FORMAT_RGBA_16;
         break;
      case GL_FLOAT:
         rb->Format = MESA_FORMAT_RGBA_FLOAT32;
         break;
      default:
         assert(0 && "Unexpected type in new_osmesa_renderbuffer()");
         rb->Format = MESA_FORMAT_RGBA8888;
      }
      rb->_BaseFormat = GL_RGBA;
      rb->DataType = type;
   }
   return rb;
}
Beispiel #3
0
/**
 * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like
 * a depth renderbuffer.
 * \return new depth renderbuffer
 */
struct gl_renderbuffer *
_mesa_new_z24_renderbuffer_wrapper(GLcontext *ctx,
                                   struct gl_renderbuffer *dsrb)
{
   struct gl_renderbuffer *z24rb;

   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
   ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);

   z24rb = _mesa_new_renderbuffer(ctx, 0);
   if (!z24rb)
      return NULL;

   z24rb->Wrapped = dsrb;
   z24rb->Name = dsrb->Name;
   z24rb->RefCount = 1;
   z24rb->Width = dsrb->Width;
   z24rb->Height = dsrb->Height;
   z24rb->InternalFormat = GL_DEPTH_COMPONENT24_ARB;
   z24rb->_ActualFormat = GL_DEPTH_COMPONENT24_ARB;
   z24rb->_BaseFormat = GL_DEPTH_COMPONENT;
   z24rb->DataType = GL_UNSIGNED_INT;
   z24rb->DepthBits = 24;
   z24rb->Data = NULL;
   z24rb->Delete = delete_wrapper;
   z24rb->AllocStorage = alloc_wrapper_storage;
   z24rb->GetPointer = nop_get_pointer;
   z24rb->GetRow = get_row_z24;
   z24rb->GetValues = get_values_z24;
   z24rb->PutRow = put_row_z24;
   z24rb->PutRowRGB = NULL;
   z24rb->PutMonoRow = put_mono_row_z24;
   z24rb->PutValues = put_values_z24;
   z24rb->PutMonoValues = put_mono_values_z24;

   return z24rb;
}
Beispiel #4
0
/**
 * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like
 * a stencil renderbuffer.
 * \return new stencil renderbuffer
 */
struct gl_renderbuffer *
_mesa_new_s8_renderbuffer_wrapper(GLcontext *ctx, struct gl_renderbuffer *dsrb)
{
   struct gl_renderbuffer *s8rb;

   ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
   ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);

   s8rb = _mesa_new_renderbuffer(ctx, 0);
   if (!s8rb)
      return NULL;

   s8rb->Wrapped = dsrb;
   s8rb->Name = dsrb->Name;
   s8rb->RefCount = 1;
   s8rb->Width = dsrb->Width;
   s8rb->Height = dsrb->Height;
   s8rb->InternalFormat = GL_STENCIL_INDEX8_EXT;
   s8rb->_ActualFormat = GL_STENCIL_INDEX8_EXT;
   s8rb->_BaseFormat = GL_STENCIL_INDEX;
   s8rb->DataType = GL_UNSIGNED_BYTE;
   s8rb->StencilBits = 8;
   s8rb->Data = NULL;
   s8rb->Delete = delete_wrapper;
   s8rb->AllocStorage = alloc_wrapper_storage;
   s8rb->GetPointer = nop_get_pointer;
   s8rb->GetRow = get_row_s8;
   s8rb->GetValues = get_values_s8;
   s8rb->PutRow = put_row_s8;
   s8rb->PutRowRGB = NULL;
   s8rb->PutMonoRow = put_mono_row_s8;
   s8rb->PutValues = put_values_s8;
   s8rb->PutMonoValues = put_mono_values_s8;

   return s8rb;
}