GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: Add Line Numbers


texture bug by mrdutchy
int perlin::InitTexture(int arrsize)
{
    texsize=arrsize;
    if (!texmap1)
    {
        texmap1 = new float [texsize*texsize*3];
        for (int x=0; x<texsize; x++)
        {
            for (int y=0;y<texsize;y++)
            {
                rgb tempcol=GetColor(x,y);

                texmap1[((y*texsize)+x)]  =1.0f;
                texmap1[((y*texsize)+x)+1]=0.0f;
                texmap1[((y*texsize)+x)+2]=0.0f;
            }
        }

        glGenTextures(1, &texture[0]);                    // Create The Texture

        if (!texmap2)
            texmap2 = new float [texsize*texsize*3];

        GaussBlur();

        glBindTexture(GL_TEXTURE_2D, texture[0]);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texsize, texsize, 0, GL_RGB, GL_UNSIGNED_BYTE, &texmap1[0]);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
        
        return true;
    }
    return false;
}