Subject: jigzo: Make window resizeable
Package: jigzo
Version: 0.6.1-4
Severity: wishlist

*** Please type your report below this line ***

I'm attaching a patch that allows Jigzo window to be resized. That
way, when playing it in a netbook it can be played in fullscreen.

Greetings,
Miry
Patch to make jigzo window resizeable
--- jigzo-0.6.1.orig/src/Screen.cxx
+++ jigzo-0.6.1/src/Screen.cxx
@@ -58,6 +58,7 @@
 	GLint maxtexsize;
 
 	flags |= SDL_OPENGL;
+	flags |= SDL_RESIZABLE;
 
 	gl_doublebuf = flags & SDL_DOUBLEBUF;
 	if (bpp == 15) {
@@ -111,6 +112,23 @@
 	glTranslatef(0.0f, 0.0f, 0.0f);
 }
 
+void Screen::Resize(int new_w, int new_h)
+{
+	printf("Resize: %i %i\n", new_w, new_h);
+	w = new_w;
+	h = new_h;
+
+	sdl_surface = SDL_SetVideoMode(w, h, bpp, flags);
+	if (!sdl_surface) {
+		fprintf(stderr, "Failed to open screen %d %d %d %d!\n", w, h, bpp, flags);
+	}
+
+	if (w > h*glw/glh) w = h*glw/glh;
+	else if (h > w*glh/glw) h = w*glh/glw;
+
+	glViewport((new_w-w)/2, (new_h-h)/2, w, h);
+}
+
 void Screen::Exit(void)
 {
 	SDL_Quit();
--- jigzo-0.6.1.orig/src/main.cxx
+++ jigzo-0.6.1/src/main.cxx
@@ -1639,6 +1639,10 @@
 						FadeOutTo(end_play,start_browse);
 					}
 				}
+				if (event.type == SDL_VIDEORESIZE) {
+					s.Resize(event.resize.w, event.resize.h);
+					break;
+				}
 				if (event.type == SDL_QUIT) {
 					mode = end;
 					break;
--- jigzo-0.6.1.orig/src/Screen.hxx
+++ jigzo-0.6.1/src/Screen.hxx
@@ -36,6 +36,7 @@
 	void FullScreen(bool b = true);
 	void DoubleBuffer(bool b = true);
 	void Init(void);
+	void Resize(int w,int h);
 	void Exit(void);
 	void Flip(void);
 };

Reply via email to