Thought i would give a quick demo of my progress.
The goal is to have all the gui_apps in the examples projects folder in sfmls cmake folder run. Preferably with as little or no changes if possible.
Below is a quick example of sfml system and sfml window parts. It simply makes the entire screen a color.
The green color is controlled by a timer and reset every second and can be reset when your finger touches the screen. The red color is controlled by your fingers last x position and blue by your fingers last y position.
all the same as normal sfml except using gles. There is one part at the top which is driving me nuts. If i have that function where I wanted in sfml window then when it is statically linked the compiler optimizes it out ><. If you have any ideas. I would appreciate it.
/*
stupid peice of code here. The android activity handling stuff would be completely unnoticed.
Though because it is adding a static library and if the ANativeActivity_onCreate entry point is in it. it seems to get Optimised out. >< joy.
*/
#include <android/native_activity.h>
extern void ANativeActivity_onCreate2(ANativeActivity* activity, void* savedState, size_t savedStateSize);
void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize)
{
ANativeActivity_onCreate2(activity, savedState, savedStateSize);
}
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window.hpp>
#include <GLES/gl.h>
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
// Create the main window
sf::Window window(sf::VideoMode(640, 480, 32), "SFML Window", sf::Style::Default, sf::ContextSettings(32));
// Create a clock for measuring the time elapsed
sf::Clock clock;
sf::Vector2u size=window.getSize();
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window : exit
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::MouseButtonPressed)
clock.restart();
// Resize event : adjust viewport
if (event.type == sf::Event::Resized)
glViewport(0, 0, event.size.width, event.size.height);
}
float x = sf::Mouse::getPosition(window).x;
float y = sf::Mouse::getPosition(window).y;
x /=size.x;
y /=size.y;
float val=clock.getElapsedTime().asSeconds();
if(val>1)
val=clock.restart().asSeconds();
glClearColor(x, val, y , 1);
glClear(GL_COLOR_BUFFER_BIT);
// Finally, display the rendered frame on screen
window.display();
}
return EXIT_SUCCESS;
}
below is a video. unfortunately it is not very clear on when i am clicking which is mean to represent my finger on the screen.
I also use extra stuff not shown. Like threads, mutex's and locks. It was required to get the main thread working.
Also any experienced OpenGL ES 2 users around? I suppose this is really not the place where they would be. Having worked on mobiles which are not really related to SFML. Restructuring the graphics library will be hardest. plus compiling it's libs for android. Hopefully I can offload that work onto you guys
![Tongue :P](https://www.sfml-dev.org/forums/Smileys/default/tongue.gif)