2011-02-02 14:34:54 -08:00
|
|
|
/*
|
|
|
|
SDL - Simple DirectMedia Layer
|
2011-02-11 22:37:15 -08:00
|
|
|
Copyright (C) 1997-2011 Sam Lantinga
|
2011-02-02 14:34:54 -08:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
Sam Lantinga
|
|
|
|
slouken@libsdl.org
|
|
|
|
*/
|
|
|
|
#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;
|
|
|
|
|
|
|
|
/* 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);
|
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);
|
|
|
|
int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points,
|
|
|
|
int count);
|
|
|
|
int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points,
|
|
|
|
int count);
|
2011-02-15 13:59:59 -08:00
|
|
|
int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect * rects,
|
2011-02-02 14:34:54 -08:00
|
|
|
int count);
|
|
|
|
int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
|
|
|
|
const SDL_Rect * srcrect, const SDL_Rect * dstrect);
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* The current renderer info */
|
|
|
|
SDL_RendererInfo info;
|
|
|
|
|
|
|
|
/* The window associated with the renderer */
|
|
|
|
SDL_Window *window;
|
2011-02-15 13:59:59 -08:00
|
|
|
|
|
|
|
/* The drawable area within the window */
|
|
|
|
SDL_Rect viewport;
|
2011-02-02 14:34:54 -08:00
|
|
|
|
|
|
|
/* The list of textures */
|
|
|
|
SDL_Texture *textures;
|
|
|
|
|
|
|
|
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: */
|