Navigation

    UBports Robot Logo

    UBports Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Craig
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Craig

    @Craig

    4
    Reputation
    3
    Posts
    34
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Craig Follow

    Posts made by Craig

    • RE: C++ and SDL with Clickable. A little help please.

      Here's the source of the main.cpp:

      #include <SDL.h>

      int main(int argc, char *argv[])
      {
      SDL_Init(SDL_INIT_VIDEO);

      SDL_Window *window = SDL_CreateWindow( "SDL2Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0 );

      SDL_SetWindowFullscreen( window, SDL_TRUE );

      SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
      SDL_SetRenderDrawColor(renderer, 255, 0, 0, SDL_ALPHA_OPAQUE);
      SDL_RenderClear(renderer);
      SDL_RenderPresent(renderer);

      SDL_Delay(5000);

      SDL_DestroyWindow(window);
      SDL_Quit();

      return 0;
      }

      posted in App Development
      Craig
    • RE: C++ and SDL with Clickable. A little help please.

      Thanks to all for your input and suggestions so far. I ran searches online for "CMakeLists.txt SDL tutorial", and read many tutorials. This is what I have so far that seems to almost work:

      1. sudo apt install libsdl2-dev
        clickable create
        I chose option [7] main-cpp - C++/QML App (built using CMake with a main.cpp)

      2. I replaced the main.cpp file in my project directory with a very small 512 byte SDL test program. It just produces a blank screen for 5 seconds and then quits. I compiled and tested it with the Code::Blocks IDE and it works fine there.

      3. I added these lines to my CMakeLists.txt file in my project directory and finally I got it to link up with the SDL library:
        add_executable(${PROJECT_NAME} main.cpp)
        find_package(SDL2 REQUIRED)
        include_directories(${SDL2_INCLUDE_DIRS})
        set(SDL2_LIBRARIES "-lSDL2")
        target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES})

      4. I run clickable from my project directory and it compiles the program just fine and sends it to my Ubuntu Touch tablet where I see the logo.svg flash on the screen for only 1 second. Finally, no error messages not being able to link up with SDL. However, I don't get the expected blank screen for 5 seconds. The logo.svg shows on the screen along with my project name for only 1 second, but it seems to quit before running the program which should show a blank screen for 5 seconds. On my tablet I now have the logo.svg icon displayed as one of my apps. When I click on it the icon shows along with the app name for about 1 second and then closes.

      Does anyone know what I need to tweak to get SDL to run on UT through clickable? Then, like Wendigo said, we will have a working SDL recipe for UT/clickable for other app developers.

      posted in App Development
      Craig
    • C++ and SDL with Clickable. A little help please.

      I've written a program in C++ and SDL2 and would like to publish it to the Ubuntu Touch open store. I have installed clickable and I've gotten the "Hello World" screen on my tablet. I added the SDL dependencies to the clickable.json file.

      Could someone be kind enough to tell me how/where to put my C++ files and what settings to make in the CMakeLists.txt file? I have four .cpp and four .h files. I wont need to use Qml.

      When I run clickable it almost compiles, but it appears to not be able to link to the SDL libraries.

      Thanks!

      posted in App Development
      Craig