2011-02-02 14:34:54 -08:00
|
|
|
/*
|
2011-04-08 13:03:26 -07:00
|
|
|
Simple DirectMedia Layer
|
2011-12-31 09:28:07 -05:00
|
|
|
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
2011-04-08 13:03:26 -07:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
2011-02-02 14:34:54 -08:00
|
|
|
*/
|
|
|
|
#include "SDL_config.h"
|
|
|
|
|
|
|
|
#ifndef _SDL_sysrender_h
|
|
|
|
#define _SDL_sysrender_h
|
|
|
|
|
|
|
|
#include "SDL_render.h"
|
|
|
|
#include "SDL_events.h"
|
2011-02-03 00:19:40 -08:00
|
|
|
#include "SDL_yuv_sw_c.h"
|
2011-02-02 14:34:54 -08:00
|
|
|
|
|
|
|
/* The SDL 2D rendering system */
|
|
|
|
|
|
|
|
typedef struct SDL_RenderDriver SDL_RenderDriver;
|
|
|
|
|
2012-10-01 20:59:33 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
} SDL_FPoint;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float w;
|
|
|
|
float h;
|
|
|
|
} SDL_FRect;
|
|
|
|
|
2011-02-02 14:34:54 -08:00
|
|
|
/* Define the SDL texture structure */
|
|
|
|
struct SDL_Texture
|
|
|
|
{
|
|
|
|
const void *magic;
|
|
|
|
Uint32 format; /**< The pixel format of the texture */
|
|
|
|
int access; /**< SDL_TextureAccess */
|
|
|
|
int w; /**< The width of the texture */
|
|
|
|
int h; /**< The height of the texture */
|
|
|
|
int modMode; /**< The texture modulation mode */
|
|
|
|
SDL_BlendMode blendMode; /**< The texture blend mode */
|
|
|
|
Uint8 r, g, b, a; /**< Texture modulation values */
|
|
|
|
|
|
|
|
SDL_Renderer *renderer;
|
|
|
|
|
2011-02-03 00:19:40 -08:00
|
|
|
/* Support for formats not supported directly by the renderer */
|
|
|
|
SDL_Texture *native;
|
|
|
|
SDL_SW_YUVTexture *yuv;
|
|
|
|
void *pixels;
|
|
|
|
int pitch;
|
|
|
|
SDL_Rect locked_rect;
|
|
|
|
|
2011-02-02 14:34:54 -08:00
|
|
|
void *driverdata; /**< Driver specific texture representation */
|
|
|
|
|
|
|
|
SDL_Texture *prev;
|
|
|
|
SDL_Texture *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Define the SDL renderer structure */
|
|
|
|
struct SDL_Renderer
|
|
|
|
{
|
|
|
|
const void *magic;
|
|
|
|
|
|
|
|
void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event);
|
|
|
|
int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
|
|
|
int (*SetTextureColorMod) (SDL_Renderer * renderer,
|
|
|
|
SDL_Texture * texture);
|
|
|
|
int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
|
|
|
|
SDL_Texture * texture);
|
|
|
|
int (*SetTextureBlendMode) (SDL_Renderer * renderer,
|
|
|
|
SDL_Texture * texture);
|
|
|
|
int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
|
|
|
const SDL_Rect * rect, const void *pixels,
|
|
|
|
int pitch);
|
|
|
|
int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
2011-02-03 00:19:40 -08:00
|
|
|
const SDL_Rect * rect, void **pixels, int *pitch);
|
2011-02-02 14:34:54 -08:00
|
|
|
void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
2012-01-22 01:26:28 -05:00
|
|
|
int (*SetRenderTarget) (SDL_Renderer * renderer, SDL_Texture * texture);
|
2011-02-15 13:59:59 -08:00
|
|
|
int (*UpdateViewport) (SDL_Renderer * renderer);
|
2011-02-02 14:34:54 -08:00
|
|
|
int (*RenderClear) (SDL_Renderer * renderer);
|
2012-10-01 20:59:33 -07:00
|
|
|
int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_FPoint * points,
|
2011-02-02 14:34:54 -08:00
|
|
|
int count);
|
2012-10-01 20:59:33 -07:00
|
|
|
int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_FPoint * points,
|
2011-02-02 14:34:54 -08:00
|
|
|
int count);
|
2012-10-01 20:59:33 -07:00
|
|
|
int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_FRect * rects,
|
2011-02-02 14:34:54 -08:00
|
|
|
int count);
|
|
|
|
int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
|
2012-10-01 20:59:33 -07:00
|
|
|
const SDL_Rect * srcrect, const SDL_FRect * dstrect);
|
2012-06-01 19:51:08 -03:00
|
|
|
int (*RenderCopyEx) (SDL_Renderer * renderer, SDL_Texture * texture,
|
2012-10-01 20:59:33 -07:00
|
|
|
const SDL_Rect * srcquad, const SDL_FRect * dstrect,
|
|
|
|
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
|
2011-02-02 14:34:54 -08:00
|
|
|
int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
|
|
|
|
Uint32 format, void * pixels, int pitch);
|
|
|
|
void (*RenderPresent) (SDL_Renderer * renderer);
|
|
|
|
void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
|
|
|
|
|
|
|
void (*DestroyRenderer) (SDL_Renderer * renderer);
|
|
|
|
|
2012-09-03 11:16:12 -03:00
|
|
|
int (*GL_BindTexture) (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh);
|
|
|
|
int (*GL_UnbindTexture) (SDL_Renderer * renderer, SDL_Texture *texture);
|
|
|
|
|
2011-02-02 14:34:54 -08:00
|
|
|
/* The current renderer info */
|
|
|
|
SDL_RendererInfo info;
|
|
|
|
|
|
|
|
/* The window associated with the renderer */
|
|
|
|
SDL_Window *window;
|
2012-01-22 21:46:06 -05:00
|
|
|
SDL_bool hidden;
|
|
|
|
SDL_bool resized;
|
2011-02-15 13:59:59 -08:00
|
|
|
|
2012-10-01 22:30:07 -07:00
|
|
|
/* The logical resolution for rendering */
|
|
|
|
int logical_w;
|
|
|
|
int logical_h;
|
|
|
|
|
2011-02-15 13:59:59 -08:00
|
|
|
/* The drawable area within the window */
|
|
|
|
SDL_Rect viewport;
|
2012-01-21 22:22:30 -05:00
|
|
|
SDL_Rect viewport_backup;
|
2011-02-02 14:34:54 -08:00
|
|
|
|
2012-10-01 20:59:33 -07:00
|
|
|
/* The render output coordinate scale */
|
|
|
|
SDL_FPoint scale;
|
|
|
|
SDL_FPoint scale_backup;
|
|
|
|
|
2011-02-02 14:34:54 -08:00
|
|
|
/* The list of textures */
|
|
|
|
SDL_Texture *textures;
|
2012-01-21 22:22:30 -05:00
|
|
|
SDL_Texture *target;
|
2011-02-02 14:34:54 -08:00
|
|
|
|
|
|
|
Uint8 r, g, b, a; /**< Color for drawing operations values */
|
|
|
|
SDL_BlendMode blendMode; /**< The drawing blend mode */
|
|
|
|
|
|
|
|
void *driverdata;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Define the SDL render driver structure */
|
|
|
|
struct SDL_RenderDriver
|
|
|
|
{
|
|
|
|
SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
|
|
|
|
|
|
|
|
/* Info about the renderer capabilities */
|
|
|
|
SDL_RendererInfo info;
|
|
|
|
};
|
|
|
|
|
2011-02-08 10:04:09 -08:00
|
|
|
#if !SDL_RENDER_DISABLED
|
|
|
|
|
2011-02-02 14:34:54 -08:00
|
|
|
#if SDL_VIDEO_RENDER_D3D
|
|
|
|
extern SDL_RenderDriver D3D_RenderDriver;
|
|
|
|
#endif
|
|
|
|
#if SDL_VIDEO_RENDER_OGL
|
|
|
|
extern SDL_RenderDriver GL_RenderDriver;
|
|
|
|
#endif
|
2011-02-06 00:00:13 -08:00
|
|
|
#if SDL_VIDEO_RENDER_OGL_ES2
|
|
|
|
extern SDL_RenderDriver GLES2_RenderDriver;
|
2011-02-02 14:34:54 -08:00
|
|
|
#endif
|
2011-02-06 10:22:25 -08:00
|
|
|
#if SDL_VIDEO_RENDER_OGL_ES
|
|
|
|
extern SDL_RenderDriver GLES_RenderDriver;
|
|
|
|
#endif
|
2011-02-05 16:07:10 -08:00
|
|
|
#if SDL_VIDEO_RENDER_DIRECTFB
|
|
|
|
extern SDL_RenderDriver DirectFB_RenderDriver;
|
|
|
|
#endif
|
a Nintendo ds update
Frank Zago to SDL
For those interested, here's a snapshot of the current port. I did away with
most of the previous attempt which was based of the sprite engine, because the
support is limited to 128 64x64 sprites. Instead I'm using the gl engine.
The drawback is that either the frame buffer or the gl engine can be used
because there's not that much video memory on a DS.
With minimal changes to their code, it can now run the following tests: ,
testspriteminimal, testscale and testsprite2. The last 2 only run under the
emulator for some reason. The tests are not included in this patch for size
reason.
In 16 bits mode, the 16th bit indicated transparency/opacity. If 0, the color
is not displayed. So I had to patch a few core file to set that bit to 1. See
patch for src/video/SDL_RLEaccel.c and src/video/SDL_blit.h. Is that ok, or is
there a better way ?
The nds also doesn't support windowed mode, so I force the fullscreen in
src/video/SDL_video.c. Is that ok, or is there a better way ?
To get a smaller library, I also tried to not compile the software renderer
when the hardware renderer is compiled in, and define SDL_NO_COMPAT; however
the compilation eventually fails in SDL_surface.c because SDL_SRCCOLORKEY is
defined in SDL_compat.h. Is SDL_NO_COMPAT only for application and not SDL
itself ?
2011-03-06 21:12:19 -08:00
|
|
|
#if SDL_VIDEO_RENDER_NDS
|
|
|
|
extern SDL_RenderDriver NDS_RenderDriver;
|
|
|
|
#endif
|
2011-02-02 14:34:54 -08:00
|
|
|
extern SDL_RenderDriver SW_RenderDriver;
|
|
|
|
|
2011-02-08 10:04:09 -08:00
|
|
|
#endif /* !SDL_RENDER_DISABLED */
|
|
|
|
|
2011-02-02 14:34:54 -08:00
|
|
|
#endif /* _SDL_sysrender_h */
|
|
|
|
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|