Skip to content

Commit 3eb68d2

Browse files
committed
maximize resolution on fullscreen
1 parent 0bcb4e5 commit 3eb68d2

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/projectM-sdl/pmSDL.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void projectMSDL::audioInputCallbackS16(void *userdata, unsigned char *stream, i
2020
projectMSDL *app = (projectMSDL *) userdata;
2121
short pcm16[2][512];
2222

23-
for (int i = 0; i < 512; i++) { //
23+
for (int i = 0; i < 512; i++) {
2424
for (int j = 0; j < app->audioChannelsCount; j++) {
2525
pcm16[j][i] = stream[i+j];
2626
}
@@ -78,19 +78,33 @@ void projectMSDL::beginAudioCapture() {
7878
unsigned int maxSamples = audioChannelsCount * audioSampleCount;
7979
pcmBuffer = (unsigned char *) malloc(maxSamples);
8080
SDL_PauseAudioDevice(audioDeviceID, false);
81-
// pm->pcm()->initPCM(maxSamples);
81+
this->pcm()->initPCM(2048);
8282
}
8383

8484
void projectMSDL::endAudioCapture() {
8585
free(pcmBuffer);
8686
SDL_PauseAudioDevice(audioDeviceID, true);
8787
}
8888

89+
void projectMSDL::maximize() {
90+
SDL_DisplayMode dm;
91+
if (SDL_GetDesktopDisplayMode(0, &dm) != 0) {
92+
SDL_Log("SDL_GetDesktopDisplayMode failed: %s", SDL_GetError());
93+
return;
94+
}
95+
96+
SDL_SetWindowSize(win, dm.w, dm.h);
97+
this->resize(dm.w, dm.h);
98+
}
99+
89100
void projectMSDL::toggleFullScreen() {
101+
maximize();
90102
if (isFullScreen) {
91103
SDL_SetWindowFullscreen(win, SDL_WINDOW_FULLSCREEN_DESKTOP);
92104
isFullScreen = false;
105+
SDL_ShowCursor(true);
93106
} else {
107+
SDL_ShowCursor(false);
94108
SDL_SetWindowFullscreen(win, SDL_WINDOW_FULLSCREEN);
95109
isFullScreen = true;
96110
}

src/projectM-sdl/pmSDL.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class projectMSDL : projectM {
4242
void resize(unsigned int width, unsigned int height);
4343
void renderFrame();
4444
void pollEvent();
45+
void maximize();
4546

4647
private:
4748
SDL_Window *win;

0 commit comments

Comments
 (0)