Skip to content

Commit

Permalink
IPHONE: Do not access Surface::pixels directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Schickel committed Aug 6, 2013
1 parent 6d86a66 commit 09f7e4d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions backends/platform/iphone/iphone_video.mm
Expand Up @@ -365,7 +365,7 @@ - (void)updateMouseCursor {
_mouseTexCoords[5] = _mouseTexCoords[7] = _videoContext.mouseHeight / (GLfloat)_videoContext.mouseTexture.h;

glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError();
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.mouseTexture.w, _videoContext.mouseTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.mouseTexture.pixels); printOpenGLError();
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.mouseTexture.w, _videoContext.mouseTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.mouseTexture.getPixels()); printOpenGLError();
}

- (void)updateMainSurface {
Expand All @@ -377,7 +377,7 @@ - (void)updateMainSurface {
// Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases
// due to the iPhone internals having to convert the whole texture back from its internal format when used.
// In the future we could use several tiled textures instead.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _videoContext.screenTexture.pixels); printOpenGLError();
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _videoContext.screenTexture.getPixels()); printOpenGLError();
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();
}

Expand All @@ -386,7 +386,7 @@ - (void)updateOverlaySurface {
glTexCoordPointer(2, GL_FLOAT, 0, _overlayTexCoords); printOpenGLError();

glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError();
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.overlayTexture.w, _videoContext.overlayTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.overlayTexture.pixels); printOpenGLError();
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.overlayTexture.w, _videoContext.overlayTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.overlayTexture.getPixels()); printOpenGLError();
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();
}

Expand Down
2 changes: 1 addition & 1 deletion backends/platform/iphone/osys_main.cpp
Expand Up @@ -78,7 +78,7 @@ OSystem_IPHONE::~OSystem_IPHONE() {
// Prevent accidental freeing of the screen texture here. This needs to be
// checked since we might use the screen texture as framebuffer in the case
// of hi-color games for example.
if (_framebuffer.pixels == _videoContext->screenTexture.pixels)
if (_framebuffer.getPixels() == _videoContext->screenTexture.getPixels())
_framebuffer.free();
_mouseBuffer.free();
}
Expand Down
6 changes: 3 additions & 3 deletions backends/platform/iphone/osys_video.mm
Expand Up @@ -76,8 +76,8 @@

// In case we use the screen texture as frame buffer we reset the pixels
// pointer here to avoid freeing the screen texture.
if (_framebuffer.pixels == _videoContext->screenTexture.pixels)
_framebuffer.pixels = 0;
if (_framebuffer.getPixels() == _videoContext->screenTexture.getPixels())
_framebuffer.setPixels(0);

// Create the screen texture right here. We need to do this here, since
// when a game requests hi-color mode, we actually set the framebuffer
Expand Down Expand Up @@ -417,7 +417,7 @@
#endif
assert(pixelFormat.bytesPerPixel == 1 || pixelFormat.bytesPerPixel == 2);

if (_mouseBuffer.w != w || _mouseBuffer.h != h || _mouseBuffer.format != pixelFormat || !_mouseBuffer.pixels)
if (_mouseBuffer.w != w || _mouseBuffer.h != h || _mouseBuffer.format != pixelFormat || !_mouseBuffer.getPixels())
_mouseBuffer.create(w, h, pixelFormat);

_videoContext->mouseWidth = w;
Expand Down

0 comments on commit 09f7e4d

Please sign in to comment.