Skip to content
Search

OpenGL:Textures

lastmod 2025-05-19created 2024-08-169 edits

Drawing directly to a texture

public float[] toFloatArray()
{
    float[] colors = new float[(width*height)*4];

    int i = 0;
    for(int y = 0; y < height; ++y){
        for(int x = 0; x < width; ++x){

            colors[i] = (( r[x][y] * 1.0f) / 255);
            colors[i+1] = (( g[x][y] * 1.0f) / 255);
            colors[i+2] = (( b[x][y] * 1.0f) / 255);
            colors[i+3] = (( a[x][y] * 1.0f) / 255);

            i += 4;
        }
    }
    return colors;
}

...

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_FLOAT, toFloatArray());

A faster method

See Pixel Buffer Object.

GL_MAX_TEXTURE_SIZE
Maximum texture size. It is not a pixel count but the size along each of the X and Y axes. That is, a pixel size of GL_MAX_TEXTURE_SIZE * GL_MAX_TEXTURE_SIZE becomes the maximum pixel site. 1

See also

Favorite site

References

author Zer0 sitemap