Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] What is a good simple test program for projectm? #849

Open
2 tasks done
eleanordoesntcode opened this issue Nov 19, 2024 · 1 comment
Open
2 tasks done

Comments

@eleanordoesntcode
Copy link

Please confirm the following points:

  • This question is NOT about the Android apps in the Play Store
  • I have searched the project page to check if the question was already asked elsewhere

Topic

General Request

Your Request

I'm currently updating the brew formula for projectm to its latest version, 4.1.2. I've gotten the build to work reliably, but I'm lacking one essential element: a small test program to verify the build and installation worked. The previous one that was used no longer work (like at all), and I do not have much knowledge in the project. Could someone propose a small program that would test the library. Thanks by advance!

For reference, here is the previous test program:
Screenshot 2024-11-20 at 00 11 04

@kblaschke
Copy link
Member

kblaschke commented Nov 21, 2024

The above progran uses the old projectM API, which has changed in the 4.x release series. For example, the API is now purely C and doesn't have a settings struct anymore, which was replaced by more convenient getter and setter methods.

We've written a short quick start guide which has all the required information to create a minimal application using projectM. The above example would look very similar, like this example which works fine for me:

projectm_test.c

#include <SDL2/SDL.h>

#include <projectM-4/projectM.h>

#include <stdlib.h>
#include <stdio.h>

int main(void)
{
    if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        fprintf(stderr, "Video init failed: %s", SDL_GetError());
        return 1;
    }

    SDL_Window* win = SDL_CreateWindow("projectM Test", 0, 0, 320, 240,
        SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI);
    if (win == NULL)
    {
        fprintf(stderr, "SDL Window creation failed: %s", SDL_GetError());
        return 2;
    }

    SDL_GLContext glCtx = SDL_GL_CreateContext(win);
    if (glCtx == NULL)
    {
        fprintf(stderr, "SDL GL context creation failed: %s", SDL_GetError());
        return 3;
    }

    projectm_handle pm = projectm_create();
    if (pm == NULL)
    {
        fprintf(stderr, "projectM instance creation failed: %s", SDL_GetError());
        return 4;
    }

    // Clean up.
    projectm_destroy(pm);
    SDL_Quit();

    return 0;
}

Remember to link the SDL2 and projectM-4 libraries, otherwise you'll be left with undefined references.

The different exit codes would make it easier to check if projectM of some SDL issue caused the application to fail when run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants