summaryrefslogtreecommitdiffstats
path: root/src/viewport.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/viewport.c')
-rw-r--r--src/viewport.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/viewport.c b/src/viewport.c
new file mode 100644
index 0000000..97e73dd
--- /dev/null
+++ b/src/viewport.c
@@ -0,0 +1,28 @@
+#include <SDL.h>
+#include "viewport.h"
+#include "logging.h"
+
+struct viewport *
+init_viewport(int width, int height, int bpp)
+{
+ struct viewport *vp;
+
+ vp = malloc(sizeof(*vp));
+ if (vp == NULL) {
+ err(1, "Failed to allocate viewport");
+ }
+
+ vp->x = 0;
+ vp->y = 0;
+ vp->w= width;
+ vp->h= height;
+
+ debug("Setting video mode...");
+ vp->screen = SDL_SetVideoMode(width, height, bpp,
+ SDL_SWSURFACE | SDL_ANYFORMAT);
+ if (vp->screen == NULL) {
+ err(1, "Failed to set video mode (%s)", SDL_GetError());
+ }
+
+ return vp;
+}