Loading OpenGL textures from FLTK

Visto 21 veces
Saltar al primer mensaje no leído

FOSS Dev

no leída,
10 oct 2020, 4:35:4410/10/20
a fltk.general
Hi my name is Dev. I want to know how i get a OpenGL texture from a raw .png, .jpeg, .bmp, etc file using FLTK.
I want the pixel data, number of components(RGB or RGBA), width and height of the raw image to make OpenGL texture.
Give me the most optimized way to do this.
Thanks

Manolo

no leída,
10 oct 2020, 6:16:4810/10/20
a fltk.general
You can get an Fl_RGB_Image object from a .png file with:
and similarly with .jpeg:
and .bmp:

In all these cases, the resulting Fl_RGB_Image object, supposing you call it img, will tell you
if its RGB (img->d() == 3) or RGBA (img->d() == 4)and its width (img->w()) and height (img->h()).
In some cases, the row length is bigger than img->w()*img->d(). In that case img->ld() is != 0
and gives that length. Finally, you get the address of the first byte of the RGB or RGBA data
by img->array of type const unsigned char *. That should put you in the position to build a texture.

FOSS Dev

no leída,
11 oct 2020, 1:20:0211/10/20
a fltk.general
Thank you very much.

Here is the OpenGL texture class which uses FLTK:
Texture.cpp
Texture.h
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos