예제 #1
0
파일: Texture.cpp 프로젝트: ruleless/CEGUI
//----------------------------------------------------------------------------//
void OpenGLESTexture::loadCompressedTextureBuffer(const Rectf& dest_area,
        const GLvoid* buffer) const
{
    const GLsizei image_size = getCompressedTextureSize(dest_area.getSize());

    glCompressedTexImage2D(GL_TEXTURE_2D, 0, d_format,
                           static_cast<GLsizei>(dest_area.getWidth()),
                           static_cast<GLsizei>(dest_area.getHeight()),
                           0, image_size, buffer);
}
예제 #2
0
파일: Texture.cpp 프로젝트: Toby91/DDEngine
//----------------------------------------------------------------------------//
void OpenGLESTexture::loadCompressedTextureBuffer(const Sizef& buffer_size,
                                                  const void* buffer) const
{
    GLsizei image_size = getCompressedTextureSize(buffer_size); 

    glCompressedTexImage2D(GL_TEXTURE_2D, 0, d_format, 
                           static_cast<GLsizei>(buffer_size.d_width),
                           static_cast<GLsizei>(buffer_size.d_height),
                           0, image_size, buffer);
}
//----------------------------------------------------------------------------//
void GLES2Texture::setTextureSize_impl(const Sizef& sz)
{
    const Sizef size(d_owner.getAdjustedTextureSize(sz));
    d_size = size;

    // make sure size is within boundaries
    GLfloat maxSize;
    glGetFloatv(GL_MAX_TEXTURE_SIZE, &maxSize);

    char tBuff[250];
    Logger::getSingleton().logEvent( tBuff );

    if((size.d_width > maxSize) || (size.d_height > maxSize))
        CEGUI_THROW(RendererException("size too big"));

    // save old texture binding
    GLuint old_tex;
    glGetIntegerv(GL_TEXTURE_BINDING_2D, reinterpret_cast<GLint*>(&old_tex));

    Logger::getSingleton().logEvent( tBuff );

    // set texture to required size
    glBindTexture(GL_TEXTURE_2D, d_ogltexture);

    Logger::getSingleton().logEvent( tBuff );

    if(d_isCompressed)
    {
        const GLsizei image_size = getCompressedTextureSize(size);
        glCompressedTexImage2D(GL_TEXTURE_2D, 0, d_format,
                               static_cast<GLsizei>(size.d_width),
                               static_cast<GLsizei>(size.d_height),
                               0, image_size, 0);
    }
    else
    {
#ifndef CEGUI_GLES3_SUPPORT
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
#else
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,
#endif
                     static_cast<GLsizei>(size.d_width),
                     static_cast<GLsizei>(size.d_height),
                     0, GL_RGBA , GL_UNSIGNED_BYTE, 0);
    }

    // restore previous texture binding.
    glBindTexture(GL_TEXTURE_2D, old_tex);
}
예제 #4
0
//----------------------------------------------------------------------------//
void OpenGL1Texture::setTextureSize_impl(const Sizef& sz)
{
    const Sizef size(d_owner.getAdjustedTextureSize(sz));
    d_size = size;

    // make sure size is within boundaries
    GLfloat maxSize;
    glGetFloatv(GL_MAX_TEXTURE_SIZE, &maxSize);

    if((size.d_width > maxSize) || (size.d_height > maxSize))
        throw RendererException("size too big");

    // save old texture binding
    GLuint old_tex;
    glGetIntegerv(GL_TEXTURE_BINDING_2D, reinterpret_cast<GLint*>(&old_tex));

    // set texture to required size
    glBindTexture(GL_TEXTURE_2D, d_ogltexture);

    if(d_isCompressed)
    {
        const GLsizei image_size = getCompressedTextureSize(size);
        glCompressedTexImage2D(GL_TEXTURE_2D, 0, d_format,
                               static_cast<GLsizei>(size.d_width),
                               static_cast<GLsizei>(size.d_height),
                               0, image_size, 0);
    }
    else
    {
        glTexImage2D(GL_TEXTURE_2D, 0, d_format,
                     static_cast<GLsizei>(size.d_width),
                     static_cast<GLsizei>(size.d_height),
                     0, d_format, d_subpixelFormat, 0);
    }

    // restore previous texture binding.
    glBindTexture(GL_TEXTURE_2D, old_tex);
}