projectm
projectm copied to clipboard
[QUESTION] What is a good simple test program for projectm?
Please confirm the following points:
- [X] This question is NOT about the Android apps in the Play Store
- [X] 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:
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.