Skip to content

Commit

Permalink
WINTERMUTE: Remove a few SDL-includes.
Browse files Browse the repository at this point in the history
  • Loading branch information
somaen committed Jun 2, 2012
1 parent 2e12f9f commit 4cf1d67
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 35 deletions.
20 changes: 12 additions & 8 deletions engines/wintermute/BFontTT.cpp
Expand Up @@ -238,7 +238,8 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex


TextLineList::iterator it;

warning("CBFontTT::RenderTextToTexture - Not ported yet");
#if 0 //TODO
int textHeight = lines.size() * (_maxCharHeight + _ascender);
SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);

Expand Down Expand Up @@ -328,29 +329,32 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex
delete wmeSurface;
return NULL;
}
#endif
return NULL;
}

//////////////////////////////////////////////////////////////////////////
void CBFontTT::BlitSurface(SDL_Surface *src, SDL_Surface *target, SDL_Rect *targetRect) {
void CBFontTT::BlitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) {
//SDL_BlitSurface(src, NULL, target, targetRect);

warning("CBFontTT::BlitSurface - not ported yet");
#if 0
for (int y = 0; y < src->h; y++) {
if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue;


Uint8 *srcBuf = (Uint8 *)src->pixels + y * src->pitch;
Uint8 *tgtBuf = (Uint8 *)target->pixels + (y + targetRect->y) * target->pitch;
uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch;
uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch;

Uint32 *srcBuf32 = (Uint32 *)srcBuf;
Uint32 *tgtBuf32 = (Uint32 *)tgtBuf;
uint32 *srcBuf32 = (uint32 *)srcBuf;
uint32 *tgtBuf32 = (uint32 *)tgtBuf;

for (int x = 0; x < src->w; x++) {
if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue;

tgtBuf32[x + targetRect->x] = srcBuf32[x];
}
}

#endif
}

//////////////////////////////////////////////////////////////////////////
Expand Down
7 changes: 4 additions & 3 deletions engines/wintermute/BFontTT.h
Expand Up @@ -32,10 +32,11 @@
#include "BFontStorage.h"
#include "BFont.h"
#include "BSurface.h"
#include "common/rect.h"
#include "graphics/surface.h"

#define NUM_CACHED_TEXTS 30
class SDL_Surface;
class SDL_Rect;

namespace WinterMute {

class FontGlyphCache;
Expand Down Expand Up @@ -150,7 +151,7 @@ class CBFontTT : public CBFont {
void CacheGlyph(wchar_t ch);

CBSurface *RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset);
void BlitSurface(SDL_Surface *src, SDL_Surface *target, SDL_Rect *targetRect);
void BlitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect);


CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS];
Expand Down
1 change: 0 additions & 1 deletion engines/wintermute/BObject.h
Expand Up @@ -30,7 +30,6 @@
#define WINTERMUTE_BOBJECT_H


//#include "SDL.h"
#include "BScriptHolder.h"
#include "persistent.h"

Expand Down
15 changes: 8 additions & 7 deletions engines/wintermute/BRenderSDL.cpp
Expand Up @@ -36,7 +36,6 @@
#include "engines/wintermute/BGame.h"
#include "engines/wintermute/BSprite.h"
#include "common/system.h"
#include "SDL.h"

