Beispiel #1
0
void Render_SW_SDL::renderTexture(PGE_Texture *texture, float x, float y, float w, float h, float ani_top, float ani_bottom, float ani_left, float ani_right)
{
    if(!texture) return;

    setRenderTexture( texture->texture );
    m_currentTextureRect.setRect( 0, 0, texture->w, texture->h );

    if(!m_currentTexture)
    {
        renderRect(x, y, w, h,
                   (unsigned char)(255.f*color_binded_texture[0]),
                   (unsigned char)(255.f*color_binded_texture[1]),
                   (unsigned char)(255.f*color_binded_texture[2]),
                   (unsigned char)(255.f*color_binded_texture[3]) );
        return;
    }

    SDL_Rect sourceRect = { (int)roundf((float)texture->w*ani_left), (int)roundf((float)texture->h*ani_top),
                            (int)roundf((float)texture->w*ani_right)-(int)roundf((float)texture->w*ani_left),
                            (int)roundf((float)texture->h*ani_bottom)-(int)roundf((float)texture->h*ani_top)
    };
    SDL_Rect destRect = scaledRect(x, y, w, h);
    SDL_SetTextureColorMod( m_currentTexture,
                            (unsigned char)(255.f*color_binded_texture[0]),
                            (unsigned char)(255.f*color_binded_texture[1]),
                            (unsigned char)(255.f*color_binded_texture[2]));
    SDL_SetTextureAlphaMod( m_currentTexture, (unsigned char)(255.f*color_binded_texture[3]));

    SDL_RenderCopy( m_gRenderer, m_currentTexture, &sourceRect, &destRect );
    setUnbindTexture();
}
Beispiel #2
0
void Render_SW_SDL::renderTexture(PGE_Texture *texture, float x, float y)
{
    if(!texture) return;
    setRenderTexture( texture->texture );
    m_currentTextureRect.setRect( 0, 0, texture->w, texture->h );

    if(!m_currentTexture)
    {
        renderRect(x, y, texture->w, texture->h,
                   (unsigned char)(255.f*color_binded_texture[0]),
                   (unsigned char)(255.f*color_binded_texture[1]),
                   (unsigned char)(255.f*color_binded_texture[2]),
                   (unsigned char)(255.f*color_binded_texture[3]) );
        return;
    }

    SDL_Rect aRect = scaledRectIS(x, y, texture->w, texture->h);
    SDL_SetTextureColorMod( m_currentTexture,
                            (unsigned char)(255.f*color_binded_texture[0]),
                            (unsigned char)(255.f*color_binded_texture[1]),
                            (unsigned char)(255.f*color_binded_texture[2]));
    SDL_SetTextureAlphaMod( m_currentTexture, (unsigned char)(255.f*color_binded_texture[3]));

    SDL_RenderCopy( m_gRenderer, m_currentTexture, NULL, &aRect );
    setUnbindTexture();
}
Beispiel #3
0
void Render_OpenGL31::renderTexture(PGE_Texture *texture, float x, float y, float w, float h, float ani_top, float ani_bottom, float ani_left, float ani_right)
{
    if(!texture) return;

    PGE_RectF rect = MapToGl(x, y, w, h);
    setRenderTexture(texture->texture);
    setAlphaBlending();
    GLdouble Vertices[] =
    {
        rect.left(),  rect.top(), 0,
        rect.right(), rect.top(), 0,
        rect.right(), rect.bottom(), 0,
        rect.left(),  rect.bottom(), 0
    };
    GLfloat TexCoord[] =
    {
        ani_left, ani_top,
        ani_right, ani_top,
        ani_right, ani_bottom,
        ani_left, ani_bottom
    };
    GLubyte indices[] =
    {
        0, 1, 3, 2
    };
    glColorPointer(4, GL_FLOAT, 0, color_binded_texture);
    GLERRORCHECK();
    glVertexPointer(3, GL_DOUBLE, 0, Vertices);
    GLERRORCHECK();
    glTexCoordPointer(2, GL_FLOAT, 0, TexCoord);
    GLERRORCHECK();
    glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, indices);
    GLERRORCHECK();
    setUnbindTexture();
}
Beispiel #4
0
void Render_OpenGL31::getPixelData(const PGE_Texture *tx, unsigned char *pixelData)
{
    if(!tx)
        return;

    setRenderTexture(const_cast<PGE_Texture *>(tx)->texture);
    glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixelData);
    setUnbindTexture();
}
Beispiel #5
0
void Render_SW_SDL::getPixelData(const PGE_Texture *tx, unsigned char *pixelData)
{
    if(!tx) return;
    setRenderTexture( ((PGE_Texture *)tx)->texture );
    int pitch, w, h, a;
    void *pixels;
    SDL_SetTextureBlendMode(m_currentTexture, SDL_BLENDMODE_BLEND);
    SDL_QueryTexture(m_currentTexture, NULL, &a, &w, &h);
    SDL_LockTexture(m_currentTexture, NULL, &pixels, &pitch);
    memcpy( pixelData, pixels, pitch*h);
    SDL_UnlockTexture(m_currentTexture);
    setUnbindTexture();
}
Beispiel #6
0
void Render_SW_SDL::UnBindTexture()
{
    setUnbindTexture();
}
Beispiel #7
0
void Render_OpenGL31::UnBindTexture()
{
    setUnbindTexture();
}