Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Making the API simpler, scaling is always defined as linear interpola…
…tion and should be supported as much as possible on all renderers.
  • Loading branch information
slouken committed Feb 1, 2011
1 parent 77e26ec commit 48e7935
Show file tree
Hide file tree
Showing 22 changed files with 9 additions and 544 deletions.
1 change: 0 additions & 1 deletion Makefile.in
Expand Up @@ -71,7 +71,6 @@ HDRS = \
SDL_rect.h \
SDL_revision.h \
SDL_rwops.h \
SDL_scalemode.h \
SDL_scancode.h \
SDL_shape.h \
SDL_stdinc.h \
Expand Down
8 changes: 0 additions & 8 deletions include/SDL_compat.h
Expand Up @@ -208,14 +208,6 @@ typedef enum
SDL_GRAB_ON = 1
} SDL_GrabMode;

typedef enum
{
SDL_TEXTURESCALEMODE_NONE = SDL_SCALEMODE_NONE,
SDL_TEXTURESCALEMODE_FAST = SDL_SCALEMODE_FAST,
SDL_TEXTURESCALEMODE_SLOW = SDL_SCALEMODE_SLOW,
SDL_TEXTURESCALEMODE_BEST = SDL_SCALEMODE_BEST
} SDL_TextureScaleMode;

struct SDL_SysWMinfo;

/**
Expand Down
69 changes: 0 additions & 69 deletions include/SDL_scalemode.h

This file was deleted.

32 changes: 0 additions & 32 deletions include/SDL_surface.h
Expand Up @@ -33,7 +33,6 @@
#include "SDL_pixels.h"
#include "SDL_rect.h"
#include "SDL_blendmode.h"
#include "SDL_scalemode.h"
#include "SDL_rwops.h"

#include "begin_code.h"
Expand Down Expand Up @@ -317,37 +316,6 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
SDL_BlendMode *blendMode);

/**
* \brief Set the scale mode used for blit operations.
*
* \param surface The surface to update.
* \param scaleMode ::SDL_ScaleMode to use for blit scaling.
*
* \return 0 on success, or -1 if the surface is not valid or the scale mode is
* not supported.
*
* \note If the scale mode is not supported, the closest supported mode is
* chosen. Currently only ::SDL_TEXTURESCALEMODE_FAST is supported on
* surfaces.
*
* \sa SDL_GetSurfaceScaleMode()
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface * surface,
SDL_ScaleMode scaleMode);

/**
* \brief Get the scale mode used for blit operations.
*
* \param surface The surface to query.
* \param scaleMode A pointer filled in with the current scale mode.
*
* \return 0 on success, or -1 if the surface is not valid.
*
* \sa SDL_SetSurfaceScaleMode()
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceScaleMode(SDL_Surface * surface,
SDL_ScaleMode *scaleMode);

/**
* Sets the clipping rectangle for the destination surface in a blit.
*
Expand Down
32 changes: 0 additions & 32 deletions include/SDL_video.h
Expand Up @@ -33,7 +33,6 @@
#include "SDL_pixels.h"
#include "SDL_rect.h"
#include "SDL_blendmode.h"
#include "SDL_scalemode.h"
#include "SDL_surface.h"

#include "begin_code.h"
Expand Down Expand Up @@ -189,7 +188,6 @@ typedef struct SDL_RendererInfo
Uint32 flags; /**< Supported ::SDL_RendererFlags */
Uint32 mod_modes; /**< A mask of supported channel modulation */
Uint32 blend_modes; /**< A mask of supported blend modes */
Uint32 scale_modes; /**< A mask of supported scale modes */
Uint32 num_texture_formats; /**< The number of available texture formats */
Uint32 texture_formats[50]; /**< The available texture formats */
int max_texture_width; /**< The maximimum texture width */
Expand Down Expand Up @@ -968,36 +966,6 @@ extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
SDL_BlendMode *blendMode);

/**
* \brief Set the scale mode used for texture copy operations.
*
* \param texture The texture to update.
* \param scaleMode ::SDL_ScaleMode to use for texture scaling.
*
* \return 0 on success, or -1 if the texture is not valid or the scale mode is
* not supported.
*
* \note If the scale mode is not supported, the closest supported mode is
* chosen.
*
* \sa SDL_GetTextureScaleMode()
*/
extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture,
SDL_ScaleMode scaleMode);

/**
* \brief Get the scale mode used for texture copy operations.
*
* \param texture The texture to query.
* \param scaleMode A pointer filled in with the current scale mode.
*
* \return 0 on success, or -1 if the texture is not valid.
*
* \sa SDL_SetTextureScaleMode()
*/
extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture,
SDL_ScaleMode *scaleMode);

