---------- Forwarded message ----------
From: Leon Moctezuma <densedev@gmail.com>
Date: Jul 7, 2007 9:29 AM
Subject: Re: FreePV Repot and Upside-Down problem
To: Pablo d'Angelo <pablo.dangelo@web.de>


> glBegin(GL_QUADS);
>           glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f , -1.0f,  - 4.0f);
>           glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  -4.0f);
>           glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  -4.0f);
>           glTexCoord2f(0.0f, 1.0f); glVertex3f(- 1.0f,  1.0f,  -4.0f);
> glEnd();


This assumes the textures are stored with the same convention as the OpenGL,
which they are not. try flipping y of the texture coordinates:

I see, I flipped the texture y coordinates and worked, I thought you was using the OpenGL convention... is there a reason for not flipping the images when they are decoded instead of not using OpenGL convention?
 
>     void FPV::copyImgToTexImg(Image * dest, Image * src, Point2D
>     destPos, Point2D srcPos, Size2D srcSize, bool pad)
>     {
>         if (srcSize.w == -1) srcSize = src->size() - Size2D(srcPos.x,
>     srcPos.y);
>
>         if (srcSize.w + srcPos.x > src->size().w) {
>             srcSize.w = src->size().w - srcPos.x;
>         }
>         if (srcSize.h + srcPos.y > src->size().h) {
>             srcSize.h = src->size().h - srcPos.y;
>         }
>
>         assert(( srcPos.x + srcSize.w <= src->size().w) && (srcPos.x +
>     srcSize.w <= src->size().w));
>         assert((destPos.x+srcSize.w <= dest->size().w) &&
>     (destPos.y+srcSize.h <= dest->size().h));
>
>         int color_channels = src->getColorChannels();
>         // pad if requested.
>         bool padX = (destPos.x+srcSize.w != dest->size().w) && pad;
>         bool padY = (destPos.y+srcSize.h != dest->size().h) && pad;
>
>         int srcStride = src->getRowStride();
>         int destStride = dest->getRowStride();

does getRowStride() return the right values for 4 channel images?

I solved It, it was a really silly mistake, I realized about it after checking the
values from getRowStride()...

bool Image::setSize(Size2D size, colorChannels channels=RGB)
{
        if (m_data) {
            free(m_data);
        }
        m_data =(unsigned char*)malloc(size.w*size.h*channels);
        m_size = size;
        m_rowStride = channels*m_size.w;
        m_color_channels = channels;
        return true;
}

The problem was that I created a tile texture and I passed the correct
type of the image to the constructor, the only problem was that I
didn't modify one of the constructor lines and setSize has it's default
channels value to RGB:

Image(Size2D sz, colorChannels channels = RGB)
{
        m_data = 0;
        //Before: setSize(sz);
        setSize(sz, channels);
       m_color_channels=channels;
}

Thanks a lot Pablo... those were two silly mistakes...