The 8-bit is data of one color, it will generate range of colors from 0 to 255 for basics colors [red, green and blue]. So, first will identity size of image [it like matrix] :
sf::Uint8 pix[x*y*4]; //linear array ordring
we multiply by 4 because three RGB and A [alpha or opacity].
set random value in this array:
for(int i=0;i<x*y*4;i++){ pix[i]=rng(rand); }
then load array in image :
sf::Image img;
img.create(x,y,pix);
then set image on texture to display it on screen
sf::Texture tex;
tex.loadFromImage(img);
while(win.isOpen())
{
win.clear();
win.draw(tex);
win.display();
}
for linux :
$ sudo apt-get install libsfml-dev
- go to
app/src/main/jni/
$ g++ -c main.cpp
$ g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
$ ./sfml-app
for android:
- first should have: - android SDK [https://developer.android.com/studio] - android NDK [https://developer.android.com/ndk] - gradle [https://gradle.org/]
- build SFML for android [https://github.com/SFML/SFML/wiki/Tutorial%3A-Building-SFML-for-Android]
- go to root of project will see
local.properties
file open it in text editor, and change paths of SDK and NDK - open CLI and type
gradle build
- plug your android phone using USB.
- also on root folder of project open CLI and type
gradle installDebug
- you will see app install on your phone