/**
* \brief Update the given texture rectangle with new pixel data.
*
Expand Down
49 changes: 2 additions & 47 deletions src/video/SDL_renderer_gl.c
Expand Up @@ -85,8 +85,6 @@ static int GL_SetTextureAlphaMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int GL_SetTextureBlendMode(SDL_Renderer * renderer,
SDL_Texture * texture);
static int GL_SetTextureScaleMode(SDL_Renderer * renderer,
SDL_Texture * texture);
static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels,
int pitch);
Expand Down Expand Up @@ -126,7 +124,6 @@ SDL_RenderDriver GL_RenderDriver = {
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW),
15,
{
SDL_PIXELFORMAT_INDEX1LSB,
Expand Down Expand Up @@ -159,7 +156,6 @@ typedef struct
SDL_bool GL_MESA_ycbcr_texture_supported;
SDL_bool GL_ARB_fragment_program_supported;
int blendMode;
int scaleMode;

/* OpenGL functions */
#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
Expand Down Expand Up @@ -303,7 +299,6 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->SetTextureColorMod = GL_SetTextureColorMod;
renderer->SetTextureAlphaMod = GL_SetTextureAlphaMod;
renderer->SetTextureBlendMode = GL_SetTextureBlendMode;
renderer->SetTextureScaleMode = GL_SetTextureScaleMode;
renderer->UpdateTexture = GL_UpdateTexture;
renderer->LockTexture = GL_LockTexture;
renderer->UnlockTexture = GL_UnlockTexture;
Expand Down Expand Up @@ -422,7 +417,6 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)

/* Set up parameters for rendering */
data->blendMode = -1;
data->scaleMode = -1;
data->glDisable(GL_DEPTH_TEST);
data->glDisable(GL_CULL_FACE);
/* This ended up causing video discrepancies between OpenGL and Direct3D */
Expand Down Expand Up @@ -842,9 +836,9 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
renderdata->glEnable(data->type);
renderdata->glBindTexture(data->type, data->texture);
renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
GL_LINEAR);
renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
GL_LINEAR);
renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
Expand Down Expand Up @@ -1000,25 +994,6 @@ GL_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
}
}

static int
GL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
switch (texture->scaleMode) {
case SDL_SCALEMODE_NONE:
case SDL_SCALEMODE_FAST:
case SDL_SCALEMODE_SLOW:
return 0;
case SDL_SCALEMODE_BEST:
SDL_Unsupported();
texture->scaleMode = SDL_SCALEMODE_SLOW;
return -1;
default:
SDL_Unsupported();
texture->scaleMode = SDL_SCALEMODE_NONE;
return -1;
}
}

static int
GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels, int pitch)
Expand Down Expand Up @@ -1363,26 +1338,6 @@ GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
}
}

if (texture->scaleMode != data->scaleMode) {
switch (texture->scaleMode) {
case SDL_SCALEMODE_NONE:
case SDL_SCALEMODE_FAST:
data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
break;
case SDL_SCALEMODE_SLOW:
case SDL_SCALEMODE_BEST:
data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
break;
}
data->scaleMode = texture->scaleMode;
}

if (shader) {
data->glEnable(GL_FRAGMENT_PROGRAM_ARB);
data->glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader);
Expand Down
44 changes: 2 additions & 42 deletions src/video/SDL_renderer_gles.c
Expand Up @@ -73,8 +73,6 @@ static int GLES_SetTextureAlphaMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int GLES_SetTextureBlendMode(SDL_Renderer * renderer,
SDL_Texture * texture);
static int GLES_SetTextureScaleMode(SDL_Renderer * renderer,
SDL_Texture * texture);
static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels,
int pitch);
Expand Down Expand Up @@ -112,7 +110,6 @@ SDL_RenderDriver GL_ES_RenderDriver = {
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW), 6,
{
/* OpenGL ES 1.x supported formats list */
SDL_PIXELFORMAT_RGBA4444,
Expand Down Expand Up @@ -241,7 +238,6 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->SetTextureColorMod = GLES_SetTextureColorMod;
renderer->SetTextureAlphaMod = GLES_SetTextureAlphaMod;
renderer->SetTextureBlendMode = GLES_SetTextureBlendMode;
renderer->SetTextureScaleMode = GLES_SetTextureScaleMode;
renderer->UpdateTexture = GLES_UpdateTexture;
renderer->LockTexture = GLES_LockTexture;
renderer->UnlockTexture = GLES_UnlockTexture;
Expand Down Expand Up @@ -449,9 +445,9 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
data->formattype = type;
renderdata->glBindTexture(data->type, data->texture);
renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
GL_LINEAR);
renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
GL_LINEAR);
renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
Expand Down Expand Up @@ -534,25 +530,6 @@ GLES_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
}
}

static int
GLES_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
switch (texture->scaleMode) {
case SDL_SCALEMODE_NONE:
case SDL_SCALEMODE_FAST:
case SDL_SCALEMODE_SLOW:
return 0;
case SDL_SCALEMODE_BEST:
SDL_Unsupported();
texture->scaleMode = SDL_SCALEMODE_SLOW;
return -1;
default:
SDL_Unsupported();
texture->scaleMode = SDL_SCALEMODE_NONE;
return -1;
}
}

static int
GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels, int pitch)
Expand Down Expand Up @@ -878,23 +855,6 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,

GLES_SetBlendMode(data, texture->blendMode, 0);

switch (texture->scaleMode) {
case SDL_SCALEMODE_NONE:
case SDL_SCALEMODE_FAST:
data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
break;
case SDL_SCALEMODE_SLOW:
case SDL_SCALEMODE_BEST:
data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
break;
}

if (data->GL_OES_draw_texture_supported && data->useDrawTexture) {
/* this code is a little funny because the viewport is upside down vs SDL's coordinate system */
SDL_Window *window = renderer->window;
Expand Down

0 comments on commit 48e7935

Please sign in to comment.