mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-05 11:15:48 +00:00
New subproject/data locations: - presets/presets-cream_of_the_crop: https://github.com/projectM-visualizer/presets-cream-of-the-crop - presets/presets-En_D: https://github.com/projectM-visualizer/presets-en-d - presets/textures: https://github.com/projectM-visualizer/presets-milkdrop-texture-pack - src/EyeTune: https://github.com/projectM-visualizer/frontend-uwp - src/museum: https://github.com/projectM-visualizer/museum - src/projectm-android: https://github.com/projectM-visualizer/examples-android - src/projectM-emscripten: https://github.com/projectM-visualizer/examples-emscripten - src/projectM-jack: https://github.com/projectM-visualizer/frontend-qt - src/projectM-libvisual: https://github.com/projectM-visualizer/frontend-libvisual-plug-in - src/projectM-libvisual-alsa: Deleted. - src/projectM-moviegen: https://github.com/projectM-visualizer/tools-moviegen - src/projectM-MusicPlugin: https://github.com/projectM-visualizer/frontend-music-plug-in - src/projectM-pulseaudio: https://github.com/projectM-visualizer/frontend-qt - src/projectM-qt: https://github.com/projectM-visualizer/frontend-qt - src/projectM-sdl: src/sdl-test-ui - src/projectM-test: tests
63 lines
1.6 KiB
C++
Executable File
63 lines
1.6 KiB
C++
Executable File
//video_init.c - SDL/Opengl Windowing Creation/Resizing Functions
|
|
//
|
|
//by Peter Sperl & Ray Telford
|
|
//
|
|
//Opens an SDL Window and creates an OpenGL session
|
|
//also able to handle resizing and fullscreening of windows
|
|
//just call init_display again with different variables
|
|
#include <SDL/SDL.h>
|
|
|
|
void resize_display(int w, int h, bool f)
|
|
{
|
|
int flags = SDL_OPENGL|SDL_HWSURFACE|(f ? SDL_FULLSCREEN : SDL_RESIZABLE);
|
|
// 0 : use current bits per pixel
|
|
if(!SDL_SetVideoMode(w, h, 0, flags))
|
|
{
|
|
fprintf(stderr, "Video mode set failed: %s\n", SDL_GetError());
|
|
return;
|
|
}
|
|
SDL_ShowCursor(f ? SDL_DISABLE : SDL_ENABLE);
|
|
}
|
|
|
|
//init_display
|
|
//
|
|
//Sets screen to new width and height (w,h)
|
|
//Also switches between fullscreen and windowed
|
|
//with the boolean f (fullscreen)
|
|
void init_display(int w, int h, int *fvw, int *fvh, bool f)
|
|
{
|
|
/* First, initialize SDL's video subsystem. */
|
|
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
|
|
{
|
|
fprintf(stderr, "Video initialization failed: %s\n",
|
|
SDL_GetError());
|
|
return;
|
|
}
|
|
|
|
/* Let's get some video information. */
|
|
const SDL_VideoInfo* info = SDL_GetVideoInfo();
|
|
if(!info)
|
|
{
|
|
/* This should probably never happen. */
|
|
fprintf(stderr, "Video query failed: %s\n",
|
|
SDL_GetError());
|
|
|
|
// todo:what is this?
|
|
// projectM_vtable.disable_plugin (&projectM_vtable);
|
|
return;
|
|
}
|
|
|
|
printf("Screen Resolution: %d x %d\n", info->current_w, info->current_h);
|
|
*fvw = info->current_w;
|
|
*fvh = info->current_h;
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
|
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
|
|
|
if (f)
|
|
resize_display(*fvw, *fvh, f);
|
|
else
|
|
resize_display(w, h, f);
|
|
}
|