Loading OpenGL textures from FLTK

瀏覽次數:21 次
跳到第一則未讀訊息

FOSS Dev

未讀,
2020年10月10日 凌晨4:35:442020/10/10
收件者: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

未讀,
2020年10月10日 清晨6:16:482020/10/10
收件者: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

未讀,
2020年10月11日 凌晨1:20:022020/10/11
收件者:fltk.general
Thank you very much.

Here is the OpenGL texture class which uses FLTK:
Texture.cpp
Texture.h
回覆所有人
回覆作者
轉寄
0 則新訊息