namespace WinterMute {

Expand Down Expand Up @@ -147,7 +146,8 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) {
if (!_win) return E_FAIL;
#endif

SDL_ShowCursor(SDL_DISABLE);
warning("TODO: Hide cursor");
//SDL_ShowCursor(SDL_DISABLE);

#ifdef __IPHONEOS__
// SDL defaults to OGL ES2, which doesn't work on old devices
Expand Down Expand Up @@ -366,11 +366,12 @@ const char *CBRenderSDL::GetName() {

//////////////////////////////////////////////////////////////////////////
HRESULT CBRenderSDL::SetViewport(int left, int top, int right, int bottom) {
SDL_Rect rect;
rect.x = left + _borderLeft;
rect.y = top + _borderTop;
rect.w = (right - left) * _ratioX;
rect.h = (bottom - top) * _ratioY;
Common::Rect rect;
// TODO: Hopefully this is the same logic that ScummVM uses.
rect.left = left + _borderLeft;
rect.top = top + _borderTop;
rect.right = (right - left) * _ratioX;
rect.bottom = (bottom - top) * _ratioY;

// TODO fix this once viewports work correctly in SDL/landscape
#ifndef __IPHONEOS__
Expand Down
1 change: 0 additions & 1 deletion engines/wintermute/BRenderSDL.h
Expand Up @@ -30,7 +30,6 @@
#define WINTERMUTE_BRENDERER_SDL_H

#include "BRenderer.h"
/*#include "SDL.h"*/
#include "common/rect.h"
#include "graphics/surface.h"

Expand Down
17 changes: 12 additions & 5 deletions engines/wintermute/BSurfaceSDL.cpp
Expand Up @@ -181,7 +181,10 @@ HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte
}

//////////////////////////////////////////////////////////////////////////
void CBSurfaceSDL::GenAlphaMask(SDL_Surface *surface) {
void CBSurfaceSDL::GenAlphaMask(Graphics::Surface *surface) {
warning("CBSurfaceSDL::GenAlphaMask - Not ported yet");
return;
#if 0
delete[] _alphaMask;
_alphaMask = NULL;
if (!surface) return;
Expand Down Expand Up @@ -220,13 +223,16 @@ void CBSurfaceSDL::GenAlphaMask(SDL_Surface *surface) {
delete[] _alphaMask;
_alphaMask = NULL;
}
#endif
}

//////////////////////////////////////////////////////////////////////////
Uint32 CBSurfaceSDL::GetPixel(SDL_Surface *surface, int x, int y) {
uint32 CBSurfaceSDL::GetPixel(Graphics::Surface *surface, int x, int y) {
warning("CBSurfaceSDL::GetPixel - Not ported yet");
#if 0
int bpp = surface->format->BytesPerPixel;
/* Here p is the address to the pixel we want to retrieve */
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;

switch (bpp) {
case 1:
Expand All @@ -251,6 +257,7 @@ Uint32 CBSurfaceSDL::GetPixel(SDL_Surface *surface, int x, int y) {
default:
return 0; /* shouldn't happen, but avoids warnings */
}
#endif
}

//////////////////////////////////////////////////////////////////////////
Expand All @@ -271,7 +278,7 @@ HRESULT CBSurfaceSDL::Create(int Width, int Height) {
}

//////////////////////////////////////////////////////////////////////////
HRESULT CBSurfaceSDL::CreateFromSDLSurface(SDL_Surface *surface) {
HRESULT CBSurfaceSDL::CreateFromSDLSurface(Graphics::Surface *surface) {
warning("CBSurfaceSDL::CreateFromSDLSurface not ported yet"); //TODO
#if 0
CBRenderSDL *renderer = static_cast<CBRenderSDL *>(Game->_renderer);
Expand Down Expand Up @@ -314,7 +321,7 @@ bool CBSurfaceSDL::IsTransparentAt(int X, int Y) {
bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) {
//if (!_lockPixels) return false;

Uint32 format;
uint32 format;
int access;
int width, height;
// This particular warning is rather messy, as this function is called a ton,
Expand Down
11 changes: 5 additions & 6 deletions engines/wintermute/BSurfaceSDL.h
Expand Up @@ -31,9 +31,8 @@

#include "graphics/surface.h"
#include "BSurface.h"
#include "SDL.h" // TODO, remove
class SDL_Texture;
class SDL_Surface;
#include "graphics/surface.h"

namespace WinterMute {

class CBSurfaceSDL : public CBSurface {
Expand All @@ -44,7 +43,7 @@ class CBSurfaceSDL : public CBSurface {
HRESULT Create(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false);
HRESULT Create(int Width, int Height);

HRESULT CreateFromSDLSurface(SDL_Surface *surface);
HRESULT CreateFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function

bool IsTransparentAt(int X, int Y);
bool IsTransparentAtLite(int X, int Y);
Expand All @@ -69,8 +68,8 @@ class CBSurfaceSDL : public CBSurface {
Graphics::Surface *_surface;

HRESULT DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX = 0, int offsetY = 0);
void GenAlphaMask(SDL_Surface *surface);
uint32 GetPixel(SDL_Surface *surface, int x, int y);
void GenAlphaMask(Graphics::Surface *surface);
uint32 GetPixel(Graphics::Surface *surface, int x, int y);

void *_lockPixels;
int _lockPitch;
Expand Down
3 changes: 3 additions & 0 deletions engines/wintermute/FontGlyphCache.cpp
Expand Up @@ -71,6 +71,8 @@ void FontGlyphCache::AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot

//////////////////////////////////////////////////////////////////////////
void GlyphInfo::SetGlyphImage(size_t width, size_t height, size_t stride, byte *pixels) {
warning("GlyphInfo::SetGlyphImage - Not ported yet");
#if 0
if (_image) SDL_FreeSurface(_image);

_image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
Expand All @@ -91,6 +93,7 @@ void GlyphInfo::SetGlyphImage(size_t width, size_t height, size_t stride, byte *
}

SDL_UnlockSurface(_image);
#endif
}

} // end of namespace WinterMute
9 changes: 5 additions & 4 deletions engines/wintermute/FontGlyphCache.h
Expand Up @@ -27,8 +27,8 @@ THE SOFTWARE.
#define __WmeFontGlyphCache_H__


#include "SDL.h"
#include "BFontStorage.h"
#include "graphics/surface.h"

namespace WinterMute {

Expand All @@ -46,7 +46,8 @@ class GlyphInfo {
}

~GlyphInfo() {
if (_image) SDL_FreeSurface(_image);
// TODO
//if (_image) SDL_FreeSurface(_image);
}

void SetGlyphInfo(float AdvanceX, float AdvanceY, int BearingX, int BearingY) {
Expand Down Expand Up @@ -79,7 +80,7 @@ class GlyphInfo {
int GetBearingY() {
return _bearingY;
}
SDL_Surface *GetImage() {
Graphics::Surface *GetImage() {
return _image;
}

Expand All @@ -94,7 +95,7 @@ class GlyphInfo {
int _width;
int _height;

SDL_Surface *_image;
Graphics::Surface *_image;
};


Expand Down

0 comments on commit 4cf1d67

Please sign in to comment.