Jump to content

[SOLVED] Loading image from memory/string


photo

Recommended Posts

Hi all,

 

My intent is to integrate Unigine engine into existing multimedia framework. I hope this is the right place for this question.

 

To make proof of concept application I need to find a way to load image/texture into engine. There is a Image class mentioned in script reference and in C++ API reference. I am guessing that Image object needs to be initialized with pixel data somehow.

Only exposed methods are:

 

int load(const char * name)
int load(const char * name, int offset)

 

The question is how to create image from pixel-data produced from external c++ code ?

 

Is there some API function like `glTexImage2D` or `glTexSubImage2D` ?

Link to comment

There are two ways to achieve that:

* Use of image->set2D(x,y,r,g,b,a) or image->set2D(x,y,Pixel) function.

* Direct copying of image data via memcpy(image->getPixels2D(),source,image->getSize());

Link to comment

Hi,

 

I should use memcpy() because of HD content that needs to render 1920x1080 image at 60fps.

 

Initialize with:

int create2D(int width, int height, int format, int num_mipmaps)

to specify image format and allocate pixmap buffer and then change pixel data directly. Because image->getPixels2D() returns pointer to the array of pixels.

 

Thanks

Link to comment
×
×
  • Create New...