Fixed bug #783
authorSam Lantinga <slouken@libsdl.org>
Sat, 19 Sep 2009 05:12:26 +0000
changeset 3264 8fe0806637df
parent 3263 924b486541dc
child 3265 8f534bf37bef
Fixed bug #783 Fixed coordinate positioning with OpenGL renderer, and added a test case
src/video/SDL_renderer_gl.c
test/testsprite2.c
--- a/src/video/SDL_renderer_gl.c	Sat Sep 19 04:47:36 2009 +0000
+++ b/src/video/SDL_renderer_gl.c	Sat Sep 19 05:12:26 2009 +0000
@@ -450,8 +450,8 @@
         data->glMatrixMode(GL_MODELVIEW);
         data->glLoadIdentity();
         data->glViewport(0, 0, window->w, window->h);
-        data->glOrtho(0.0, (GLdouble) window->w, (GLdouble) window->h, 0.0,
-                      0.0, 1.0);
+        data->glOrtho(-0.5, (GLdouble) window->w-0.5,
+                      (GLdouble) window->h-0.5, -0.5, 0.0, 1.0);
         data->updateSize = SDL_FALSE;
     }
     return 0;
--- a/test/testsprite2.c	Sat Sep 19 04:47:36 2009 +0000
+++ b/test/testsprite2.c	Sat Sep 19 05:12:26 2009 +0000
@@ -134,10 +134,19 @@
         SDL_SetTextureAlphaMod(sprite, (Uint8) current_alpha);
     }
 
+    /* Draw a gray background */
+    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
+    SDL_RenderFill(NULL);
+
+    /* Draw two red points to make sure they show up correctly */
+    SDL_SetRenderDrawColor(0xFF, 0x00, 0x00, 0xFF);
+    SDL_RenderPoint(0, 0);
+    SDL_RenderPoint(window_w-1, 0);
+    SDL_RenderPoint(0, window_h-1);
+    SDL_RenderPoint(window_w-1, window_h-1);
+
     /* Move the sprite, bounce at the wall, and draw */
     n = 0;
-    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-    SDL_RenderFill(NULL);
     for (i = 0; i < num_sprites; ++i) {
         position = &positions[i];
         velocity = &velocities[i];