aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEhsan Akhgari <ehsan.akhgari@gmail.com>2012-04-13 17:47:17 -0400
committerEhsan Akhgari <ehsan.akhgari@gmail.com>2012-04-13 18:18:23 -0400
commit5edc8d89a3d46928b78cf0e571d4851f73dcd599 (patch)
tree4b0a1f4b8c47c7dc622a9cf813cb784110745357
parent0a1f4c4d22c7313f45d5b31ff19cca3b4928ae45 (diff)
Lock and unlock the surface to access the raw pixel data
-rw-r--r--tests/sdl_ogl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/sdl_ogl.c b/tests/sdl_ogl.c
index 6884f478..cec32bf1 100644
--- a/tests/sdl_ogl.c
+++ b/tests/sdl_ogl.c
@@ -90,12 +90,16 @@ int main(int argc, char *argv[])
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+ SDL_LockSurface(surface);
+
// Add some greyness
memset(surface->pixels, 0x66, surface->w*surface->h);
-
+
// Edit the texture object's image data using the information SDL_Surface gives us
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0,
GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels );
+
+ SDL_UnlockSurface(surface);
}
else {
printf("SDL could not load image.bmp: %s\n", SDL_GetError());