mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-30 20:31:59 +00:00
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.
In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.
The script I ran for the src directory is added as build-scripts/clang-format-src.sh
This fixes:
#6592
#6593
#6594
(cherry picked from commit 5750bcb174)
This commit is contained in:
@@ -128,7 +128,6 @@ Float4X4 MatrixRotationZ(float r)
|
||||
m.v._33 = 1.0f;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
|
||||
}
|
||||
|
||||
#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) && !SDL_RENDER_DISABLED */
|
||||
|
||||
@@ -52,8 +52,10 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float _11, _12, _13, _14;
|
||||
float _21, _22, _23, _24;
|
||||
float _31, _32, _33, _34;
|
||||
@@ -63,7 +65,6 @@ typedef struct
|
||||
};
|
||||
} Float4X4;
|
||||
|
||||
|
||||
Float4X4 MatrixIdentity();
|
||||
Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2);
|
||||
Float4X4 MatrixScaling(float x, float y, float z);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -44,7 +44,6 @@ typedef struct SDL_DRect
|
||||
double h;
|
||||
} SDL_DRect;
|
||||
|
||||
|
||||
/* The SDL 2D rendering system */
|
||||
|
||||
typedef struct SDL_RenderDriver SDL_RenderDriver;
|
||||
@@ -53,14 +52,14 @@ typedef struct SDL_RenderDriver SDL_RenderDriver;
|
||||
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 */
|
||||
SDL_ScaleMode scaleMode; /**< The texture scale mode */
|
||||
SDL_Color color; /**< Texture modulation values */
|
||||
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 */
|
||||
SDL_ScaleMode scaleMode; /**< The texture scale mode */
|
||||
SDL_Color color; /**< Texture modulation values */
|
||||
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
@@ -70,11 +69,11 @@ struct SDL_Texture
|
||||
void *pixels;
|
||||
int pitch;
|
||||
SDL_Rect locked_rect;
|
||||
SDL_Surface *locked_surface; /**< Locked region exposed as a SDL surface */
|
||||
SDL_Surface *locked_surface; /**< Locked region exposed as a SDL surface */
|
||||
|
||||
Uint32 last_command_generation; /* last command queue generation this texture was in. */
|
||||
|
||||
void *driverdata; /**< Driver specific texture representation */
|
||||
void *driverdata; /**< Driver specific texture representation */
|
||||
void *userdata;
|
||||
|
||||
SDL_Texture *prev;
|
||||
@@ -99,23 +98,28 @@ typedef enum
|
||||
typedef struct SDL_RenderCommand
|
||||
{
|
||||
SDL_RenderCommandType command;
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
size_t first;
|
||||
SDL_Rect rect;
|
||||
} viewport;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
SDL_bool enabled;
|
||||
SDL_Rect rect;
|
||||
} cliprect;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
size_t first;
|
||||
size_t count;
|
||||
Uint8 r, g, b, a;
|
||||
SDL_BlendMode blend;
|
||||
SDL_Texture *texture;
|
||||
} draw;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
size_t first;
|
||||
Uint8 r, g, b, a;
|
||||
} color;
|
||||
@@ -123,14 +127,12 @@ typedef struct SDL_RenderCommand
|
||||
struct SDL_RenderCommand *next;
|
||||
} SDL_RenderCommand;
|
||||
|
||||
|
||||
typedef struct SDL_VertexSolid
|
||||
{
|
||||
SDL_FPoint position;
|
||||
SDL_Color color;
|
||||
SDL_Color color;
|
||||
} SDL_VertexSolid;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDL_RENDERLINEMETHOD_POINTS,
|
||||
@@ -138,68 +140,67 @@ typedef enum
|
||||
SDL_RENDERLINEMETHOD_GEOMETRY,
|
||||
} SDL_RenderLineMethod;
|
||||
|
||||
|
||||
/* Define the SDL renderer structure */
|
||||
struct SDL_Renderer
|
||||
{
|
||||
const void *magic;
|
||||
|
||||
void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event);
|
||||
int (*GetOutputSize) (SDL_Renderer * renderer, int *w, int *h);
|
||||
SDL_bool (*SupportsBlendMode)(SDL_Renderer * renderer, SDL_BlendMode blendMode);
|
||||
int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
int (*QueueSetViewport) (SDL_Renderer * renderer, SDL_RenderCommand *cmd);
|
||||
int (*QueueSetDrawColor) (SDL_Renderer * renderer, SDL_RenderCommand *cmd);
|
||||
int (*QueueDrawPoints) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points,
|
||||
int count);
|
||||
int (*QueueDrawLines) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points,
|
||||
int count);
|
||||
int (*QueueFillRects) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects,
|
||||
int count);
|
||||
int (*QueueCopy) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect);
|
||||
int (*QueueCopyEx) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
|
||||
const SDL_Rect * srcquad, const SDL_FRect * dstrect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y);
|
||||
int (*QueueGeometry) (SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y);
|
||||
void (*WindowEvent)(SDL_Renderer *renderer, const SDL_WindowEvent *event);
|
||||
int (*GetOutputSize)(SDL_Renderer *renderer, int *w, int *h);
|
||||
SDL_bool (*SupportsBlendMode)(SDL_Renderer *renderer, SDL_BlendMode blendMode);
|
||||
int (*CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture);
|
||||
int (*QueueSetViewport)(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
|
||||
int (*QueueSetDrawColor)(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
|
||||
int (*QueueDrawPoints)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points,
|
||||
int count);
|
||||
int (*QueueDrawLines)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points,
|
||||
int count);
|
||||
int (*QueueFillRects)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects,
|
||||
int count);
|
||||
int (*QueueCopy)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const SDL_Rect *srcrect, const SDL_FRect *dstrect);
|
||||
int (*QueueCopyEx)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const SDL_Rect *srcquad, const SDL_FRect *dstrect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y);
|
||||
int (*QueueGeometry)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y);
|
||||
|
||||
int (*RunCommandQueue) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize);
|
||||
int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels,
|
||||
int pitch);
|
||||
int (*RunCommandQueue)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize);
|
||||
int (*UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels,
|
||||
int pitch);
|
||||
#if SDL_HAVE_YUV
|
||||
int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
int (*UpdateTextureYUV)(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch);
|
||||
int (*UpdateTextureNV) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
int (*UpdateTextureNV)(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
#endif
|
||||
int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch);
|
||||
void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
void (*SetTextureScaleMode) (SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode);
|
||||
int (*SetRenderTarget) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch);
|
||||
int (*RenderPresent) (SDL_Renderer * renderer);
|
||||
void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
int (*LockTexture)(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch);
|
||||
void (*UnlockTexture)(SDL_Renderer *renderer, SDL_Texture *texture);
|
||||
void (*SetTextureScaleMode)(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode);
|
||||
int (*SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture);
|
||||
int (*RenderReadPixels)(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||
Uint32 format, void *pixels, int pitch);
|
||||
int (*RenderPresent)(SDL_Renderer *renderer);
|
||||
void (*DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture);
|
||||
|
||||
void (*DestroyRenderer) (SDL_Renderer * renderer);
|
||||
void (*DestroyRenderer)(SDL_Renderer *renderer);
|
||||
|
||||
int (*SetVSync) (SDL_Renderer * renderer, int vsync);
|
||||
int (*SetVSync)(SDL_Renderer *renderer, int vsync);
|
||||
|
||||
int (*GL_BindTexture) (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh);
|
||||
int (*GL_UnbindTexture) (SDL_Renderer * renderer, SDL_Texture *texture);
|
||||
int (*GL_BindTexture)(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh);
|
||||
int (*GL_UnbindTexture)(SDL_Renderer *renderer, SDL_Texture *texture);
|
||||
|
||||
void *(*GetMetalLayer) (SDL_Renderer * renderer);
|
||||
void *(*GetMetalCommandEncoder) (SDL_Renderer * renderer);
|
||||
void *(*GetMetalLayer)(SDL_Renderer *renderer);
|
||||
void *(*GetMetalCommandEncoder)(SDL_Renderer *renderer);
|
||||
|
||||
/* The current renderer info */
|
||||
SDL_RendererInfo info;
|
||||
@@ -260,8 +261,8 @@ struct SDL_Renderer
|
||||
SDL_Texture *target;
|
||||
SDL_mutex *target_mutex;
|
||||
|
||||
SDL_Color color; /**< Color for drawing operations values */
|
||||
SDL_BlendMode blendMode; /**< The drawing blend mode */
|
||||
SDL_Color color; /**< Color for drawing operations values */
|
||||
SDL_BlendMode blendMode; /**< The drawing blend mode */
|
||||
|
||||
SDL_bool always_batch;
|
||||
SDL_bool batching;
|
||||
@@ -287,7 +288,7 @@ struct SDL_Renderer
|
||||
/* Define the SDL render driver structure */
|
||||
struct SDL_RenderDriver
|
||||
{
|
||||
SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
|
||||
SDL_Renderer *(*CreateRenderer)(SDL_Window *window, Uint32 flags);
|
||||
|
||||
/* Info about the renderer capabilities */
|
||||
SDL_RendererInfo info;
|
||||
@@ -320,8 +321,8 @@ extern SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode
|
||||
the next call, because it might be in an array that gets realloc()'d. */
|
||||
extern void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset);
|
||||
|
||||
extern int SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode);
|
||||
extern int SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode);
|
||||
extern int SDL_PrivateLowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
|
||||
extern int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -24,11 +24,9 @@
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
|
||||
|
||||
#include "SDL_yuv_sw_c.h"
|
||||
#include "SDL_cpuinfo.h"
|
||||
|
||||
|
||||
SDL_SW_YUVTexture *
|
||||
SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
||||
{
|
||||
@@ -48,7 +46,7 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
swdata = (SDL_SW_YUVTexture *) SDL_calloc(1, sizeof(*swdata));
|
||||
swdata = (SDL_SW_YUVTexture *)SDL_calloc(1, sizeof(*swdata));
|
||||
if (swdata == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -59,33 +57,32 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
||||
swdata->w = w;
|
||||
swdata->h = h;
|
||||
{
|
||||
const int sz_plane = w * h;
|
||||
const int sz_plane_chroma = ((w + 1) / 2) * ((h + 1) / 2);
|
||||
const int sz_plane_packed = ((w + 1) / 2) * h;
|
||||
int dst_size = 0;
|
||||
switch(format)
|
||||
{
|
||||
case SDL_PIXELFORMAT_YV12: /**< Planar mode: Y + V + U (3 planes) */
|
||||
case SDL_PIXELFORMAT_IYUV: /**< Planar mode: Y + U + V (3 planes) */
|
||||
dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma;
|
||||
break;
|
||||
const int sz_plane = w * h;
|
||||
const int sz_plane_chroma = ((w + 1) / 2) * ((h + 1) / 2);
|
||||
const int sz_plane_packed = ((w + 1) / 2) * h;
|
||||
int dst_size = 0;
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_YV12: /**< Planar mode: Y + V + U (3 planes) */
|
||||
case SDL_PIXELFORMAT_IYUV: /**< Planar mode: Y + U + V (3 planes) */
|
||||
dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma;
|
||||
break;
|
||||
|
||||
case SDL_PIXELFORMAT_YUY2: /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
|
||||
case SDL_PIXELFORMAT_UYVY: /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
||||
case SDL_PIXELFORMAT_YVYU: /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
||||
dst_size = 4 * sz_plane_packed;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_YUY2: /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
|
||||
case SDL_PIXELFORMAT_UYVY: /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
||||
case SDL_PIXELFORMAT_YVYU: /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
||||
dst_size = 4 * sz_plane_packed;
|
||||
break;
|
||||
|
||||
case SDL_PIXELFORMAT_NV12: /**< Planar mode: Y + U/V interleaved (2 planes) */
|
||||
case SDL_PIXELFORMAT_NV21: /**< Planar mode: Y + V/U interleaved (2 planes) */
|
||||
dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_NV12: /**< Planar mode: Y + U/V interleaved (2 planes) */
|
||||
case SDL_PIXELFORMAT_NV21: /**< Planar mode: Y + V/U interleaved (2 planes) */
|
||||
dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma;
|
||||
break;
|
||||
|
||||
default:
|
||||
SDL_assert(0 && "We should never get here (caught above)");
|
||||
break;
|
||||
default:
|
||||
SDL_assert(0 && "We should never get here (caught above)");
|
||||
break;
|
||||
}
|
||||
swdata->pixels = (Uint8 *) SDL_SIMDAlloc(dst_size);
|
||||
swdata->pixels = (Uint8 *)SDL_SIMDAlloc(dst_size);
|
||||
if (!swdata->pixels) {
|
||||
SDL_SW_DestroyYUVTexture(swdata);
|
||||
SDL_OutOfMemory();
|
||||
@@ -128,33 +125,31 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
||||
return swdata;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels,
|
||||
int *pitch)
|
||||
int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels,
|
||||
int *pitch)
|
||||
{
|
||||
*pixels = swdata->planes[0];
|
||||
*pitch = swdata->pitches[0];
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const void *pixels, int pitch)
|
||||
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const void *pixels, int pitch)
|
||||
{
|
||||
switch (swdata->format) {
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
if (rect->x == 0 && rect->y == 0 &&
|
||||
rect->w == swdata->w && rect->h == swdata->h) {
|
||||
SDL_memcpy(swdata->pixels, pixels,
|
||||
(swdata->h * swdata->w) + 2* ((swdata->h + 1) /2) * ((swdata->w + 1) / 2));
|
||||
SDL_memcpy(swdata->pixels, pixels,
|
||||
(swdata->h * swdata->w) + 2 * ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2));
|
||||
} else {
|
||||
Uint8 *src, *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
/* Copy the Y plane */
|
||||
src = (Uint8 *) pixels;
|
||||
src = (Uint8 *)pixels;
|
||||
dst = swdata->pixels + rect->y * swdata->w + rect->x;
|
||||
length = rect->w;
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
@@ -162,94 +157,92 @@ SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
src += pitch;
|
||||
dst += swdata->w;
|
||||
}
|
||||
|
||||
|
||||
/* Copy the next plane */
|
||||
src = (Uint8 *) pixels + rect->h * pitch;
|
||||
src = (Uint8 *)pixels + rect->h * pitch;
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
dst += rect->y/2 * ((swdata->w + 1) / 2) + rect->x/2;
|
||||
dst += rect->y / 2 * ((swdata->w + 1) / 2) + rect->x / 2;
|
||||
length = (rect->w + 1) / 2;
|
||||
for (row = 0; row < (rect->h + 1)/2; ++row) {
|
||||
for (row = 0; row < (rect->h + 1) / 2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += (pitch + 1)/2;
|
||||
dst += (swdata->w + 1)/2;
|
||||
src += (pitch + 1) / 2;
|
||||
dst += (swdata->w + 1) / 2;
|
||||
}
|
||||
|
||||
/* Copy the next plane */
|
||||
src = (Uint8 *) pixels + rect->h * pitch + ((rect->h + 1) / 2) * ((pitch + 1) / 2);
|
||||
src = (Uint8 *)pixels + rect->h * pitch + ((rect->h + 1) / 2) * ((pitch + 1) / 2);
|
||||
dst = swdata->pixels + swdata->h * swdata->w +
|
||||
((swdata->h + 1)/2) * ((swdata->w+1) / 2);
|
||||
dst += rect->y/2 * ((swdata->w + 1)/2) + rect->x/2;
|
||||
((swdata->h + 1) / 2) * ((swdata->w + 1) / 2);
|
||||
dst += rect->y / 2 * ((swdata->w + 1) / 2) + rect->x / 2;
|
||||
length = (rect->w + 1) / 2;
|
||||
for (row = 0; row < (rect->h + 1)/2; ++row) {
|
||||
for (row = 0; row < (rect->h + 1) / 2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += (pitch + 1)/2;
|
||||
dst += (swdata->w + 1)/2;
|
||||
src += (pitch + 1) / 2;
|
||||
dst += (swdata->w + 1) / 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_PIXELFORMAT_YUY2:
|
||||
case SDL_PIXELFORMAT_UYVY:
|
||||
case SDL_PIXELFORMAT_YVYU:
|
||||
{
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
src = (Uint8 *)pixels;
|
||||
dst =
|
||||
swdata->planes[0] + rect->y * swdata->pitches[0] +
|
||||
rect->x * 2;
|
||||
length = 4 * ((rect->w + 1) / 2);
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += pitch;
|
||||
dst += swdata->pitches[0];
|
||||
}
|
||||
} break;
|
||||
case SDL_PIXELFORMAT_NV12:
|
||||
case SDL_PIXELFORMAT_NV21:
|
||||
{
|
||||
if (rect->x == 0 && rect->y == 0 && rect->w == swdata->w && rect->h == swdata->h) {
|
||||
SDL_memcpy(swdata->pixels, pixels,
|
||||
(swdata->h * swdata->w) + 2 * ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2));
|
||||
} else {
|
||||
|
||||
Uint8 *src, *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
src = (Uint8 *) pixels;
|
||||
dst =
|
||||
swdata->planes[0] + rect->y * swdata->pitches[0] +
|
||||
rect->x * 2;
|
||||
length = 4 * ((rect->w + 1) / 2);
|
||||
/* Copy the Y plane */
|
||||
src = (Uint8 *)pixels;
|
||||
dst = swdata->pixels + rect->y * swdata->w + rect->x;
|
||||
length = rect->w;
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += pitch;
|
||||
dst += swdata->pitches[0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_PIXELFORMAT_NV12:
|
||||
case SDL_PIXELFORMAT_NV21:
|
||||
{
|
||||
if (rect->x == 0 && rect->y == 0 && rect->w == swdata->w && rect->h == swdata->h) {
|
||||
SDL_memcpy(swdata->pixels, pixels,
|
||||
(swdata->h * swdata->w) + 2* ((swdata->h + 1) /2) * ((swdata->w + 1) / 2));
|
||||
} else {
|
||||
|
||||
Uint8 *src, *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
/* Copy the Y plane */
|
||||
src = (Uint8 *) pixels;
|
||||
dst = swdata->pixels + rect->y * swdata->w + rect->x;
|
||||
length = rect->w;
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += pitch;
|
||||
dst += swdata->w;
|
||||
}
|
||||
|
||||
/* Copy the next plane */
|
||||
src = (Uint8 *) pixels + rect->h * pitch;
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
dst += 2 * ((rect->y + 1)/2) * ((swdata->w + 1) / 2) + 2 * (rect->x/2);
|
||||
length = 2 * ((rect->w + 1) / 2);
|
||||
for (row = 0; row < (rect->h + 1)/2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += 2 * ((pitch + 1)/2);
|
||||
dst += 2 * ((swdata->w + 1)/2);
|
||||
}
|
||||
dst += swdata->w;
|
||||
}
|
||||
|
||||
/* Copy the next plane */
|
||||
src = (Uint8 *)pixels + rect->h * pitch;
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
dst += 2 * ((rect->y + 1) / 2) * ((swdata->w + 1) / 2) + 2 * (rect->x / 2);
|
||||
length = 2 * ((rect->w + 1) / 2);
|
||||
for (row = 0; row < (rect->h + 1) / 2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += 2 * ((pitch + 1) / 2);
|
||||
dst += 2 * ((swdata->w + 1) / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch)
|
||||
int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch)
|
||||
{
|
||||
const Uint8 *src;
|
||||
Uint8 *dst;
|
||||
@@ -274,12 +267,12 @@ SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
dst = swdata->pixels + swdata->h * swdata->w +
|
||||
((swdata->h + 1) / 2) * ((swdata->w + 1) / 2);
|
||||
}
|
||||
dst += rect->y/2 * ((swdata->w + 1)/2) + rect->x/2;
|
||||
dst += rect->y / 2 * ((swdata->w + 1) / 2) + rect->x / 2;
|
||||
length = (rect->w + 1) / 2;
|
||||
for (row = 0; row < (rect->h + 1)/2; ++row) {
|
||||
for (row = 0; row < (rect->h + 1) / 2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += Upitch;
|
||||
dst += (swdata->w + 1)/2;
|
||||
dst += (swdata->w + 1) / 2;
|
||||
}
|
||||
|
||||
/* Copy the V plane */
|
||||
@@ -290,19 +283,19 @@ SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
dst = swdata->pixels + swdata->h * swdata->w +
|
||||
((swdata->h + 1) / 2) * ((swdata->w + 1) / 2);
|
||||
}
|
||||
dst += rect->y/2 * ((swdata->w + 1)/2) + rect->x/2;
|
||||
dst += rect->y / 2 * ((swdata->w + 1) / 2) + rect->x / 2;
|
||||
length = (rect->w + 1) / 2;
|
||||
for (row = 0; row < (rect->h + 1)/2; ++row) {
|
||||
for (row = 0; row < (rect->h + 1) / 2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += Vpitch;
|
||||
dst += (swdata->w + 1)/2;
|
||||
dst += (swdata->w + 1) / 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
{
|
||||
const Uint8 *src;
|
||||
Uint8 *dst;
|
||||
@@ -322,30 +315,27 @@ int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * re
|
||||
/* Copy the UV or VU plane */
|
||||
src = UVplane;
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
dst += rect->y * ((swdata->w + 1)/2) + rect->x;
|
||||
dst += rect->y * ((swdata->w + 1) / 2) + rect->x;
|
||||
length = (rect->w + 1) / 2;
|
||||
length *= 2;
|
||||
for (row = 0; row < (rect->h + 1)/2; ++row) {
|
||||
for (row = 0; row < (rect->h + 1) / 2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += UVpitch;
|
||||
dst += 2 * ((swdata->w + 1)/2);
|
||||
dst += 2 * ((swdata->w + 1) / 2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
void **pixels, int *pitch)
|
||||
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
void **pixels, int *pitch)
|
||||
{
|
||||
switch (swdata->format) {
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
case SDL_PIXELFORMAT_NV12:
|
||||
case SDL_PIXELFORMAT_NV21:
|
||||
if (rect
|
||||
&& (rect->x != 0 || rect->y != 0 || rect->w != swdata->w
|
||||
|| rect->h != swdata->h)) {
|
||||
if (rect && (rect->x != 0 || rect->y != 0 || rect->w != swdata->w || rect->h != swdata->h)) {
|
||||
return SDL_SetError("YV12, IYUV, NV12, NV21 textures only support full surface locks");
|
||||
}
|
||||
break;
|
||||
@@ -360,15 +350,13 @@ SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata)
|
||||
void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
||||
Uint32 target_format, int w, int h, void *pixels,
|
||||
int pitch)
|
||||
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
|
||||
Uint32 target_format, int w, int h, void *pixels,
|
||||
int pitch)
|
||||
{
|
||||
int stretch;
|
||||
|
||||
@@ -424,7 +412,7 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
||||
pitch = swdata->stretch->pitch;
|
||||
}
|
||||
if (SDL_ConvertPixels(swdata->w, swdata->h, swdata->format,
|
||||
swdata->planes[0], swdata->pitches[0],
|
||||
swdata->planes[0], swdata->pitches[0],
|
||||
target_format, pixels, pitch) < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -435,8 +423,7 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata)
|
||||
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata)
|
||||
{
|
||||
if (swdata) {
|
||||
SDL_SIMDFree(swdata->pixels);
|
||||
|
||||
@@ -47,24 +47,24 @@ struct SDL_SW_YUVTexture
|
||||
typedef struct SDL_SW_YUVTexture SDL_SW_YUVTexture;
|
||||
|
||||
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h);
|
||||
int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels,
|
||||
int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels,
|
||||
int *pitch);
|
||||
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const void *pixels, int pitch);
|
||||
int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch);
|
||||
int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
void **pixels, int *pitch);
|
||||
void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata);
|
||||
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
||||
void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata);
|
||||
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
|
||||
Uint32 target_format, int w, int h, void *pixels,
|
||||
int pitch);
|
||||
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata);
|
||||
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata);
|
||||
|
||||
#endif /* SDL_yuv_sw_c_h_ */
|
||||
|
||||
|
||||
@@ -54,12 +54,11 @@ typedef struct
|
||||
LPDIRECT3DPIXELSHADER9 shader;
|
||||
} D3D_DrawStateCache;
|
||||
|
||||
|
||||
/* Direct3D renderer implementation */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void* d3dDLL;
|
||||
void *d3dDLL;
|
||||
IDirect3D9 *d3d;
|
||||
IDirect3DDevice9 *device;
|
||||
UINT adapter;
|
||||
@@ -70,7 +69,7 @@ typedef struct
|
||||
D3DTEXTUREFILTERTYPE scaleMode[8];
|
||||
IDirect3DSurface9 *defaultRenderTarget;
|
||||
IDirect3DSurface9 *currentRenderTarget;
|
||||
void* d3dxDLL;
|
||||
void *d3dxDLL;
|
||||
#if SDL_HAVE_YUV
|
||||
LPDIRECT3DPIXELSHADER9 shaders[NUM_SHADERS];
|
||||
#endif
|
||||
@@ -115,8 +114,7 @@ typedef struct
|
||||
float u, v;
|
||||
} Vertex;
|
||||
|
||||
static int
|
||||
D3D_SetError(const char *prefix, HRESULT result)
|
||||
static int D3D_SetError(const char *prefix, HRESULT result)
|
||||
{
|
||||
const char *error;
|
||||
|
||||
@@ -194,8 +192,7 @@ D3D_SetError(const char *prefix, HRESULT result)
|
||||
return SDL_SetError("%s: %s", prefix, error);
|
||||
}
|
||||
|
||||
static D3DFORMAT
|
||||
PixelFormatToD3DFMT(Uint32 format)
|
||||
static D3DFORMAT PixelFormatToD3DFMT(Uint32 format)
|
||||
{
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_RGB565:
|
||||
@@ -214,8 +211,7 @@ PixelFormatToD3DFMT(Uint32 format)
|
||||
}
|
||||
}
|
||||
|
||||
static Uint32
|
||||
D3DFMTToPixelFormat(D3DFORMAT format)
|
||||
static Uint32 D3DFMTToPixelFormat(D3DFORMAT format)
|
||||
{
|
||||
switch (format) {
|
||||
case D3DFMT_R5G6B5:
|
||||
@@ -229,8 +225,7 @@ D3DFMTToPixelFormat(D3DFORMAT format)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
D3D_InitRenderState(D3D_RenderData *data)
|
||||
static void D3D_InitRenderState(D3D_RenderData *data)
|
||||
{
|
||||
D3DMATRIX matrix;
|
||||
|
||||
@@ -288,12 +283,11 @@ D3D_InitRenderState(D3D_RenderData *data)
|
||||
data->beginScene = SDL_TRUE;
|
||||
}
|
||||
|
||||
static int D3D_Reset(SDL_Renderer * renderer);
|
||||
static int D3D_Reset(SDL_Renderer *renderer);
|
||||
|
||||
static int
|
||||
D3D_ActivateRenderer(SDL_Renderer * renderer)
|
||||
static int D3D_ActivateRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
HRESULT result;
|
||||
|
||||
if (data->updateSize) {
|
||||
@@ -337,25 +331,22 @@ D3D_ActivateRenderer(SDL_Renderer * renderer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
D3D_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
static void D3D_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
|
||||
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||
data->updateSize = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
|
||||
static int D3D_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
|
||||
{
|
||||
SDL_GetWindowSizeInPixels(renderer->window, w, h);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static D3DBLEND
|
||||
GetBlendFunc(SDL_BlendFactor factor)
|
||||
static D3DBLEND GetBlendFunc(SDL_BlendFactor factor)
|
||||
{
|
||||
switch (factor) {
|
||||
case SDL_BLENDFACTOR_ZERO:
|
||||
@@ -378,13 +369,13 @@ GetBlendFunc(SDL_BlendFactor factor)
|
||||
return D3DBLEND_DESTALPHA;
|
||||
case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA:
|
||||
return D3DBLEND_INVDESTALPHA;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (D3DBLEND) 0;
|
||||
return (D3DBLEND)0;
|
||||
}
|
||||
|
||||
static D3DBLENDOP
|
||||
GetBlendEquation(SDL_BlendOperation operation)
|
||||
static D3DBLENDOP GetBlendEquation(SDL_BlendOperation operation)
|
||||
{
|
||||
switch (operation) {
|
||||
case SDL_BLENDOPERATION_ADD:
|
||||
@@ -397,15 +388,15 @@ GetBlendEquation(SDL_BlendOperation operation)
|
||||
return D3DBLENDOP_MIN;
|
||||
case SDL_BLENDOPERATION_MAXIMUM:
|
||||
return D3DBLENDOP_MAX;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (D3DBLENDOP) 0;
|
||||
return (D3DBLENDOP)0;
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
D3D_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
|
||||
static SDL_bool D3D_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode);
|
||||
SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode);
|
||||
SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode);
|
||||
@@ -428,8 +419,7 @@ D3D_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD usage, Uint32 format, D3DFORMAT d3dfmt, int w, int h)
|
||||
static int D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD usage, Uint32 format, D3DFORMAT d3dfmt, int w, int h)
|
||||
{
|
||||
HRESULT result;
|
||||
|
||||
@@ -441,23 +431,21 @@ D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD us
|
||||
texture->d3dfmt = d3dfmt;
|
||||
|
||||
result = IDirect3DDevice9_CreateTexture(device, w, h, 1, usage,
|
||||
PixelFormatToD3DFMT(format),
|
||||
D3DPOOL_DEFAULT, &texture->texture, NULL);
|
||||
PixelFormatToD3DFMT(format),
|
||||
D3DPOOL_DEFAULT, &texture->texture, NULL);
|
||||
if (FAILED(result)) {
|
||||
return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
static int D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
{
|
||||
HRESULT result;
|
||||
|
||||
if (texture->staging == NULL) {
|
||||
result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, 0,
|
||||
texture->d3dfmt, D3DPOOL_SYSTEMMEM, &texture->staging, NULL);
|
||||
texture->d3dfmt, D3DPOOL_SYSTEMMEM, &texture->staging, NULL);
|
||||
if (FAILED(result)) {
|
||||
return D3D_SetError("CreateTexture(D3DPOOL_SYSTEMMEM)", result);
|
||||
}
|
||||
@@ -465,8 +453,7 @@ D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
static int D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
{
|
||||
if (texture->texture) {
|
||||
IDirect3DTexture9_Release(texture->texture);
|
||||
@@ -479,8 +466,7 @@ D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, int y, int w, int h, const void *pixels, int pitch)
|
||||
static int D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, int y, int w, int h, const void *pixels, int pitch)
|
||||
{
|
||||
RECT d3drect;
|
||||
D3DLOCKED_RECT locked;
|
||||
@@ -497,7 +483,7 @@ D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, i
|
||||
d3drect.right = x + w;
|
||||
d3drect.top = y;
|
||||
d3drect.bottom = y + h;
|
||||
|
||||
|
||||
result = IDirect3DTexture9_LockRect(texture->staging, 0, &locked, &d3drect, 0);
|
||||
if (FAILED(result)) {
|
||||
return D3D_SetError("LockRect()", result);
|
||||
@@ -507,7 +493,7 @@ D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, i
|
||||
dst = (Uint8 *)locked.pBits;
|
||||
length = w * SDL_BYTESPERPIXEL(texture->format);
|
||||
if (length == pitch && length == locked.Pitch) {
|
||||
SDL_memcpy(dst, src, length*h);
|
||||
SDL_memcpy(dst, src, length * h);
|
||||
} else {
|
||||
if (length > pitch) {
|
||||
length = pitch;
|
||||
@@ -530,8 +516,7 @@ D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, i
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
D3D_DestroyTextureRep(D3D_TextureRep *texture)
|
||||
static void D3D_DestroyTextureRep(D3D_TextureRep *texture)
|
||||
{
|
||||
if (texture->texture) {
|
||||
IDirect3DTexture9_Release(texture->texture);
|
||||
@@ -543,14 +528,13 @@ D3D_DestroyTextureRep(D3D_TextureRep *texture)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static int D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata;
|
||||
DWORD usage;
|
||||
|
||||
texturedata = (D3D_TextureData *) SDL_calloc(1, sizeof(*texturedata));
|
||||
texturedata = (D3D_TextureData *)SDL_calloc(1, sizeof(*texturedata));
|
||||
if (texturedata == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
@@ -584,8 +568,7 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_RecreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static int D3D_RecreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
@@ -611,12 +594,11 @@ D3D_RecreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||
static int D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
if (texturedata == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
@@ -628,14 +610,14 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
#if SDL_HAVE_YUV
|
||||
if (texturedata->yuv) {
|
||||
/* Skip to the correct offset into the next texture */
|
||||
pixels = (const void*)((const Uint8*)pixels + rect->h * pitch);
|
||||
pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch);
|
||||
|
||||
if (D3D_UpdateTextureRep(data->device, texture->format == SDL_PIXELFORMAT_YV12 ? &texturedata->vtexture : &texturedata->utexture, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, pixels, (pitch + 1) / 2) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Skip to the correct offset into the next texture */
|
||||
pixels = (const void*)((const Uint8*)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2));
|
||||
pixels = (const void *)((const Uint8 *)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2));
|
||||
if (D3D_UpdateTextureRep(data->device, texture->format == SDL_PIXELFORMAT_YV12 ? &texturedata->utexture : &texturedata->vtexture, rect->x / 2, (rect->y + 1) / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, pixels, (pitch + 1) / 2) < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -645,15 +627,14 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int
|
||||
D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch)
|
||||
static int D3D_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
if (texturedata == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
@@ -672,9 +653,8 @@ D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch)
|
||||
static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
@@ -696,8 +676,8 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
}
|
||||
}
|
||||
*pixels =
|
||||
(void *) ((Uint8 *) texturedata->pixels + rect->y * texturedata->pitch +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
(void *)((Uint8 *)texturedata->pixels + rect->y * texturedata->pitch +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
*pitch = texturedata->pitch;
|
||||
} else
|
||||
#endif
|
||||
@@ -725,8 +705,7 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static void D3D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
@@ -738,8 +717,8 @@ D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
if (texturedata->yuv) {
|
||||
const SDL_Rect *rect = &texturedata->locked_rect;
|
||||
void *pixels =
|
||||
(void *) ((Uint8 *) texturedata->pixels + rect->y * texturedata->pitch +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
(void *)((Uint8 *)texturedata->pixels + rect->y * texturedata->pitch +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
D3D_UpdateTexture(renderer, texture, rect, pixels, texturedata->pitch);
|
||||
} else
|
||||
#endif
|
||||
@@ -755,8 +734,7 @@ D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
D3D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode)
|
||||
static void D3D_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
@@ -767,10 +745,9 @@ D3D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Scal
|
||||
texturedata->scaleMode = (scaleMode == SDL_ScaleModeNearest) ? D3DTEXF_POINT : D3DTEXF_LINEAR;
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata;
|
||||
D3D_TextureRep *texturerep;
|
||||
HRESULT result;
|
||||
@@ -797,7 +774,7 @@ D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
if (texturerep->dirty && texturerep->staging) {
|
||||
if (!texturerep->texture) {
|
||||
result = IDirect3DDevice9_CreateTexture(device, texturerep->w, texturerep->h, 1, texturerep->usage,
|
||||
PixelFormatToD3DFMT(texturerep->format), D3DPOOL_DEFAULT, &texturerep->texture, NULL);
|
||||
PixelFormatToD3DFMT(texturerep->format), D3DPOOL_DEFAULT, &texturerep->texture, NULL);
|
||||
if (FAILED(result)) {
|
||||
return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result);
|
||||
}
|
||||
@@ -822,8 +799,7 @@ D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static int D3D_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
if (D3D_ActivateRenderer(renderer) < 0) {
|
||||
return -1;
|
||||
@@ -832,19 +808,16 @@ D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
return D3D_SetRenderTargetInternal(renderer, texture);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
D3D_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd)
|
||||
static int D3D_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; /* nothing to do in this backend. */
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
|
||||
static int D3D_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
const DWORD color = D3DCOLOR_ARGB(cmd->data.draw.a, cmd->data.draw.r, cmd->data.draw.g, cmd->data.draw.b);
|
||||
const size_t vertslen = count * sizeof (Vertex);
|
||||
Vertex *verts = (Vertex *) SDL_AllocateRenderVertices(renderer, vertslen, 0, &cmd->data.draw.first);
|
||||
const size_t vertslen = count * sizeof(Vertex);
|
||||
Vertex *verts = (Vertex *)SDL_AllocateRenderVertices(renderer, vertslen, 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (verts == NULL) {
|
||||
@@ -863,15 +836,14 @@ D3D_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
static int D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
{
|
||||
int i;
|
||||
int count = indices ? num_indices : num_vertices;
|
||||
Vertex *verts = (Vertex *) SDL_AllocateRenderVertices(renderer, count * sizeof (Vertex), 0, &cmd->data.draw.first);
|
||||
Vertex *verts = (Vertex *)SDL_AllocateRenderVertices(renderer, count * sizeof(Vertex), 0, &cmd->data.draw.first);
|
||||
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
@@ -894,8 +866,8 @@ D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
|
||||
j = i;
|
||||
}
|
||||
|
||||
xy_ = (float *)((char*)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char*)color + j * color_stride);
|
||||
xy_ = (float *)((char *)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char *)color + j * color_stride);
|
||||
|
||||
verts->x = xy_[0] * scale_x - 0.5f;
|
||||
verts->y = xy_[1] * scale_y - 0.5f;
|
||||
@@ -903,7 +875,7 @@ D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
|
||||
verts->color = D3DCOLOR_ARGB(col_.a, col_.r, col_.g, col_.b);
|
||||
|
||||
if (texture) {
|
||||
float *uv_ = (float *)((char*)uv + j * uv_stride);
|
||||
float *uv_ = (float *)((char *)uv + j * uv_stride);
|
||||
verts->u = uv_[0];
|
||||
verts->v = uv_[1];
|
||||
} else {
|
||||
@@ -916,14 +888,13 @@ D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
UpdateDirtyTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
static int UpdateDirtyTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
{
|
||||
if (texture->dirty && texture->staging) {
|
||||
HRESULT result;
|
||||
if (!texture->texture) {
|
||||
result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, texture->usage,
|
||||
PixelFormatToD3DFMT(texture->format), D3DPOOL_DEFAULT, &texture->texture, NULL);
|
||||
PixelFormatToD3DFMT(texture->format), D3DPOOL_DEFAULT, &texture->texture, NULL);
|
||||
if (FAILED(result)) {
|
||||
return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result);
|
||||
}
|
||||
@@ -938,8 +909,7 @@ UpdateDirtyTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
BindTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD sampler)
|
||||
static int BindTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD sampler)
|
||||
{
|
||||
HRESULT result;
|
||||
UpdateDirtyTexture(device, texture);
|
||||
@@ -950,8 +920,7 @@ BindTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD sampler)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
UpdateTextureScaleMode(D3D_RenderData *data, D3D_TextureData *texturedata, unsigned index)
|
||||
static void UpdateTextureScaleMode(D3D_RenderData *data, D3D_TextureData *texturedata, unsigned index)
|
||||
{
|
||||
if (texturedata->scaleMode != data->scaleMode[index]) {
|
||||
IDirect3DDevice9_SetSamplerState(data->device, index, D3DSAMP_MINFILTER,
|
||||
@@ -966,8 +935,7 @@ UpdateTextureScaleMode(D3D_RenderData *data, D3D_TextureData *texturedata, unsig
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SetupTextureState(D3D_RenderData *data, SDL_Texture * texture, LPDIRECT3DPIXELSHADER9 *shader)
|
||||
static int SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, LPDIRECT3DPIXELSHADER9 *shader)
|
||||
{
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
@@ -1012,16 +980,15 @@ SetupTextureState(D3D_RenderData *data, SDL_Texture * texture, LPDIRECT3DPIXELSH
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
{
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
|
||||
if (texture != data->drawstate.texture) {
|
||||
#if SDL_HAVE_YUV
|
||||
D3D_TextureData *oldtexturedata = data->drawstate.texture ? (D3D_TextureData *) data->drawstate.texture->driverdata : NULL;
|
||||
D3D_TextureData *newtexturedata = texture ? (D3D_TextureData *) texture->driverdata : NULL;
|
||||
D3D_TextureData *oldtexturedata = data->drawstate.texture ? (D3D_TextureData *)data->drawstate.texture->driverdata : NULL;
|
||||
D3D_TextureData *newtexturedata = texture ? (D3D_TextureData *)texture->driverdata : NULL;
|
||||
#endif
|
||||
LPDIRECT3DPIXELSHADER9 shader = NULL;
|
||||
|
||||
@@ -1049,7 +1016,7 @@ SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
|
||||
data->drawstate.texture = texture;
|
||||
} else if (texture) {
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
UpdateDirtyTexture(data->device, &texturedata->texture);
|
||||
#if SDL_HAVE_YUV
|
||||
if (texturedata->yuv) {
|
||||
@@ -1130,10 +1097,9 @@ SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
const int vboidx = data->currentVertexBuffer;
|
||||
IDirect3DVertexBuffer9 *vbo = NULL;
|
||||
const SDL_bool istarget = renderer->target != NULL;
|
||||
@@ -1152,7 +1118,7 @@ D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
|
||||
IDirect3DVertexBuffer9_Release(vbo);
|
||||
}
|
||||
|
||||
if (FAILED(IDirect3DDevice9_CreateVertexBuffer(data->device, (UINT) vertsize, usage, fvf, D3DPOOL_DEFAULT, &vbo, NULL))) {
|
||||
if (FAILED(IDirect3DDevice9_CreateVertexBuffer(data->device, (UINT)vertsize, usage, fvf, D3DPOOL_DEFAULT, &vbo, NULL))) {
|
||||
vbo = NULL;
|
||||
}
|
||||
data->vertexBuffers[vboidx] = vbo;
|
||||
@@ -1161,12 +1127,12 @@ D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
|
||||
|
||||
if (vbo) {
|
||||
void *ptr;
|
||||
if (FAILED(IDirect3DVertexBuffer9_Lock(vbo, 0, (UINT) vertsize, &ptr, D3DLOCK_DISCARD))) {
|
||||
vbo = NULL; /* oh well, we'll do immediate mode drawing. :( */
|
||||
if (FAILED(IDirect3DVertexBuffer9_Lock(vbo, 0, (UINT)vertsize, &ptr, D3DLOCK_DISCARD))) {
|
||||
vbo = NULL; /* oh well, we'll do immediate mode drawing. :( */
|
||||
} else {
|
||||
SDL_memcpy(ptr, vertices, vertsize);
|
||||
if (FAILED(IDirect3DVertexBuffer9_Unlock(vbo))) {
|
||||
vbo = NULL; /* oh well, we'll do immediate mode drawing. :( */
|
||||
vbo = NULL; /* oh well, we'll do immediate mode drawing. :( */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1186,130 +1152,137 @@ D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
|
||||
}
|
||||
}
|
||||
|
||||
IDirect3DDevice9_SetStreamSource(data->device, 0, vbo, 0, sizeof (Vertex));
|
||||
IDirect3DDevice9_SetStreamSource(data->device, 0, vbo, 0, sizeof(Vertex));
|
||||
|
||||
while (cmd) {
|
||||
switch (cmd->command) {
|
||||
case SDL_RENDERCMD_SETDRAWCOLOR: {
|
||||
/* currently this is sent with each vertex, but if we move to
|
||||
shaders, we can put this in a uniform here and reduce vertex
|
||||
buffer bandwidth */
|
||||
break;
|
||||
case SDL_RENDERCMD_SETDRAWCOLOR:
|
||||
{
|
||||
/* currently this is sent with each vertex, but if we move to
|
||||
shaders, we can put this in a uniform here and reduce vertex
|
||||
buffer bandwidth */
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETVIEWPORT:
|
||||
{
|
||||
SDL_Rect *viewport = &data->drawstate.viewport;
|
||||
if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) {
|
||||
SDL_copyp(viewport, &cmd->data.viewport.rect);
|
||||
data->drawstate.viewport_dirty = SDL_TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETCLIPRECT:
|
||||
{
|
||||
const SDL_Rect *rect = &cmd->data.cliprect.rect;
|
||||
if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) {
|
||||
data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled;
|
||||
data->drawstate.cliprect_enabled_dirty = SDL_TRUE;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETVIEWPORT: {
|
||||
SDL_Rect *viewport = &data->drawstate.viewport;
|
||||
if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) {
|
||||
SDL_copyp(viewport, &cmd->data.viewport.rect);
|
||||
data->drawstate.viewport_dirty = SDL_TRUE;
|
||||
}
|
||||
break;
|
||||
if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) {
|
||||
SDL_copyp(&data->drawstate.cliprect, rect);
|
||||
data->drawstate.cliprect_dirty = SDL_TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_CLEAR:
|
||||
{
|
||||
const DWORD color = D3DCOLOR_ARGB(cmd->data.color.a, cmd->data.color.r, cmd->data.color.g, cmd->data.color.b);
|
||||
const SDL_Rect *viewport = &data->drawstate.viewport;
|
||||
const int backw = istarget ? renderer->target->w : data->pparams.BackBufferWidth;
|
||||
const int backh = istarget ? renderer->target->h : data->pparams.BackBufferHeight;
|
||||
const SDL_bool viewport_equal = ((viewport->x == 0) && (viewport->y == 0) && (viewport->w == backw) && (viewport->h == backh)) ? SDL_TRUE : SDL_FALSE;
|
||||
|
||||
if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) {
|
||||
IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, FALSE);
|
||||
data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETCLIPRECT: {
|
||||
const SDL_Rect *rect = &cmd->data.cliprect.rect;
|
||||
if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) {
|
||||
data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled;
|
||||
data->drawstate.cliprect_enabled_dirty = SDL_TRUE;
|
||||
}
|
||||
|
||||
if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) {
|
||||
SDL_copyp(&data->drawstate.cliprect, rect);
|
||||
data->drawstate.cliprect_dirty = SDL_TRUE;
|
||||
}
|
||||
break;
|
||||
/* Don't reset the viewport if we don't have to! */
|
||||
if (!data->drawstate.viewport_dirty && viewport_equal) {
|
||||
IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
|
||||
} else {
|
||||
/* Clear is defined to clear the entire render target */
|
||||
D3DVIEWPORT9 wholeviewport = { 0, 0, 0, 0, 0.0f, 1.0f };
|
||||
wholeviewport.Width = backw;
|
||||
wholeviewport.Height = backh;
|
||||
IDirect3DDevice9_SetViewport(data->device, &wholeviewport);
|
||||
data->drawstate.viewport_dirty = SDL_TRUE; /* we still need to (re)set orthographic projection, so always mark it dirty. */
|
||||
IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_CLEAR: {
|
||||
const DWORD color = D3DCOLOR_ARGB(cmd->data.color.a, cmd->data.color.r, cmd->data.color.g, cmd->data.color.b);
|
||||
const SDL_Rect *viewport = &data->drawstate.viewport;
|
||||
const int backw = istarget ? renderer->target->w : data->pparams.BackBufferWidth;
|
||||
const int backh = istarget ? renderer->target->h : data->pparams.BackBufferHeight;
|
||||
const SDL_bool viewport_equal = ((viewport->x == 0) && (viewport->y == 0) && (viewport->w == backw) && (viewport->h == backh)) ? SDL_TRUE : SDL_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) {
|
||||
IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, FALSE);
|
||||
data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled;
|
||||
}
|
||||
|
||||
/* Don't reset the viewport if we don't have to! */
|
||||
if (!data->drawstate.viewport_dirty && viewport_equal) {
|
||||
IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
|
||||
} else {
|
||||
/* Clear is defined to clear the entire render target */
|
||||
D3DVIEWPORT9 wholeviewport = { 0, 0, 0, 0, 0.0f, 1.0f };
|
||||
wholeviewport.Width = backw;
|
||||
wholeviewport.Height = backh;
|
||||
IDirect3DDevice9_SetViewport(data->device, &wholeviewport);
|
||||
data->drawstate.viewport_dirty = SDL_TRUE; /* we still need to (re)set orthographic projection, so always mark it dirty. */
|
||||
IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
case SDL_RENDERCMD_DRAW_POINTS:
|
||||
{
|
||||
const size_t count = cmd->data.draw.count;
|
||||
const size_t first = cmd->data.draw.first;
|
||||
SetDrawState(data, cmd);
|
||||
if (vbo) {
|
||||
IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_POINTLIST, (UINT)(first / sizeof(Vertex)), (UINT)count);
|
||||
} else {
|
||||
const Vertex *verts = (Vertex *)(((Uint8 *)vertices) + first);
|
||||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, (UINT)count, verts, sizeof(Vertex));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_DRAW_POINTS: {
|
||||
const size_t count = cmd->data.draw.count;
|
||||
const size_t first = cmd->data.draw.first;
|
||||
SetDrawState(data, cmd);
|
||||
if (vbo) {
|
||||
IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_POINTLIST, (UINT) (first / sizeof (Vertex)), (UINT) count);
|
||||
} else {
|
||||
const Vertex *verts = (Vertex *) (((Uint8 *) vertices) + first);
|
||||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, (UINT) count, verts, sizeof (Vertex));
|
||||
case SDL_RENDERCMD_DRAW_LINES:
|
||||
{
|
||||
const size_t count = cmd->data.draw.count;
|
||||
const size_t first = cmd->data.draw.first;
|
||||
const Vertex *verts = (Vertex *)(((Uint8 *)vertices) + first);
|
||||
|
||||
/* DirectX 9 has the same line rasterization semantics as GDI,
|
||||
so we need to close the endpoint of the line with a second draw call. */
|
||||
const SDL_bool close_endpoint = ((count == 2) || (verts[0].x != verts[count - 1].x) || (verts[0].y != verts[count - 1].y));
|
||||
|
||||
SetDrawState(data, cmd);
|
||||
|
||||
if (vbo) {
|
||||
IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_LINESTRIP, (UINT)(first / sizeof(Vertex)), (UINT)(count - 1));
|
||||
if (close_endpoint) {
|
||||
IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_POINTLIST, (UINT)((first / sizeof(Vertex)) + (count - 1)), 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_DRAW_LINES: {
|
||||
const size_t count = cmd->data.draw.count;
|
||||
const size_t first = cmd->data.draw.first;
|
||||
const Vertex *verts = (Vertex *) (((Uint8 *) vertices) + first);
|
||||
|
||||
/* DirectX 9 has the same line rasterization semantics as GDI,
|
||||
so we need to close the endpoint of the line with a second draw call. */
|
||||
const SDL_bool close_endpoint = ((count == 2) || (verts[0].x != verts[count-1].x) || (verts[0].y != verts[count-1].y));
|
||||
|
||||
SetDrawState(data, cmd);
|
||||
|
||||
if (vbo) {
|
||||
IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_LINESTRIP, (UINT) (first / sizeof (Vertex)), (UINT) (count - 1));
|
||||
if (close_endpoint) {
|
||||
IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_POINTLIST, (UINT) ((first / sizeof (Vertex)) + (count - 1)), 1);
|
||||
}
|
||||
} else {
|
||||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, (UINT) (count - 1), verts, sizeof (Vertex));
|
||||
if (close_endpoint) {
|
||||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, &verts[count-1], sizeof (Vertex));
|
||||
}
|
||||
} else {
|
||||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, (UINT)(count - 1), verts, sizeof(Vertex));
|
||||
if (close_endpoint) {
|
||||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, &verts[count - 1], sizeof(Vertex));
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
break;
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
break;
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
break;
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_GEOMETRY: {
|
||||
const size_t count = cmd->data.draw.count;
|
||||
const size_t first = cmd->data.draw.first;
|
||||
SetDrawState(data, cmd);
|
||||
if (vbo) {
|
||||
IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_TRIANGLELIST, (UINT) (first / sizeof (Vertex)), (UINT) count / 3);
|
||||
} else {
|
||||
const Vertex* verts = (Vertex*)(((Uint8*)vertices) + first);
|
||||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLELIST, (UINT) count / 3, verts, sizeof(Vertex));
|
||||
}
|
||||
break;
|
||||
case SDL_RENDERCMD_GEOMETRY:
|
||||
{
|
||||
const size_t count = cmd->data.draw.count;
|
||||
const size_t first = cmd->data.draw.first;
|
||||
SetDrawState(data, cmd);
|
||||
if (vbo) {
|
||||
IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_TRIANGLELIST, (UINT)(first / sizeof(Vertex)), (UINT)count / 3);
|
||||
} else {
|
||||
const Vertex *verts = (Vertex *)(((Uint8 *)vertices) + first);
|
||||
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLELIST, (UINT)count / 3, verts, sizeof(Vertex));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_NO_OP:
|
||||
break;
|
||||
case SDL_RENDERCMD_NO_OP:
|
||||
break;
|
||||
}
|
||||
|
||||
cmd = cmd->next;
|
||||
@@ -1318,12 +1291,10 @@ D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch)
|
||||
static int D3D_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||
Uint32 format, void *pixels, int pitch)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3DSURFACE_DESC desc;
|
||||
LPDIRECT3DSURFACE9 backBuffer;
|
||||
LPDIRECT3DSURFACE9 surface;
|
||||
@@ -1366,8 +1337,8 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
}
|
||||
|
||||
status = SDL_ConvertPixels(rect->w, rect->h,
|
||||
D3DFMTToPixelFormat(desc.Format), locked.pBits, locked.Pitch,
|
||||
format, pixels, pitch);
|
||||
D3DFMTToPixelFormat(desc.Format), locked.pBits, locked.Pitch,
|
||||
format, pixels, pitch);
|
||||
|
||||
IDirect3DSurface9_UnlockRect(surface);
|
||||
|
||||
@@ -1376,10 +1347,9 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
return status;
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_RenderPresent(SDL_Renderer * renderer)
|
||||
static int D3D_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
HRESULT result;
|
||||
|
||||
if (!data->beginScene) {
|
||||
@@ -1402,11 +1372,10 @@ D3D_RenderPresent(SDL_Renderer * renderer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static void D3D_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
|
||||
D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
|
||||
D3D_RenderData *renderdata = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *data = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
if (renderdata->drawstate.texture == texture) {
|
||||
renderdata->drawstate.texture = NULL;
|
||||
@@ -1435,10 +1404,9 @@ D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
texture->driverdata = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
D3D_DestroyRenderer(SDL_Renderer * renderer)
|
||||
static void D3D_DestroyRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
|
||||
if (data) {
|
||||
int i;
|
||||
@@ -1480,10 +1448,9 @@ D3D_DestroyRenderer(SDL_Renderer * renderer)
|
||||
SDL_free(renderer);
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_Reset(SDL_Renderer * renderer)
|
||||
static int D3D_Reset(SDL_Renderer *renderer)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
const Float4X4 d3dmatrix = MatrixIdentity();
|
||||
HRESULT result;
|
||||
SDL_Texture *texture;
|
||||
@@ -1549,7 +1516,7 @@ D3D_Reset(SDL_Renderer * renderer)
|
||||
data->drawstate.texture = NULL;
|
||||
data->drawstate.shader = NULL;
|
||||
data->drawstate.blend = SDL_BLENDMODE_INVALID;
|
||||
IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&d3dmatrix);
|
||||
IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX *)&d3dmatrix);
|
||||
|
||||
/* Let the application know that render targets were reset */
|
||||
{
|
||||
@@ -1561,8 +1528,7 @@ D3D_Reset(SDL_Renderer * renderer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_SetVSync(SDL_Renderer * renderer, const int vsync)
|
||||
static int D3D_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
D3D_RenderData *data = renderer->driverdata;
|
||||
if (vsync) {
|
||||
@@ -1580,7 +1546,7 @@ D3D_SetVSync(SDL_Renderer * renderer, const int vsync)
|
||||
}
|
||||
|
||||
SDL_Renderer *
|
||||
D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
D3D_RenderData *data;
|
||||
@@ -1601,7 +1567,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
data = (D3D_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
@@ -1628,9 +1594,9 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
renderer->SetTextureScaleMode = D3D_SetTextureScaleMode;
|
||||
renderer->SetRenderTarget = D3D_SetRenderTarget;
|
||||
renderer->QueueSetViewport = D3D_QueueSetViewport;
|
||||
renderer->QueueSetDrawColor = D3D_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|
||||
renderer->QueueSetDrawColor = D3D_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|
||||
renderer->QueueDrawPoints = D3D_QueueDrawPoints;
|
||||
renderer->QueueDrawLines = D3D_QueueDrawPoints; /* lines and points queue vertices the same way. */
|
||||
renderer->QueueDrawLines = D3D_QueueDrawPoints; /* lines and points queue vertices the same way. */
|
||||
renderer->QueueGeometry = D3D_QueueGeometry;
|
||||
renderer->RunCommandQueue = D3D_RunCommandQueue;
|
||||
renderer->RenderReadPixels = D3D_RenderReadPixels;
|
||||
@@ -1758,25 +1724,24 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
|
||||
SDL_RenderDriver D3D_RenderDriver = {
|
||||
D3D_CreateRenderer,
|
||||
{
|
||||
"direct3d",
|
||||
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
|
||||
1,
|
||||
{SDL_PIXELFORMAT_ARGB8888},
|
||||
0,
|
||||
0}
|
||||
{ "direct3d",
|
||||
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
|
||||
1,
|
||||
{ SDL_PIXELFORMAT_ARGB8888 },
|
||||
0,
|
||||
0 }
|
||||
};
|
||||
#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */
|
||||
|
||||
#if defined(__WIN32__) || defined(__WINGDK__)
|
||||
/* This function needs to always exist on Windows, for the Dynamic API. */
|
||||
IDirect3DDevice9 *
|
||||
SDL_RenderGetD3D9Device(SDL_Renderer * renderer)
|
||||
SDL_RenderGetD3D9Device(SDL_Renderer *renderer)
|
||||
{
|
||||
IDirect3DDevice9 *device = NULL;
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED
|
||||
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
|
||||
/* Make sure that this is a D3D renderer */
|
||||
if (renderer->DestroyRenderer != D3D_DestroyRenderer) {
|
||||
|
||||
@@ -257,7 +257,6 @@ static const DWORD D3D9_PixelShader_YUV_BT709[] = {
|
||||
0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff
|
||||
};
|
||||
|
||||
|
||||
static const DWORD *D3D9_shaders[] = {
|
||||
D3D9_PixelShader_YUV_JPEG,
|
||||
D3D9_PixelShader_YUV_BT601,
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
/* D3D9 shader implementation */
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
SHADER_YUV_JPEG,
|
||||
SHADER_YUV_BT601,
|
||||
SHADER_YUV_BT709,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -42,11 +42,10 @@ using namespace Windows::Graphics::Display;
|
||||
|
||||
#include "SDL_render_winrt.h"
|
||||
|
||||
|
||||
extern "C" void *
|
||||
D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer)
|
||||
D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_Window * sdlWindow = renderer->window;
|
||||
SDL_Window *sdlWindow = renderer->window;
|
||||
if (renderer->window == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -110,7 +109,6 @@ D3D11_GetCurrentRotation()
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer);
|
||||
void *D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer);
|
||||
DXGI_MODE_ROTATION D3D11_GetCurrentRotation();
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
|
||||
|
||||
|
||||
/* Direct3D 11.x shaders
|
||||
|
||||
SDL's shaders are compiled into SDL itself, to simplify distribution.
|
||||
@@ -52,7 +51,7 @@
|
||||
- vs_4_0_level_9_1: Vertex shader for Windows 8+, including Windows RT
|
||||
- ps_4_0_level_9_3: Pixel shader for Windows Phone 8
|
||||
- vs_4_0_level_9_3: Vertex shader for Windows Phone 8
|
||||
|
||||
|
||||
|
||||
Shader object code was converted to a list of DWORDs via the following
|
||||
*nix style command (available separately from Windows + MSVC):
|
||||
@@ -1905,8 +1904,7 @@ static struct
|
||||
int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout)
|
||||
{
|
||||
/* Declare how the input layout for SDL's vertex shader will be setup: */
|
||||
const D3D11_INPUT_ELEMENT_DESC vertexDesc[] =
|
||||
{
|
||||
const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = {
|
||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
@@ -1915,23 +1913,21 @@ int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vert
|
||||
|
||||
/* Load in SDL's one and only vertex shader: */
|
||||
result = ID3D11Device_CreateVertexShader(d3dDevice,
|
||||
D3D11_VertexShader,
|
||||
sizeof(D3D11_VertexShader),
|
||||
NULL,
|
||||
vertexShader
|
||||
);
|
||||
D3D11_VertexShader,
|
||||
sizeof(D3D11_VertexShader),
|
||||
NULL,
|
||||
vertexShader);
|
||||
if (FAILED(result)) {
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateVertexShader"), result);
|
||||
}
|
||||
|
||||
/* Create an input layout for SDL's vertex shader: */
|
||||
result = ID3D11Device_CreateInputLayout(d3dDevice,
|
||||
vertexDesc,
|
||||
ARRAYSIZE(vertexDesc),
|
||||
D3D11_VertexShader,
|
||||
sizeof(D3D11_VertexShader),
|
||||
inputLayout
|
||||
);
|
||||
vertexDesc,
|
||||
ARRAYSIZE(vertexDesc),
|
||||
D3D11_VertexShader,
|
||||
sizeof(D3D11_VertexShader),
|
||||
inputLayout);
|
||||
if (FAILED(result)) {
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateInputLayout"), result);
|
||||
}
|
||||
@@ -1943,11 +1939,10 @@ int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D1
|
||||
HRESULT result;
|
||||
|
||||
result = ID3D11Device_CreatePixelShader(d3dDevice,
|
||||
D3D11_shaders[shader].shader_data,
|
||||
D3D11_shaders[shader].shader_size,
|
||||
NULL,
|
||||
pixelShader
|
||||
);
|
||||
D3D11_shaders[shader].shader_data,
|
||||
D3D11_shaders[shader].shader_size,
|
||||
NULL,
|
||||
pixelShader);
|
||||
if (FAILED(result)) {
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader"), result);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
/* D3D11 shader implementation */
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
SHADER_SOLID,
|
||||
SHADER_RGB,
|
||||
#if SDL_HAVE_YUV
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,6 @@
|
||||
|
||||
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
|
||||
|
||||
|
||||
/* Direct3D 12 shaders
|
||||
|
||||
SDL's shaders are compiled into SDL itself, to simplify distribution.
|
||||
@@ -51,7 +50,7 @@
|
||||
Shader types:
|
||||
- ps_6_0: Pixel shader
|
||||
- vs_6_0: Vertex shader
|
||||
|
||||
|
||||
|
||||
Shader object code was converted to unsigned chars via the following
|
||||
*nix style command (available separately from Windows + MSVC):
|
||||
@@ -1729,7 +1728,7 @@ static unsigned char D3D12_PixelShader_YUV_BT601[] = {
|
||||
float2 tex : TEXCOORD0;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
|
||||
#define YUVRS \
|
||||
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
|
||||
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
|
||||
@@ -6770,7 +6769,7 @@ static unsigned char D3D12_VertexShader_NV[] = {
|
||||
/* Root signature blobs extracted from Vertex Shader
|
||||
dxc command line is:
|
||||
dxc -E <RS> -T rootsig_1_1 -rootsig-define <RS> -Fo <OUTFILE> D3D12_VertexShader.hlsl
|
||||
|
||||
|
||||
Variables:
|
||||
- <RS>: the root signature define
|
||||
- <OUTFILE>: the output file name.
|
||||
@@ -6858,78 +6857,57 @@ static struct
|
||||
{
|
||||
const void *ps_shader_data;
|
||||
SIZE_T ps_shader_size;
|
||||
const void* vs_shader_data;
|
||||
const void *vs_shader_data;
|
||||
SIZE_T vs_shader_size;
|
||||
D3D12_RootSignature root_sig;
|
||||
} D3D12_shaders[NUM_SHADERS] = {
|
||||
{
|
||||
D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors),
|
||||
D3D12_VertexShader_Colors, sizeof(D3D12_VertexShader_Colors),
|
||||
ROOTSIG_COLOR
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures),
|
||||
D3D12_VertexShader_Textures, sizeof(D3D12_VertexShader_Textures),
|
||||
ROOTSIG_TEXTURE
|
||||
},
|
||||
{ D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors),
|
||||
D3D12_VertexShader_Colors, sizeof(D3D12_VertexShader_Colors),
|
||||
ROOTSIG_COLOR },
|
||||
{ D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures),
|
||||
D3D12_VertexShader_Textures, sizeof(D3D12_VertexShader_Textures),
|
||||
ROOTSIG_TEXTURE },
|
||||
#if SDL_HAVE_YUV
|
||||
{
|
||||
D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV
|
||||
},
|
||||
{ D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV },
|
||||
{ D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV },
|
||||
{ D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV },
|
||||
{ D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct {
|
||||
const void* rs_shader_data;
|
||||
static struct
|
||||
{
|
||||
const void *rs_shader_data;
|
||||
SIZE_T rs_shader_size;
|
||||
} D3D12_rootsigs[NUM_ROOTSIGS] = {
|
||||
{D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color)},
|
||||
{D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture)},
|
||||
{ D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color) },
|
||||
{ D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture) },
|
||||
#if SDL_HAVE_YUV
|
||||
{D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV)},
|
||||
{D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV)},
|
||||
{ D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV) },
|
||||
{ D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV) },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
SHADER_SOLID,
|
||||
SHADER_RGB,
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -44,7 +45,8 @@ typedef enum {
|
||||
NUM_SHADERS
|
||||
} D3D12_Shader;
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
ROOTSIG_COLOR,
|
||||
ROOTSIG_TEXTURE,
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -57,7 +59,7 @@ typedef enum {
|
||||
extern void D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode);
|
||||
extern void D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode);
|
||||
extern D3D12_RootSignature D3D12_GetRootSignatureType(D3D12_Shader shader);
|
||||
extern void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE* outBytecode);
|
||||
extern void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@
|
||||
If you need to use a GL function from the SDL video subsystem,
|
||||
change its entry from SDL_PROC_UNUSED to SDL_PROC and rebuild.
|
||||
*/
|
||||
#define SDL_PROC_UNUSED(ret,func,params)
|
||||
#define SDL_PROC_UNUSED(ret, func, params)
|
||||
|
||||
SDL_PROC_UNUSED(void, glAccum, (GLenum, GLfloat))
|
||||
SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum, GLclampf))
|
||||
@@ -74,21 +74,21 @@ SDL_PROC_UNUSED(void, glColor4iv, (const GLint *))
|
||||
SDL_PROC_UNUSED(void, glColor4s, (GLshort, GLshort, GLshort, GLshort))
|
||||
SDL_PROC_UNUSED(void, glColor4sv, (const GLshort *))
|
||||
SDL_PROC(void, glColor4ub,
|
||||
(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
|
||||
SDL_PROC_UNUSED(void, glColor4ubv, (const GLubyte * v))
|
||||
(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
|
||||
SDL_PROC_UNUSED(void, glColor4ubv, (const GLubyte *v))
|
||||
SDL_PROC_UNUSED(void, glColor4ui,
|
||||
(GLuint red, GLuint green, GLuint blue, GLuint alpha))
|
||||
SDL_PROC_UNUSED(void, glColor4uiv, (const GLuint * v))
|
||||
SDL_PROC_UNUSED(void, glColor4uiv, (const GLuint *v))
|
||||
SDL_PROC_UNUSED(void, glColor4us,
|
||||
(GLushort red, GLushort green, GLushort blue, GLushort alpha))
|
||||
SDL_PROC_UNUSED(void, glColor4usv, (const GLushort * v))
|
||||
SDL_PROC_UNUSED(void, glColor4usv, (const GLushort *v))
|
||||
SDL_PROC_UNUSED(void, glColorMask,
|
||||
(GLboolean red, GLboolean green, GLboolean blue,
|
||||
GLboolean alpha))
|
||||
SDL_PROC_UNUSED(void, glColorMaterial, (GLenum face, GLenum mode))
|
||||
SDL_PROC(void, glColorPointer,
|
||||
(GLint size, GLenum type, GLsizei stride,
|
||||
const GLvoid * pointer))
|
||||
(GLint size, GLenum type, GLsizei stride,
|
||||
const GLvoid *pointer))
|
||||
SDL_PROC_UNUSED(void, glCopyPixels,
|
||||
(GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLenum type))
|
||||
@@ -106,7 +106,7 @@ SDL_PROC_UNUSED(void, glCopyTexSubImage2D,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height))
|
||||
SDL_PROC_UNUSED(void, glCullFace, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glDeleteLists, (GLuint list, GLsizei range))
|
||||
SDL_PROC(void, glDeleteTextures, (GLsizei n, const GLuint * textures))
|
||||
SDL_PROC(void, glDeleteTextures, (GLsizei n, const GLuint *textures))
|
||||
SDL_PROC(void, glDepthFunc, (GLenum func))
|
||||
SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag))
|
||||
SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar))
|
||||
@@ -116,141 +116,141 @@ SDL_PROC(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count))
|
||||
SDL_PROC_UNUSED(void, glDrawBuffer, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glDrawElements,
|
||||
(GLenum mode, GLsizei count, GLenum type,
|
||||
const GLvoid * indices))
|
||||
const GLvoid *indices))
|
||||
SDL_PROC(void, glDrawPixels,
|
||||
(GLsizei width, GLsizei height, GLenum format, GLenum type,
|
||||
const GLvoid * pixels))
|
||||
const GLvoid *pixels))
|
||||
SDL_PROC_UNUSED(void, glEdgeFlag, (GLboolean flag))
|
||||
SDL_PROC_UNUSED(void, glEdgeFlagPointer,
|
||||
(GLsizei stride, const GLvoid * pointer))
|
||||
SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean * flag))
|
||||
(GLsizei stride, const GLvoid *pointer))
|
||||
SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean *flag))
|
||||
SDL_PROC(void, glEnable, (GLenum cap))
|
||||
SDL_PROC(void, glEnableClientState, (GLenum array))
|
||||
SDL_PROC(void, glEnd, (void))
|
||||
SDL_PROC_UNUSED(void, glEndList, (void))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1d, (GLdouble u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1dv, (const GLdouble * u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1dv, (const GLdouble *u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1f, (GLfloat u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1fv, (const GLfloat * u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1fv, (const GLfloat *u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2d, (GLdouble u, GLdouble v))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2dv, (const GLdouble * u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2dv, (const GLdouble *u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2f, (GLfloat u, GLfloat v))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2fv, (const GLfloat * u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2fv, (const GLfloat *u))
|
||||
SDL_PROC_UNUSED(void, glEvalMesh1, (GLenum mode, GLint i1, GLint i2))
|
||||
SDL_PROC_UNUSED(void, glEvalMesh2,
|
||||
(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2))
|
||||
SDL_PROC_UNUSED(void, glEvalPoint1, (GLint i))
|
||||
SDL_PROC_UNUSED(void, glEvalPoint2, (GLint i, GLint j))
|
||||
SDL_PROC_UNUSED(void, glFeedbackBuffer,
|
||||
(GLsizei size, GLenum type, GLfloat * buffer))
|
||||
(GLsizei size, GLenum type, GLfloat *buffer))
|
||||
SDL_PROC_UNUSED(void, glFinish, (void))
|
||||
SDL_PROC_UNUSED(void, glFlush, (void))
|
||||
SDL_PROC_UNUSED(void, glFogf, (GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat *params))
|
||||
SDL_PROC_UNUSED(void, glFogi, (GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glFogiv, (GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glFogiv, (GLenum pname, const GLint *params))
|
||||
SDL_PROC_UNUSED(void, glFrontFace, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glFrustum,
|
||||
(GLdouble left, GLdouble right, GLdouble bottom,
|
||||
GLdouble top, GLdouble zNear, GLdouble zFar))
|
||||
SDL_PROC_UNUSED(GLuint, glGenLists, (GLsizei range))
|
||||
SDL_PROC(void, glGenTextures, (GLsizei n, GLuint * textures))
|
||||
SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean * params))
|
||||
SDL_PROC_UNUSED(void, glGetClipPlane, (GLenum plane, GLdouble * equation))
|
||||
SDL_PROC_UNUSED(void, glGetDoublev, (GLenum pname, GLdouble * params))
|
||||
SDL_PROC(void, glGenTextures, (GLsizei n, GLuint *textures))
|
||||
SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean *params))
|
||||
SDL_PROC_UNUSED(void, glGetClipPlane, (GLenum plane, GLdouble *equation))
|
||||
SDL_PROC_UNUSED(void, glGetDoublev, (GLenum pname, GLdouble *params))
|
||||
SDL_PROC(GLenum, glGetError, (void))
|
||||
SDL_PROC(void, glGetFloatv, (GLenum pname, GLfloat * params))
|
||||
SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint * params))
|
||||
SDL_PROC(void, glGetFloatv, (GLenum pname, GLfloat *params))
|
||||
SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint *params))
|
||||
SDL_PROC_UNUSED(void, glGetLightfv,
|
||||
(GLenum light, GLenum pname, GLfloat * params))
|
||||
(GLenum light, GLenum pname, GLfloat *params))
|
||||
SDL_PROC_UNUSED(void, glGetLightiv,
|
||||
(GLenum light, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetMapdv, (GLenum target, GLenum query, GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glGetMapfv, (GLenum target, GLenum query, GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glGetMapiv, (GLenum target, GLenum query, GLint * v))
|
||||
(GLenum light, GLenum pname, GLint *params))
|
||||
SDL_PROC_UNUSED(void, glGetMapdv, (GLenum target, GLenum query, GLdouble *v))
|
||||
SDL_PROC_UNUSED(void, glGetMapfv, (GLenum target, GLenum query, GLfloat *v))
|
||||
SDL_PROC_UNUSED(void, glGetMapiv, (GLenum target, GLenum query, GLint *v))
|
||||
SDL_PROC_UNUSED(void, glGetMaterialfv,
|
||||
(GLenum face, GLenum pname, GLfloat * params))
|
||||
(GLenum face, GLenum pname, GLfloat *params))
|
||||
SDL_PROC_UNUSED(void, glGetMaterialiv,
|
||||
(GLenum face, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetPixelMapfv, (GLenum map, GLfloat * values))
|
||||
SDL_PROC_UNUSED(void, glGetPixelMapuiv, (GLenum map, GLuint * values))
|
||||
SDL_PROC_UNUSED(void, glGetPixelMapusv, (GLenum map, GLushort * values))
|
||||
SDL_PROC(void, glGetPointerv, (GLenum pname, GLvoid * *params))
|
||||
(GLenum face, GLenum pname, GLint *params))
|
||||
SDL_PROC_UNUSED(void, glGetPixelMapfv, (GLenum map, GLfloat *values))
|
||||
SDL_PROC_UNUSED(void, glGetPixelMapuiv, (GLenum map, GLuint *values))
|
||||
SDL_PROC_UNUSED(void, glGetPixelMapusv, (GLenum map, GLushort *values))
|
||||
SDL_PROC(void, glGetPointerv, (GLenum pname, GLvoid **params))
|
||||
SDL_PROC_UNUSED(void, glGetPolygonStipple, (GLubyte * mask))
|
||||
SDL_PROC(const GLubyte *, glGetString, (GLenum name))
|
||||
SDL_PROC_UNUSED(void, glGetTexEnvfv,
|
||||
(GLenum target, GLenum pname, GLfloat * params))
|
||||
(GLenum target, GLenum pname, GLfloat *params))
|
||||
SDL_PROC_UNUSED(void, glGetTexEnviv,
|
||||
(GLenum target, GLenum pname, GLint * params))
|
||||
(GLenum target, GLenum pname, GLint *params))
|
||||
SDL_PROC_UNUSED(void, glGetTexGendv,
|
||||
(GLenum coord, GLenum pname, GLdouble * params))
|
||||
(GLenum coord, GLenum pname, GLdouble *params))
|
||||
SDL_PROC_UNUSED(void, glGetTexGenfv,
|
||||
(GLenum coord, GLenum pname, GLfloat * params))
|
||||
(GLenum coord, GLenum pname, GLfloat *params))
|
||||
SDL_PROC_UNUSED(void, glGetTexGeniv,
|
||||
(GLenum coord, GLenum pname, GLint * params))
|
||||
(GLenum coord, GLenum pname, GLint *params))
|
||||
SDL_PROC_UNUSED(void, glGetTexImage,
|
||||
(GLenum target, GLint level, GLenum format, GLenum type,
|
||||
GLvoid * pixels))
|
||||
GLvoid *pixels))
|
||||
SDL_PROC_UNUSED(void, glGetTexLevelParameterfv,
|
||||
(GLenum target, GLint level, GLenum pname, GLfloat * params))
|
||||
(GLenum target, GLint level, GLenum pname, GLfloat *params))
|
||||
SDL_PROC_UNUSED(void, glGetTexLevelParameteriv,
|
||||
(GLenum target, GLint level, GLenum pname, GLint * params))
|
||||
(GLenum target, GLint level, GLenum pname, GLint *params))
|
||||
SDL_PROC_UNUSED(void, glGetTexParameterfv,
|
||||
(GLenum target, GLenum pname, GLfloat * params))
|
||||
(GLenum target, GLenum pname, GLfloat *params))
|
||||
SDL_PROC_UNUSED(void, glGetTexParameteriv,
|
||||
(GLenum target, GLenum pname, GLint * params))
|
||||
(GLenum target, GLenum pname, GLint *params))
|
||||
SDL_PROC_UNUSED(void, glHint, (GLenum target, GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glIndexMask, (GLuint mask))
|
||||
SDL_PROC_UNUSED(void, glIndexPointer,
|
||||
(GLenum type, GLsizei stride, const GLvoid * pointer))
|
||||
(GLenum type, GLsizei stride, const GLvoid *pointer))
|
||||
SDL_PROC_UNUSED(void, glIndexd, (GLdouble c))
|
||||
SDL_PROC_UNUSED(void, glIndexdv, (const GLdouble * c))
|
||||
SDL_PROC_UNUSED(void, glIndexdv, (const GLdouble *c))
|
||||
SDL_PROC_UNUSED(void, glIndexf, (GLfloat c))
|
||||
SDL_PROC_UNUSED(void, glIndexfv, (const GLfloat * c))
|
||||
SDL_PROC_UNUSED(void, glIndexfv, (const GLfloat *c))
|
||||
SDL_PROC_UNUSED(void, glIndexi, (GLint c))
|
||||
SDL_PROC_UNUSED(void, glIndexiv, (const GLint * c))
|
||||
SDL_PROC_UNUSED(void, glIndexiv, (const GLint *c))
|
||||
SDL_PROC_UNUSED(void, glIndexs, (GLshort c))
|
||||
SDL_PROC_UNUSED(void, glIndexsv, (const GLshort * c))
|
||||
SDL_PROC_UNUSED(void, glIndexsv, (const GLshort *c))
|
||||
SDL_PROC_UNUSED(void, glIndexub, (GLubyte c))
|
||||
SDL_PROC_UNUSED(void, glIndexubv, (const GLubyte * c))
|
||||
SDL_PROC_UNUSED(void, glIndexubv, (const GLubyte *c))
|
||||
SDL_PROC_UNUSED(void, glInitNames, (void))
|
||||
SDL_PROC_UNUSED(void, glInterleavedArrays,
|
||||
(GLenum format, GLsizei stride, const GLvoid * pointer))
|
||||
(GLenum format, GLsizei stride, const GLvoid *pointer))
|
||||
SDL_PROC_UNUSED(GLboolean, glIsEnabled, (GLenum cap))
|
||||
SDL_PROC_UNUSED(GLboolean, glIsList, (GLuint list))
|
||||
SDL_PROC_UNUSED(GLboolean, glIsTexture, (GLuint texture))
|
||||
SDL_PROC_UNUSED(void, glLightModelf, (GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat *params))
|
||||
SDL_PROC_UNUSED(void, glLightModeli, (GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glLightModeliv, (GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glLightModeliv, (GLenum pname, const GLint *params))
|
||||
SDL_PROC_UNUSED(void, glLightf, (GLenum light, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glLightfv,
|
||||
(GLenum light, GLenum pname, const GLfloat * params))
|
||||
(GLenum light, GLenum pname, const GLfloat *params))
|
||||
SDL_PROC_UNUSED(void, glLighti, (GLenum light, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glLightiv,
|
||||
(GLenum light, GLenum pname, const GLint * params))
|
||||
(GLenum light, GLenum pname, const GLint *params))
|
||||
SDL_PROC_UNUSED(void, glLineStipple, (GLint factor, GLushort pattern))
|
||||
SDL_PROC(void, glLineWidth, (GLfloat width))
|
||||
SDL_PROC_UNUSED(void, glListBase, (GLuint base))
|
||||
SDL_PROC(void, glLoadIdentity, (void))
|
||||
SDL_PROC_UNUSED(void, glLoadMatrixd, (const GLdouble * m))
|
||||
SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat * m))
|
||||
SDL_PROC_UNUSED(void, glLoadMatrixd, (const GLdouble *m))
|
||||
SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat *m))
|
||||
SDL_PROC_UNUSED(void, glLoadName, (GLuint name))
|
||||
SDL_PROC_UNUSED(void, glLogicOp, (GLenum opcode))
|
||||
SDL_PROC_UNUSED(void, glMap1d,
|
||||
(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
|
||||
GLint order, const GLdouble * points))
|
||||
GLint order, const GLdouble *points))
|
||||
SDL_PROC_UNUSED(void, glMap1f,
|
||||
(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
|
||||
GLint order, const GLfloat * points))
|
||||
GLint order, const GLfloat *points))
|
||||
SDL_PROC_UNUSED(void, glMap2d,
|
||||
(GLenum target, GLdouble u1, GLdouble u2, GLint ustride,
|
||||
GLint uorder, GLdouble v1, GLdouble v2, GLint vstride,
|
||||
GLint vorder, const GLdouble * points))
|
||||
GLint vorder, const GLdouble *points))
|
||||
SDL_PROC_UNUSED(void, glMap2f,
|
||||
(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
|
||||
GLint uorder, GLfloat v1, GLfloat v2, GLint vstride,
|
||||
GLint vorder, const GLfloat * points))
|
||||
GLint vorder, const GLfloat *points))
|
||||
SDL_PROC_UNUSED(void, glMapGrid1d, (GLint un, GLdouble u1, GLdouble u2))
|
||||
SDL_PROC_UNUSED(void, glMapGrid1f, (GLint un, GLfloat u1, GLfloat u2))
|
||||
SDL_PROC_UNUSED(void, glMapGrid2d,
|
||||
@@ -261,36 +261,36 @@ SDL_PROC_UNUSED(void, glMapGrid2f,
|
||||
GLfloat v2))
|
||||
SDL_PROC_UNUSED(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glMaterialfv,
|
||||
(GLenum face, GLenum pname, const GLfloat * params))
|
||||
(GLenum face, GLenum pname, const GLfloat *params))
|
||||
SDL_PROC_UNUSED(void, glMateriali, (GLenum face, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glMaterialiv,
|
||||
(GLenum face, GLenum pname, const GLint * params))
|
||||
(GLenum face, GLenum pname, const GLint *params))
|
||||
SDL_PROC(void, glMatrixMode, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glMultMatrixd, (const GLdouble * m))
|
||||
SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat * m))
|
||||
SDL_PROC_UNUSED(void, glMultMatrixd, (const GLdouble *m))
|
||||
SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat *m))
|
||||
SDL_PROC_UNUSED(void, glNewList, (GLuint list, GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glNormal3b, (GLbyte nx, GLbyte ny, GLbyte nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3bv, (const GLbyte * v))
|
||||
SDL_PROC_UNUSED(void, glNormal3bv, (const GLbyte *v))
|
||||
SDL_PROC_UNUSED(void, glNormal3d, (GLdouble nx, GLdouble ny, GLdouble nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glNormal3dv, (const GLdouble *v))
|
||||
SDL_PROC_UNUSED(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glNormal3fv, (const GLfloat *v))
|
||||
SDL_PROC_UNUSED(void, glNormal3i, (GLint nx, GLint ny, GLint nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glNormal3iv, (const GLint *v))
|
||||
SDL_PROC_UNUSED(void, glNormal3s, (GLshort nx, GLshort ny, GLshort nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glNormal3sv, (const GLshort *v))
|
||||
SDL_PROC_UNUSED(void, glNormalPointer,
|
||||
(GLenum type, GLsizei stride, const GLvoid * pointer))
|
||||
(GLenum type, GLsizei stride, const GLvoid *pointer))
|
||||
SDL_PROC(void, glOrtho,
|
||||
(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
|
||||
GLdouble zNear, GLdouble zFar))
|
||||
SDL_PROC_UNUSED(void, glPassThrough, (GLfloat token))
|
||||
SDL_PROC_UNUSED(void, glPixelMapfv,
|
||||
(GLenum map, GLsizei mapsize, const GLfloat * values))
|
||||
(GLenum map, GLsizei mapsize, const GLfloat *values))
|
||||
SDL_PROC_UNUSED(void, glPixelMapuiv,
|
||||
(GLenum map, GLsizei mapsize, const GLuint * values))
|
||||
(GLenum map, GLsizei mapsize, const GLuint *values))
|
||||
SDL_PROC_UNUSED(void, glPixelMapusv,
|
||||
(GLenum map, GLsizei mapsize, const GLushort * values))
|
||||
(GLenum map, GLsizei mapsize, const GLushort *values))
|
||||
SDL_PROC_UNUSED(void, glPixelStoref, (GLenum pname, GLfloat param))
|
||||
SDL_PROC(void, glPixelStorei, (GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glPixelTransferf, (GLenum pname, GLfloat param))
|
||||
@@ -299,180 +299,180 @@ SDL_PROC_UNUSED(void, glPixelZoom, (GLfloat xfactor, GLfloat yfactor))
|
||||
SDL_PROC(void, glPointSize, (GLfloat size))
|
||||
SDL_PROC_UNUSED(void, glPolygonMode, (GLenum face, GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units))
|
||||
SDL_PROC_UNUSED(void, glPolygonStipple, (const GLubyte * mask))
|
||||
SDL_PROC_UNUSED(void, glPolygonStipple, (const GLubyte *mask))
|
||||
SDL_PROC_UNUSED(void, glPopAttrib, (void))
|
||||
SDL_PROC_UNUSED(void, glPopClientAttrib, (void))
|
||||
SDL_PROC_UNUSED(void, glPopMatrix, (void))
|
||||
SDL_PROC_UNUSED(void, glPopName, (void))
|
||||
SDL_PROC_UNUSED(void, glPrioritizeTextures,
|
||||
(GLsizei n, const GLuint * textures,
|
||||
const GLclampf * priorities))
|
||||
(GLsizei n, const GLuint *textures,
|
||||
const GLclampf *priorities))
|
||||
SDL_PROC_UNUSED(void, glPushAttrib, (GLbitfield mask))
|
||||
SDL_PROC_UNUSED(void, glPushClientAttrib, (GLbitfield mask))
|
||||
SDL_PROC_UNUSED(void, glPushMatrix, (void))
|
||||
SDL_PROC_UNUSED(void, glPushName, (GLuint name))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2d, (GLdouble x, GLdouble y))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2dv, (const GLdouble *v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2f, (GLfloat x, GLfloat y))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2fv, (const GLfloat *v))
|
||||
SDL_PROC(void, glRasterPos2i, (GLint x, GLint y))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2iv, (const GLint *v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2s, (GLshort x, GLshort y))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2sv, (const GLshort *v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3d, (GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3dv, (const GLdouble *v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3f, (GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3fv, (const GLfloat *v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3i, (GLint x, GLint y, GLint z))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3iv, (const GLint *v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3s, (GLshort x, GLshort y, GLshort z))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3sv, (const GLshort *v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4d,
|
||||
(GLdouble x, GLdouble y, GLdouble z, GLdouble w))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4dv, (const GLdouble *v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4f,
|
||||
(GLfloat x, GLfloat y, GLfloat z, GLfloat w))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4fv, (const GLfloat *v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4i, (GLint x, GLint y, GLint z, GLint w))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4iv, (const GLint *v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4s,
|
||||
(GLshort x, GLshort y, GLshort z, GLshort w))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4sv, (const GLshort *v))
|
||||
SDL_PROC(void, glReadBuffer, (GLenum mode))
|
||||
SDL_PROC(void, glReadPixels,
|
||||
(GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type, GLvoid * pixels))
|
||||
GLenum format, GLenum type, GLvoid *pixels))
|
||||
SDL_PROC_UNUSED(void, glRectd,
|
||||
(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2))
|
||||
SDL_PROC_UNUSED(void, glRectdv, (const GLdouble * v1, const GLdouble * v2))
|
||||
SDL_PROC_UNUSED(void, glRectdv, (const GLdouble *v1, const GLdouble *v2))
|
||||
SDL_PROC(void, glRectf,
|
||||
(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2))
|
||||
SDL_PROC_UNUSED(void, glRectfv, (const GLfloat * v1, const GLfloat * v2))
|
||||
(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2))
|
||||
SDL_PROC_UNUSED(void, glRectfv, (const GLfloat *v1, const GLfloat *v2))
|
||||
SDL_PROC_UNUSED(void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2))
|
||||
SDL_PROC_UNUSED(void, glRectiv, (const GLint * v1, const GLint * v2))
|
||||
SDL_PROC_UNUSED(void, glRectiv, (const GLint *v1, const GLint *v2))
|
||||
SDL_PROC_UNUSED(void, glRects,
|
||||
(GLshort x1, GLshort y1, GLshort x2, GLshort y2))
|
||||
SDL_PROC_UNUSED(void, glRectsv, (const GLshort * v1, const GLshort * v2))
|
||||
SDL_PROC_UNUSED(void, glRectsv, (const GLshort *v1, const GLshort *v2))
|
||||
SDL_PROC_UNUSED(GLint, glRenderMode, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glRotated,
|
||||
(GLdouble angle, GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC(void, glRotatef,
|
||||
(GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
|
||||
(GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC_UNUSED(void, glScaled, (GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height))
|
||||
SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint * buffer))
|
||||
SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint *buffer))
|
||||
SDL_PROC(void, glShadeModel, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask))
|
||||
SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask))
|
||||
SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1d, (GLdouble s))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1dv, (const GLdouble *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1f, (GLfloat s))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1fv, (const GLfloat *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1i, (GLint s))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1iv, (const GLint *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1s, (GLshort s))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1sv, (const GLshort *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2d, (GLdouble s, GLdouble t))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2dv, (const GLdouble *v))
|
||||
SDL_PROC(void, glTexCoord2f, (GLfloat s, GLfloat t))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2fv, (const GLfloat *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2i, (GLint s, GLint t))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2iv, (const GLint *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2s, (GLshort s, GLshort t))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2sv, (const GLshort *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3d, (GLdouble s, GLdouble t, GLdouble r))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3dv, (const GLdouble *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3f, (GLfloat s, GLfloat t, GLfloat r))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3fv, (const GLfloat *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3i, (GLint s, GLint t, GLint r))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3iv, (const GLint *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3s, (GLshort s, GLshort t, GLshort r))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3sv, (const GLshort *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4d,
|
||||
(GLdouble s, GLdouble t, GLdouble r, GLdouble q))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4dv, (const GLdouble *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4f,
|
||||
(GLfloat s, GLfloat t, GLfloat r, GLfloat q))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4fv, (const GLfloat *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4i, (GLint s, GLint t, GLint r, GLint q))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4iv, (const GLint *v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4s,
|
||||
(GLshort s, GLshort t, GLshort r, GLshort q))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4sv, (const GLshort *v))
|
||||
SDL_PROC(void, glTexCoordPointer,
|
||||
(GLint size, GLenum type, GLsizei stride,
|
||||
const GLvoid * pointer))
|
||||
(GLint size, GLenum type, GLsizei stride,
|
||||
const GLvoid *pointer))
|
||||
SDL_PROC(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glTexEnvfv,
|
||||
(GLenum target, GLenum pname, const GLfloat * params))
|
||||
(GLenum target, GLenum pname, const GLfloat *params))
|
||||
SDL_PROC_UNUSED(void, glTexEnvi, (GLenum target, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glTexEnviv,
|
||||
(GLenum target, GLenum pname, const GLint * params))
|
||||
(GLenum target, GLenum pname, const GLint *params))
|
||||
SDL_PROC_UNUSED(void, glTexGend, (GLenum coord, GLenum pname, GLdouble param))
|
||||
SDL_PROC_UNUSED(void, glTexGendv,
|
||||
(GLenum coord, GLenum pname, const GLdouble * params))
|
||||
(GLenum coord, GLenum pname, const GLdouble *params))
|
||||
SDL_PROC_UNUSED(void, glTexGenf, (GLenum coord, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glTexGenfv,
|
||||
(GLenum coord, GLenum pname, const GLfloat * params))
|
||||
(GLenum coord, GLenum pname, const GLfloat *params))
|
||||
SDL_PROC_UNUSED(void, glTexGeni, (GLenum coord, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glTexGeniv,
|
||||
(GLenum coord, GLenum pname, const GLint * params))
|
||||
(GLenum coord, GLenum pname, const GLint *params))
|
||||
SDL_PROC_UNUSED(void, glTexImage1D,
|
||||
(GLenum target, GLint level, GLint internalformat,
|
||||
GLsizei width, GLint border, GLenum format, GLenum type,
|
||||
const GLvoid * pixels))
|
||||
const GLvoid *pixels))
|
||||
SDL_PROC(void, glTexImage2D,
|
||||
(GLenum target, GLint level, GLint internalformat, GLsizei width,
|
||||
GLsizei height, GLint border, GLenum format, GLenum type,
|
||||
const GLvoid * pixels))
|
||||
const GLvoid *pixels))
|
||||
SDL_PROC_UNUSED(void, glTexParameterf,
|
||||
(GLenum target, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glTexParameterfv,
|
||||
(GLenum target, GLenum pname, const GLfloat * params))
|
||||
(GLenum target, GLenum pname, const GLfloat *params))
|
||||
SDL_PROC(void, glTexParameteri, (GLenum target, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glTexParameteriv,
|
||||
(GLenum target, GLenum pname, const GLint * params))
|
||||
(GLenum target, GLenum pname, const GLint *params))
|
||||
SDL_PROC_UNUSED(void, glTexSubImage1D,
|
||||
(GLenum target, GLint level, GLint xoffset, GLsizei width,
|
||||
GLenum format, GLenum type, const GLvoid * pixels))
|
||||
GLenum format, GLenum type, const GLvoid *pixels))
|
||||
SDL_PROC(void, glTexSubImage2D,
|
||||
(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
||||
GLsizei width, GLsizei height, GLenum format, GLenum type,
|
||||
const GLvoid * pixels))
|
||||
const GLvoid *pixels))
|
||||
SDL_PROC_UNUSED(void, glTranslated, (GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC_UNUSED(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC_UNUSED(void, glVertex2d, (GLdouble x, GLdouble y))
|
||||
SDL_PROC_UNUSED(void, glVertex2dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glVertex2dv, (const GLdouble *v))
|
||||
SDL_PROC(void, glVertex2f, (GLfloat x, GLfloat y))
|
||||
SDL_PROC_UNUSED(void, glVertex2fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glVertex2fv, (const GLfloat *v))
|
||||
SDL_PROC_UNUSED(void, glVertex2i, (GLint x, GLint y))
|
||||
SDL_PROC_UNUSED(void, glVertex2iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glVertex2iv, (const GLint *v))
|
||||
SDL_PROC_UNUSED(void, glVertex2s, (GLshort x, GLshort y))
|
||||
SDL_PROC_UNUSED(void, glVertex2sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glVertex2sv, (const GLshort *v))
|
||||
SDL_PROC_UNUSED(void, glVertex3d, (GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC_UNUSED(void, glVertex3dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glVertex3dv, (const GLdouble *v))
|
||||
SDL_PROC_UNUSED(void, glVertex3f, (GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC(void, glVertex3fv, (const GLfloat * v))
|
||||
SDL_PROC(void, glVertex3fv, (const GLfloat *v))
|
||||
SDL_PROC_UNUSED(void, glVertex3i, (GLint x, GLint y, GLint z))
|
||||
SDL_PROC_UNUSED(void, glVertex3iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glVertex3iv, (const GLint *v))
|
||||
SDL_PROC_UNUSED(void, glVertex3s, (GLshort x, GLshort y, GLshort z))
|
||||
SDL_PROC_UNUSED(void, glVertex3sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glVertex3sv, (const GLshort *v))
|
||||
SDL_PROC_UNUSED(void, glVertex4d,
|
||||
(GLdouble x, GLdouble y, GLdouble z, GLdouble w))
|
||||
SDL_PROC_UNUSED(void, glVertex4dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glVertex4dv, (const GLdouble *v))
|
||||
SDL_PROC_UNUSED(void, glVertex4f,
|
||||
(GLfloat x, GLfloat y, GLfloat z, GLfloat w))
|
||||
SDL_PROC_UNUSED(void, glVertex4fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glVertex4fv, (const GLfloat *v))
|
||||
SDL_PROC_UNUSED(void, glVertex4i, (GLint x, GLint y, GLint z, GLint w))
|
||||
SDL_PROC_UNUSED(void, glVertex4iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glVertex4iv, (const GLint *v))
|
||||
SDL_PROC_UNUSED(void, glVertex4s,
|
||||
(GLshort x, GLshort y, GLshort z, GLshort w))
|
||||
SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort *v))
|
||||
SDL_PROC(void, glVertexPointer,
|
||||
(GLint size, GLenum type, GLsizei stride,
|
||||
const GLvoid * pointer))
|
||||
(GLint size, GLenum type, GLsizei stride,
|
||||
const GLvoid *pointer))
|
||||
SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height))
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -61,6 +61,8 @@ struct GL_ShaderContext
|
||||
GL_ShaderData shaders[NUM_SHADERS];
|
||||
};
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
||||
#define COLOR_VERTEX_SHADER \
|
||||
"varying vec4 v_color;\n" \
|
||||
"\n" \
|
||||
@@ -235,8 +237,7 @@ struct GL_ShaderContext
|
||||
* NOTE: Always use sampler2D, etc here. We'll #define them to the
|
||||
* texture_rectangle versions if we choose to use that extension.
|
||||
*/
|
||||
static const char *shader_source[NUM_SHADERS][2] =
|
||||
{
|
||||
static const char *shader_source[NUM_SHADERS][2] = {
|
||||
/* SHADER_NONE */
|
||||
{ NULL, NULL },
|
||||
|
||||
@@ -387,8 +388,9 @@ static const char *shader_source[NUM_SHADERS][2] =
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
};
|
||||
|
||||
static SDL_bool
|
||||
CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source)
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
static SDL_bool CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source)
|
||||
{
|
||||
GLint status;
|
||||
const char *sources[2];
|
||||
@@ -405,13 +407,13 @@ CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, co
|
||||
char *info;
|
||||
|
||||
ctx->glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
|
||||
info = SDL_small_alloc(char, length+1, &isstack);
|
||||
info = SDL_small_alloc(char, length + 1, &isstack);
|
||||
ctx->glGetInfoLogARB(shader, length, NULL, info);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER,
|
||||
"Failed to compile shader:\n%s%s\n%s", defines, source, info);
|
||||
"Failed to compile shader:\n%s%s\n%s", defines, source, info);
|
||||
#ifdef DEBUG_SHADERS
|
||||
fprintf(stderr,
|
||||
"Failed to compile shader:\n%s%s\n%s", defines, source, info);
|
||||
"Failed to compile shader:\n%s%s\n%s", defines, source, info);
|
||||
#endif
|
||||
SDL_small_free(info, isstack);
|
||||
|
||||
@@ -421,8 +423,7 @@ CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, co
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
|
||||
static SDL_bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
|
||||
{
|
||||
const int num_tmus_bound = 4;
|
||||
const char *vert_defines = "";
|
||||
@@ -439,12 +440,12 @@ CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
|
||||
/* Make sure we use the correct sampler type for our texture type */
|
||||
if (ctx->GL_ARB_texture_rectangle_supported) {
|
||||
frag_defines =
|
||||
"#define sampler2D sampler2DRect\n"
|
||||
"#define texture2D texture2DRect\n"
|
||||
"#define UVCoordScale 0.5\n";
|
||||
"#define sampler2D sampler2DRect\n"
|
||||
"#define texture2D texture2DRect\n"
|
||||
"#define UVCoordScale 0.5\n";
|
||||
} else {
|
||||
frag_defines =
|
||||
"#define UVCoordScale 1.0\n";
|
||||
frag_defines =
|
||||
"#define UVCoordScale 1.0\n";
|
||||
}
|
||||
|
||||
/* Create one program object to rule them all */
|
||||
@@ -482,8 +483,7 @@ CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
|
||||
return ctx->glGetError() == GL_NO_ERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyShaderProgram(GL_ShaderContext *ctx, GL_ShaderData *data)
|
||||
static void DestroyShaderProgram(GL_ShaderContext *ctx, GL_ShaderData *data)
|
||||
{
|
||||
ctx->glDeleteObjectARB(data->vert_shader);
|
||||
ctx->glDeleteObjectARB(data->frag_shader);
|
||||
@@ -514,20 +514,20 @@ GL_CreateShaderContext(void)
|
||||
SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") &&
|
||||
SDL_GL_ExtensionSupported("GL_ARB_vertex_shader") &&
|
||||
SDL_GL_ExtensionSupported("GL_ARB_fragment_shader")) {
|
||||
ctx->glGetError = (GLenum (*)(void)) SDL_GL_GetProcAddress("glGetError");
|
||||
ctx->glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) SDL_GL_GetProcAddress("glAttachObjectARB");
|
||||
ctx->glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) SDL_GL_GetProcAddress("glCompileShaderARB");
|
||||
ctx->glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glCreateProgramObjectARB");
|
||||
ctx->glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) SDL_GL_GetProcAddress("glCreateShaderObjectARB");
|
||||
ctx->glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) SDL_GL_GetProcAddress("glDeleteObjectARB");
|
||||
ctx->glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) SDL_GL_GetProcAddress("glGetInfoLogARB");
|
||||
ctx->glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB");
|
||||
ctx->glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetUniformLocationARB");
|
||||
ctx->glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) SDL_GL_GetProcAddress("glLinkProgramARB");
|
||||
ctx->glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glShaderSourceARB");
|
||||
ctx->glUniform1iARB = (PFNGLUNIFORM1IARBPROC) SDL_GL_GetProcAddress("glUniform1iARB");
|
||||
ctx->glUniform1fARB = (PFNGLUNIFORM1FARBPROC) SDL_GL_GetProcAddress("glUniform1fARB");
|
||||
ctx->glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glUseProgramObjectARB");
|
||||
ctx->glGetError = (GLenum(*)(void))SDL_GL_GetProcAddress("glGetError");
|
||||
ctx->glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)SDL_GL_GetProcAddress("glAttachObjectARB");
|
||||
ctx->glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)SDL_GL_GetProcAddress("glCompileShaderARB");
|
||||
ctx->glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glCreateProgramObjectARB");
|
||||
ctx->glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)SDL_GL_GetProcAddress("glCreateShaderObjectARB");
|
||||
ctx->glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)SDL_GL_GetProcAddress("glDeleteObjectARB");
|
||||
ctx->glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)SDL_GL_GetProcAddress("glGetInfoLogARB");
|
||||
ctx->glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)SDL_GL_GetProcAddress("glGetObjectParameterivARB");
|
||||
ctx->glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)SDL_GL_GetProcAddress("glGetUniformLocationARB");
|
||||
ctx->glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)SDL_GL_GetProcAddress("glLinkProgramARB");
|
||||
ctx->glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)SDL_GL_GetProcAddress("glShaderSourceARB");
|
||||
ctx->glUniform1iARB = (PFNGLUNIFORM1IARBPROC)SDL_GL_GetProcAddress("glUniform1iARB");
|
||||
ctx->glUniform1fARB = (PFNGLUNIFORM1FARBPROC)SDL_GL_GetProcAddress("glUniform1fARB");
|
||||
ctx->glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glUseProgramObjectARB");
|
||||
if (ctx->glGetError &&
|
||||
ctx->glAttachObjectARB &&
|
||||
ctx->glCompileShaderARB &&
|
||||
@@ -563,14 +563,12 @@ GL_CreateShaderContext(void)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void
|
||||
GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader)
|
||||
void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader)
|
||||
{
|
||||
ctx->glUseProgramObjectARB(ctx->shaders[shader].program);
|
||||
}
|
||||
|
||||
void
|
||||
GL_DestroyShaderContext(GL_ShaderContext *ctx)
|
||||
void GL_DestroyShaderContext(GL_ShaderContext *ctx)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
|
||||
/* OpenGL shader implementation */
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
SHADER_INVALID = -1,
|
||||
SHADER_NONE,
|
||||
SHADER_SOLID,
|
||||
@@ -50,7 +51,7 @@ typedef enum {
|
||||
|
||||
typedef struct GL_ShaderContext GL_ShaderContext;
|
||||
|
||||
extern GL_ShaderContext * GL_CreateShaderContext(void);
|
||||
extern GL_ShaderContext *GL_CreateShaderContext(void);
|
||||
extern void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader);
|
||||
extern void GL_DestroyShaderContext(GL_ShaderContext *ctx);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ SDL_PROC(void, glLoadIdentity, (void))
|
||||
SDL_PROC(void, glMatrixMode, (GLenum))
|
||||
SDL_PROC(void, glOrthof, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glPixelStorei, (GLenum, GLint))
|
||||
SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
|
||||
SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *))
|
||||
SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
|
||||
SDL_PROC(void, glTexCoordPointer, (GLint, GLenum, GLsizei, const GLvoid *))
|
||||
SDL_PROC(void, glTexEnvf, (GLenum, GLenum, GLfloat))
|
||||
@@ -57,6 +57,6 @@ SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei))
|
||||
SDL_PROC_OES(void, glBindFramebufferOES, (GLenum, GLuint))
|
||||
SDL_PROC_OES(void, glFramebufferTexture2DOES, (GLenum, GLenum, GLenum, GLuint, GLint))
|
||||
SDL_PROC_OES(GLenum, glCheckFramebufferStatusOES, (GLenum))
|
||||
SDL_PROC_OES(void, glDeleteFramebuffersOES, (GLsizei, const GLuint*))
|
||||
SDL_PROC_OES(void, glDeleteFramebuffersOES, (GLsizei, const GLuint *))
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -50,7 +50,7 @@ glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height)
|
||||
/* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */
|
||||
|
||||
/* Used to re-create the window with OpenGL ES capability */
|
||||
extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
|
||||
extern int SDL_RecreateWindow(SDL_Window *window, Uint32 flags);
|
||||
|
||||
static const float inv255f = 1.0f / 255.0f;
|
||||
|
||||
@@ -58,9 +58,9 @@ typedef struct GLES_FBOList GLES_FBOList;
|
||||
|
||||
struct GLES_FBOList
|
||||
{
|
||||
Uint32 w, h;
|
||||
GLuint FBO;
|
||||
GLES_FBOList *next;
|
||||
Uint32 w, h;
|
||||
GLuint FBO;
|
||||
GLES_FBOList *next;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
@@ -85,8 +85,8 @@ typedef struct
|
||||
{
|
||||
SDL_GLContext context;
|
||||
|
||||
#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
|
||||
#define SDL_PROC_OES SDL_PROC
|
||||
#define SDL_PROC(ret, func, params) ret(APIENTRY *func) params;
|
||||
#define SDL_PROC_OES SDL_PROC
|
||||
#include "SDL_glesfuncs.h"
|
||||
#undef SDL_PROC
|
||||
#undef SDL_PROC_OES
|
||||
@@ -114,8 +114,7 @@ typedef struct
|
||||
GLES_FBOList *fbo;
|
||||
} GLES_TextureData;
|
||||
|
||||
static int
|
||||
GLES_SetError(const char *prefix, GLenum result)
|
||||
static int GLES_SetError(const char *prefix, GLenum result)
|
||||
{
|
||||
const char *error;
|
||||
|
||||
@@ -148,7 +147,7 @@ GLES_SetError(const char *prefix, GLenum result)
|
||||
return SDL_SetError("%s: %s", prefix, error);
|
||||
}
|
||||
|
||||
static int GLES_LoadFunctions(GLES_RenderData * data)
|
||||
static int GLES_LoadFunctions(GLES_RenderData *data)
|
||||
{
|
||||
#if SDL_VIDEO_DRIVER_UIKIT
|
||||
#define __SDL_NOGETPROCADDR__
|
||||
@@ -159,20 +158,20 @@ static int GLES_LoadFunctions(GLES_RenderData * data)
|
||||
#endif
|
||||
|
||||
#ifdef __SDL_NOGETPROCADDR__
|
||||
#define SDL_PROC(ret,func,params) data->func=func;
|
||||
#define SDL_PROC_OES(ret,func,params) data->func=func;
|
||||
#define SDL_PROC(ret, func, params) data->func = func;
|
||||
#define SDL_PROC_OES(ret, func, params) data->func = func;
|
||||
#else
|
||||
#define SDL_PROC(ret,func,params) \
|
||||
do { \
|
||||
data->func = SDL_GL_GetProcAddress(#func); \
|
||||
if ( ! data->func ) { \
|
||||
#define SDL_PROC(ret, func, params) \
|
||||
do { \
|
||||
data->func = SDL_GL_GetProcAddress(#func); \
|
||||
if (!data->func) { \
|
||||
return SDL_SetError("Couldn't load GLES function %s: %s", #func, SDL_GetError()); \
|
||||
} \
|
||||
} while ( 0 );
|
||||
#define SDL_PROC_OES(ret,func,params) \
|
||||
do { \
|
||||
} \
|
||||
} while (0);
|
||||
#define SDL_PROC_OES(ret, func, params) \
|
||||
do { \
|
||||
data->func = SDL_GL_GetProcAddress(#func); \
|
||||
} while ( 0 );
|
||||
} while (0);
|
||||
#endif /* __SDL_NOGETPROCADDR__ */
|
||||
|
||||
#include "SDL_glesfuncs.h"
|
||||
@@ -181,29 +180,26 @@ static int GLES_LoadFunctions(GLES_RenderData * data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GLES_FBOList *
|
||||
GLES_GetFBO(GLES_RenderData *data, Uint32 w, Uint32 h)
|
||||
static GLES_FBOList *GLES_GetFBO(GLES_RenderData *data, Uint32 w, Uint32 h)
|
||||
{
|
||||
GLES_FBOList *result = data->framebuffers;
|
||||
while ((result) && ((result->w != w) || (result->h != h)) ) {
|
||||
result = result->next;
|
||||
}
|
||||
if (result == NULL) {
|
||||
result = SDL_malloc(sizeof(GLES_FBOList));
|
||||
result->w = w;
|
||||
result->h = h;
|
||||
data->glGenFramebuffersOES(1, &result->FBO);
|
||||
result->next = data->framebuffers;
|
||||
data->framebuffers = result;
|
||||
}
|
||||
return result;
|
||||
GLES_FBOList *result = data->framebuffers;
|
||||
while ((result) && ((result->w != w) || (result->h != h))) {
|
||||
result = result->next;
|
||||
}
|
||||
if (result == NULL) {
|
||||
result = SDL_malloc(sizeof(GLES_FBOList));
|
||||
result->w = w;
|
||||
result->h = h;
|
||||
data->glGenFramebuffersOES(1, &result->FBO);
|
||||
result->next = data->framebuffers;
|
||||
data->framebuffers = result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
GLES_ActivateRenderer(SDL_Renderer * renderer)
|
||||
static int GLES_ActivateRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata;
|
||||
|
||||
if (SDL_GL_GetCurrentContext() != data->context) {
|
||||
if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) {
|
||||
@@ -214,10 +210,9 @@ GLES_ActivateRenderer(SDL_Renderer * renderer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
static void GLES_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||
{
|
||||
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata;
|
||||
|
||||
if (event->event == SDL_WINDOWEVENT_MINIMIZED) {
|
||||
/* According to Apple documentation, we need to finish drawing NOW! */
|
||||
@@ -225,8 +220,7 @@ GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
GLES_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
|
||||
static int GLES_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
|
||||
{
|
||||
SDL_GL_GetDrawableSize(renderer->window, w, h);
|
||||
return 0;
|
||||
@@ -274,10 +268,9 @@ static GLenum GetBlendEquation(SDL_BlendOperation operation)
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
GLES_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
|
||||
static SDL_bool GLES_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode)
|
||||
{
|
||||
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata;
|
||||
SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode);
|
||||
SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode);
|
||||
SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode);
|
||||
@@ -305,10 +298,9 @@ GLES_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static int GLES_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_RenderData *renderdata = (GLES_RenderData *)renderer->driverdata;
|
||||
GLES_TextureData *data;
|
||||
GLint internalFormat;
|
||||
GLenum format, type;
|
||||
@@ -328,7 +320,7 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
return SDL_SetError("Texture format not supported");
|
||||
}
|
||||
|
||||
data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data));
|
||||
data = (GLES_TextureData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
@@ -342,7 +334,6 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
|
||||
if (!renderdata->GL_OES_framebuffer_object_supported) {
|
||||
SDL_free(data);
|
||||
@@ -353,7 +344,6 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
data->fbo = NULL;
|
||||
}
|
||||
|
||||
|
||||
renderdata->glGetError();
|
||||
renderdata->glEnable(GL_TEXTURE_2D);
|
||||
renderdata->glGenTextures(1, &data->texture);
|
||||
@@ -370,8 +360,8 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
/* no NPOV textures allowed in OpenGL ES (yet) */
|
||||
texture_w = SDL_powerof2(texture->w);
|
||||
texture_h = SDL_powerof2(texture->h);
|
||||
data->texw = (GLfloat) texture->w / texture_w;
|
||||
data->texh = (GLfloat) texture->h / texture_h;
|
||||
data->texw = (GLfloat)texture->w / texture_w;
|
||||
data->texh = (GLfloat)texture->h / texture_h;
|
||||
|
||||
data->format = format;
|
||||
data->formattype = type;
|
||||
@@ -401,12 +391,11 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||
static int GLES_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch)
|
||||
{
|
||||
GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
|
||||
GLES_RenderData *renderdata = (GLES_RenderData *)renderer->driverdata;
|
||||
GLES_TextureData *data = (GLES_TextureData *)texture->driverdata;
|
||||
Uint8 *blob = NULL;
|
||||
Uint8 *src;
|
||||
int srcPitch;
|
||||
@@ -442,14 +431,14 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
renderdata->glBindTexture(data->type, data->texture);
|
||||
renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
renderdata->glTexSubImage2D(data->type,
|
||||
0,
|
||||
rect->x,
|
||||
rect->y,
|
||||
rect->w,
|
||||
rect->h,
|
||||
data->format,
|
||||
data->formattype,
|
||||
src);
|
||||
0,
|
||||
rect->x,
|
||||
rect->y,
|
||||
rect->w,
|
||||
rect->h,
|
||||
data->format,
|
||||
data->formattype,
|
||||
src);
|
||||
renderdata->glDisable(data->type);
|
||||
SDL_free(blob);
|
||||
|
||||
@@ -462,23 +451,21 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch)
|
||||
static int GLES_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
|
||||
GLES_TextureData *data = (GLES_TextureData *)texture->driverdata;
|
||||
|
||||
*pixels =
|
||||
(void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
(void *)((Uint8 *)data->pixels + rect->y * data->pitch +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
*pitch = data->pitch;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static void GLES_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
|
||||
GLES_TextureData *data = (GLES_TextureData *)texture->driverdata;
|
||||
SDL_Rect rect;
|
||||
|
||||
/* We do whole texture updates, at least for now */
|
||||
@@ -489,11 +476,10 @@ GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
GLES_UpdateTexture(renderer, texture, &rect, data->pixels, data->pitch);
|
||||
}
|
||||
|
||||
static void
|
||||
GLES_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode)
|
||||
static void GLES_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
|
||||
GLES_RenderData *renderdata = (GLES_RenderData *)renderer->driverdata;
|
||||
GLES_TextureData *data = (GLES_TextureData *)texture->driverdata;
|
||||
GLenum glScaleMode = (scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR;
|
||||
|
||||
renderdata->glBindTexture(data->type, data->texture);
|
||||
@@ -501,10 +487,9 @@ GLES_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Sca
|
||||
renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, glScaleMode);
|
||||
}
|
||||
|
||||
static int
|
||||
GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static int GLES_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata;
|
||||
GLES_TextureData *texturedata = NULL;
|
||||
GLenum status;
|
||||
|
||||
@@ -519,7 +504,7 @@ GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
return 0;
|
||||
}
|
||||
|
||||
texturedata = (GLES_TextureData *) texture->driverdata;
|
||||
texturedata = (GLES_TextureData *)texture->driverdata;
|
||||
data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, texturedata->fbo->FBO);
|
||||
/* TODO: check if texture pixel format allows this operation */
|
||||
data->glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, texturedata->type, texturedata->texture, 0);
|
||||
@@ -531,17 +516,14 @@ GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
GLES_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd)
|
||||
static int GLES_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; /* nothing to do in this backend. */
|
||||
}
|
||||
|
||||
static int
|
||||
GLES_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
|
||||
static int GLES_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (GLfloat), 0, &cmd->data.draw.first);
|
||||
GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(GLfloat), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (verts == NULL) {
|
||||
@@ -557,13 +539,12 @@ GLES_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
GLES_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
|
||||
static int GLES_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
int i;
|
||||
GLfloat prevx, prevy;
|
||||
const size_t vertlen = (sizeof (GLfloat) * 2) * count;
|
||||
GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first);
|
||||
const size_t vertlen = (sizeof(GLfloat) * 2) * count;
|
||||
GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first);
|
||||
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
@@ -583,7 +564,7 @@ GLES_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F
|
||||
for (i = 1; i < count; i++) {
|
||||
const GLfloat xstart = prevx;
|
||||
const GLfloat ystart = prevy;
|
||||
const GLfloat xend = points[i].x + 0.5f; /* 0.5f to hit pixel center. */
|
||||
const GLfloat xend = points[i].x + 0.5f; /* 0.5f to hit pixel center. */
|
||||
const GLfloat yend = points[i].y + 0.5f;
|
||||
/* bump a little in the direction we are moving in. */
|
||||
const GLfloat deltax = xend - xstart;
|
||||
@@ -598,11 +579,10 @@ GLES_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
static int GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
{
|
||||
GLES_TextureData *texturedata = NULL;
|
||||
int i;
|
||||
@@ -610,13 +590,13 @@ GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *
|
||||
GLfloat *verts;
|
||||
int sz = 2 + 4 + (texture ? 2 : 0);
|
||||
|
||||
verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * sz * sizeof (GLfloat), 0, &cmd->data.draw.first);
|
||||
verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * sz * sizeof(GLfloat), 0, &cmd->data.draw.first);
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (texture) {
|
||||
texturedata = (GLES_TextureData *) texture->driverdata;
|
||||
texturedata = (GLES_TextureData *)texture->driverdata;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -636,8 +616,8 @@ GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *
|
||||
j = i;
|
||||
}
|
||||
|
||||
xy_ = (float *)((char*)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char*)color + j * color_stride);
|
||||
xy_ = (float *)((char *)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char *)color + j * color_stride);
|
||||
|
||||
*(verts++) = xy_[0] * scale_x;
|
||||
*(verts++) = xy_[1] * scale_y;
|
||||
@@ -648,7 +628,7 @@ GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *
|
||||
*(verts++) = col_.a * inv255f;
|
||||
|
||||
if (texture) {
|
||||
float *uv_ = (float *)((char*)uv + j * uv_stride);
|
||||
float *uv_ = (float *)((char *)uv + j * uv_stride);
|
||||
*(verts++) = uv_[0] * texturedata->texw;
|
||||
*(verts++) = uv_[1] * texturedata->texh;
|
||||
}
|
||||
@@ -656,8 +636,7 @@ GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
SetDrawState(GLES_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
static void SetDrawState(GLES_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
{
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
@@ -667,10 +646,10 @@ SetDrawState(GLES_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
const Uint32 color = (((Uint32)a << 24) | (r << 16) | (g << 8) | b);
|
||||
|
||||
if (color != data->drawstate.color) {
|
||||
const GLfloat fr = ((GLfloat) r) * inv255f;
|
||||
const GLfloat fg = ((GLfloat) g) * inv255f;
|
||||
const GLfloat fb = ((GLfloat) b) * inv255f;
|
||||
const GLfloat fa = ((GLfloat) a) * inv255f;
|
||||
const GLfloat fr = ((GLfloat)r) * inv255f;
|
||||
const GLfloat fg = ((GLfloat)g) * inv255f;
|
||||
const GLfloat fb = ((GLfloat)b) * inv255f;
|
||||
const GLfloat fa = ((GLfloat)a) * inv255f;
|
||||
data->glColor4f(fr, fg, fb, fa);
|
||||
data->drawstate.color = color;
|
||||
}
|
||||
@@ -684,9 +663,9 @@ SetDrawState(GLES_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
istarget ? viewport->y : (data->drawstate.drawableh - viewport->y - viewport->h),
|
||||
viewport->w, viewport->h);
|
||||
if (viewport->w && viewport->h) {
|
||||
data->glOrthof((GLfloat) 0, (GLfloat) viewport->w,
|
||||
(GLfloat) (istarget ? 0 : viewport->h),
|
||||
(GLfloat) (istarget ? viewport->h : 0),
|
||||
data->glOrthof((GLfloat)0, (GLfloat)viewport->w,
|
||||
(GLfloat)(istarget ? 0 : viewport->h),
|
||||
(GLfloat)(istarget ? viewport->h : 0),
|
||||
0.0, 1.0);
|
||||
}
|
||||
data->glMatrixMode(GL_MODELVIEW);
|
||||
@@ -749,23 +728,21 @@ SetDrawState(GLES_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SetCopyState(GLES_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
static void SetCopyState(GLES_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
{
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
SetDrawState(data, cmd);
|
||||
|
||||
if (texture != data->drawstate.texture) {
|
||||
GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
|
||||
GLES_TextureData *texturedata = (GLES_TextureData *)texture->driverdata;
|
||||
data->glBindTexture(GL_TEXTURE_2D, texturedata->texture);
|
||||
data->drawstate.texture = texture;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
GLES_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static int GLES_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata;
|
||||
|
||||
if (GLES_ActivateRenderer(renderer) < 0) {
|
||||
return -1;
|
||||
@@ -777,123 +754,129 @@ GLES_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vert
|
||||
int w, h;
|
||||
SDL_GL_GetDrawableSize(renderer->window, &w, &h);
|
||||
if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) {
|
||||
data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc.
|
||||
data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc.
|
||||
data->drawstate.cliprect_dirty = SDL_TRUE;
|
||||
data->drawstate.drawablew = w;
|
||||
data->drawstate.drawableh = h;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
while (cmd) {
|
||||
switch (cmd->command) {
|
||||
case SDL_RENDERCMD_SETDRAWCOLOR: {
|
||||
break; /* not used in this render backend. */
|
||||
case SDL_RENDERCMD_SETDRAWCOLOR:
|
||||
{
|
||||
break; /* not used in this render backend. */
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETVIEWPORT:
|
||||
{
|
||||
SDL_Rect *viewport = &data->drawstate.viewport;
|
||||
if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) {
|
||||
SDL_copyp(viewport, &cmd->data.viewport.rect);
|
||||
data->drawstate.viewport_dirty = SDL_TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETCLIPRECT:
|
||||
{
|
||||
const SDL_Rect *rect = &cmd->data.cliprect.rect;
|
||||
if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) {
|
||||
data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled;
|
||||
data->drawstate.cliprect_enabled_dirty = SDL_TRUE;
|
||||
}
|
||||
if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) {
|
||||
SDL_copyp(&data->drawstate.cliprect, rect);
|
||||
data->drawstate.cliprect_dirty = SDL_TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_CLEAR:
|
||||
{
|
||||
const Uint8 r = cmd->data.color.r;
|
||||
const Uint8 g = cmd->data.color.g;
|
||||
const Uint8 b = cmd->data.color.b;
|
||||
const Uint8 a = cmd->data.color.a;
|
||||
const Uint32 color = (((Uint32)a << 24) | (r << 16) | (g << 8) | b);
|
||||
if (color != data->drawstate.clear_color) {
|
||||
const GLfloat fr = ((GLfloat)r) * inv255f;
|
||||
const GLfloat fg = ((GLfloat)g) * inv255f;
|
||||
const GLfloat fb = ((GLfloat)b) * inv255f;
|
||||
const GLfloat fa = ((GLfloat)a) * inv255f;
|
||||
data->glClearColor(fr, fg, fb, fa);
|
||||
data->drawstate.clear_color = color;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETVIEWPORT: {
|
||||
SDL_Rect *viewport = &data->drawstate.viewport;
|
||||
if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) {
|
||||
SDL_copyp(viewport, &cmd->data.viewport.rect);
|
||||
data->drawstate.viewport_dirty = SDL_TRUE;
|
||||
}
|
||||
break;
|
||||
if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) {
|
||||
data->glDisable(GL_SCISSOR_TEST);
|
||||
data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETCLIPRECT: {
|
||||
const SDL_Rect *rect = &cmd->data.cliprect.rect;
|
||||
if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) {
|
||||
data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled;
|
||||
data->drawstate.cliprect_enabled_dirty = SDL_TRUE;
|
||||
}
|
||||
if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) {
|
||||
SDL_copyp(&data->drawstate.cliprect, rect);
|
||||
data->drawstate.cliprect_dirty = SDL_TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
data->glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
case SDL_RENDERCMD_CLEAR: {
|
||||
const Uint8 r = cmd->data.color.r;
|
||||
const Uint8 g = cmd->data.color.g;
|
||||
const Uint8 b = cmd->data.color.b;
|
||||
const Uint8 a = cmd->data.color.a;
|
||||
const Uint32 color = (((Uint32)a << 24) | (r << 16) | (g << 8) | b);
|
||||
if (color != data->drawstate.clear_color) {
|
||||
const GLfloat fr = ((GLfloat) r) * inv255f;
|
||||
const GLfloat fg = ((GLfloat) g) * inv255f;
|
||||
const GLfloat fb = ((GLfloat) b) * inv255f;
|
||||
const GLfloat fa = ((GLfloat) a) * inv255f;
|
||||
data->glClearColor(fr, fg, fb, fa);
|
||||
data->drawstate.clear_color = color;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) {
|
||||
data->glDisable(GL_SCISSOR_TEST);
|
||||
data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled;
|
||||
}
|
||||
case SDL_RENDERCMD_DRAW_POINTS:
|
||||
{
|
||||
const size_t count = cmd->data.draw.count;
|
||||
const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
SetDrawState(data, cmd);
|
||||
data->glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
data->glDrawArrays(GL_POINTS, 0, (GLsizei)count);
|
||||
break;
|
||||
}
|
||||
|
||||
data->glClear(GL_COLOR_BUFFER_BIT);
|
||||
case SDL_RENDERCMD_DRAW_LINES:
|
||||
{
|
||||
const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
const size_t count = cmd->data.draw.count;
|
||||
SDL_assert(count >= 2);
|
||||
SetDrawState(data, cmd);
|
||||
data->glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)count);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_DRAW_POINTS: {
|
||||
const size_t count = cmd->data.draw.count;
|
||||
const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first);
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_GEOMETRY:
|
||||
{
|
||||
const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
const size_t count = cmd->data.draw.count;
|
||||
int stride = (2 + 4 + (texture ? 2 : 0)) * sizeof(float);
|
||||
|
||||
if (texture) {
|
||||
SetCopyState(data, cmd);
|
||||
} else {
|
||||
SetDrawState(data, cmd);
|
||||
data->glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
data->glDrawArrays(GL_POINTS, 0, (GLsizei) count);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_DRAW_LINES: {
|
||||
const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first);
|
||||
const size_t count = cmd->data.draw.count;
|
||||
SDL_assert(count >= 2);
|
||||
SetDrawState(data, cmd);
|
||||
data->glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) count);
|
||||
break;
|
||||
data->glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
data->glVertexPointer(2, GL_FLOAT, stride, verts);
|
||||
data->glColorPointer(4, GL_FLOAT, stride, verts + 2);
|
||||
if (texture) {
|
||||
data->glTexCoordPointer(2, GL_FLOAT, stride, verts + 2 + 4);
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
break;
|
||||
data->glDrawArrays(GL_TRIANGLES, 0, (GLsizei)count);
|
||||
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
break;
|
||||
data->glDisableClientState(GL_COLOR_ARRAY);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_GEOMETRY: {
|
||||
const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first);
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
const size_t count = cmd->data.draw.count;
|
||||
int stride = (2 + 4 + (texture ? 2 : 0)) * sizeof (float);
|
||||
|
||||
if (texture) {
|
||||
SetCopyState(data, cmd);
|
||||
} else {
|
||||
SetDrawState(data, cmd);
|
||||
}
|
||||
|
||||
data->glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
data->glVertexPointer(2, GL_FLOAT, stride, verts);
|
||||
data->glColorPointer(4, GL_FLOAT, stride, verts + 2);
|
||||
if (texture) {
|
||||
data->glTexCoordPointer(2, GL_FLOAT, stride, verts + 2 + 4);
|
||||
}
|
||||
|
||||
data->glDrawArrays(GL_TRIANGLES, 0, (GLsizei) count);
|
||||
|
||||
data->glDisableClientState(GL_COLOR_ARRAY);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_NO_OP:
|
||||
break;
|
||||
case SDL_RENDERCMD_NO_OP:
|
||||
break;
|
||||
}
|
||||
|
||||
cmd = cmd->next;
|
||||
@@ -902,11 +885,10 @@ GLES_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vert
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 pixel_format, void * pixels, int pitch)
|
||||
static int GLES_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||
Uint32 pixel_format, void *pixels, int pitch)
|
||||
{
|
||||
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata;
|
||||
Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888;
|
||||
void *temp_pixels;
|
||||
int temp_pitch;
|
||||
@@ -926,15 +908,15 @@ GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
|
||||
data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
|
||||
data->glReadPixels(rect->x, renderer->target ? rect->y : (h-rect->y)-rect->h,
|
||||
data->glReadPixels(rect->x, renderer->target ? rect->y : (h - rect->y) - rect->h,
|
||||
rect->w, rect->h, GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels);
|
||||
|
||||
/* Flip the rows to be top-down if necessary */
|
||||
if (!renderer->target) {
|
||||
SDL_bool isstack;
|
||||
length = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch;
|
||||
dst = (Uint8*)temp_pixels;
|
||||
src = (Uint8 *)temp_pixels + (rect->h - 1) * temp_pitch;
|
||||
dst = (Uint8 *)temp_pixels;
|
||||
tmp = SDL_small_alloc(Uint8, length, &isstack);
|
||||
rows = rect->h / 2;
|
||||
while (rows--) {
|
||||
@@ -955,20 +937,18 @@ GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
return status;
|
||||
}
|
||||
|
||||
static int
|
||||
GLES_RenderPresent(SDL_Renderer * renderer)
|
||||
static int GLES_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
GLES_ActivateRenderer(renderer);
|
||||
|
||||
return SDL_GL_SwapWindowWithResult(renderer->window);
|
||||
}
|
||||
|
||||
static void
|
||||
GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static void GLES_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_RenderData *renderdata = (GLES_RenderData *)renderer->driverdata;
|
||||
|
||||
GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
|
||||
GLES_TextureData *data = (GLES_TextureData *)texture->driverdata;
|
||||
|
||||
GLES_ActivateRenderer(renderer);
|
||||
|
||||
@@ -990,18 +970,17 @@ GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
texture->driverdata = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
GLES_DestroyRenderer(SDL_Renderer * renderer)
|
||||
static void GLES_DestroyRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata;
|
||||
|
||||
if (data) {
|
||||
if (data->context) {
|
||||
while (data->framebuffers) {
|
||||
GLES_FBOList *nextnode = data->framebuffers->next;
|
||||
data->glDeleteFramebuffersOES(1, &data->framebuffers->FBO);
|
||||
SDL_free(data->framebuffers);
|
||||
data->framebuffers = nextnode;
|
||||
GLES_FBOList *nextnode = data->framebuffers->next;
|
||||
data->glDeleteFramebuffersOES(1, &data->framebuffers->FBO);
|
||||
SDL_free(data->framebuffers);
|
||||
data->framebuffers = nextnode;
|
||||
}
|
||||
SDL_GL_DeleteContext(data->context);
|
||||
}
|
||||
@@ -1010,10 +989,10 @@ GLES_DestroyRenderer(SDL_Renderer * renderer)
|
||||
SDL_free(renderer);
|
||||
}
|
||||
|
||||
static int GLES_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh)
|
||||
static int GLES_BindTexture(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh)
|
||||
{
|
||||
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
|
||||
GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata;
|
||||
GLES_TextureData *texturedata = (GLES_TextureData *)texture->driverdata;
|
||||
GLES_ActivateRenderer(renderer);
|
||||
|
||||
data->glEnable(GL_TEXTURE_2D);
|
||||
@@ -1032,10 +1011,10 @@ static int GLES_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, floa
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int GLES_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
|
||||
static int GLES_UnbindTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
|
||||
GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
|
||||
GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata;
|
||||
GLES_TextureData *texturedata = (GLES_TextureData *)texture->driverdata;
|
||||
GLES_ActivateRenderer(renderer);
|
||||
data->glDisable(texturedata->type);
|
||||
|
||||
@@ -1045,8 +1024,7 @@ static int GLES_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
GLES_SetVSync(SDL_Renderer * renderer, const int vsync)
|
||||
static int GLES_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
int retval;
|
||||
if (vsync) {
|
||||
@@ -1065,9 +1043,7 @@ GLES_SetVSync(SDL_Renderer * renderer, const int vsync)
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
static SDL_Renderer *
|
||||
GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
static SDL_Renderer *GLES_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
GLES_RenderData *data;
|
||||
@@ -1094,13 +1070,13 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
}
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
||||
data = (GLES_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
data = (GLES_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
GLES_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
@@ -1117,7 +1093,7 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
renderer->SetTextureScaleMode = GLES_SetTextureScaleMode;
|
||||
renderer->SetRenderTarget = GLES_SetRenderTarget;
|
||||
renderer->QueueSetViewport = GLES_QueueSetViewport;
|
||||
renderer->QueueSetDrawColor = GLES_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|
||||
renderer->QueueSetDrawColor = GLES_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|
||||
renderer->QueueDrawPoints = GLES_QueueDrawPoints;
|
||||
renderer->QueueDrawLines = GLES_QueueDrawLines;
|
||||
renderer->QueueGeometry = GLES_QueueGeometry;
|
||||
@@ -1217,14 +1193,12 @@ error:
|
||||
|
||||
SDL_RenderDriver GLES_RenderDriver = {
|
||||
GLES_CreateRenderer,
|
||||
{
|
||||
"opengles",
|
||||
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
|
||||
1,
|
||||
{SDL_PIXELFORMAT_ABGR8888},
|
||||
0,
|
||||
0
|
||||
}
|
||||
{ "opengles",
|
||||
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
|
||||
1,
|
||||
{ SDL_PIXELFORMAT_ABGR8888 },
|
||||
0,
|
||||
0 }
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL_ES && !SDL_RENDER_DISABLED */
|
||||
|
||||
@@ -50,7 +50,7 @@ SDL_PROC(void, glGetShaderiv, (GLuint, GLenum, GLint *))
|
||||
SDL_PROC(GLint, glGetUniformLocation, (GLuint, const char *))
|
||||
SDL_PROC(void, glLinkProgram, (GLuint))
|
||||
SDL_PROC(void, glPixelStorei, (GLenum, GLint))
|
||||
SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
|
||||
SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *))
|
||||
SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
|
||||
SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei))
|
||||
#if __NACL__
|
||||
@@ -72,7 +72,7 @@ SDL_PROC(void, glFramebufferTexture2D, (GLenum, GLenum, GLenum, GLuint, GLint))
|
||||
SDL_PROC(GLenum, glCheckFramebufferStatus, (GLenum))
|
||||
SDL_PROC(void, glDeleteFramebuffers, (GLsizei, const GLuint *))
|
||||
SDL_PROC(GLint, glGetAttribLocation, (GLuint, const GLchar *))
|
||||
SDL_PROC(void, glGetProgramInfoLog, (GLuint, GLsizei, GLsizei*, GLchar*))
|
||||
SDL_PROC(void, glGetProgramInfoLog, (GLuint, GLsizei, GLsizei *, GLchar *))
|
||||
SDL_PROC(void, glGenBuffers, (GLsizei, GLuint *))
|
||||
SDL_PROC(void, glDeleteBuffers, (GLsizei, const GLuint *))
|
||||
SDL_PROC(void, glBindBuffer, (GLenum, GLuint))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,8 @@
|
||||
#include "SDL_shaders_gles2.h"
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
||||
/*************************************************************************************************
|
||||
* Vertex/fragment shader source *
|
||||
*************************************************************************************************/
|
||||
@@ -346,6 +348,7 @@ static const char GLES2_Fragment_TextureExternalOES[] = \
|
||||
"}\n" \
|
||||
;
|
||||
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
/*************************************************************************************************
|
||||
* Shader selector *
|
||||
@@ -444,4 +447,3 @@ const char *GLES2_GetShader(GLES2_ShaderType type)
|
||||
#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
|
||||
@@ -51,43 +51,40 @@ typedef struct
|
||||
uint8_t vsync; /* 0 (Disabled), 1 (Enabled), 2 (Dynamic) */
|
||||
} PS2_RenderData;
|
||||
|
||||
|
||||
static int vsync_sema_id = 0;
|
||||
|
||||
/* PRIVATE METHODS */
|
||||
static int vsync_handler()
|
||||
{
|
||||
iSignalSema(vsync_sema_id);
|
||||
iSignalSema(vsync_sema_id);
|
||||
|
||||
ExitHandler();
|
||||
return 0;
|
||||
ExitHandler();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy of gsKit_sync_flip, but without the 'flip' */
|
||||
static void gsKit_sync(GSGLOBAL *gsGlobal)
|
||||
{
|
||||
if (!gsGlobal->FirstFrame) {
|
||||
WaitSema(vsync_sema_id);
|
||||
}
|
||||
while (PollSema(vsync_sema_id) >= 0)
|
||||
;
|
||||
if (!gsGlobal->FirstFrame) {
|
||||
WaitSema(vsync_sema_id);
|
||||
}
|
||||
while (PollSema(vsync_sema_id) >= 0)
|
||||
;
|
||||
}
|
||||
|
||||
/* Copy of gsKit_sync_flip, but without the 'sync' */
|
||||
static void gsKit_flip(GSGLOBAL *gsGlobal)
|
||||
{
|
||||
if (!gsGlobal->FirstFrame) {
|
||||
if (gsGlobal->DoubleBuffering == GS_SETTING_ON) {
|
||||
GS_SET_DISPFB2( gsGlobal->ScreenBuffer[
|
||||
gsGlobal->ActiveBuffer & 1] / 8192,
|
||||
gsGlobal->Width / 64, gsGlobal->PSM, 0, 0 );
|
||||
if (!gsGlobal->FirstFrame) {
|
||||
if (gsGlobal->DoubleBuffering == GS_SETTING_ON) {
|
||||
GS_SET_DISPFB2(gsGlobal->ScreenBuffer[gsGlobal->ActiveBuffer & 1] / 8192,
|
||||
gsGlobal->Width / 64, gsGlobal->PSM, 0, 0);
|
||||
|
||||
gsGlobal->ActiveBuffer ^= 1;
|
||||
}
|
||||
gsGlobal->ActiveBuffer ^= 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gsKit_setactive(gsGlobal);
|
||||
gsKit_setactive(gsGlobal);
|
||||
}
|
||||
|
||||
static int PixelFormatToPS2PSM(Uint32 format)
|
||||
@@ -100,16 +97,13 @@ static int PixelFormatToPS2PSM(Uint32 format)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
PS2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
static void PS2_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static int PS2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
GSTEXTURE* ps2_tex = (GSTEXTURE*) SDL_calloc(1, sizeof(GSTEXTURE));
|
||||
GSTEXTURE *ps2_tex = (GSTEXTURE *)SDL_calloc(1, sizeof(GSTEXTURE));
|
||||
|
||||
if (ps2_tex == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
@@ -130,41 +124,38 @@ PS2_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch)
|
||||
static int PS2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
GSTEXTURE *ps2_texture = (GSTEXTURE *) texture->driverdata;
|
||||
GSTEXTURE *ps2_texture = (GSTEXTURE *)texture->driverdata;
|
||||
|
||||
*pixels =
|
||||
(void *) ((Uint8 *) ps2_texture->Mem + rect->y * ps2_texture->Width * SDL_BYTESPERPIXEL(texture->format) +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
(void *)((Uint8 *)ps2_texture->Mem + rect->y * ps2_texture->Width * SDL_BYTESPERPIXEL(texture->format) +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
*pitch = ps2_texture->Width * SDL_BYTESPERPIXEL(texture->format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
PS2_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static void PS2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
GSTEXTURE *ps2_texture = (GSTEXTURE *) texture->driverdata;
|
||||
PS2_RenderData *data = (PS2_RenderData *) renderer->driverdata;
|
||||
GSTEXTURE *ps2_texture = (GSTEXTURE *)texture->driverdata;
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
|
||||
gsKit_TexManager_invalidate(data->gsGlobal, ps2_texture);
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||
static int PS2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch)
|
||||
{
|
||||
const Uint8 *src;
|
||||
Uint8 *dst;
|
||||
int row, length,dpitch;
|
||||
int row, length, dpitch;
|
||||
src = pixels;
|
||||
|
||||
PS2_LockTexture(renderer, texture, rect, (void **)&dst, &dpitch);
|
||||
length = rect->w * SDL_BYTESPERPIXEL(texture->format);
|
||||
if (length == pitch && length == dpitch) {
|
||||
SDL_memcpy(dst, src, length*rect->h);
|
||||
SDL_memcpy(dst, src, length * rect->h);
|
||||
} else {
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
@@ -178,10 +169,9 @@ PS2_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
PS2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode)
|
||||
static void PS2_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
GSTEXTURE *ps2_texture = (GSTEXTURE *) texture->driverdata;
|
||||
GSTEXTURE *ps2_texture = (GSTEXTURE *)texture->driverdata;
|
||||
/*
|
||||
set texture filtering according to scaleMode
|
||||
suported hint values are nearest (0, default) or linear (1)
|
||||
@@ -189,28 +179,25 @@ PS2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Scal
|
||||
or GS_FILTER_LINEAR (good for scaling)
|
||||
*/
|
||||
uint32_t gsKitScaleMode = (scaleMode == SDL_ScaleModeNearest
|
||||
? GS_FILTER_NEAREST
|
||||
: GS_FILTER_LINEAR);
|
||||
? GS_FILTER_NEAREST
|
||||
: GS_FILTER_LINEAR);
|
||||
ps2_texture->Filter = gsKitScaleMode;
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static int PS2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd)
|
||||
static int PS2_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; /* nothing to do in this backend. */
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
|
||||
static int PS2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *) renderer->driverdata;
|
||||
GSPRIMPOINT *vertices = (GSPRIMPOINT *) SDL_AllocateRenderVertices(renderer, count * sizeof (GSPRIMPOINT), 4, &cmd->data.draw.first);
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
GSPRIMPOINT *vertices = (GSPRIMPOINT *)SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMPOINT), 4, &cmd->data.draw.first);
|
||||
uint8_t colorR, colorG, colorB, colorA;
|
||||
gs_rgbaq rgbaq;
|
||||
int i;
|
||||
@@ -234,11 +221,10 @@ PS2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
{
|
||||
int i;
|
||||
int count = indices ? num_indices : num_vertices;
|
||||
@@ -248,8 +234,8 @@ PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
|
||||
size_indices = indices ? size_indices : 0;
|
||||
|
||||
if (texture) {
|
||||
GSPRIMSTQPOINT *vertices = (GSPRIMSTQPOINT *) SDL_AllocateRenderVertices(renderer, count * sizeof (GSPRIMSTQPOINT), 4, &cmd->data.draw.first);
|
||||
|
||||
GSPRIMSTQPOINT *vertices = (GSPRIMSTQPOINT *)SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMSTQPOINT), 4, &cmd->data.draw.first);
|
||||
|
||||
if (vertices == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@@ -269,9 +255,9 @@ PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
|
||||
j = i;
|
||||
}
|
||||
|
||||
xy_ = (float *)((char*)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char*)color + j * color_stride);
|
||||
uv_ = (float *)((char*)uv + j * uv_stride);
|
||||
xy_ = (float *)((char *)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char *)color + j * color_stride);
|
||||
uv_ = (float *)((char *)uv + j * uv_stride);
|
||||
|
||||
vertices->xyz2 = vertex_to_XYZ2(data->gsGlobal, xy_[0] * scale_x, xy_[1] * scale_y, 0);
|
||||
vertices->stq = vertex_to_STQ(uv_[0], uv_[1]);
|
||||
@@ -279,9 +265,9 @@ PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
|
||||
|
||||
vertices++;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
GSPRIMPOINT *vertices = (GSPRIMPOINT *) SDL_AllocateRenderVertices(renderer, count * sizeof (GSPRIMPOINT), 4, &cmd->data.draw.first);
|
||||
GSPRIMPOINT *vertices = (GSPRIMPOINT *)SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMPOINT), 4, &cmd->data.draw.first);
|
||||
|
||||
if (vertices == NULL) {
|
||||
return -1;
|
||||
@@ -301,8 +287,8 @@ PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
|
||||
j = i;
|
||||
}
|
||||
|
||||
xy_ = (float *)((char*)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char*)color + j * color_stride);
|
||||
xy_ = (float *)((char *)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char *)color + j * color_stride);
|
||||
|
||||
vertices->xyz2 = vertex_to_XYZ2(data->gsGlobal, xy_[0] * scale_x, xy_[1] * scale_y, 0);
|
||||
vertices->rgbaq = color_to_RGBAQ(col_.r >> 1, col_.g >> 1, col_.b >> 1, col_.a >> 1, 0.0f);
|
||||
@@ -314,8 +300,7 @@ PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_RenderSetViewPort(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static int PS2_RenderSetViewPort(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
const SDL_Rect *viewport = &cmd->data.viewport.rect;
|
||||
@@ -326,8 +311,7 @@ PS2_RenderSetViewPort(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static int PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
|
||||
@@ -342,14 +326,12 @@ PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
PS2_RenderSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static int PS2_RenderSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
int colorR, colorG, colorB, colorA;
|
||||
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
|
||||
|
||||
colorR = (cmd->data.color.r) >> 1;
|
||||
colorG = (cmd->data.color.g) >> 1;
|
||||
colorB = (cmd->data.color.b) >> 1;
|
||||
@@ -358,60 +340,60 @@ PS2_RenderSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static int PS2_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
int colorR, colorG, colorB, colorA;
|
||||
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
|
||||
|
||||
colorR = (cmd->data.color.r) >> 1;
|
||||
colorG = (cmd->data.color.g) >> 1;
|
||||
colorB = (cmd->data.color.b) >> 1;
|
||||
colorA = (cmd->data.color.a) >> 1;
|
||||
gsKit_clear(data->gsGlobal, GS_SETREG_RGBAQ(colorR, colorG, colorB, colorA, 0x00));
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
PS2_SetBlendMode(PS2_RenderData *data, int blendMode)
|
||||
static void PS2_SetBlendMode(PS2_RenderData *data, int blendMode)
|
||||
{
|
||||
#define A_COLOR_SOURCE 0
|
||||
#define A_COLOR_DEST 1
|
||||
#define A_COLOR_NULL 2
|
||||
#define A_ALPHA_SOURCE 0
|
||||
#define A_ALPHA_DEST 1
|
||||
#define A_ALPHA_FIX 2
|
||||
#define A_COLOR_SOURCE 0
|
||||
#define A_COLOR_DEST 1
|
||||
#define A_COLOR_NULL 2
|
||||
#define A_ALPHA_SOURCE 0
|
||||
#define A_ALPHA_DEST 1
|
||||
#define A_ALPHA_FIX 2
|
||||
|
||||
switch (blendMode)
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_NONE:
|
||||
{
|
||||
case SDL_BLENDMODE_NONE: {
|
||||
data->gsGlobal->PrimAlphaEnable = GS_SETTING_OFF;
|
||||
break;
|
||||
}
|
||||
case SDL_BLENDMODE_BLEND:{
|
||||
gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_DEST, A_ALPHA_SOURCE, A_COLOR_DEST, 0), 0);
|
||||
data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||
break;
|
||||
}
|
||||
case SDL_BLENDMODE_ADD: {
|
||||
gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_NULL, A_ALPHA_FIX, A_COLOR_DEST, 0x80), 0);
|
||||
data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||
break;
|
||||
}
|
||||
case SDL_BLENDMODE_MUL:
|
||||
case SDL_BLENDMODE_MOD: {
|
||||
/* We don't fully support MOD and MUL, however this is the best we can do */
|
||||
gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_DEST, A_COLOR_NULL, A_ALPHA_SOURCE, A_COLOR_SOURCE, 0x80), 0);
|
||||
data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||
break;
|
||||
}
|
||||
data->gsGlobal->PrimAlphaEnable = GS_SETTING_OFF;
|
||||
break;
|
||||
}
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
{
|
||||
gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_DEST, A_ALPHA_SOURCE, A_COLOR_DEST, 0), 0);
|
||||
data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||
break;
|
||||
}
|
||||
case SDL_BLENDMODE_ADD:
|
||||
{
|
||||
gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_NULL, A_ALPHA_FIX, A_COLOR_DEST, 0x80), 0);
|
||||
data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||
break;
|
||||
}
|
||||
case SDL_BLENDMODE_MUL:
|
||||
case SDL_BLENDMODE_MOD:
|
||||
{
|
||||
/* We don't fully support MOD and MUL, however this is the best we can do */
|
||||
gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_DEST, A_COLOR_NULL, A_ALPHA_SOURCE, A_COLOR_SOURCE, 0x80), 0);
|
||||
data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd)
|
||||
static int PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
const size_t count = cmd->data.draw.count;
|
||||
@@ -419,26 +401,24 @@ PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cm
|
||||
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
||||
|
||||
if (cmd->data.draw.texture) {
|
||||
const GSPRIMSTQPOINT *verts = (GSPRIMSTQPOINT *) (vertices + cmd->data.draw.first);
|
||||
GSTEXTURE *ps2_tex = (GSTEXTURE *) cmd->data.draw.texture->driverdata;
|
||||
const GSPRIMSTQPOINT *verts = (GSPRIMSTQPOINT *)(vertices + cmd->data.draw.first);
|
||||
GSTEXTURE *ps2_tex = (GSTEXTURE *)cmd->data.draw.texture->driverdata;
|
||||
|
||||
gsKit_TexManager_bind(data->gsGlobal, ps2_tex);
|
||||
gsKit_prim_list_triangle_goraud_texture_stq_3d(data->gsGlobal, ps2_tex, count, verts);
|
||||
} else {
|
||||
const GSPRIMPOINT *verts = (GSPRIMPOINT *) (vertices + cmd->data.draw.first);
|
||||
const GSPRIMPOINT *verts = (GSPRIMPOINT *)(vertices + cmd->data.draw.first);
|
||||
gsKit_prim_list_triangle_gouraud_3d(data->gsGlobal, count, verts);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
PS2_RenderLines(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand * cmd)
|
||||
int PS2_RenderLines(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
const size_t count = cmd->data.draw.count;
|
||||
const GSPRIMPOINT *verts = (GSPRIMPOINT *) (vertices + cmd->data.draw.first);
|
||||
const GSPRIMPOINT *verts = (GSPRIMPOINT *)(vertices + cmd->data.draw.first);
|
||||
|
||||
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
||||
gsKit_prim_list_line_goraud_3d(data->gsGlobal, count, verts);
|
||||
@@ -447,12 +427,11 @@ PS2_RenderLines(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand * cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand * cmd)
|
||||
int PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
const size_t count = cmd->data.draw.count;
|
||||
const GSPRIMPOINT *verts = (GSPRIMPOINT *) (vertices + cmd->data.draw.first);
|
||||
const GSPRIMPOINT *verts = (GSPRIMPOINT *)(vertices + cmd->data.draw.first);
|
||||
|
||||
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
||||
gsKit_prim_list_points(data->gsGlobal, count, verts);
|
||||
@@ -461,91 +440,94 @@ PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand * cmd
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static int PS2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
while (cmd) {
|
||||
switch (cmd->command) {
|
||||
case SDL_RENDERCMD_SETVIEWPORT: {
|
||||
PS2_RenderSetViewPort(renderer, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_SETCLIPRECT: {
|
||||
PS2_RenderSetClipRect(renderer, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_SETDRAWCOLOR: {
|
||||
PS2_RenderSetDrawColor(renderer, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_CLEAR: {
|
||||
PS2_RenderClear(renderer, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_DRAW_POINTS: {
|
||||
PS2_RenderPoints(renderer, vertices, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_DRAW_LINES: {
|
||||
PS2_RenderLines(renderer, vertices, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
break;
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
break;
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
break;
|
||||
case SDL_RENDERCMD_GEOMETRY: {
|
||||
PS2_RenderGeometry(renderer, vertices, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_NO_OP:
|
||||
break;
|
||||
case SDL_RENDERCMD_SETVIEWPORT:
|
||||
{
|
||||
PS2_RenderSetViewPort(renderer, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_SETCLIPRECT:
|
||||
{
|
||||
PS2_RenderSetClipRect(renderer, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_SETDRAWCOLOR:
|
||||
{
|
||||
PS2_RenderSetDrawColor(renderer, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_CLEAR:
|
||||
{
|
||||
PS2_RenderClear(renderer, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_DRAW_POINTS:
|
||||
{
|
||||
PS2_RenderPoints(renderer, vertices, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_DRAW_LINES:
|
||||
{
|
||||
PS2_RenderLines(renderer, vertices, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
break;
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
break;
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
break;
|
||||
case SDL_RENDERCMD_GEOMETRY:
|
||||
{
|
||||
PS2_RenderGeometry(renderer, vertices, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_NO_OP:
|
||||
break;
|
||||
}
|
||||
cmd = cmd->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch)
|
||||
static int PS2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||
Uint32 format, void *pixels, int pitch)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_RenderPresent(SDL_Renderer * renderer)
|
||||
static int PS2_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *) renderer->driverdata;
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
|
||||
if (data->gsGlobal->DoubleBuffering == GS_SETTING_OFF) {
|
||||
if (data->vsync == 2) { // Dynamic
|
||||
if (data->vsync == 2) { // Dynamic
|
||||
gsKit_sync(data->gsGlobal);
|
||||
} else if (data->vsync == 1) {
|
||||
gsKit_vsync_wait();
|
||||
}
|
||||
gsKit_queue_exec(data->gsGlobal);
|
||||
gsKit_queue_exec(data->gsGlobal);
|
||||
} else {
|
||||
gsKit_queue_exec(data->gsGlobal);
|
||||
gsKit_finish();
|
||||
if (data->vsync == 2) { // Dynamic
|
||||
gsKit_queue_exec(data->gsGlobal);
|
||||
gsKit_finish();
|
||||
if (data->vsync == 2) { // Dynamic
|
||||
gsKit_sync(data->gsGlobal);
|
||||
} else if (data->vsync == 1) {
|
||||
gsKit_vsync_wait();
|
||||
}
|
||||
gsKit_flip(data->gsGlobal);
|
||||
}
|
||||
gsKit_TexManager_nextFrame(data->gsGlobal);
|
||||
gsKit_flip(data->gsGlobal);
|
||||
}
|
||||
gsKit_TexManager_nextFrame(data->gsGlobal);
|
||||
gsKit_clear(data->gsGlobal, GS_BLACK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
PS2_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static void PS2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
GSTEXTURE *ps2_texture = (GSTEXTURE *) texture->driverdata;
|
||||
GSTEXTURE *ps2_texture = (GSTEXTURE *)texture->driverdata;
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
|
||||
if (data == NULL) {
|
||||
@@ -558,14 +540,13 @@ PS2_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
|
||||
// Free from vram
|
||||
gsKit_TexManager_free(data->gsGlobal, ps2_texture);
|
||||
|
||||
|
||||
SDL_free(ps2_texture->Mem);
|
||||
SDL_free(ps2_texture);
|
||||
texture->driverdata = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
PS2_DestroyRenderer(SDL_Renderer * renderer)
|
||||
static void PS2_DestroyRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
|
||||
@@ -585,8 +566,7 @@ PS2_DestroyRenderer(SDL_Renderer * renderer)
|
||||
SDL_free(renderer);
|
||||
}
|
||||
|
||||
static int
|
||||
PS2_SetVSync(SDL_Renderer * renderer, const int vsync)
|
||||
static int PS2_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
SDL_bool dynamicVsync = SDL_GetHintBoolean(SDL_HINT_PS2_DYNAMIC_VSYNC, SDL_FALSE);
|
||||
@@ -594,8 +574,7 @@ PS2_SetVSync(SDL_Renderer * renderer, const int vsync)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static SDL_Renderer *
|
||||
PS2_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
static SDL_Renderer *PS2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
PS2_RenderData *data;
|
||||
@@ -603,13 +582,13 @@ PS2_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
ee_sema_t sema;
|
||||
SDL_bool dynamicVsync;
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (PS2_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
data = (PS2_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
PS2_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
@@ -621,35 +600,35 @@ PS2_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
sema.max_count = 1;
|
||||
sema.option = 0;
|
||||
vsync_sema_id = CreateSema(&sema);
|
||||
|
||||
|
||||
gsGlobal = gsKit_init_global_custom(RENDER_QUEUE_OS_POOLSIZE, RENDER_QUEUE_PER_POOLSIZE);
|
||||
|
||||
gsGlobal->Mode = GS_MODE_NTSC;
|
||||
gsGlobal->Mode = GS_MODE_NTSC;
|
||||
gsGlobal->Height = 448;
|
||||
|
||||
gsGlobal->PSM = GS_PSM_CT24;
|
||||
gsGlobal->PSMZ = GS_PSMZ_16S;
|
||||
gsGlobal->ZBuffering = GS_SETTING_OFF;
|
||||
gsGlobal->DoubleBuffering = GS_SETTING_ON;
|
||||
gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||
gsGlobal->Dithering = GS_SETTING_OFF;
|
||||
gsGlobal->PSM = GS_PSM_CT24;
|
||||
gsGlobal->PSMZ = GS_PSMZ_16S;
|
||||
gsGlobal->ZBuffering = GS_SETTING_OFF;
|
||||
gsGlobal->DoubleBuffering = GS_SETTING_ON;
|
||||
gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||
gsGlobal->Dithering = GS_SETTING_OFF;
|
||||
|
||||
gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0, 1, 0, 1, 0), 0);
|
||||
gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0, 1, 0, 1, 0), 0);
|
||||
|
||||
dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
|
||||
dmaKit_chan_init(DMA_CHANNEL_GIF);
|
||||
dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
|
||||
dmaKit_chan_init(DMA_CHANNEL_GIF);
|
||||
|
||||
gsKit_set_clamp(gsGlobal, GS_CMODE_REPEAT);
|
||||
gsKit_set_clamp(gsGlobal, GS_CMODE_REPEAT);
|
||||
|
||||
gsKit_vram_clear(gsGlobal);
|
||||
gsKit_vram_clear(gsGlobal);
|
||||
|
||||
gsKit_init_screen(gsGlobal);
|
||||
gsKit_init_screen(gsGlobal);
|
||||
|
||||
gsKit_TexManager_init(gsGlobal);
|
||||
gsKit_TexManager_init(gsGlobal);
|
||||
|
||||
data->vsync_callback_id = gsKit_add_vsync_handler(vsync_handler);
|
||||
data->vsync_callback_id = gsKit_add_vsync_handler(vsync_handler);
|
||||
|
||||
gsKit_mode_switch(gsGlobal, GS_ONESHOT);
|
||||
gsKit_mode_switch(gsGlobal, GS_ONESHOT);
|
||||
|
||||
gsKit_clear(gsGlobal, GS_BLACK);
|
||||
|
||||
@@ -688,7 +667,7 @@ SDL_RenderDriver PS2_RenderDriver = {
|
||||
.name = "PS2 gsKit",
|
||||
.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE,
|
||||
.num_texture_formats = 2,
|
||||
.texture_formats = {
|
||||
.texture_formats = {
|
||||
[0] = SDL_PIXELFORMAT_ABGR1555,
|
||||
[1] = SDL_PIXELFORMAT_ABGR8888,
|
||||
},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,10 +25,8 @@
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendfillrect.h"
|
||||
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendFillRect_RGB555(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -52,9 +50,8 @@ SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendFillRect_RGB565(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -78,9 +75,8 @@ SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendFillRect_RGB888(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -104,9 +100,8 @@ SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendFillRect_ARGB8888(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -130,9 +125,8 @@ SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -181,9 +175,8 @@ SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -213,9 +206,8 @@ SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_Rect clipped;
|
||||
|
||||
@@ -280,13 +272,12 @@ SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_Rect rect;
|
||||
int i;
|
||||
int (*func)(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
int (*func)(SDL_Surface * dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
int status = 0;
|
||||
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
#endif /* SDL_blendfillrect_h_ */
|
||||
|
||||
|
||||
@@ -26,11 +26,9 @@
|
||||
#include "SDL_blendline.h"
|
||||
#include "SDL_blendpoint.h"
|
||||
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
@@ -133,10 +131,9 @@ SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_BlendLine_RGB555(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
@@ -238,10 +235,9 @@ SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_BlendLine_RGB565(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
@@ -343,10 +339,9 @@ SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_BlendLine_RGB4(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
@@ -449,10 +444,9 @@ SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_BlendLine_RGBA4(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
@@ -555,10 +549,9 @@ SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_BlendLine_RGB888(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
@@ -660,10 +653,9 @@ SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_BlendLine_ARGB8888(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
@@ -765,14 +757,13 @@ SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*BlendLineFunc) (SDL_Surface * dst,
|
||||
int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
|
||||
SDL_bool draw_end);
|
||||
typedef void (*BlendLineFunc)(SDL_Surface *dst,
|
||||
int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
|
||||
SDL_bool draw_end);
|
||||
|
||||
static BlendLineFunc
|
||||
SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt)
|
||||
static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormat *fmt)
|
||||
{
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 2:
|
||||
@@ -802,9 +793,8 @@ SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
BlendLineFunc func;
|
||||
|
||||
@@ -827,9 +817,8 @@ SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
int i;
|
||||
int x1, y1;
|
||||
@@ -847,8 +836,8 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
x1 = points[i-1].x;
|
||||
y1 = points[i-1].y;
|
||||
x1 = points[i - 1].x;
|
||||
y1 = points[i - 1].y;
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
@@ -863,8 +852,8 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
|
||||
func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end);
|
||||
}
|
||||
if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
|
||||
SDL_BlendPoint(dst, points[count-1].x, points[count-1].y,
|
||||
if (points[0].x != points[count - 1].x || points[0].y != points[count - 1].y) {
|
||||
SDL_BlendPoint(dst, points[count - 1].x, points[count - 1].y,
|
||||
blendMode, r, g, b, a);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
#endif /* SDL_blendline_h_ */
|
||||
|
||||
|
||||
@@ -25,10 +25,8 @@
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendpoint.h"
|
||||
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendPoint_RGB555(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -52,9 +50,8 @@ SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendPoint_RGB565(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -78,9 +75,8 @@ SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendPoint_RGB888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -104,9 +100,8 @@ SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendPoint_ARGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -130,9 +125,8 @@ SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -181,9 +175,8 @@ SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uin
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -213,9 +206,8 @@ SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Ui
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_BlendPoint(): dst");
|
||||
@@ -274,9 +266,8 @@ SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
int minx, miny;
|
||||
int maxx, maxy;
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
#endif /* SDL_blendpoint_h_ */
|
||||
|
||||
|
||||
@@ -26,77 +26,93 @@
|
||||
* and in the blend and add case, the RGB values are premultiplied by a.
|
||||
*/
|
||||
|
||||
#define DRAW_MUL(_a, _b) (((unsigned)(_a)*(_b))/255)
|
||||
#define DRAW_MUL(_a, _b) (((unsigned)(_a) * (_b)) / 255)
|
||||
|
||||
#define DRAW_FASTSETPIXEL(type) \
|
||||
*pixel = (type) color
|
||||
*pixel = (type)color
|
||||
|
||||
#define DRAW_FASTSETPIXEL1 DRAW_FASTSETPIXEL(Uint8)
|
||||
#define DRAW_FASTSETPIXEL2 DRAW_FASTSETPIXEL(Uint16)
|
||||
#define DRAW_FASTSETPIXEL4 DRAW_FASTSETPIXEL(Uint32)
|
||||
|
||||
#define DRAW_FASTSETPIXELXY(x, y, type, bpp, color) \
|
||||
*(type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
|
||||
+ (x) * bpp) = (type) color
|
||||
*(type *)((Uint8 *)dst->pixels + (y)*dst->pitch + (x)*bpp) = (type)color
|
||||
|
||||
#define DRAW_FASTSETPIXELXY1(x, y) DRAW_FASTSETPIXELXY(x, y, Uint8, 1, color)
|
||||
#define DRAW_FASTSETPIXELXY2(x, y) DRAW_FASTSETPIXELXY(x, y, Uint16, 2, color)
|
||||
#define DRAW_FASTSETPIXELXY4(x, y) DRAW_FASTSETPIXELXY(x, y, Uint32, 4, color)
|
||||
|
||||
#define DRAW_SETPIXEL(setpixel) \
|
||||
do { \
|
||||
unsigned sr = r, sg = g, sb = b, sa = a; (void) sa; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
#define DRAW_SETPIXEL(setpixel) \
|
||||
do { \
|
||||
unsigned sr = r, sg = g, sb = b, sa = a; \
|
||||
(void)sa; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa = 0xFF; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(inva, sr) + r; \
|
||||
sg = DRAW_MUL(inva, sg) + g; \
|
||||
sb = DRAW_MUL(inva, sb) + b; \
|
||||
sa = DRAW_MUL(inva, sa) + a; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa = 0xFF; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(inva, sr) + r; \
|
||||
sg = DRAW_MUL(inva, sg) + g; \
|
||||
sb = DRAW_MUL(inva, sb) + b; \
|
||||
sa = DRAW_MUL(inva, sa) + a; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_ADD(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; (void) sa; \
|
||||
getpixel; \
|
||||
sr += r; if (sr > 0xff) sr = 0xff; \
|
||||
sg += g; if (sg > 0xff) sg = 0xff; \
|
||||
sb += b; if (sb > 0xff) sb = 0xff; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; \
|
||||
(void)sa; \
|
||||
getpixel; \
|
||||
sr += r; \
|
||||
if (sr > 0xff) \
|
||||
sr = 0xff; \
|
||||
sg += g; \
|
||||
if (sg > 0xff) \
|
||||
sg = 0xff; \
|
||||
sb += b; \
|
||||
if (sb > 0xff) \
|
||||
sb = 0xff; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_MOD(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; (void) sa; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(sr, r); \
|
||||
sg = DRAW_MUL(sg, g); \
|
||||
sb = DRAW_MUL(sb, b); \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; \
|
||||
(void)sa; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(sr, r); \
|
||||
sg = DRAW_MUL(sg, g); \
|
||||
sb = DRAW_MUL(sb, b); \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_MUL(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; sa = 0xFF; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(sr, r) + DRAW_MUL(inva, sr); if (sr > 0xff) sr = 0xff; \
|
||||
sg = DRAW_MUL(sg, g) + DRAW_MUL(inva, sg); if (sg > 0xff) sg = 0xff; \
|
||||
sb = DRAW_MUL(sb, b) + DRAW_MUL(inva, sb); if (sb > 0xff) sb = 0xff; \
|
||||
sa = DRAW_MUL(sa, a) + DRAW_MUL(inva, sa); if (sa > 0xff) sa = 0xff; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
#define DRAW_SETPIXEL_MUL(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; \
|
||||
sa = 0xFF; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(sr, r) + DRAW_MUL(inva, sr); \
|
||||
if (sr > 0xff) \
|
||||
sr = 0xff; \
|
||||
sg = DRAW_MUL(sg, g) + DRAW_MUL(inva, sg); \
|
||||
if (sg > 0xff) \
|
||||
sg = 0xff; \
|
||||
sb = DRAW_MUL(sb, b) + DRAW_MUL(inva, sb); \
|
||||
if (sb > 0xff) \
|
||||
sb = 0xff; \
|
||||
sa = DRAW_MUL(sa, a) + DRAW_MUL(inva, sa); \
|
||||
if (sa > 0xff) \
|
||||
sa = 0xff; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXELXY(x, y, type, bpp, op) \
|
||||
do { \
|
||||
type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
|
||||
+ (x) * bpp); \
|
||||
op; \
|
||||
} while (0)
|
||||
#define DRAW_SETPIXELXY(x, y, type, bpp, op) \
|
||||
do { \
|
||||
type *pixel = (type *)((Uint8 *)dst->pixels + (y)*dst->pitch + (x)*bpp); \
|
||||
op; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Define draw operators for RGB555
|
||||
@@ -105,19 +121,19 @@ do { \
|
||||
#define DRAW_SETPIXEL_RGB555 \
|
||||
DRAW_SETPIXEL(RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB555 \
|
||||
#define DRAW_SETPIXEL_BLEND_RGB555 \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB555 \
|
||||
#define DRAW_SETPIXEL_ADD_RGB555 \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB555 \
|
||||
#define DRAW_SETPIXEL_MOD_RGB555 \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGB555 \
|
||||
#define DRAW_SETPIXEL_MUL_RGB555 \
|
||||
DRAW_SETPIXEL_MUL(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
@@ -143,19 +159,19 @@ do { \
|
||||
#define DRAW_SETPIXEL_RGB565 \
|
||||
DRAW_SETPIXEL(RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB565 \
|
||||
#define DRAW_SETPIXEL_BLEND_RGB565 \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB565 \
|
||||
#define DRAW_SETPIXEL_ADD_RGB565 \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB565 \
|
||||
#define DRAW_SETPIXEL_MOD_RGB565 \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGB565 \
|
||||
#define DRAW_SETPIXEL_MUL_RGB565 \
|
||||
DRAW_SETPIXEL_MUL(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
@@ -181,19 +197,19 @@ do { \
|
||||
#define DRAW_SETPIXEL_RGB888 \
|
||||
DRAW_SETPIXEL(RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB888 \
|
||||
#define DRAW_SETPIXEL_BLEND_RGB888 \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB888 \
|
||||
#define DRAW_SETPIXEL_ADD_RGB888 \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB888 \
|
||||
#define DRAW_SETPIXEL_MOD_RGB888 \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGB888 \
|
||||
#define DRAW_SETPIXEL_MUL_RGB888 \
|
||||
DRAW_SETPIXEL_MUL(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
@@ -219,19 +235,19 @@ do { \
|
||||
#define DRAW_SETPIXEL_ARGB8888 \
|
||||
DRAW_SETPIXEL(ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_ARGB8888 \
|
||||
#define DRAW_SETPIXEL_BLEND_ARGB8888 \
|
||||
DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_ARGB8888 \
|
||||
#define DRAW_SETPIXEL_ADD_ARGB8888 \
|
||||
DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_ARGB8888 \
|
||||
#define DRAW_SETPIXEL_MOD_ARGB8888 \
|
||||
DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_ARGB8888 \
|
||||
#define DRAW_SETPIXEL_MUL_ARGB8888 \
|
||||
DRAW_SETPIXEL_MUL(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
@@ -257,19 +273,19 @@ do { \
|
||||
#define DRAW_SETPIXEL_RGB \
|
||||
DRAW_SETPIXEL(PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB \
|
||||
#define DRAW_SETPIXEL_BLEND_RGB \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB \
|
||||
#define DRAW_SETPIXEL_ADD_RGB \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB \
|
||||
#define DRAW_SETPIXEL_MOD_RGB \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGB \
|
||||
#define DRAW_SETPIXEL_MUL_RGB \
|
||||
DRAW_SETPIXEL_MUL(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
@@ -303,7 +319,6 @@ do { \
|
||||
#define DRAW_SETPIXELXY4_MUL_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MUL_RGB)
|
||||
|
||||
|
||||
/*
|
||||
* Define draw operators for general RGBA
|
||||
*/
|
||||
@@ -311,19 +326,19 @@ do { \
|
||||
#define DRAW_SETPIXEL_RGBA \
|
||||
DRAW_SETPIXEL(PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGBA \
|
||||
#define DRAW_SETPIXEL_BLEND_RGBA \
|
||||
DRAW_SETPIXEL_BLEND(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGBA \
|
||||
#define DRAW_SETPIXEL_ADD_RGBA \
|
||||
DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGBA \
|
||||
#define DRAW_SETPIXEL_MOD_RGBA \
|
||||
DRAW_SETPIXEL_MOD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGBA \
|
||||
#define DRAW_SETPIXEL_MUL_RGBA \
|
||||
DRAW_SETPIXEL_MUL(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
@@ -349,284 +364,301 @@ do { \
|
||||
#define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
|
||||
|
||||
/* Horizontal line */
|
||||
#define HLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (x1 <= x2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
length = draw_end ? (x2-x1+1) : (x2-x1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x2; \
|
||||
if (!draw_end) { \
|
||||
++pixel; \
|
||||
} \
|
||||
length = draw_end ? (x1-x2+1) : (x1-x2); \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
++pixel; \
|
||||
} \
|
||||
}
|
||||
#define HLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (x1 <= x2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
length = draw_end ? (x2 - x1 + 1) : (x2 - x1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x2; \
|
||||
if (!draw_end) { \
|
||||
++pixel; \
|
||||
} \
|
||||
length = draw_end ? (x1 - x2 + 1) : (x1 - x2); \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
++pixel; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Vertical line */
|
||||
#define VLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
length = draw_end ? (y2-y1+1) : (y2-y1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y2 * pitch + x1; \
|
||||
if (!draw_end) { \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
length = draw_end ? (y1-y2+1) : (y1-y2); \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
}
|
||||
#define VLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
length = draw_end ? (y2 - y1 + 1) : (y2 - y1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y2 * pitch + x1; \
|
||||
if (!draw_end) { \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
length = draw_end ? (y1 - y2 + 1) : (y1 - y2); \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Diagonal line */
|
||||
#define DLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
if (x1 <= x2) { \
|
||||
++pitch; \
|
||||
} else { \
|
||||
--pitch; \
|
||||
} \
|
||||
length = (y2-y1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y2 * pitch + x2; \
|
||||
if (x2 <= x1) { \
|
||||
++pitch; \
|
||||
} else { \
|
||||
--pitch; \
|
||||
} \
|
||||
if (!draw_end) { \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
length = (y1-y2); \
|
||||
} \
|
||||
if (draw_end) { \
|
||||
++length; \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
}
|
||||
#define DLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
if (x1 <= x2) { \
|
||||
++pitch; \
|
||||
} else { \
|
||||
--pitch; \
|
||||
} \
|
||||
length = (y2 - y1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y2 * pitch + x2; \
|
||||
if (x2 <= x1) { \
|
||||
++pitch; \
|
||||
} else { \
|
||||
--pitch; \
|
||||
} \
|
||||
if (!draw_end) { \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
length = (y1 - y2); \
|
||||
} \
|
||||
if (draw_end) { \
|
||||
++length; \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Bresenham's line algorithm */
|
||||
#define BLINE(x1, y1, x2, y2, op, draw_end) \
|
||||
{ \
|
||||
int i, deltax, deltay, numpixels; \
|
||||
int d, dinc1, dinc2; \
|
||||
int x, xinc1, xinc2; \
|
||||
int y, yinc1, yinc2; \
|
||||
\
|
||||
deltax = ABS(x2 - x1); \
|
||||
deltay = ABS(y2 - y1); \
|
||||
\
|
||||
if (deltax >= deltay) { \
|
||||
numpixels = deltax + 1; \
|
||||
d = (2 * deltay) - deltax; \
|
||||
dinc1 = deltay * 2; \
|
||||
dinc2 = (deltay - deltax) * 2; \
|
||||
xinc1 = 1; \
|
||||
xinc2 = 1; \
|
||||
yinc1 = 0; \
|
||||
yinc2 = 1; \
|
||||
} else { \
|
||||
numpixels = deltay + 1; \
|
||||
d = (2 * deltax) - deltay; \
|
||||
dinc1 = deltax * 2; \
|
||||
dinc2 = (deltax - deltay) * 2; \
|
||||
xinc1 = 0; \
|
||||
xinc2 = 1; \
|
||||
yinc1 = 1; \
|
||||
yinc2 = 1; \
|
||||
} \
|
||||
\
|
||||
if (x1 > x2) { \
|
||||
xinc1 = -xinc1; \
|
||||
xinc2 = -xinc2; \
|
||||
} \
|
||||
if (y1 > y2) { \
|
||||
yinc1 = -yinc1; \
|
||||
yinc2 = -yinc2; \
|
||||
} \
|
||||
\
|
||||
x = x1; \
|
||||
y = y1; \
|
||||
\
|
||||
if (!draw_end) { \
|
||||
--numpixels; \
|
||||
} \
|
||||
for (i = 0; i < numpixels; ++i) { \
|
||||
op(x, y); \
|
||||
if (d < 0) { \
|
||||
d += dinc1; \
|
||||
x += xinc1; \
|
||||
y += yinc1; \
|
||||
} else { \
|
||||
d += dinc2; \
|
||||
x += xinc2; \
|
||||
y += yinc2; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
{ \
|
||||
int i, deltax, deltay, numpixels; \
|
||||
int d, dinc1, dinc2; \
|
||||
int x, xinc1, xinc2; \
|
||||
int y, yinc1, yinc2; \
|
||||
\
|
||||
deltax = ABS(x2 - x1); \
|
||||
deltay = ABS(y2 - y1); \
|
||||
\
|
||||
if (deltax >= deltay) { \
|
||||
numpixels = deltax + 1; \
|
||||
d = (2 * deltay) - deltax; \
|
||||
dinc1 = deltay * 2; \
|
||||
dinc2 = (deltay - deltax) * 2; \
|
||||
xinc1 = 1; \
|
||||
xinc2 = 1; \
|
||||
yinc1 = 0; \
|
||||
yinc2 = 1; \
|
||||
} else { \
|
||||
numpixels = deltay + 1; \
|
||||
d = (2 * deltax) - deltay; \
|
||||
dinc1 = deltax * 2; \
|
||||
dinc2 = (deltax - deltay) * 2; \
|
||||
xinc1 = 0; \
|
||||
xinc2 = 1; \
|
||||
yinc1 = 1; \
|
||||
yinc2 = 1; \
|
||||
} \
|
||||
\
|
||||
if (x1 > x2) { \
|
||||
xinc1 = -xinc1; \
|
||||
xinc2 = -xinc2; \
|
||||
} \
|
||||
if (y1 > y2) { \
|
||||
yinc1 = -yinc1; \
|
||||
yinc2 = -yinc2; \
|
||||
} \
|
||||
\
|
||||
x = x1; \
|
||||
y = y1; \
|
||||
\
|
||||
if (!draw_end) { \
|
||||
--numpixels; \
|
||||
} \
|
||||
for (i = 0; i < numpixels; ++i) { \
|
||||
op(x, y); \
|
||||
if (d < 0) { \
|
||||
d += dinc1; \
|
||||
x += xinc1; \
|
||||
y += yinc1; \
|
||||
} else { \
|
||||
d += dinc2; \
|
||||
x += xinc2; \
|
||||
y += yinc2; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Xiaolin Wu's line algorithm, based on Michael Abrash's implementation */
|
||||
#define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
{ \
|
||||
Uint16 ErrorAdj, ErrorAcc; \
|
||||
Uint16 ErrorAccTemp, Weighting; \
|
||||
int DeltaX, DeltaY, Temp, XDir; \
|
||||
unsigned r, g, b, a, inva; \
|
||||
\
|
||||
/* Draw the initial pixel, which is always exactly intersected by \
|
||||
the line and so needs no weighting */ \
|
||||
opaque_op(x1, y1); \
|
||||
\
|
||||
/* Draw the final pixel, which is always exactly intersected by the line \
|
||||
and so needs no weighting */ \
|
||||
if (draw_end) { \
|
||||
opaque_op(x2, y2); \
|
||||
} \
|
||||
\
|
||||
/* Make sure the line runs top to bottom */ \
|
||||
if (y1 > y2) { \
|
||||
Temp = y1; y1 = y2; y2 = Temp; \
|
||||
Temp = x1; x1 = x2; x2 = Temp; \
|
||||
} \
|
||||
DeltaY = y2 - y1; \
|
||||
\
|
||||
if ((DeltaX = x2 - x1) >= 0) { \
|
||||
XDir = 1; \
|
||||
} else { \
|
||||
XDir = -1; \
|
||||
DeltaX = -DeltaX; /* make DeltaX positive */ \
|
||||
} \
|
||||
\
|
||||
/* line is not horizontal, diagonal, or vertical */ \
|
||||
ErrorAcc = 0; /* initialize the line error accumulator to 0 */ \
|
||||
\
|
||||
/* Is this an X-major or Y-major line? */ \
|
||||
if (DeltaY > DeltaX) { \
|
||||
/* Y-major line; calculate 16-bit fixed-point fractional part of a \
|
||||
pixel that X advances each time Y advances 1 pixel, truncating the \
|
||||
result so that we won't overrun the endpoint along the X axis */ \
|
||||
ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY; \
|
||||
/* Draw all pixels other than the first and last */ \
|
||||
while (--DeltaY) { \
|
||||
ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
|
||||
ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
|
||||
if (ErrorAcc <= ErrorAccTemp) { \
|
||||
/* The error accumulator turned over, so advance the X coord */ \
|
||||
x1 += XDir; \
|
||||
} \
|
||||
y1++; /* Y-major, so always advance Y */ \
|
||||
/* The IntensityBits most significant bits of ErrorAcc give us the \
|
||||
intensity weighting for this pixel, and the complement of the \
|
||||
weighting for the paired pixel */ \
|
||||
Weighting = ErrorAcc >> 8; \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, (Weighting ^ 255)); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1); \
|
||||
} \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, Weighting); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1 + XDir, y1); \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
/* X-major line; calculate 16-bit fixed-point fractional part of a \
|
||||
pixel that Y advances each time X advances 1 pixel, truncating the \
|
||||
result to avoid overrunning the endpoint along the X axis */ \
|
||||
ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX; \
|
||||
/* Draw all pixels other than the first and last */ \
|
||||
while (--DeltaX) { \
|
||||
ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
|
||||
ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
|
||||
if (ErrorAcc <= ErrorAccTemp) { \
|
||||
/* The error accumulator turned over, so advance the Y coord */ \
|
||||
y1++; \
|
||||
} \
|
||||
x1 += XDir; /* X-major, so always advance X */ \
|
||||
/* The IntensityBits most significant bits of ErrorAcc give us the \
|
||||
intensity weighting for this pixel, and the complement of the \
|
||||
weighting for the paired pixel */ \
|
||||
Weighting = ErrorAcc >> 8; \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, (Weighting ^ 255)); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1); \
|
||||
} \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, Weighting); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1 + 1); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
{ \
|
||||
Uint16 ErrorAdj, ErrorAcc; \
|
||||
Uint16 ErrorAccTemp, Weighting; \
|
||||
int DeltaX, DeltaY, Temp, XDir; \
|
||||
unsigned r, g, b, a, inva; \
|
||||
\
|
||||
/* Draw the initial pixel, which is always exactly intersected by \
|
||||
the line and so needs no weighting */ \
|
||||
opaque_op(x1, y1); \
|
||||
\
|
||||
/* Draw the final pixel, which is always exactly intersected by the line \
|
||||
and so needs no weighting */ \
|
||||
if (draw_end) { \
|
||||
opaque_op(x2, y2); \
|
||||
} \
|
||||
\
|
||||
/* Make sure the line runs top to bottom */ \
|
||||
if (y1 > y2) { \
|
||||
Temp = y1; \
|
||||
y1 = y2; \
|
||||
y2 = Temp; \
|
||||
Temp = x1; \
|
||||
x1 = x2; \
|
||||
x2 = Temp; \
|
||||
} \
|
||||
DeltaY = y2 - y1; \
|
||||
\
|
||||
if ((DeltaX = x2 - x1) >= 0) { \
|
||||
XDir = 1; \
|
||||
} else { \
|
||||
XDir = -1; \
|
||||
DeltaX = -DeltaX; /* make DeltaX positive */ \
|
||||
} \
|
||||
\
|
||||
/* line is not horizontal, diagonal, or vertical */ \
|
||||
ErrorAcc = 0; /* initialize the line error accumulator to 0 */ \
|
||||
\
|
||||
/* Is this an X-major or Y-major line? */ \
|
||||
if (DeltaY > DeltaX) { \
|
||||
/* Y-major line; calculate 16-bit fixed-point fractional part of a \
|
||||
pixel that X advances each time Y advances 1 pixel, truncating the \
|
||||
result so that we won't overrun the endpoint along the X axis */ \
|
||||
ErrorAdj = ((unsigned long)DeltaX << 16) / (unsigned long)DeltaY; \
|
||||
/* Draw all pixels other than the first and last */ \
|
||||
while (--DeltaY) { \
|
||||
ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
|
||||
ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
|
||||
if (ErrorAcc <= ErrorAccTemp) { \
|
||||
/* The error accumulator turned over, so advance the X coord */ \
|
||||
x1 += XDir; \
|
||||
} \
|
||||
y1++; /* Y-major, so always advance Y */ \
|
||||
/* The IntensityBits most significant bits of ErrorAcc give us the \
|
||||
intensity weighting for this pixel, and the complement of the \
|
||||
weighting for the paired pixel */ \
|
||||
Weighting = ErrorAcc >> 8; \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, (Weighting ^ 255)); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1); \
|
||||
} \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, Weighting); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1 + XDir, y1); \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
/* X-major line; calculate 16-bit fixed-point fractional part of a \
|
||||
pixel that Y advances each time X advances 1 pixel, truncating the \
|
||||
result to avoid overrunning the endpoint along the X axis */ \
|
||||
ErrorAdj = ((unsigned long)DeltaY << 16) / (unsigned long)DeltaX; \
|
||||
/* Draw all pixels other than the first and last */ \
|
||||
while (--DeltaX) { \
|
||||
ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
|
||||
ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
|
||||
if (ErrorAcc <= ErrorAccTemp) { \
|
||||
/* The error accumulator turned over, so advance the Y coord */ \
|
||||
y1++; \
|
||||
} \
|
||||
x1 += XDir; /* X-major, so always advance X */ \
|
||||
/* The IntensityBits most significant bits of ErrorAcc give us the \
|
||||
intensity weighting for this pixel, and the complement of the \
|
||||
weighting for the paired pixel */ \
|
||||
Weighting = ErrorAcc >> 8; \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, (Weighting ^ 255)); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1); \
|
||||
} \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, Weighting); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1 + 1); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifdef AA_LINES
|
||||
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
|
||||
WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
|
||||
#else
|
||||
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
BLINE(x1, y1, x2, y2, opaque_op, draw_end)
|
||||
BLINE(x1, y1, x2, y2, opaque_op, draw_end)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define fill rect macro
|
||||
*/
|
||||
|
||||
#define FILLRECT(type, op) \
|
||||
do { \
|
||||
int width = rect->w; \
|
||||
int height = rect->h; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
int skip = pitch - width; \
|
||||
type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
|
||||
while (height--) { \
|
||||
{ int n = (width+3)/4; \
|
||||
switch (width & 3) { \
|
||||
case 0: do { op; pixel++; SDL_FALLTHROUGH; \
|
||||
case 3: op; pixel++; SDL_FALLTHROUGH; \
|
||||
case 2: op; pixel++; SDL_FALLTHROUGH; \
|
||||
case 1: op; pixel++; \
|
||||
} while ( --n > 0 ); \
|
||||
} \
|
||||
} \
|
||||
pixel += skip; \
|
||||
} \
|
||||
} while (0)
|
||||
#define FILLRECT(type, op) \
|
||||
do { \
|
||||
int width = rect->w; \
|
||||
int height = rect->h; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
int skip = pitch - width; \
|
||||
type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
|
||||
while (height--) { \
|
||||
{ \
|
||||
int n = (width + 3) / 4; \
|
||||
switch (width & 3) { \
|
||||
case 0: \
|
||||
do { \
|
||||
op; \
|
||||
pixel++; \
|
||||
SDL_FALLTHROUGH; \
|
||||
case 3: \
|
||||
op; \
|
||||
pixel++; \
|
||||
SDL_FALLTHROUGH; \
|
||||
case 2: \
|
||||
op; \
|
||||
pixel++; \
|
||||
SDL_FALLTHROUGH; \
|
||||
case 1: \
|
||||
op; \
|
||||
pixel++; \
|
||||
} while (--n > 0); \
|
||||
} \
|
||||
} \
|
||||
pixel += skip; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -26,10 +26,8 @@
|
||||
#include "SDL_drawline.h"
|
||||
#include "SDL_drawpoint.h"
|
||||
|
||||
|
||||
static void
|
||||
SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_DrawLine1(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
if (y1 == y2) {
|
||||
int length;
|
||||
@@ -37,13 +35,13 @@ SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
Uint8 *pixel;
|
||||
if (x1 <= x2) {
|
||||
pixel = (Uint8 *)dst->pixels + y1 * pitch + x1;
|
||||
length = draw_end ? (x2-x1+1) : (x2-x1);
|
||||
length = draw_end ? (x2 - x1 + 1) : (x2 - x1);
|
||||
} else {
|
||||
pixel = (Uint8 *)dst->pixels + y1 * pitch + x2;
|
||||
if (!draw_end) {
|
||||
++pixel;
|
||||
}
|
||||
length = draw_end ? (x1-x2+1) : (x1-x2);
|
||||
length = draw_end ? (x1 - x2 + 1) : (x1 - x2);
|
||||
}
|
||||
SDL_memset(pixel, color, length);
|
||||
} else if (x1 == x2) {
|
||||
@@ -55,9 +53,8 @@ SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_DrawLine2(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
if (y1 == y2) {
|
||||
HLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
||||
@@ -67,7 +64,7 @@ SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
DLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
||||
} else {
|
||||
Uint8 _r, _g, _b, _a;
|
||||
const SDL_PixelFormat * fmt = dst->format;
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
|
||||
if (fmt->Rmask == 0x7C00) {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
@@ -85,9 +82,8 @@ SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_DrawLine4(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
if (y1 == y2) {
|
||||
HLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
||||
@@ -97,7 +93,7 @@ SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
DLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
||||
} else {
|
||||
Uint8 _r, _g, _b, _a;
|
||||
const SDL_PixelFormat * fmt = dst->format;
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
|
||||
if (fmt->Rmask == 0x00FF0000) {
|
||||
if (!fmt->Amask) {
|
||||
@@ -117,12 +113,11 @@ SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*DrawLineFunc) (SDL_Surface * dst,
|
||||
int x1, int y1, int x2, int y2,
|
||||
Uint32 color, SDL_bool draw_end);
|
||||
typedef void (*DrawLineFunc)(SDL_Surface *dst,
|
||||
int x1, int y1, int x2, int y2,
|
||||
Uint32 color, SDL_bool draw_end);
|
||||
|
||||
static DrawLineFunc
|
||||
SDL_CalculateDrawLineFunc(const SDL_PixelFormat * fmt)
|
||||
static DrawLineFunc SDL_CalculateDrawLineFunc(const SDL_PixelFormat *fmt)
|
||||
{
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 1:
|
||||
@@ -138,8 +133,7 @@ SDL_CalculateDrawLineFunc(const SDL_PixelFormat * fmt)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
{
|
||||
DrawLineFunc func;
|
||||
|
||||
@@ -162,9 +156,8 @@ SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
Uint32 color)
|
||||
int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
Uint32 color)
|
||||
{
|
||||
int i;
|
||||
int x1, y1;
|
||||
@@ -182,8 +175,8 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
x1 = points[i-1].x;
|
||||
y1 = points[i-1].y;
|
||||
x1 = points[i - 1].x;
|
||||
y1 = points[i - 1].y;
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
@@ -198,8 +191,8 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
|
||||
func(dst, x1, y1, x2, y2, color, draw_end);
|
||||
}
|
||||
if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
|
||||
SDL_DrawPoint(dst, points[count-1].x, points[count-1].y, color);
|
||||
if (points[0].x != points[count - 1].x || points[0].y != points[count - 1].y) {
|
||||
SDL_DrawPoint(dst, points[count - 1].x, points[count - 1].y, color);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color);
|
||||
extern int SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color);
|
||||
extern int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color);
|
||||
extern int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color);
|
||||
|
||||
#endif /* SDL_drawline_h_ */
|
||||
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_drawpoint.h"
|
||||
|
||||
|
||||
int
|
||||
SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
|
||||
int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
|
||||
{
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_DrawPoint(): dst");
|
||||
@@ -61,9 +59,8 @@ SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
Uint32 color)
|
||||
int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
Uint32 color)
|
||||
{
|
||||
int minx, miny;
|
||||
int maxx, maxy;
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color);
|
||||
extern int SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color);
|
||||
extern int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color);
|
||||
extern int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color);
|
||||
|
||||
#endif /* SDL_drawpoint_h_ */
|
||||
|
||||
|
||||
@@ -50,11 +50,9 @@ typedef struct
|
||||
SDL_Surface *window;
|
||||
} SW_RenderData;
|
||||
|
||||
|
||||
static SDL_Surface *
|
||||
SW_ActivateRenderer(SDL_Renderer * renderer)
|
||||
static SDL_Surface *SW_ActivateRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
|
||||
if (!data->surface) {
|
||||
data->surface = data->window;
|
||||
@@ -68,10 +66,9 @@ SW_ActivateRenderer(SDL_Renderer * renderer)
|
||||
return data->surface;
|
||||
}
|
||||
|
||||
static void
|
||||
SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
static void SW_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
|
||||
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||
data->surface = NULL;
|
||||
@@ -79,10 +76,9 @@ SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
|
||||
static int SW_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
|
||||
if (data->surface) {
|
||||
if (w) {
|
||||
@@ -102,14 +98,12 @@ SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
|
||||
return SDL_SetError("Software renderer doesn't have an output surface");
|
||||
}
|
||||
|
||||
static int
|
||||
SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
if (!SDL_PixelFormatEnumToMasks
|
||||
(texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
|
||||
if (!SDL_PixelFormatEnumToMasks(texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
|
||||
return SDL_SetError("Unknown texture format");
|
||||
}
|
||||
|
||||
@@ -133,11 +127,10 @@ SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||
static int SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->driverdata;
|
||||
Uint8 *src, *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
@@ -145,10 +138,10 @@ SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
SDL_LockSurface(surface);
|
||||
}
|
||||
src = (Uint8 *) pixels;
|
||||
dst = (Uint8 *) surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel;
|
||||
src = (Uint8 *)pixels;
|
||||
dst = (Uint8 *)surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel;
|
||||
length = rect->w * surface->format->BytesPerPixel;
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
@@ -161,52 +154,46 @@ SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch)
|
||||
static int SW_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->driverdata;
|
||||
|
||||
*pixels =
|
||||
(void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel);
|
||||
(void *)((Uint8 *)surface->pixels + rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel);
|
||||
*pitch = surface->pitch;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static void SW_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
SW_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode)
|
||||
static void SW_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
SW_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static int SW_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
|
||||
if (texture) {
|
||||
data->surface = (SDL_Surface *) texture->driverdata;
|
||||
data->surface = (SDL_Surface *)texture->driverdata;
|
||||
} else {
|
||||
data->surface = data->window;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd)
|
||||
static int SW_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; /* nothing to do in this backend. */
|
||||
}
|
||||
|
||||
static int
|
||||
SW_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
|
||||
static int SW_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
SDL_Point *verts = (SDL_Point *) SDL_AllocateRenderVertices(renderer, count * sizeof (SDL_Point), 0, &cmd->data.draw.first);
|
||||
SDL_Point *verts = (SDL_Point *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Point), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (verts == NULL) {
|
||||
@@ -223,10 +210,9 @@ SW_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FP
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count)
|
||||
static int SW_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count)
|
||||
{
|
||||
SDL_Rect *verts = (SDL_Rect *) SDL_AllocateRenderVertices(renderer, count * sizeof (SDL_Rect), 0, &cmd->data.draw.first);
|
||||
SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Rect), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (verts == NULL) {
|
||||
@@ -245,11 +231,10 @@ SW_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRe
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect)
|
||||
static int SW_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const SDL_Rect *srcrect, const SDL_FRect *dstrect)
|
||||
{
|
||||
SDL_Rect *verts = (SDL_Rect *) SDL_AllocateRenderVertices(renderer, 2 * sizeof (SDL_Rect), 0, &cmd->data.draw.first);
|
||||
SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(SDL_Rect), 0, &cmd->data.draw.first);
|
||||
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
@@ -279,12 +264,11 @@ typedef struct CopyExData
|
||||
float scale_y;
|
||||
} CopyExData;
|
||||
|
||||
static int
|
||||
SW_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y)
|
||||
static int SW_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const SDL_Rect *srcrect, const SDL_FRect *dstrect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y)
|
||||
{
|
||||
CopyExData *verts = (CopyExData *) SDL_AllocateRenderVertices(renderer, sizeof (CopyExData), 0, &cmd->data.draw.first);
|
||||
CopyExData *verts = (CopyExData *)SDL_AllocateRenderVertices(renderer, sizeof(CopyExData), 0, &cmd->data.draw.first);
|
||||
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
@@ -307,18 +291,17 @@ SW_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * te
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surface, SDL_Rect *dstrect,
|
||||
float scale_x, float scale_y, SDL_ScaleMode scaleMode)
|
||||
static int Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surface, SDL_Rect *dstrect,
|
||||
float scale_x, float scale_y, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
int retval;
|
||||
/* Renderer scaling, if needed */
|
||||
if (scale_x != 1.0f || scale_y != 1.0f) {
|
||||
SDL_Rect r;
|
||||
r.x = (int)((float) dstrect->x * scale_x);
|
||||
r.y = (int)((float) dstrect->y * scale_y);
|
||||
r.w = (int)((float) dstrect->w * scale_x);
|
||||
r.h = (int)((float) dstrect->h * scale_y);
|
||||
r.x = (int)((float)dstrect->x * scale_x);
|
||||
r.y = (int)((float)dstrect->y * scale_y);
|
||||
r.w = (int)((float)dstrect->w * scale_x);
|
||||
r.h = (int)((float)dstrect->h * scale_y);
|
||||
retval = SDL_PrivateUpperBlitScaled(src, srcrect, surface, &r, scaleMode);
|
||||
} else {
|
||||
retval = SDL_BlitSurface(src, srcrect, surface, dstrect);
|
||||
@@ -326,12 +309,11 @@ Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surface, SDL_Re
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_Rect * final_rect,
|
||||
const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip, float scale_x, float scale_y)
|
||||
static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Texture *texture,
|
||||
const SDL_Rect *srcrect, const SDL_Rect *final_rect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y)
|
||||
{
|
||||
SDL_Surface *src = (SDL_Surface *) texture->driverdata;
|
||||
SDL_Surface *src = (SDL_Surface *)texture->driverdata;
|
||||
SDL_Rect tmp_rect;
|
||||
SDL_Surface *src_clone, *src_rotated, *src_scaled;
|
||||
SDL_Surface *mask = NULL, *mask_rotated = NULL;
|
||||
@@ -441,18 +423,18 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
|
||||
double cangle, sangle;
|
||||
|
||||
SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, angle, center,
|
||||
&rect_dest, &cangle, &sangle);
|
||||
&rect_dest, &cangle, &sangle);
|
||||
src_rotated = SDLgfx_rotateSurface(src_clone, angle,
|
||||
(texture->scaleMode == SDL_ScaleModeNearest) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL,
|
||||
&rect_dest, cangle, sangle, center);
|
||||
(texture->scaleMode == SDL_ScaleModeNearest) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL,
|
||||
&rect_dest, cangle, sangle, center);
|
||||
if (src_rotated == NULL) {
|
||||
retval = -1;
|
||||
}
|
||||
if (!retval && mask != NULL) {
|
||||
/* The mask needed for the NONE blend mode gets rotated with the same parameters. */
|
||||
mask_rotated = SDLgfx_rotateSurface(mask, angle,
|
||||
SDL_FALSE, 0, 0,
|
||||
&rect_dest, cangle, sangle, center);
|
||||
SDL_FALSE, 0, 0,
|
||||
&rect_dest, cangle, sangle, center);
|
||||
if (mask_rotated == NULL) {
|
||||
retval = -1;
|
||||
}
|
||||
@@ -535,7 +517,6 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
typedef struct GeometryFillData
|
||||
{
|
||||
SDL_Point dst;
|
||||
@@ -549,18 +530,17 @@ typedef struct GeometryCopyData
|
||||
SDL_Color color;
|
||||
} GeometryCopyData;
|
||||
|
||||
static int
|
||||
SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
static int SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
{
|
||||
int i;
|
||||
int count = indices ? num_indices : num_vertices;
|
||||
void *verts;
|
||||
int sz = texture ? sizeof (GeometryCopyData) : sizeof (GeometryFillData);
|
||||
int sz = texture ? sizeof(GeometryCopyData) : sizeof(GeometryFillData);
|
||||
|
||||
verts = (void *) SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
|
||||
verts = (void *)SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@@ -569,7 +549,7 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
|
||||
size_indices = indices ? size_indices : 0;
|
||||
|
||||
if (texture) {
|
||||
GeometryCopyData *ptr = (GeometryCopyData *) verts;
|
||||
GeometryCopyData *ptr = (GeometryCopyData *)verts;
|
||||
for (i = 0; i < count; i++) {
|
||||
int j;
|
||||
float *xy_;
|
||||
@@ -585,10 +565,10 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
|
||||
j = i;
|
||||
}
|
||||
|
||||
xy_ = (float *)((char*)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char*)color + j * color_stride);
|
||||
xy_ = (float *)((char *)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char *)color + j * color_stride);
|
||||
|
||||
uv_ = (float *)((char*)uv + j * uv_stride);
|
||||
uv_ = (float *)((char *)uv + j * uv_stride);
|
||||
|
||||
ptr->src.x = (int)(uv_[0] * texture->w);
|
||||
ptr->src.y = (int)(uv_[1] * texture->h);
|
||||
@@ -600,9 +580,9 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
|
||||
ptr->color = col_;
|
||||
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
GeometryFillData *ptr = (GeometryFillData *) verts;
|
||||
GeometryFillData *ptr = (GeometryFillData *)verts;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
int j;
|
||||
@@ -618,8 +598,8 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
|
||||
j = i;
|
||||
}
|
||||
|
||||
xy_ = (float *)((char*)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char*)color + j * color_stride);
|
||||
xy_ = (float *)((char *)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char *)color + j * color_stride);
|
||||
|
||||
ptr->dst.x = (int)(xy_[0] * scale_x);
|
||||
ptr->dst.y = (int)(xy_[1] * scale_y);
|
||||
@@ -628,13 +608,12 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
|
||||
ptr->color = col_;
|
||||
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
PrepTextureForCopy(const SDL_RenderCommand *cmd)
|
||||
static void PrepTextureForCopy(const SDL_RenderCommand *cmd)
|
||||
{
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
@@ -642,7 +621,7 @@ PrepTextureForCopy(const SDL_RenderCommand *cmd)
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->driverdata;
|
||||
const SDL_bool colormod = ((r & g & b) != 0xFF);
|
||||
const SDL_bool alphamod = (a != 0xFF);
|
||||
const SDL_bool blending = ((blend == SDL_BLENDMODE_ADD) || (blend == SDL_BLENDMODE_MOD) || (blend == SDL_BLENDMODE_MUL));
|
||||
@@ -657,13 +636,12 @@ PrepTextureForCopy(const SDL_RenderCommand *cmd)
|
||||
SDL_SetSurfaceBlendMode(surface, blend);
|
||||
}
|
||||
|
||||
static void
|
||||
SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
|
||||
static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
|
||||
{
|
||||
if (drawstate->surface_cliprect_dirty) {
|
||||
const SDL_Rect *viewport = drawstate->viewport;
|
||||
const SDL_Rect *cliprect = drawstate->cliprect;
|
||||
SDL_assert(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */
|
||||
SDL_assert(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */
|
||||
|
||||
if (cliprect != NULL) {
|
||||
SDL_Rect clip_rect;
|
||||
@@ -680,8 +658,7 @@ SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
SW_DrawStateCache drawstate;
|
||||
@@ -696,43 +673,48 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
|
||||
|
||||
while (cmd) {
|
||||
switch (cmd->command) {
|
||||
case SDL_RENDERCMD_SETDRAWCOLOR: {
|
||||
break; /* Not used in this backend. */
|
||||
}
|
||||
case SDL_RENDERCMD_SETDRAWCOLOR:
|
||||
{
|
||||
break; /* Not used in this backend. */
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETVIEWPORT: {
|
||||
drawstate.viewport = &cmd->data.viewport.rect;
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_SETVIEWPORT:
|
||||
{
|
||||
drawstate.viewport = &cmd->data.viewport.rect;
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETCLIPRECT: {
|
||||
drawstate.cliprect = cmd->data.cliprect.enabled ? &cmd->data.cliprect.rect : NULL;
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_SETCLIPRECT:
|
||||
{
|
||||
drawstate.cliprect = cmd->data.cliprect.enabled ? &cmd->data.cliprect.rect : NULL;
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_CLEAR: {
|
||||
const Uint8 r = cmd->data.color.r;
|
||||
const Uint8 g = cmd->data.color.g;
|
||||
const Uint8 b = cmd->data.color.b;
|
||||
const Uint8 a = cmd->data.color.a;
|
||||
/* By definition the clear ignores the clip rect */
|
||||
SDL_SetClipRect(surface, NULL);
|
||||
SDL_FillRect(surface, NULL, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_CLEAR:
|
||||
{
|
||||
const Uint8 r = cmd->data.color.r;
|
||||
const Uint8 g = cmd->data.color.g;
|
||||
const Uint8 b = cmd->data.color.b;
|
||||
const Uint8 a = cmd->data.color.a;
|
||||
/* By definition the clear ignores the clip rect */
|
||||
SDL_SetClipRect(surface, NULL);
|
||||
SDL_FillRect(surface, NULL, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_DRAW_POINTS: {
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
const Uint8 b = cmd->data.draw.b;
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const int count = (int) cmd->data.draw.count;
|
||||
SDL_Point *verts = (SDL_Point *) (((Uint8 *) vertices) + cmd->data.draw.first);
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
case SDL_RENDERCMD_DRAW_POINTS:
|
||||
{
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
const Uint8 b = cmd->data.draw.b;
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const int count = (int)cmd->data.draw.count;
|
||||
SDL_Point *verts = (SDL_Point *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
@@ -888,64 +870,220 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
|
||||
|
||||
case SDL_RENDERCMD_GEOMETRY: {
|
||||
int i;
|
||||
SDL_Rect *verts = (SDL_Rect *) (((Uint8 *) vertices) + cmd->data.draw.first);
|
||||
const int count = (int) cmd->data.draw.count;
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
if (texture) {
|
||||
SDL_Surface *src = (SDL_Surface *) texture->driverdata;
|
||||
|
||||
GeometryCopyData *ptr = (GeometryCopyData *) verts;
|
||||
|
||||
PrepTextureForCopy(cmd);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
vp.y = drawstate.viewport->y;
|
||||
trianglepoint_2_fixedpoint(&vp);
|
||||
for (i = 0; i < count; i++) {
|
||||
ptr[i].dst.x += vp.x;
|
||||
ptr[i].dst.y += vp.y;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i += 3, ptr += 3) {
|
||||
SDL_SW_BlitTriangle(
|
||||
src,
|
||||
&(ptr[0].src), &(ptr[1].src), &(ptr[2].src),
|
||||
surface,
|
||||
&(ptr[0].dst), &(ptr[1].dst), &(ptr[2].dst),
|
||||
ptr[0].color, ptr[1].color, ptr[2].color);
|
||||
}
|
||||
} else {
|
||||
GeometryFillData *ptr = (GeometryFillData *) verts;
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
vp.y = drawstate.viewport->y;
|
||||
trianglepoint_2_fixedpoint(&vp);
|
||||
for (i = 0; i < count; i++) {
|
||||
ptr[i].dst.x += vp.x;
|
||||
ptr[i].dst.y += vp.y;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i += 3, ptr += 3) {
|
||||
SDL_SW_FillTriangle(surface, &(ptr[0].dst), &(ptr[1].dst), &(ptr[2].dst), blend, ptr[0].color, ptr[1].color, ptr[2].color);
|
||||
}
|
||||
for (i = 0; i < count; i++) {
|
||||
verts[i].x += drawstate.viewport->x;
|
||||
verts[i].y += drawstate.viewport->y;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_NO_OP:
|
||||
break;
|
||||
if (blend == SDL_BLENDMODE_NONE) {
|
||||
SDL_DrawPoints(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
} else {
|
||||
SDL_BlendPoints(surface, verts, count, blend, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_DRAW_LINES:
|
||||
{
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
const Uint8 b = cmd->data.draw.b;
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const int count = (int)cmd->data.draw.count;
|
||||
SDL_Point *verts = (SDL_Point *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
verts[i].x += drawstate.viewport->x;
|
||||
verts[i].y += drawstate.viewport->y;
|
||||
}
|
||||
}
|
||||
|
||||
if (blend == SDL_BLENDMODE_NONE) {
|
||||
SDL_DrawLines(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
} else {
|
||||
SDL_BlendLines(surface, verts, count, blend, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_FILL_RECTS:
|
||||
{
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
const Uint8 b = cmd->data.draw.b;
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const int count = (int)cmd->data.draw.count;
|
||||
SDL_Rect *verts = (SDL_Rect *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
verts[i].x += drawstate.viewport->x;
|
||||
verts[i].y += drawstate.viewport->y;
|
||||
}
|
||||
}
|
||||
|
||||
if (blend == SDL_BLENDMODE_NONE) {
|
||||
SDL_FillRects(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
} else {
|
||||
SDL_BlendFillRects(surface, verts, count, blend, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_COPY:
|
||||
{
|
||||
SDL_Rect *verts = (SDL_Rect *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
const SDL_Rect *srcrect = verts;
|
||||
SDL_Rect *dstrect = verts + 1;
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
SDL_Surface *src = (SDL_Surface *)texture->driverdata;
|
||||
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
PrepTextureForCopy(cmd);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
dstrect->x += drawstate.viewport->x;
|
||||
dstrect->y += drawstate.viewport->y;
|
||||
}
|
||||
|
||||
if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
|
||||
SDL_BlitSurface(src, srcrect, surface, dstrect);
|
||||
} else {
|
||||
/* If scaling is ever done, permanently disable RLE (which doesn't support scaling)
|
||||
* to avoid potentially frequent RLE encoding/decoding.
|
||||
*/
|
||||
SDL_SetSurfaceRLE(surface, 0);
|
||||
|
||||
/* Prevent to do scaling + clipping on viewport boundaries as it may lose proportion */
|
||||
if (dstrect->x < 0 || dstrect->y < 0 || dstrect->x + dstrect->w > surface->w || dstrect->y + dstrect->h > surface->h) {
|
||||
SDL_Surface *tmp = SDL_CreateRGBSurfaceWithFormat(dstrect->w, dstrect->h, src->format->format);
|
||||
/* Scale to an intermediate surface, then blit */
|
||||
if (tmp) {
|
||||
SDL_Rect r;
|
||||
SDL_BlendMode blendmode;
|
||||
Uint8 alphaMod, rMod, gMod, bMod;
|
||||
|
||||
SDL_GetSurfaceBlendMode(src, &blendmode);
|
||||
SDL_GetSurfaceAlphaMod(src, &alphaMod);
|
||||
SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod);
|
||||
|
||||
r.x = 0;
|
||||
r.y = 0;
|
||||
r.w = dstrect->w;
|
||||
r.h = dstrect->h;
|
||||
|
||||
SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_NONE);
|
||||
SDL_SetSurfaceColorMod(src, 255, 255, 255);
|
||||
SDL_SetSurfaceAlphaMod(src, 255);
|
||||
|
||||
SDL_PrivateUpperBlitScaled(src, srcrect, tmp, &r, texture->scaleMode);
|
||||
|
||||
SDL_SetSurfaceColorMod(tmp, rMod, gMod, bMod);
|
||||
SDL_SetSurfaceAlphaMod(tmp, alphaMod);
|
||||
SDL_SetSurfaceBlendMode(tmp, blendmode);
|
||||
|
||||
SDL_BlitSurface(tmp, NULL, surface, dstrect);
|
||||
SDL_FreeSurface(tmp);
|
||||
/* No need to set back r/g/b/a/blendmode to 'src' since it's done in PrepTextureForCopy() */
|
||||
}
|
||||
} else {
|
||||
SDL_PrivateUpperBlitScaled(src, srcrect, surface, dstrect, texture->scaleMode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_COPY_EX:
|
||||
{
|
||||
CopyExData *copydata = (CopyExData *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
SetDrawState(surface, &drawstate);
|
||||
PrepTextureForCopy(cmd);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
copydata->dstrect.x += drawstate.viewport->x;
|
||||
copydata->dstrect.y += drawstate.viewport->y;
|
||||
}
|
||||
|
||||
SW_RenderCopyEx(renderer, surface, cmd->data.draw.texture, ©data->srcrect,
|
||||
©data->dstrect, copydata->angle, ©data->center, copydata->flip,
|
||||
copydata->scale_x, copydata->scale_y);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_GEOMETRY:
|
||||
{
|
||||
int i;
|
||||
SDL_Rect *verts = (SDL_Rect *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
const int count = (int)cmd->data.draw.count;
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
if (texture) {
|
||||
SDL_Surface *src = (SDL_Surface *)texture->driverdata;
|
||||
|
||||
GeometryCopyData *ptr = (GeometryCopyData *)verts;
|
||||
|
||||
PrepTextureForCopy(cmd);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
vp.y = drawstate.viewport->y;
|
||||
trianglepoint_2_fixedpoint(&vp);
|
||||
for (i = 0; i < count; i++) {
|
||||
ptr[i].dst.x += vp.x;
|
||||
ptr[i].dst.y += vp.y;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i += 3, ptr += 3) {
|
||||
SDL_SW_BlitTriangle(
|
||||
src,
|
||||
&(ptr[0].src), &(ptr[1].src), &(ptr[2].src),
|
||||
surface,
|
||||
&(ptr[0].dst), &(ptr[1].dst), &(ptr[2].dst),
|
||||
ptr[0].color, ptr[1].color, ptr[2].color);
|
||||
}
|
||||
} else {
|
||||
GeometryFillData *ptr = (GeometryFillData *)verts;
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
vp.y = drawstate.viewport->y;
|
||||
trianglepoint_2_fixedpoint(&vp);
|
||||
for (i = 0; i < count; i++) {
|
||||
ptr[i].dst.x += vp.x;
|
||||
ptr[i].dst.y += vp.y;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i += 3, ptr += 3) {
|
||||
SDL_SW_FillTriangle(surface, &(ptr[0].dst), &(ptr[1].dst), &(ptr[2].dst), blend, ptr[0].color, ptr[1].color, ptr[2].color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_NO_OP:
|
||||
break;
|
||||
}
|
||||
|
||||
cmd = cmd->next;
|
||||
@@ -954,9 +1092,8 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch)
|
||||
static int SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||
Uint32 format, void *pixels, int pitch)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
Uint32 src_format;
|
||||
@@ -970,23 +1107,22 @@ SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
* SDL_RenderReadPixels.
|
||||
*/
|
||||
|
||||
if (rect->x < 0 || rect->x+rect->w > surface->w ||
|
||||
rect->y < 0 || rect->y+rect->h > surface->h) {
|
||||
if (rect->x < 0 || rect->x + rect->w > surface->w ||
|
||||
rect->y < 0 || rect->y + rect->h > surface->h) {
|
||||
return SDL_SetError("Tried to read outside of surface bounds");
|
||||
}
|
||||
|
||||
src_format = surface->format->format;
|
||||
src_pixels = (void*)((Uint8 *) surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel);
|
||||
src_pixels = (void *)((Uint8 *)surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel);
|
||||
|
||||
return SDL_ConvertPixels(rect->w, rect->h,
|
||||
src_format, src_pixels, surface->pitch,
|
||||
format, pixels, pitch);
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderPresent(SDL_Renderer * renderer)
|
||||
static int SW_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_Window *window = renderer->window;
|
||||
|
||||
@@ -996,25 +1132,23 @@ SW_RenderPresent(SDL_Renderer * renderer)
|
||||
return SDL_UpdateWindowSurface(window);
|
||||
}
|
||||
|
||||
static void
|
||||
SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static void SW_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->driverdata;
|
||||
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
|
||||
static void
|
||||
SW_DestroyRenderer(SDL_Renderer * renderer)
|
||||
static void SW_DestroyRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
|
||||
SDL_free(data);
|
||||
SDL_free(renderer);
|
||||
}
|
||||
|
||||
SDL_Renderer *
|
||||
SW_CreateRendererForSurface(SDL_Surface * surface)
|
||||
SW_CreateRendererForSurface(SDL_Surface *surface)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
SW_RenderData *data;
|
||||
@@ -1024,13 +1158,13 @@ SW_CreateRendererForSurface(SDL_Surface * surface)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (SW_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
data = (SW_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
SW_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
@@ -1048,9 +1182,9 @@ SW_CreateRendererForSurface(SDL_Surface * surface)
|
||||
renderer->SetTextureScaleMode = SW_SetTextureScaleMode;
|
||||
renderer->SetRenderTarget = SW_SetRenderTarget;
|
||||
renderer->QueueSetViewport = SW_QueueSetViewport;
|
||||
renderer->QueueSetDrawColor = SW_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|
||||
renderer->QueueSetDrawColor = SW_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|
||||
renderer->QueueDrawPoints = SW_QueueDrawPoints;
|
||||
renderer->QueueDrawLines = SW_QueueDrawPoints; /* lines and points queue vertices the same way. */
|
||||
renderer->QueueDrawLines = SW_QueueDrawPoints; /* lines and points queue vertices the same way. */
|
||||
renderer->QueueFillRects = SW_QueueFillRects;
|
||||
renderer->QueueCopy = SW_QueueCopy;
|
||||
renderer->QueueCopyEx = SW_QueueCopyEx;
|
||||
@@ -1068,8 +1202,7 @@ SW_CreateRendererForSurface(SDL_Surface * surface)
|
||||
return renderer;
|
||||
}
|
||||
|
||||
static SDL_Renderer *
|
||||
SW_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
{
|
||||
const char *hint;
|
||||
SDL_Surface *surface;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef SDL_render_sw_c_h_
|
||||
#define SDL_render_sw_c_h_
|
||||
|
||||
extern SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface * surface);
|
||||
extern SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface);
|
||||
|
||||
#endif /* SDL_render_sw_c_h_ */
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
/* !
|
||||
\brief A 32 bit RGBA pixel.
|
||||
*/
|
||||
typedef struct tColorRGBA {
|
||||
typedef struct tColorRGBA
|
||||
{
|
||||
Uint8 r;
|
||||
Uint8 g;
|
||||
Uint8 b;
|
||||
@@ -57,7 +58,8 @@ typedef struct tColorRGBA {
|
||||
/* !
|
||||
\brief A 8bit Y/palette pixel.
|
||||
*/
|
||||
typedef struct tColorY {
|
||||
typedef struct tColorY
|
||||
{
|
||||
Uint8 y;
|
||||
} tColorY;
|
||||
|
||||
@@ -76,8 +78,7 @@ to a situation where the program can segfault.
|
||||
/* !
|
||||
\brief Returns colorkey info for a surface
|
||||
*/
|
||||
static Uint32
|
||||
get_colorkey(SDL_Surface *src)
|
||||
static Uint32 get_colorkey(SDL_Surface *src)
|
||||
{
|
||||
Uint32 key = 0;
|
||||
if (SDL_HasColorKey(src)) {
|
||||
@@ -87,8 +88,8 @@ get_colorkey(SDL_Surface *src)
|
||||
}
|
||||
|
||||
/* rotate (sx, sy) by (angle, center) into (dx, dy) */
|
||||
static void
|
||||
rotate(double sx, double sy, double sinangle, double cosangle, const SDL_FPoint *center, double *dx, double *dy) {
|
||||
static void rotate(double sx, double sy, double sinangle, double cosangle, const SDL_FPoint *center, double *dx, double *dy)
|
||||
{
|
||||
sx -= center->x;
|
||||
sy -= center->y;
|
||||
|
||||
@@ -111,9 +112,8 @@ rotate(double sx, double sy, double sinangle, double cosangle, const SDL_FPoint
|
||||
\param sangle The cosine of the angle
|
||||
|
||||
*/
|
||||
void
|
||||
SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center,
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle)
|
||||
void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center,
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle)
|
||||
{
|
||||
int minx, maxx, miny, maxy;
|
||||
double radangle;
|
||||
@@ -129,16 +129,16 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP
|
||||
/*
|
||||
* Determine destination width and height by rotating a source box, at pixel center
|
||||
*/
|
||||
rotate(0.5, 0.5, sinangle, cosangle, center, &x0, &y0);
|
||||
rotate(width - 0.5, 0.5, sinangle, cosangle, center, &x1, &y1);
|
||||
rotate(0.5, height - 0.5, sinangle, cosangle, center, &x2, &y2);
|
||||
rotate(0.5, 0.5, sinangle, cosangle, center, &x0, &y0);
|
||||
rotate(width - 0.5, 0.5, sinangle, cosangle, center, &x1, &y1);
|
||||
rotate(0.5, height - 0.5, sinangle, cosangle, center, &x2, &y2);
|
||||
rotate(width - 0.5, height - 0.5, sinangle, cosangle, center, &x3, &y3);
|
||||
|
||||
minx = (int)SDL_floor( SDL_min( SDL_min(x0, x1), SDL_min(x2, x3) ) );
|
||||
maxx = (int)SDL_ceil( SDL_max( SDL_max(x0, x1), SDL_max(x2, x3) ) );
|
||||
minx = (int)SDL_floor(SDL_min(SDL_min(x0, x1), SDL_min(x2, x3)));
|
||||
maxx = (int)SDL_ceil(SDL_max(SDL_max(x0, x1), SDL_max(x2, x3)));
|
||||
|
||||
miny = (int)SDL_floor( SDL_min( SDL_min(y0, y1), SDL_min(y2, y3) ) );
|
||||
maxy = (int)SDL_ceil( SDL_max( SDL_max(y0, y1), SDL_max(y2, y3) ) );
|
||||
miny = (int)SDL_floor(SDL_min(SDL_min(y0, y1), SDL_min(y2, y3)));
|
||||
maxy = (int)SDL_ceil(SDL_max(SDL_max(y0, y1), SDL_max(y2, y3)));
|
||||
|
||||
rect_dest->w = maxx - minx;
|
||||
rect_dest->h = maxy - miny;
|
||||
@@ -151,20 +151,20 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP
|
||||
|
||||
{
|
||||
/* The trig code below gets the wrong size (due to FP inaccuracy?) when angle is a multiple of 90 degrees */
|
||||
int angle90 = (int)(angle/90);
|
||||
if (angle90 == angle/90) { /* if the angle is a multiple of 90 degrees */
|
||||
int angle90 = (int)(angle / 90);
|
||||
if (angle90 == angle / 90) { /* if the angle is a multiple of 90 degrees */
|
||||
angle90 %= 4;
|
||||
if (angle90 < 0) {
|
||||
angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
}
|
||||
|
||||
if (angle90 & 1) {
|
||||
rect_dest->w = height;
|
||||
rect_dest->w = height;
|
||||
rect_dest->h = width;
|
||||
*cangle = 0;
|
||||
*sangle = angle90 == 1 ? -1 : 1; /* reversed because our rotations are clockwise */
|
||||
} else {
|
||||
rect_dest->w = width;
|
||||
rect_dest->w = width;
|
||||
rect_dest->h = height;
|
||||
*cangle = angle90 == 0 ? 1 : -1;
|
||||
*sangle = 0;
|
||||
@@ -174,19 +174,37 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP
|
||||
}
|
||||
|
||||
/* Computes source pointer X/Y increments for a rotation that's a multiple of 90 degrees. */
|
||||
static void
|
||||
computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int flipy,
|
||||
int *sincx, int *sincy, int *signx, int *signy)
|
||||
static void computeSourceIncrements90(SDL_Surface *src, int bpp, int angle, int flipx, int flipy,
|
||||
int *sincx, int *sincy, int *signx, int *signy)
|
||||
{
|
||||
int pitch = flipy ? -src->pitch : src->pitch;
|
||||
if (flipx) {
|
||||
bpp = -bpp;
|
||||
}
|
||||
switch (angle) { /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
case 0: *sincx = bpp; *sincy = pitch - src->w * *sincx; *signx = *signy = 1; break;
|
||||
case 1: *sincx = -pitch; *sincy = bpp - *sincx * src->h; *signx = 1; *signy = -1; break;
|
||||
case 2: *sincx = -bpp; *sincy = -src->w * *sincx - pitch; *signx = *signy = -1; break;
|
||||
case 3: default: *sincx = pitch; *sincy = -*sincx * src->h - bpp; *signx = -1; *signy = 1; break;
|
||||
case 0:
|
||||
*sincx = bpp;
|
||||
*sincy = pitch - src->w * *sincx;
|
||||
*signx = *signy = 1;
|
||||
break;
|
||||
case 1:
|
||||
*sincx = -pitch;
|
||||
*sincy = bpp - *sincx * src->h;
|
||||
*signx = 1;
|
||||
*signy = -1;
|
||||
break;
|
||||
case 2:
|
||||
*sincx = -bpp;
|
||||
*sincy = -src->w * *sincx - pitch;
|
||||
*signx = *signy = -1;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
*sincx = pitch;
|
||||
*sincy = -*sincx * src->h - bpp;
|
||||
*signx = -1;
|
||||
*signy = 1;
|
||||
break;
|
||||
}
|
||||
if (flipx) {
|
||||
*signx = -*signx;
|
||||
@@ -197,34 +215,34 @@ computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int
|
||||
}
|
||||
|
||||
/* Performs a relatively fast rotation/flip when the angle is a multiple of 90 degrees. */
|
||||
#define TRANSFORM_SURFACE_90(pixelType) \
|
||||
int dy, dincy = dst->pitch - dst->w*sizeof(pixelType), sincx, sincy, signx, signy; \
|
||||
Uint8 *sp = (Uint8*)src->pixels, *dp = (Uint8*)dst->pixels, *de; \
|
||||
#define TRANSFORM_SURFACE_90(pixelType) \
|
||||
int dy, dincy = dst->pitch - dst->w * sizeof(pixelType), sincx, sincy, signx, signy; \
|
||||
Uint8 *sp = (Uint8 *)src->pixels, *dp = (Uint8 *)dst->pixels, *de; \
|
||||
\
|
||||
computeSourceIncrements90(src, sizeof(pixelType), angle, flipx, flipy, &sincx, &sincy, &signx, &signy); \
|
||||
if (signx < 0) sp += (src->w-1)*sizeof(pixelType); \
|
||||
if (signy < 0) sp += (src->h-1)*src->pitch; \
|
||||
if (signx < 0) \
|
||||
sp += (src->w - 1) * sizeof(pixelType); \
|
||||
if (signy < 0) \
|
||||
sp += (src->h - 1) * src->pitch; \
|
||||
\
|
||||
for (dy = 0; dy < dst->h; sp += sincy, dp += dincy, dy++) { \
|
||||
if (sincx == sizeof(pixelType)) { /* if advancing src and dest equally, use SDL_memcpy */ \
|
||||
SDL_memcpy(dp, sp, dst->w*sizeof(pixelType)); \
|
||||
sp += dst->w*sizeof(pixelType); \
|
||||
dp += dst->w*sizeof(pixelType); \
|
||||
SDL_memcpy(dp, sp, dst->w * sizeof(pixelType)); \
|
||||
sp += dst->w * sizeof(pixelType); \
|
||||
dp += dst->w * sizeof(pixelType); \
|
||||
} else { \
|
||||
for (de = dp + dst->w*sizeof(pixelType); dp != de; sp += sincx, dp += sizeof(pixelType)) { \
|
||||
*(pixelType*)dp = *(pixelType*)sp; \
|
||||
for (de = dp + dst->w * sizeof(pixelType); dp != de; sp += sincx, dp += sizeof(pixelType)) { \
|
||||
*(pixelType *)dp = *(pixelType *)sp; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
static void
|
||||
transformSurfaceRGBA90(SDL_Surface * src, SDL_Surface * dst, int angle, int flipx, int flipy)
|
||||
static void transformSurfaceRGBA90(SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy)
|
||||
{
|
||||
TRANSFORM_SURFACE_90(tColorRGBA);
|
||||
}
|
||||
|
||||
static void
|
||||
transformSurfaceY90(SDL_Surface * src, SDL_Surface * dst, int angle, int flipx, int flipy)
|
||||
static void transformSurfaceY90(SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy)
|
||||
{
|
||||
TRANSFORM_SURFACE_90(tColorY);
|
||||
}
|
||||
@@ -250,32 +268,31 @@ Assumes dst surface was allocated with the correct dimensions.
|
||||
\param dst_rect destination coordinates
|
||||
\param center true center.
|
||||
*/
|
||||
static void
|
||||
transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
int flipx, int flipy, int smooth,
|
||||
const SDL_Rect *rect_dest,
|
||||
const SDL_FPoint *center)
|
||||
static void transformSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int isin, int icos,
|
||||
int flipx, int flipy, int smooth,
|
||||
const SDL_Rect *rect_dest,
|
||||
const SDL_FPoint *center)
|
||||
{
|
||||
int sw, sh;
|
||||
int cx, cy;
|
||||
tColorRGBA c00, c01, c10, c11, cswap;
|
||||
tColorRGBA *pc, *sp;
|
||||
int gap;
|
||||
const int fp_half = (1<<15);
|
||||
const int fp_half = (1 << 15);
|
||||
|
||||
/*
|
||||
* Variable setup
|
||||
*/
|
||||
* Variable setup
|
||||
*/
|
||||
sw = src->w - 1;
|
||||
sh = src->h - 1;
|
||||
pc = (tColorRGBA*) dst->pixels;
|
||||
pc = (tColorRGBA *)dst->pixels;
|
||||
gap = dst->pitch - dst->w * 4;
|
||||
cx = (int)(center->x * 65536.0);
|
||||
cy = (int)(center->y * 65536.0);
|
||||
|
||||
/*
|
||||
* Switch between interpolating and non-interpolating code
|
||||
*/
|
||||
* Switch between interpolating and non-interpolating code
|
||||
*/
|
||||
if (smooth) {
|
||||
int y;
|
||||
for (y = 0; y < dst->h; y++) {
|
||||
@@ -293,28 +310,36 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
if (flipy) {
|
||||
dy = sh - dy;
|
||||
}
|
||||
if ((dx > -1) && (dy > -1) && (dx < (src->w-1)) && (dy < (src->h-1))) {
|
||||
if ((dx > -1) && (dy > -1) && (dx < (src->w - 1)) && (dy < (src->h - 1))) {
|
||||
int ex, ey;
|
||||
int t1, t2;
|
||||
sp = (tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy) + dx;
|
||||
sp = (tColorRGBA *)((Uint8 *)src->pixels + src->pitch * dy) + dx;
|
||||
c00 = *sp;
|
||||
sp += 1;
|
||||
c01 = *sp;
|
||||
sp += (src->pitch/4);
|
||||
sp += (src->pitch / 4);
|
||||
c11 = *sp;
|
||||
sp -= 1;
|
||||
c10 = *sp;
|
||||
if (flipx) {
|
||||
cswap = c00; c00=c01; c01=cswap;
|
||||
cswap = c10; c10=c11; c11=cswap;
|
||||
cswap = c00;
|
||||
c00 = c01;
|
||||
c01 = cswap;
|
||||
cswap = c10;
|
||||
c10 = c11;
|
||||
c11 = cswap;
|
||||
}
|
||||
if (flipy) {
|
||||
cswap = c00; c00=c10; c10=cswap;
|
||||
cswap = c01; c01=c11; c11=cswap;
|
||||
cswap = c00;
|
||||
c00 = c10;
|
||||
c10 = cswap;
|
||||
cswap = c01;
|
||||
c01 = c11;
|
||||
c11 = cswap;
|
||||
}
|
||||
/*
|
||||
* Interpolate colors
|
||||
*/
|
||||
* Interpolate colors
|
||||
*/
|
||||
ex = (sdx & 0xffff);
|
||||
ey = (sdy & 0xffff);
|
||||
t1 = ((((c01.r - c00.r) * ex) >> 16) + c00.r) & 0xff;
|
||||
@@ -334,7 +359,7 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
sdy += isin;
|
||||
pc++;
|
||||
}
|
||||
pc = (tColorRGBA *) ((Uint8 *) pc + gap);
|
||||
pc = (tColorRGBA *)((Uint8 *)pc + gap);
|
||||
}
|
||||
} else {
|
||||
int y;
|
||||
@@ -360,7 +385,7 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
sdy += isin;
|
||||
pc++;
|
||||
}
|
||||
pc = (tColorRGBA *) ((Uint8 *) pc + gap);
|
||||
pc = (tColorRGBA *)((Uint8 *)pc + gap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -383,35 +408,34 @@ Assumes dst surface was allocated with the correct dimensions.
|
||||
\param dst_rect destination coordinates
|
||||
\param center true center.
|
||||
*/
|
||||
static void
|
||||
transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int isin, int icos, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest,
|
||||
const SDL_FPoint *center)
|
||||
static void transformSurfaceY(SDL_Surface *src, SDL_Surface *dst, int isin, int icos, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest,
|
||||
const SDL_FPoint *center)
|
||||
{
|
||||
int sw, sh;
|
||||
int cx, cy;
|
||||
tColorY *pc;
|
||||
int gap;
|
||||
const int fp_half = (1<<15);
|
||||
const int fp_half = (1 << 15);
|
||||
int y;
|
||||
|
||||
/*
|
||||
* Variable setup
|
||||
*/
|
||||
* Variable setup
|
||||
*/
|
||||
sw = src->w - 1;
|
||||
sh = src->h - 1;
|
||||
pc = (tColorY*) dst->pixels;
|
||||
pc = (tColorY *)dst->pixels;
|
||||
gap = dst->pitch - dst->w;
|
||||
cx = (int)(center->x * 65536.0);
|
||||
cy = (int)(center->y * 65536.0);
|
||||
|
||||
/*
|
||||
* Clear surface to colorkey
|
||||
*/
|
||||
* Clear surface to colorkey
|
||||
*/
|
||||
SDL_memset(pc, (int)(get_colorkey(src) & 0xff), dst->pitch * dst->h);
|
||||
/*
|
||||
* Iterate through destination surface
|
||||
*/
|
||||
* Iterate through destination surface
|
||||
*/
|
||||
for (y = 0; y < dst->h; y++) {
|
||||
int x;
|
||||
double src_x = (rect_dest->x + 0 + 0.5 - center->x);
|
||||
@@ -438,7 +462,6 @@ transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int isin, int icos, int
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* !
|
||||
\brief Rotates and zooms a surface with different horizontal and vertival scaling factors and optional anti-aliasing.
|
||||
|
||||
@@ -466,8 +489,8 @@ When using the NONE and MOD modes, color and alpha modulation must be applied be
|
||||
*/
|
||||
|
||||
SDL_Surface *
|
||||
SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center)
|
||||
SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center)
|
||||
{
|
||||
SDL_Surface *rz_dst;
|
||||
int is8bit, angle90;
|
||||
@@ -494,8 +517,8 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
|
||||
}
|
||||
|
||||
/* Calculate target factors from sine/cosine and zoom */
|
||||
sangleinv = sangle*65536.0;
|
||||
cangleinv = cangle*65536.0;
|
||||
sangleinv = sangle * 65536.0;
|
||||
cangleinv = cangle * 65536.0;
|
||||
|
||||
/* Alloc space to completely contain the rotated surface */
|
||||
rz_dst = NULL;
|
||||
@@ -557,8 +580,8 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
|
||||
* the off-by-one problem in transformSurfaceRGBA that expresses itself when the rotation is near
|
||||
* multiples of 90 degrees.
|
||||
*/
|
||||
angle90 = (int)(angle/90);
|
||||
if (angle90 == angle/90) {
|
||||
angle90 = (int)(angle / 90);
|
||||
if (angle90 == angle / 90) {
|
||||
angle90 %= 4;
|
||||
if (angle90 < 0) {
|
||||
angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
@@ -582,7 +605,7 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
|
||||
transformSurfaceRGBA90(src, rz_dst, angle90, flipx, flipy);
|
||||
} else {
|
||||
transformSurfaceRGBA(src, rz_dst, (int)sangleinv, (int)cangleinv,
|
||||
flipx, flipy, smooth, rect_dest, center);
|
||||
flipx, flipy, smooth, rect_dest, center);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
#ifndef SDL_rotate_h_
|
||||
#define SDL_rotate_h_
|
||||
|
||||
extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center);
|
||||
extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center);
|
||||
extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center,
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle);
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle);
|
||||
|
||||
#endif /* SDL_rotate_h_ */
|
||||
|
||||
@@ -33,16 +33,15 @@
|
||||
* But, if increased too much, it overflows (srcx, srcy) coordinates used for filling with texture.
|
||||
* (which could be turned to int64).
|
||||
*/
|
||||
#define FP_BITS 1
|
||||
#define FP_BITS 1
|
||||
|
||||
#define COLOR_EQ(c1, c2) ((c1).r == (c2).r && (c1).g == (c2).g && (c1).b == (c2).b && (c1).a == (c2).a)
|
||||
|
||||
#define COLOR_EQ(c1, c2) ((c1).r == (c2).r && (c1).g == (c2).g && (c1).b == (c2).b && (c1).a == (c2).a)
|
||||
|
||||
static void SDL_BlitTriangle_Slow(SDL_BlitInfo * info,
|
||||
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
|
||||
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
|
||||
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform);
|
||||
static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
|
||||
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
|
||||
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform);
|
||||
|
||||
#if 0
|
||||
int SDL_BlitTriangle(SDL_Surface *src, const SDL_Point srcpoints[3], SDL_Surface *dst, const SDL_Point dstpoints[3])
|
||||
@@ -114,7 +113,8 @@ static int is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void trianglepoint_2_fixedpoint(SDL_Point *a) {
|
||||
void trianglepoint_2_fixedpoint(SDL_Point *a)
|
||||
{
|
||||
a->x <<= FP_BITS;
|
||||
a->y <<= FP_BITS;
|
||||
}
|
||||
@@ -146,7 +146,6 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin
|
||||
r->h = (max_y - min_y);
|
||||
}
|
||||
|
||||
|
||||
/* Triangle rendering, using Barycentric coordinates (w0, w1, w2)
|
||||
*
|
||||
* The cross product isn't computed from scratch at each iteration,
|
||||
@@ -154,53 +153,51 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin
|
||||
*
|
||||
*/
|
||||
|
||||
#define TRIANGLE_BEGIN_LOOP \
|
||||
{ \
|
||||
int x, y; \
|
||||
for (y = 0; y < dstrect.h; y++) { \
|
||||
/* y start */ \
|
||||
int w0 = w0_row; \
|
||||
int w1 = w1_row; \
|
||||
int w2 = w2_row; \
|
||||
for (x = 0; x < dstrect.w; x++) { \
|
||||
/* In triangle */ \
|
||||
if (w0 + bias_w0 >= 0 && w1 + bias_w1 >= 0 && w2 + bias_w2 >= 0) { \
|
||||
Uint8 *dptr = (Uint8 *) dst_ptr + x * dstbpp; \
|
||||
|
||||
#define TRIANGLE_BEGIN_LOOP \
|
||||
{ \
|
||||
int x, y; \
|
||||
for (y = 0; y < dstrect.h; y++) { \
|
||||
/* y start */ \
|
||||
int w0 = w0_row; \
|
||||
int w1 = w1_row; \
|
||||
int w2 = w2_row; \
|
||||
for (x = 0; x < dstrect.w; x++) { \
|
||||
/* In triangle */ \
|
||||
if (w0 + bias_w0 >= 0 && w1 + bias_w1 >= 0 && w2 + bias_w2 >= 0) { \
|
||||
Uint8 *dptr = (Uint8 *)dst_ptr + x * dstbpp;
|
||||
|
||||
/* Use 64 bits precision to prevent overflow when interpolating color / texture with wide triangles */
|
||||
#define TRIANGLE_GET_TEXTCOORD \
|
||||
int srcx = (int)(((Sint64)w0 * s2s0_x + (Sint64)w1 * s2s1_x + s2_x_area.x) / area); \
|
||||
int srcy = (int)(((Sint64)w0 * s2s0_y + (Sint64)w1 * s2s1_y + s2_x_area.y) / area); \
|
||||
#define TRIANGLE_GET_TEXTCOORD \
|
||||
int srcx = (int)(((Sint64)w0 * s2s0_x + (Sint64)w1 * s2s1_x + s2_x_area.x) / area); \
|
||||
int srcy = (int)(((Sint64)w0 * s2s0_y + (Sint64)w1 * s2s1_y + s2_x_area.y) / area);
|
||||
|
||||
#define TRIANGLE_GET_MAPPED_COLOR \
|
||||
int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \
|
||||
int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \
|
||||
int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \
|
||||
int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); \
|
||||
int color = SDL_MapRGBA(format, r, g, b, a); \
|
||||
#define TRIANGLE_GET_MAPPED_COLOR \
|
||||
int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \
|
||||
int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \
|
||||
int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \
|
||||
int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); \
|
||||
int color = SDL_MapRGBA(format, r, g, b, a);
|
||||
|
||||
#define TRIANGLE_GET_COLOR \
|
||||
int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \
|
||||
int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \
|
||||
int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \
|
||||
int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); \
|
||||
#define TRIANGLE_GET_COLOR \
|
||||
int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \
|
||||
int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \
|
||||
int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \
|
||||
int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area);
|
||||
|
||||
|
||||
#define TRIANGLE_END_LOOP \
|
||||
} \
|
||||
/* x += 1 */ \
|
||||
w0 += d2d1_y; \
|
||||
w1 += d0d2_y; \
|
||||
w2 += d1d0_y; \
|
||||
} \
|
||||
/* y += 1 */ \
|
||||
w0_row += d1d2_x; \
|
||||
w1_row += d2d0_x; \
|
||||
w2_row += d0d1_x; \
|
||||
dst_ptr += dst_pitch; \
|
||||
} \
|
||||
} \
|
||||
#define TRIANGLE_END_LOOP \
|
||||
} \
|
||||
/* x += 1 */ \
|
||||
w0 += d2d1_y; \
|
||||
w1 += d0d2_y; \
|
||||
w2 += d1d0_y; \
|
||||
} \
|
||||
/* y += 1 */ \
|
||||
w0_row += d1d2_x; \
|
||||
w1_row += d2d0_x; \
|
||||
w2_row += d0d1_x; \
|
||||
dst_ptr += dst_pitch; \
|
||||
} \
|
||||
}
|
||||
|
||||
int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2)
|
||||
{
|
||||
@@ -265,12 +262,11 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
SDL_IntersectRect(&dstrect, &rect, &dstrect);
|
||||
}
|
||||
|
||||
|
||||
if (blend != SDL_BLENDMODE_NONE) {
|
||||
int format = dst->format->format;
|
||||
|
||||
/* need an alpha format */
|
||||
if (! dst->format->Amask) {
|
||||
if (!dst->format->Amask) {
|
||||
format = SDL_PIXELFORMAT_ARGB8888;
|
||||
}
|
||||
|
||||
@@ -323,7 +319,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
}
|
||||
|
||||
/* Handle anti-clockwise triangles */
|
||||
if (! is_clockwise) {
|
||||
if (!is_clockwise) {
|
||||
d2d1_y *= -1;
|
||||
d0d2_y *= -1;
|
||||
d1d0_y *= -1;
|
||||
@@ -346,7 +342,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
if (dst->format->Amask) {
|
||||
color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a);
|
||||
} else {
|
||||
//color = SDL_MapRGB(tmp->format, c0.r, c0.g, c0.b);
|
||||
// color = SDL_MapRGB(tmp->format, c0.r, c0.g, c0.b);
|
||||
color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a);
|
||||
}
|
||||
} else {
|
||||
@@ -362,7 +358,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
} else if (dstbpp == 3) {
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
Uint8 *s = (Uint8*)&color;
|
||||
Uint8 *s = (Uint8 *)&color;
|
||||
dptr[0] = s[0];
|
||||
dptr[1] = s[1];
|
||||
dptr[2] = s[2];
|
||||
@@ -397,7 +393,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_MAPPED_COLOR
|
||||
Uint8 *s = (Uint8*)&color;
|
||||
Uint8 *s = (Uint8 *)&color;
|
||||
dptr[0] = s[0];
|
||||
dptr[1] = s[1];
|
||||
dptr[2] = s[2];
|
||||
@@ -433,18 +429,12 @@ end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int SDL_SW_BlitTriangle(
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2)
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2)
|
||||
{
|
||||
int ret = 0;
|
||||
int src_locked = 0;
|
||||
@@ -584,7 +574,6 @@ int SDL_SW_BlitTriangle(
|
||||
d0d2_y = (d2->y - d0->y) << FP_BITS;
|
||||
d1d0_y = (d0->y - d1->y) << FP_BITS;
|
||||
|
||||
|
||||
d1d2_x = (d2->x - d1->x) << FP_BITS;
|
||||
d2d0_x = (d0->x - d2->x) << FP_BITS;
|
||||
d0d1_x = (d1->x - d0->x) << FP_BITS;
|
||||
@@ -608,7 +597,7 @@ int SDL_SW_BlitTriangle(
|
||||
}
|
||||
|
||||
/* Handle anti-clockwise triangles */
|
||||
if (! is_clockwise) {
|
||||
if (!is_clockwise) {
|
||||
d2d1_y *= -1;
|
||||
d0d2_y *= -1;
|
||||
d1d0_y *= -1;
|
||||
@@ -629,7 +618,7 @@ int SDL_SW_BlitTriangle(
|
||||
s2_x_area.x = s2->x * area;
|
||||
s2_x_area.y = s2->y * area;
|
||||
|
||||
if (blend != SDL_BLENDMODE_NONE || src->format->format != dst->format->format || has_modulation || ! is_uniform) {
|
||||
if (blend != SDL_BLENDMODE_NONE || src->format->format != dst->format->format || has_modulation || !is_uniform) {
|
||||
/* Use SDL_BlitTriangle_Slow */
|
||||
|
||||
SDL_BlitInfo *info = &src->map->info;
|
||||
@@ -651,12 +640,11 @@ int SDL_SW_BlitTriangle(
|
||||
tmp_info.b = c0.b;
|
||||
tmp_info.a = c0.a;
|
||||
|
||||
|
||||
tmp_info.flags &= ~(SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA);
|
||||
|
||||
if (c0.r != 255 || c1.r != 255 || c2.r != 255 ||
|
||||
c0.g != 255 || c1.g != 255 || c2.g != 255 ||
|
||||
c0.b != 255 || c1.b != 255 || c2.b != 255) {
|
||||
if (c0.r != 255 || c1.r != 255 || c2.r != 255 ||
|
||||
c0.g != 255 || c1.g != 255 || c2.g != 255 ||
|
||||
c0.b != 255 || c1.b != 255 || c2.b != 255) {
|
||||
tmp_info.flags |= SDL_COPY_MODULATE_COLOR;
|
||||
}
|
||||
|
||||
@@ -667,17 +655,17 @@ int SDL_SW_BlitTriangle(
|
||||
tmp_info.colorkey = info->colorkey;
|
||||
|
||||
/* src */
|
||||
tmp_info.src = (Uint8 *) src_ptr;
|
||||
tmp_info.src = (Uint8 *)src_ptr;
|
||||
tmp_info.src_pitch = src_pitch;
|
||||
|
||||
/* dst */
|
||||
tmp_info.dst = (Uint8 *) dst_ptr;
|
||||
tmp_info.dst = (Uint8 *)dst_ptr;
|
||||
tmp_info.dst_pitch = dst_pitch;
|
||||
|
||||
SDL_BlitTriangle_Slow(&tmp_info, s2_x_area, dstrect, area, bias_w0, bias_w1, bias_w2,
|
||||
d2d1_y, d1d2_x, d0d2_y, d2d0_x, d1d0_y, d0d1_x,
|
||||
s2s0_x, s2s1_x, s2s0_y, s2s1_y, w0_row, w1_row, w2_row,
|
||||
c0, c1, c2, is_uniform);
|
||||
d2d1_y, d1d2_x, d0d2_y, d2d0_x, d1d0_y, d0d1_x,
|
||||
s2s0_x, s2s1_x, s2s0_y, s2s1_y, w0_row, w1_row, w2_row,
|
||||
c0, c1, c2, is_uniform);
|
||||
|
||||
goto end;
|
||||
}
|
||||
@@ -686,7 +674,7 @@ int SDL_SW_BlitTriangle(
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_TEXTCOORD
|
||||
Uint32 *sptr = (Uint32 *)((Uint8 *) src_ptr + srcy * src_pitch);
|
||||
Uint32 *sptr = (Uint32 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
||||
*(Uint32 *)dptr = sptr[srcx];
|
||||
}
|
||||
TRIANGLE_END_LOOP
|
||||
@@ -694,7 +682,7 @@ int SDL_SW_BlitTriangle(
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_TEXTCOORD
|
||||
Uint8 *sptr = (Uint8 *)((Uint8 *) src_ptr + srcy * src_pitch);
|
||||
Uint8 *sptr = (Uint8 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
||||
dptr[0] = sptr[3 * srcx];
|
||||
dptr[1] = sptr[3 * srcx + 1];
|
||||
dptr[2] = sptr[3 * srcx + 2];
|
||||
@@ -704,7 +692,7 @@ int SDL_SW_BlitTriangle(
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_TEXTCOORD
|
||||
Uint16 *sptr = (Uint16 *)((Uint8 *) src_ptr + srcy * src_pitch);
|
||||
Uint16 *sptr = (Uint16 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
||||
*(Uint16 *)dptr = sptr[srcx];
|
||||
}
|
||||
TRIANGLE_END_LOOP
|
||||
@@ -712,7 +700,7 @@ int SDL_SW_BlitTriangle(
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_TEXTCOORD
|
||||
Uint8 *sptr = (Uint8 *)((Uint8 *) src_ptr + srcy * src_pitch);
|
||||
Uint8 *sptr = (Uint8 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
||||
*dptr = sptr[srcx];
|
||||
}
|
||||
TRIANGLE_END_LOOP
|
||||
@@ -729,13 +717,13 @@ end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#define FORMAT_ALPHA 0
|
||||
#define FORMAT_NO_ALPHA -1
|
||||
#define FORMAT_2101010 1
|
||||
#define FORMAT_HAS_ALPHA(format) format == 0
|
||||
#define FORMAT_HAS_NO_ALPHA(format) format < 0
|
||||
static int SDL_INLINE detect_format(SDL_PixelFormat *pf) {
|
||||
#define FORMAT_ALPHA 0
|
||||
#define FORMAT_NO_ALPHA -1
|
||||
#define FORMAT_2101010 1
|
||||
#define FORMAT_HAS_ALPHA(format) format == 0
|
||||
#define FORMAT_HAS_NO_ALPHA(format) format < 0
|
||||
static int SDL_INLINE detect_format(SDL_PixelFormat *pf)
|
||||
{
|
||||
if (pf->format == SDL_PIXELFORMAT_ARGB2101010) {
|
||||
return FORMAT_2101010;
|
||||
} else if (pf->Amask) {
|
||||
@@ -745,12 +733,11 @@ static int SDL_INLINE detect_format(SDL_PixelFormat *pf) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
|
||||
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
|
||||
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform)
|
||||
static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
|
||||
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
|
||||
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform)
|
||||
{
|
||||
const int flags = info->flags;
|
||||
Uint32 modulateR = info->r;
|
||||
@@ -796,7 +783,7 @@ SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
/* srcpixel isn't set for 24 bpp */
|
||||
if (srcbpp == 3) {
|
||||
srcpixel = (srcR << src_fmt->Rshift) |
|
||||
(srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift);
|
||||
(srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift);
|
||||
}
|
||||
if ((srcpixel & rgbmask) == ckey) {
|
||||
continue;
|
||||
@@ -813,7 +800,7 @@ SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA);
|
||||
}
|
||||
|
||||
if (! is_uniform) {
|
||||
if (!is_uniform) {
|
||||
TRIANGLE_GET_COLOR
|
||||
modulateR = r;
|
||||
modulateG = g;
|
||||
|
||||
@@ -25,15 +25,15 @@
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
extern int SDL_SW_FillTriangle(SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
|
||||
extern int SDL_SW_BlitTriangle(
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
|
||||
extern void trianglepoint_2_fixedpoint(SDL_Point *a);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31,9 +31,9 @@ vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignment, uns
|
||||
void *mem;
|
||||
|
||||
if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) {
|
||||
size = ALIGN(size, 256*1024);
|
||||
size = ALIGN(size, 256 * 1024);
|
||||
} else {
|
||||
size = ALIGN(size, 4*1024);
|
||||
size = ALIGN(size, 4 * 1024);
|
||||
}
|
||||
|
||||
*uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL);
|
||||
@@ -53,8 +53,7 @@ vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignment, uns
|
||||
return mem;
|
||||
}
|
||||
|
||||
void
|
||||
vita_mem_free(SceUID uid)
|
||||
void vita_mem_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
@@ -76,9 +75,9 @@ vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size)
|
||||
info.size = sizeof(SceKernelFreeMemorySizeInfo);
|
||||
sceKernelGetFreeMemorySize(&info);
|
||||
|
||||
poolsize = ALIGN(info.size_cdram, 256*1024);
|
||||
poolsize = ALIGN(info.size_cdram, 256 * 1024);
|
||||
if (poolsize > info.size_cdram) {
|
||||
poolsize = ALIGN(info.size_cdram - 256*1024, 256*1024);
|
||||
poolsize = ALIGN(info.size_cdram - 256 * 1024, 256 * 1024);
|
||||
}
|
||||
data->texturePoolUID = sceKernelAllocMemBlock("gpu_texture_pool", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, poolsize, NULL);
|
||||
if (data->texturePoolUID < 0) {
|
||||
@@ -86,7 +85,7 @@ vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size)
|
||||
}
|
||||
|
||||
ret = sceKernelGetMemBlockBase(data->texturePoolUID, &mem);
|
||||
if ( ret < 0) {
|
||||
if (ret < 0) {
|
||||
return NULL;
|
||||
}
|
||||
data->texturePool = sceClibMspaceCreate(mem, poolsize);
|
||||
@@ -102,16 +101,14 @@ vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size)
|
||||
return sceClibMspaceMemalign(data->texturePool, SCE_GXM_TEXTURE_ALIGNMENT, size);
|
||||
}
|
||||
|
||||
void
|
||||
vita_gpu_mem_free(VITA_GXM_RenderData *data, void* ptr)
|
||||
void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr)
|
||||
{
|
||||
if (data->texturePool != NULL) {
|
||||
sceClibMspaceFree(data->texturePool, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vita_gpu_mem_destroy(VITA_GXM_RenderData *data)
|
||||
void vita_gpu_mem_destroy(VITA_GXM_RenderData *data)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (data->texturePool != NULL) {
|
||||
@@ -143,8 +140,7 @@ vita_mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_of
|
||||
return mem;
|
||||
}
|
||||
|
||||
void
|
||||
vita_mem_vertex_usse_free(SceUID uid)
|
||||
void vita_mem_vertex_usse_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
@@ -172,8 +168,7 @@ vita_mem_fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_
|
||||
return mem;
|
||||
}
|
||||
|
||||
void
|
||||
vita_mem_fragment_usse_free(SceUID uid)
|
||||
void vita_mem_fragment_usse_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
#include <psp2/kernel/sysmem.h>
|
||||
#include "SDL_render_vita_gxm_types.h"
|
||||
|
||||
#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
|
||||
#define ALIGN(x, a) (((x) + ((a)-1)) & ~((a)-1))
|
||||
|
||||
void *vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignment, unsigned int attribs, SceUID *uid);
|
||||
void vita_mem_free(SceUID uid);
|
||||
void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size);
|
||||
void vita_gpu_mem_free(VITA_GXM_RenderData *data, void* ptr);
|
||||
void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr);
|
||||
void vita_gpu_mem_destroy(VITA_GXM_RenderData *data);
|
||||
void *vita_mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset);
|
||||
void vita_mem_vertex_usse_free(SceUID uid);
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include <psp2/gxm.h>
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
||||
#define gxm_shader_clear_f_size 232
|
||||
static const unsigned char gxm_shader_clear_f[gxm_shader_clear_f_size] = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
|
||||
@@ -268,12 +270,14 @@ static const unsigned char gxm_shader_texture_v[gxm_shader_texture_v_size] = {
|
||||
0x6f, 0x72, 0x00, 0x77, 0x76, 0x70, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static const SceGxmProgram *const clearVertexProgramGxp = (const SceGxmProgram *)gxm_shader_clear_v;
|
||||
static const SceGxmProgram *const clearFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_clear_f;
|
||||
static const SceGxmProgram *const colorVertexProgramGxp = (const SceGxmProgram *)gxm_shader_color_v;
|
||||
static const SceGxmProgram *const colorFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_color_f;
|
||||
static const SceGxmProgram *const textureVertexProgramGxp = (const SceGxmProgram *)gxm_shader_texture_v;
|
||||
static const SceGxmProgram *const textureFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_f;
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
static const SceGxmProgram *const clearVertexProgramGxp = (const SceGxmProgram *)gxm_shader_clear_v;
|
||||
static const SceGxmProgram *const clearFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_clear_f;
|
||||
static const SceGxmProgram *const colorVertexProgramGxp = (const SceGxmProgram *)gxm_shader_color_v;
|
||||
static const SceGxmProgram *const colorFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_color_f;
|
||||
static const SceGxmProgram *const textureVertexProgramGxp = (const SceGxmProgram *)gxm_shader_texture_v;
|
||||
static const SceGxmProgram *const textureFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_f;
|
||||
|
||||
#endif // SDL_RENDER_VITA_GXM_SHADERS_H
|
||||
|
||||
|
||||
@@ -45,23 +45,22 @@
|
||||
#include "SDL_render_vita_gxm_memory.h"
|
||||
#include "SDL_render_vita_gxm_shaders.h"
|
||||
|
||||
void
|
||||
init_orthographic_matrix(float *m, float left, float right, float bottom, float top, float near, float far)
|
||||
void init_orthographic_matrix(float *m, float left, float right, float bottom, float top, float near, float far)
|
||||
{
|
||||
m[0x0] = 2.0f/(right-left);
|
||||
m[0x0] = 2.0f / (right - left);
|
||||
m[0x4] = 0.0f;
|
||||
m[0x8] = 0.0f;
|
||||
m[0xC] = -(right+left)/(right-left);
|
||||
m[0xC] = -(right + left) / (right - left);
|
||||
|
||||
m[0x1] = 0.0f;
|
||||
m[0x5] = 2.0f/(top-bottom);
|
||||
m[0x5] = 2.0f / (top - bottom);
|
||||
m[0x9] = 0.0f;
|
||||
m[0xD] = -(top+bottom)/(top-bottom);
|
||||
m[0xD] = -(top + bottom) / (top - bottom);
|
||||
|
||||
m[0x2] = 0.0f;
|
||||
m[0x6] = 0.0f;
|
||||
m[0xA] = -2.0f/(far-near);
|
||||
m[0xE] = (far+near)/(far-near);
|
||||
m[0xA] = -2.0f / (far - near);
|
||||
m[0xE] = (far + near) / (far - near);
|
||||
|
||||
m[0x3] = 0.0f;
|
||||
m[0x7] = 0.0f;
|
||||
@@ -69,16 +68,14 @@ init_orthographic_matrix(float *m, float left, float right, float bottom, float
|
||||
m[0xF] = 1.0f;
|
||||
}
|
||||
|
||||
static void *
|
||||
patcher_host_alloc(void *user_data, unsigned int size)
|
||||
static void *patcher_host_alloc(void *user_data, unsigned int size)
|
||||
{
|
||||
void *mem = SDL_malloc(size);
|
||||
(void)user_data;
|
||||
return mem;
|
||||
}
|
||||
|
||||
static void
|
||||
patcher_host_free(void *user_data, void *mem)
|
||||
static void patcher_host_free(void *user_data, void *mem)
|
||||
{
|
||||
(void)user_data;
|
||||
SDL_free(mem);
|
||||
@@ -110,8 +107,7 @@ pool_memalign(VITA_GXM_RenderData *data, unsigned int size, unsigned int alignme
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
tex_format_to_bytespp(SceGxmTextureFormat format)
|
||||
static int tex_format_to_bytespp(SceGxmTextureFormat format)
|
||||
{
|
||||
switch (format & 0x9f000000U) {
|
||||
case SCE_GXM_TEXTURE_BASE_FORMAT_U8:
|
||||
@@ -141,19 +137,18 @@ tex_format_to_bytespp(SceGxmTextureFormat format)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
display_callback(const void *callback_data)
|
||||
static void display_callback(const void *callback_data)
|
||||
{
|
||||
SceDisplayFrameBuf framebuf;
|
||||
const VITA_GXM_DisplayData *display_data = (const VITA_GXM_DisplayData *)callback_data;
|
||||
|
||||
SDL_memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf));
|
||||
framebuf.size = sizeof(SceDisplayFrameBuf);
|
||||
framebuf.base = display_data->address;
|
||||
framebuf.pitch = VITA_GXM_SCREEN_STRIDE;
|
||||
framebuf.size = sizeof(SceDisplayFrameBuf);
|
||||
framebuf.base = display_data->address;
|
||||
framebuf.pitch = VITA_GXM_SCREEN_STRIDE;
|
||||
framebuf.pixelformat = VITA_GXM_PIXEL_FORMAT;
|
||||
framebuf.width = VITA_GXM_SCREEN_WIDTH;
|
||||
framebuf.height = VITA_GXM_SCREEN_HEIGHT;
|
||||
framebuf.width = VITA_GXM_SCREEN_WIDTH;
|
||||
framebuf.height = VITA_GXM_SCREEN_HEIGHT;
|
||||
sceDisplaySetFrameBuf(&framebuf, SCE_DISPLAY_SETBUF_NEXTFRAME);
|
||||
|
||||
if (display_data->wait_vblank) {
|
||||
@@ -161,16 +156,14 @@ display_callback(const void *callback_data)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
free_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out)
|
||||
static void free_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out)
|
||||
{
|
||||
sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, out->color);
|
||||
sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, out->texture);
|
||||
}
|
||||
|
||||
static void
|
||||
make_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out,
|
||||
const SceGxmBlendInfo *blend_info)
|
||||
static void make_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out,
|
||||
const SceGxmBlendInfo *blend_info)
|
||||
{
|
||||
int err;
|
||||
|
||||
@@ -181,8 +174,7 @@ make_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out,
|
||||
0,
|
||||
blend_info,
|
||||
colorVertexProgramGxp,
|
||||
&out->color
|
||||
);
|
||||
&out->color);
|
||||
|
||||
if (err != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Patcher create fragment failed: %d\n", err);
|
||||
@@ -196,8 +188,7 @@ make_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out,
|
||||
0,
|
||||
blend_info,
|
||||
textureVertexProgramGxp,
|
||||
&out->texture
|
||||
);
|
||||
&out->texture);
|
||||
|
||||
if (err != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Patcher create fragment failed: %d\n", err);
|
||||
@@ -205,16 +196,13 @@ make_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_stencil_mask(VITA_GXM_RenderData *data, float x, float y, float w, float h)
|
||||
static void set_stencil_mask(VITA_GXM_RenderData *data, float x, float y, float w, float h)
|
||||
{
|
||||
void *vertexDefaultBuffer;
|
||||
color_vertex *vertices = (color_vertex *)pool_memalign(
|
||||
data,
|
||||
4 * sizeof(color_vertex), // 4 vertices
|
||||
sizeof(color_vertex)
|
||||
);
|
||||
sizeof(color_vertex));
|
||||
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
@@ -256,9 +244,7 @@ set_stencil_mask(VITA_GXM_RenderData *data, float x, float y, float w, float h)
|
||||
sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, 4);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, int y_max)
|
||||
void set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, int y_max)
|
||||
{
|
||||
if (data->drawing) {
|
||||
// clear the stencil buffer to 0
|
||||
@@ -269,8 +255,7 @@ set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, i
|
||||
SCE_GXM_STENCIL_OP_ZERO,
|
||||
SCE_GXM_STENCIL_OP_ZERO,
|
||||
0xFF,
|
||||
0xFF
|
||||
);
|
||||
0xFF);
|
||||
|
||||
set_stencil_mask(data, 0, 0, VITA_GXM_SCREEN_WIDTH, VITA_GXM_SCREEN_HEIGHT);
|
||||
|
||||
@@ -282,8 +267,7 @@ set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, i
|
||||
SCE_GXM_STENCIL_OP_REPLACE,
|
||||
SCE_GXM_STENCIL_OP_REPLACE,
|
||||
0xFF,
|
||||
0xFF
|
||||
);
|
||||
0xFF);
|
||||
|
||||
set_stencil_mask(data, x_min, y_min, x_max - x_min, y_max - y_min);
|
||||
|
||||
@@ -295,13 +279,11 @@ set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, i
|
||||
SCE_GXM_STENCIL_OP_KEEP,
|
||||
SCE_GXM_STENCIL_OP_KEEP,
|
||||
0xFF,
|
||||
0xFF
|
||||
);
|
||||
0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
unset_clip_rectangle(VITA_GXM_RenderData *data)
|
||||
void unset_clip_rectangle(VITA_GXM_RenderData *data)
|
||||
{
|
||||
sceGxmSetFrontStencilFunc(
|
||||
data->gxm_context,
|
||||
@@ -310,12 +292,10 @@ unset_clip_rectangle(VITA_GXM_RenderData *data)
|
||||
SCE_GXM_STENCIL_OP_KEEP,
|
||||
SCE_GXM_STENCIL_OP_KEEP,
|
||||
0xFF,
|
||||
0xFF
|
||||
);
|
||||
0xFF);
|
||||
}
|
||||
|
||||
int
|
||||
gxm_init(SDL_Renderer *renderer)
|
||||
int gxm_init(SDL_Renderer *renderer)
|
||||
{
|
||||
unsigned int i, x, y;
|
||||
int err;
|
||||
@@ -341,38 +321,38 @@ gxm_init(SDL_Renderer *renderer)
|
||||
unsigned int depthStrideInSamples = alignedWidth;
|
||||
|
||||
// set buffer sizes for this sample
|
||||
const unsigned int patcherBufferSize = 64*1024;
|
||||
const unsigned int patcherVertexUsseSize = 64*1024;
|
||||
const unsigned int patcherFragmentUsseSize = 64*1024;
|
||||
const unsigned int patcherBufferSize = 64 * 1024;
|
||||
const unsigned int patcherVertexUsseSize = 64 * 1024;
|
||||
const unsigned int patcherFragmentUsseSize = 64 * 1024;
|
||||
|
||||
// Fill SceGxmBlendInfo
|
||||
static const SceGxmBlendInfo blend_info_none = {
|
||||
.colorFunc = SCE_GXM_BLEND_FUNC_NONE,
|
||||
.alphaFunc = SCE_GXM_BLEND_FUNC_NONE,
|
||||
.colorSrc = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.colorDst = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.alphaDst = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.colorSrc = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.colorDst = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.alphaDst = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.colorMask = SCE_GXM_COLOR_MASK_ALL
|
||||
};
|
||||
|
||||
static const SceGxmBlendInfo blend_info_blend = {
|
||||
.colorFunc = SCE_GXM_BLEND_FUNC_ADD,
|
||||
.alphaFunc = SCE_GXM_BLEND_FUNC_ADD,
|
||||
.colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA,
|
||||
.colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
||||
.alphaSrc = SCE_GXM_BLEND_FACTOR_ONE,
|
||||
.alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
||||
.colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA,
|
||||
.colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
||||
.alphaSrc = SCE_GXM_BLEND_FACTOR_ONE,
|
||||
.alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
||||
.colorMask = SCE_GXM_COLOR_MASK_ALL
|
||||
};
|
||||
|
||||
static const SceGxmBlendInfo blend_info_add = {
|
||||
.colorFunc = SCE_GXM_BLEND_FUNC_ADD,
|
||||
.alphaFunc = SCE_GXM_BLEND_FUNC_ADD,
|
||||
.colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA,
|
||||
.colorDst = SCE_GXM_BLEND_FACTOR_ONE,
|
||||
.alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.alphaDst = SCE_GXM_BLEND_FACTOR_ONE,
|
||||
.colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA,
|
||||
.colorDst = SCE_GXM_BLEND_FACTOR_ONE,
|
||||
.alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.alphaDst = SCE_GXM_BLEND_FACTOR_ONE,
|
||||
.colorMask = SCE_GXM_COLOR_MASK_ALL
|
||||
};
|
||||
|
||||
@@ -380,33 +360,33 @@ gxm_init(SDL_Renderer *renderer)
|
||||
.colorFunc = SCE_GXM_BLEND_FUNC_ADD,
|
||||
.alphaFunc = SCE_GXM_BLEND_FUNC_ADD,
|
||||
|
||||
.colorSrc = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.colorDst = SCE_GXM_BLEND_FACTOR_SRC_COLOR,
|
||||
.colorSrc = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.colorDst = SCE_GXM_BLEND_FACTOR_SRC_COLOR,
|
||||
|
||||
.alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.alphaDst = SCE_GXM_BLEND_FACTOR_ONE,
|
||||
.alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO,
|
||||
.alphaDst = SCE_GXM_BLEND_FACTOR_ONE,
|
||||
.colorMask = SCE_GXM_COLOR_MASK_ALL
|
||||
};
|
||||
|
||||
static const SceGxmBlendInfo blend_info_mul = {
|
||||
.colorFunc = SCE_GXM_BLEND_FUNC_ADD,
|
||||
.alphaFunc = SCE_GXM_BLEND_FUNC_ADD,
|
||||
.colorSrc = SCE_GXM_BLEND_FACTOR_DST_COLOR,
|
||||
.colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
||||
.alphaSrc = SCE_GXM_BLEND_FACTOR_DST_ALPHA,
|
||||
.alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
||||
.colorSrc = SCE_GXM_BLEND_FACTOR_DST_COLOR,
|
||||
.colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
||||
.alphaSrc = SCE_GXM_BLEND_FACTOR_DST_ALPHA,
|
||||
.alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
||||
.colorMask = SCE_GXM_COLOR_MASK_ALL
|
||||
};
|
||||
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata;
|
||||
|
||||
SceGxmInitializeParams initializeParams;
|
||||
SDL_memset(&initializeParams, 0, sizeof(SceGxmInitializeParams));
|
||||
initializeParams.flags = 0;
|
||||
initializeParams.displayQueueMaxPendingCount = VITA_GXM_PENDING_SWAPS;
|
||||
initializeParams.displayQueueCallback = display_callback;
|
||||
initializeParams.displayQueueCallbackDataSize = sizeof(VITA_GXM_DisplayData);
|
||||
initializeParams.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE;
|
||||
initializeParams.flags = 0;
|
||||
initializeParams.displayQueueMaxPendingCount = VITA_GXM_PENDING_SWAPS;
|
||||
initializeParams.displayQueueCallback = display_callback;
|
||||
initializeParams.displayQueueCallbackDataSize = sizeof(VITA_GXM_DisplayData);
|
||||
initializeParams.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE;
|
||||
|
||||
err = sceGxmInitialize(&initializeParams);
|
||||
|
||||
@@ -443,17 +423,17 @@ gxm_init(SDL_Renderer *renderer)
|
||||
&fragmentUsseRingBufferOffset);
|
||||
|
||||
SDL_memset(&data->contextParams, 0, sizeof(SceGxmContextParams));
|
||||
data->contextParams.hostMem = SDL_malloc(SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE);
|
||||
data->contextParams.hostMemSize = SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE;
|
||||
data->contextParams.vdmRingBufferMem = vdmRingBuffer;
|
||||
data->contextParams.vdmRingBufferMemSize = SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE;
|
||||
data->contextParams.vertexRingBufferMem = vertexRingBuffer;
|
||||
data->contextParams.vertexRingBufferMemSize = SCE_GXM_DEFAULT_VERTEX_RING_BUFFER_SIZE;
|
||||
data->contextParams.fragmentRingBufferMem = fragmentRingBuffer;
|
||||
data->contextParams.fragmentRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_RING_BUFFER_SIZE;
|
||||
data->contextParams.fragmentUsseRingBufferMem = fragmentUsseRingBuffer;
|
||||
data->contextParams.hostMem = SDL_malloc(SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE);
|
||||
data->contextParams.hostMemSize = SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE;
|
||||
data->contextParams.vdmRingBufferMem = vdmRingBuffer;
|
||||
data->contextParams.vdmRingBufferMemSize = SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE;
|
||||
data->contextParams.vertexRingBufferMem = vertexRingBuffer;
|
||||
data->contextParams.vertexRingBufferMemSize = SCE_GXM_DEFAULT_VERTEX_RING_BUFFER_SIZE;
|
||||
data->contextParams.fragmentRingBufferMem = fragmentRingBuffer;
|
||||
data->contextParams.fragmentRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_RING_BUFFER_SIZE;
|
||||
data->contextParams.fragmentUsseRingBufferMem = fragmentUsseRingBuffer;
|
||||
data->contextParams.fragmentUsseRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE;
|
||||
data->contextParams.fragmentUsseRingBufferOffset = fragmentUsseRingBufferOffset;
|
||||
data->contextParams.fragmentUsseRingBufferOffset = fragmentUsseRingBufferOffset;
|
||||
|
||||
err = sceGxmCreateContext(&data->contextParams, &data->gxm_context);
|
||||
if (err != 0) {
|
||||
@@ -463,13 +443,13 @@ gxm_init(SDL_Renderer *renderer)
|
||||
|
||||
// set up parameters
|
||||
SDL_memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams));
|
||||
renderTargetParams.flags = 0;
|
||||
renderTargetParams.width = VITA_GXM_SCREEN_WIDTH;
|
||||
renderTargetParams.height = VITA_GXM_SCREEN_HEIGHT;
|
||||
renderTargetParams.scenesPerFrame = 1;
|
||||
renderTargetParams.multisampleMode = 0;
|
||||
renderTargetParams.flags = 0;
|
||||
renderTargetParams.width = VITA_GXM_SCREEN_WIDTH;
|
||||
renderTargetParams.height = VITA_GXM_SCREEN_HEIGHT;
|
||||
renderTargetParams.scenesPerFrame = 1;
|
||||
renderTargetParams.multisampleMode = 0;
|
||||
renderTargetParams.multisampleLocations = 0;
|
||||
renderTargetParams.driverMemBlock = -1; // Invalid UID
|
||||
renderTargetParams.driverMemBlock = -1; // Invalid UID
|
||||
|
||||
// create the render target
|
||||
err = sceGxmCreateRenderTarget(&renderTargetParams, &data->renderTarget);
|
||||
@@ -507,25 +487,21 @@ gxm_init(SDL_Renderer *renderer)
|
||||
VITA_GXM_SCREEN_WIDTH,
|
||||
VITA_GXM_SCREEN_HEIGHT,
|
||||
VITA_GXM_SCREEN_STRIDE,
|
||||
data->displayBufferData[i]
|
||||
);
|
||||
data->displayBufferData[i]);
|
||||
|
||||
if (err != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "color surface init failed: %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
// create a sync object that we will associate with this buffer
|
||||
err = sceGxmSyncObjectCreate(&data->displayBufferSync[i]);
|
||||
if (err != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "sync object creation failed: %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// allocate the depth buffer
|
||||
data->depthBufferData = vita_mem_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
|
||||
@@ -554,7 +530,6 @@ gxm_init(SDL_Renderer *renderer)
|
||||
// set the stencil test reference (this is currently assumed to always remain 1 after here for region clipping)
|
||||
sceGxmSetFrontStencilRef(data->gxm_context, 1);
|
||||
|
||||
|
||||
// set the stencil function (this wouldn't actually be needed, as the set clip rectangle function has to call this at the begginning of every scene)
|
||||
sceGxmSetFrontStencilFunc(
|
||||
data->gxm_context,
|
||||
@@ -565,7 +540,6 @@ gxm_init(SDL_Renderer *renderer)
|
||||
0xFF,
|
||||
0xFF);
|
||||
|
||||
|
||||
// allocate memory for buffers and USSE code
|
||||
patcherBuffer = vita_mem_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
|
||||
@@ -586,23 +560,23 @@ gxm_init(SDL_Renderer *renderer)
|
||||
|
||||
// create a shader patcher
|
||||
SDL_memset(&patcherParams, 0, sizeof(SceGxmShaderPatcherParams));
|
||||
patcherParams.userData = NULL;
|
||||
patcherParams.hostAllocCallback = &patcher_host_alloc;
|
||||
patcherParams.hostFreeCallback = &patcher_host_free;
|
||||
patcherParams.bufferAllocCallback = NULL;
|
||||
patcherParams.bufferFreeCallback = NULL;
|
||||
patcherParams.bufferMem = patcherBuffer;
|
||||
patcherParams.bufferMemSize = patcherBufferSize;
|
||||
patcherParams.vertexUsseAllocCallback = NULL;
|
||||
patcherParams.vertexUsseFreeCallback = NULL;
|
||||
patcherParams.vertexUsseMem = patcherVertexUsse;
|
||||
patcherParams.vertexUsseMemSize = patcherVertexUsseSize;
|
||||
patcherParams.vertexUsseOffset = patcherVertexUsseOffset;
|
||||
patcherParams.userData = NULL;
|
||||
patcherParams.hostAllocCallback = &patcher_host_alloc;
|
||||
patcherParams.hostFreeCallback = &patcher_host_free;
|
||||
patcherParams.bufferAllocCallback = NULL;
|
||||
patcherParams.bufferFreeCallback = NULL;
|
||||
patcherParams.bufferMem = patcherBuffer;
|
||||
patcherParams.bufferMemSize = patcherBufferSize;
|
||||
patcherParams.vertexUsseAllocCallback = NULL;
|
||||
patcherParams.vertexUsseFreeCallback = NULL;
|
||||
patcherParams.vertexUsseMem = patcherVertexUsse;
|
||||
patcherParams.vertexUsseMemSize = patcherVertexUsseSize;
|
||||
patcherParams.vertexUsseOffset = patcherVertexUsseOffset;
|
||||
patcherParams.fragmentUsseAllocCallback = NULL;
|
||||
patcherParams.fragmentUsseFreeCallback = NULL;
|
||||
patcherParams.fragmentUsseMem = patcherFragmentUsse;
|
||||
patcherParams.fragmentUsseMemSize = patcherFragmentUsseSize;
|
||||
patcherParams.fragmentUsseOffset = patcherFragmentUsseOffset;
|
||||
patcherParams.fragmentUsseFreeCallback = NULL;
|
||||
patcherParams.fragmentUsseMem = patcherFragmentUsse;
|
||||
patcherParams.fragmentUsseMemSize = patcherFragmentUsseSize;
|
||||
patcherParams.fragmentUsseOffset = patcherFragmentUsseOffset;
|
||||
|
||||
err = sceGxmShaderPatcherCreate(&patcherParams, &data->shaderPatcher);
|
||||
if (err != 0) {
|
||||
@@ -610,7 +584,6 @@ gxm_init(SDL_Renderer *renderer)
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
// check the shaders
|
||||
err = sceGxmProgramCheck(clearVertexProgramGxp);
|
||||
if (err != 0) {
|
||||
@@ -692,13 +665,13 @@ gxm_init(SDL_Renderer *renderer)
|
||||
// create clear vertex format
|
||||
SceGxmVertexAttribute clearVertexAttributes[1];
|
||||
SceGxmVertexStream clearVertexStreams[1];
|
||||
clearVertexAttributes[0].streamIndex = 0;
|
||||
clearVertexAttributes[0].offset = 0;
|
||||
clearVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
|
||||
clearVertexAttributes[0].streamIndex = 0;
|
||||
clearVertexAttributes[0].offset = 0;
|
||||
clearVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
|
||||
clearVertexAttributes[0].componentCount = 2;
|
||||
clearVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramClearPositionAttribute);
|
||||
clearVertexStreams[0].stride = sizeof(clear_vertex);
|
||||
clearVertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
|
||||
clearVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramClearPositionAttribute);
|
||||
clearVertexStreams[0].stride = sizeof(clear_vertex);
|
||||
clearVertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
|
||||
|
||||
// create clear programs
|
||||
err = sceGxmShaderPatcherCreateVertexProgram(
|
||||
@@ -708,8 +681,7 @@ gxm_init(SDL_Renderer *renderer)
|
||||
1,
|
||||
clearVertexStreams,
|
||||
1,
|
||||
&data->clearVertexProgram
|
||||
);
|
||||
&data->clearVertexProgram);
|
||||
if (err != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (clear vertex) failed: %d\n", err);
|
||||
return err;
|
||||
@@ -722,8 +694,7 @@ gxm_init(SDL_Renderer *renderer)
|
||||
0,
|
||||
NULL,
|
||||
clearVertexProgramGxp,
|
||||
&data->clearFragmentProgram
|
||||
);
|
||||
&data->clearFragmentProgram);
|
||||
if (err != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (clear fragment) failed: %d\n", err);
|
||||
return err;
|
||||
@@ -732,11 +703,10 @@ gxm_init(SDL_Renderer *renderer)
|
||||
// create the clear triangle vertex/index data
|
||||
data->clearVertices = (clear_vertex *)vita_mem_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
|
||||
3*sizeof(clear_vertex),
|
||||
3 * sizeof(clear_vertex),
|
||||
4,
|
||||
SCE_GXM_MEMORY_ATTRIB_READ,
|
||||
&data->clearVerticesUid
|
||||
);
|
||||
&data->clearVerticesUid);
|
||||
}
|
||||
|
||||
// Allocate a 64k * 2 bytes = 128 KiB buffer and store all possible
|
||||
@@ -744,11 +714,10 @@ gxm_init(SDL_Renderer *renderer)
|
||||
// all drawing operations where we don't want to use indexing.
|
||||
data->linearIndices = (uint16_t *)vita_mem_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
|
||||
UINT16_MAX*sizeof(uint16_t),
|
||||
UINT16_MAX * sizeof(uint16_t),
|
||||
sizeof(uint16_t),
|
||||
SCE_GXM_MEMORY_ATTRIB_READ,
|
||||
&data->linearIndicesUid
|
||||
);
|
||||
&data->linearIndicesUid);
|
||||
|
||||
for (i = 0; i <= UINT16_MAX; ++i) {
|
||||
data->linearIndices[i] = i;
|
||||
@@ -756,10 +725,10 @@ gxm_init(SDL_Renderer *renderer)
|
||||
|
||||
data->clearVertices[0].x = -1.0f;
|
||||
data->clearVertices[0].y = -1.0f;
|
||||
data->clearVertices[1].x = 3.0f;
|
||||
data->clearVertices[1].x = 3.0f;
|
||||
data->clearVertices[1].y = -1.0f;
|
||||
data->clearVertices[2].x = -1.0f;
|
||||
data->clearVertices[2].y = 3.0f;
|
||||
data->clearVertices[2].y = 3.0f;
|
||||
|
||||
{
|
||||
const SceGxmProgramParameter *paramColorPositionAttribute = sceGxmProgramFindParameterByName(colorVertexProgramGxp, "aPosition");
|
||||
@@ -793,16 +762,13 @@ gxm_init(SDL_Renderer *renderer)
|
||||
2,
|
||||
colorVertexStreams,
|
||||
1,
|
||||
&data->colorVertexProgram
|
||||
);
|
||||
&data->colorVertexProgram);
|
||||
if (err != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (color vertex) failed: %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
const SceGxmProgramParameter *paramTexturePositionAttribute = sceGxmProgramFindParameterByName(textureVertexProgramGxp, "aPosition");
|
||||
const SceGxmProgramParameter *paramTextureTexcoordAttribute = sceGxmProgramFindParameterByName(textureVertexProgramGxp, "aTexcoord");
|
||||
@@ -841,13 +807,11 @@ gxm_init(SDL_Renderer *renderer)
|
||||
3,
|
||||
textureVertexStreams,
|
||||
1,
|
||||
&data->textureVertexProgram
|
||||
);
|
||||
&data->textureVertexProgram);
|
||||
if (err != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (texture vertex) failed: %x\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Create variations of the fragment program based on blending mode
|
||||
@@ -863,7 +827,6 @@ gxm_init(SDL_Renderer *renderer)
|
||||
|
||||
data->colorFragmentProgram = in->color;
|
||||
data->textureFragmentProgram = in->texture;
|
||||
|
||||
}
|
||||
|
||||
// find vertex uniforms by name and cache parameter information
|
||||
@@ -877,16 +840,14 @@ gxm_init(SDL_Renderer *renderer)
|
||||
VITA_GXM_POOL_SIZE,
|
||||
sizeof(void *),
|
||||
SCE_GXM_MEMORY_ATTRIB_READ,
|
||||
&data->poolUid[0]
|
||||
);
|
||||
&data->poolUid[0]);
|
||||
|
||||
data->pool_addr[1] = vita_mem_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW,
|
||||
VITA_GXM_POOL_SIZE,
|
||||
sizeof(void *),
|
||||
SCE_GXM_MEMORY_ATTRIB_READ,
|
||||
&data->poolUid[1]
|
||||
);
|
||||
&data->poolUid[1]);
|
||||
|
||||
init_orthographic_matrix(data->ortho_matrix, 0.0f, VITA_GXM_SCREEN_WIDTH, VITA_GXM_SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
@@ -901,7 +862,7 @@ gxm_init(SDL_Renderer *renderer)
|
||||
|
||||
void gxm_finish(SDL_Renderer *renderer)
|
||||
{
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata;
|
||||
|
||||
// wait until rendering is done
|
||||
sceGxmFinish(data->gxm_context);
|
||||
@@ -912,7 +873,6 @@ void gxm_finish(SDL_Renderer *renderer)
|
||||
sceGxmShaderPatcherReleaseVertexProgram(data->shaderPatcher, data->colorVertexProgram);
|
||||
sceGxmShaderPatcherReleaseVertexProgram(data->shaderPatcher, data->textureVertexProgram);
|
||||
|
||||
|
||||
free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_none);
|
||||
free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_blend);
|
||||
free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_add);
|
||||
@@ -975,8 +935,7 @@ void gxm_finish(SDL_Renderer *renderer)
|
||||
|
||||
// textures
|
||||
|
||||
void
|
||||
free_gxm_texture(VITA_GXM_RenderData *data, gxm_texture *texture)
|
||||
void free_gxm_texture(VITA_GXM_RenderData *data, gxm_texture *texture)
|
||||
{
|
||||
if (texture) {
|
||||
if (texture->gxm_rendertarget) {
|
||||
@@ -1032,18 +991,18 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
|
||||
gxm_texture *texture = SDL_calloc(1, sizeof(gxm_texture));
|
||||
int aligned_w = ALIGN(w, 8);
|
||||
int texture_w = w;
|
||||
int tex_size = aligned_w * h * tex_format_to_bytespp(format);
|
||||
int tex_size = aligned_w * h * tex_format_to_bytespp(format);
|
||||
void *texture_data;
|
||||
int ret;
|
||||
|
||||
*return_wscale = 1.0f;
|
||||
|
||||
// SCE_GXM_TEXTURE_BASE_FORMAT_YUV420P3/P2 based formats require width aligned to 16
|
||||
if ( (format & 0x9f000000U) == SCE_GXM_TEXTURE_BASE_FORMAT_YUV420P3 || (format & 0x9f000000U) == SCE_GXM_TEXTURE_BASE_FORMAT_YUV420P2) {
|
||||
if ((format & 0x9f000000U) == SCE_GXM_TEXTURE_BASE_FORMAT_YUV420P3 || (format & 0x9f000000U) == SCE_GXM_TEXTURE_BASE_FORMAT_YUV420P2) {
|
||||
aligned_w = ALIGN(w, 16);
|
||||
texture_w = aligned_w;
|
||||
tex_size = aligned_w * h * tex_format_to_bytespp(format);
|
||||
*return_wscale = (float) (w) / texture_w;
|
||||
tex_size = aligned_w * h * tex_format_to_bytespp(format);
|
||||
*return_wscale = (float)(w) / texture_w;
|
||||
// add storage for UV planes
|
||||
tex_size += (((aligned_w + 1) / 2) * ((h + 1) / 2)) * 2;
|
||||
}
|
||||
@@ -1059,8 +1018,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
|
||||
/* Allocate a GPU buffer for the texture */
|
||||
texture_data = vita_gpu_mem_alloc(
|
||||
data,
|
||||
tex_size
|
||||
);
|
||||
tex_size);
|
||||
|
||||
/* Try SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE in case we're out of VRAM */
|
||||
if (texture_data == NULL) {
|
||||
@@ -1070,8 +1028,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
|
||||
tex_size,
|
||||
SCE_GXM_TEXTURE_ALIGNMENT,
|
||||
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
|
||||
&texture->data_UID
|
||||
);
|
||||
&texture->data_UID);
|
||||
texture->cdram = 0;
|
||||
} else {
|
||||
texture->cdram = 1;
|
||||
@@ -1086,22 +1043,21 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
|
||||
SDL_memset(texture_data, 0, tex_size);
|
||||
|
||||
/* Create the gxm texture */
|
||||
ret = sceGxmTextureInitLinear( &texture->gxm_tex, texture_data, format, texture_w, h, 0);
|
||||
ret = sceGxmTextureInitLinear(&texture->gxm_tex, texture_data, format, texture_w, h, 0);
|
||||
if (ret < 0) {
|
||||
free_gxm_texture(data, texture);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "texture init failed: %x\n", ret);
|
||||
return NULL;
|
||||
free_gxm_texture(data, texture);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "texture init failed: %x\n", ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (isRenderTarget) {
|
||||
void *depthBufferData;
|
||||
const uint32_t alignedWidth = ALIGN(w, SCE_GXM_TILE_SIZEX);
|
||||
const uint32_t alignedHeight = ALIGN(h, SCE_GXM_TILE_SIZEY);
|
||||
uint32_t sampleCount = alignedWidth*alignedHeight;
|
||||
uint32_t sampleCount = alignedWidth * alignedHeight;
|
||||
uint32_t depthStrideInSamples = alignedWidth;
|
||||
const uint32_t alignedColorSurfaceStride = ALIGN(w, 8);
|
||||
|
||||
|
||||
int err = sceGxmColorSurfaceInit(
|
||||
&texture->gxm_colorsurface,
|
||||
tex_format_to_color_format(format),
|
||||
@@ -1111,8 +1067,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
|
||||
w,
|
||||
h,
|
||||
alignedColorSurfaceStride,
|
||||
texture_data
|
||||
);
|
||||
texture_data);
|
||||
|
||||
if (err < 0) {
|
||||
free_gxm_texture(data, texture);
|
||||
@@ -1123,7 +1078,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
|
||||
// allocate it
|
||||
depthBufferData = vita_mem_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
|
||||
4*sampleCount,
|
||||
4 * sampleCount,
|
||||
SCE_GXM_DEPTHSTENCIL_SURFACE_ALIGNMENT,
|
||||
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
|
||||
&texture->depth_UID);
|
||||
@@ -1168,14 +1123,12 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
void
|
||||
gxm_texture_set_filters(gxm_texture *texture, SceGxmTextureFilter min_filter, SceGxmTextureFilter mag_filter)
|
||||
void gxm_texture_set_filters(gxm_texture *texture, SceGxmTextureFilter min_filter, SceGxmTextureFilter mag_filter)
|
||||
{
|
||||
sceGxmTextureSetMinFilter(&texture->gxm_tex, min_filter);
|
||||
sceGxmTextureSetMagFilter(&texture->gxm_tex, mag_filter);
|
||||
@@ -1186,7 +1139,7 @@ static unsigned int front_buffer_index_for_common_dialog = 0;
|
||||
struct
|
||||
{
|
||||
VITA_GXM_DisplayData displayData;
|
||||
SceGxmSyncObject* sync;
|
||||
SceGxmSyncObject *sync;
|
||||
SceGxmColorSurface surf;
|
||||
SceUID uid;
|
||||
} buffer_for_common_dialog[VITA_GXM_BUFFERS];
|
||||
@@ -1195,11 +1148,11 @@ void gxm_minimal_init_for_common_dialog(void)
|
||||
{
|
||||
SceGxmInitializeParams initializeParams;
|
||||
SDL_zero(initializeParams);
|
||||
initializeParams.flags = 0;
|
||||
initializeParams.displayQueueMaxPendingCount = VITA_GXM_PENDING_SWAPS;
|
||||
initializeParams.displayQueueCallback = display_callback;
|
||||
initializeParams.displayQueueCallbackDataSize = sizeof(VITA_GXM_DisplayData);
|
||||
initializeParams.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE;
|
||||
initializeParams.flags = 0;
|
||||
initializeParams.displayQueueMaxPendingCount = VITA_GXM_PENDING_SWAPS;
|
||||
initializeParams.displayQueueCallback = display_callback;
|
||||
initializeParams.displayQueueCallbackDataSize = sizeof(VITA_GXM_DisplayData);
|
||||
initializeParams.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE;
|
||||
sceGxmInitialize(&initializeParams);
|
||||
}
|
||||
|
||||
@@ -1227,8 +1180,7 @@ void gxm_init_for_common_dialog(void)
|
||||
VITA_GXM_SCREEN_WIDTH,
|
||||
VITA_GXM_SCREEN_HEIGHT,
|
||||
VITA_GXM_SCREEN_STRIDE,
|
||||
buffer_for_common_dialog[i].displayData.address
|
||||
);
|
||||
buffer_for_common_dialog[i].displayData.address);
|
||||
sceGxmSyncObjectCreate(&buffer_for_common_dialog[i].sync);
|
||||
}
|
||||
sceGxmDisplayQueueFinish();
|
||||
@@ -1238,10 +1190,10 @@ void gxm_swap_for_common_dialog(void)
|
||||
{
|
||||
SceCommonDialogUpdateParam updateParam;
|
||||
SDL_zero(updateParam);
|
||||
updateParam.renderTarget.colorFormat = VITA_GXM_PIXEL_FORMAT;
|
||||
updateParam.renderTarget.surfaceType = SCE_GXM_COLOR_SURFACE_LINEAR;
|
||||
updateParam.renderTarget.width = VITA_GXM_SCREEN_WIDTH;
|
||||
updateParam.renderTarget.height = VITA_GXM_SCREEN_HEIGHT;
|
||||
updateParam.renderTarget.colorFormat = VITA_GXM_PIXEL_FORMAT;
|
||||
updateParam.renderTarget.surfaceType = SCE_GXM_COLOR_SURFACE_LINEAR;
|
||||
updateParam.renderTarget.width = VITA_GXM_SCREEN_WIDTH;
|
||||
updateParam.renderTarget.height = VITA_GXM_SCREEN_HEIGHT;
|
||||
updateParam.renderTarget.strideInPixels = VITA_GXM_SCREEN_STRIDE;
|
||||
|
||||
updateParam.renderTarget.colorSurfaceData = buffer_for_common_dialog[back_buffer_index_for_common_dialog].displayData.address;
|
||||
|
||||
@@ -36,8 +36,7 @@
|
||||
|
||||
#include "SDL_render_vita_gxm_types.h"
|
||||
|
||||
void
|
||||
init_orthographic_matrix(float *m, float left, float right, float bottom, float top, float near, float far);
|
||||
void init_orthographic_matrix(float *m, float left, float right, float bottom, float top, float near, float far);
|
||||
|
||||
void *pool_malloc(VITA_GXM_RenderData *data, unsigned int size);
|
||||
void *pool_memalign(VITA_GXM_RenderData *data, unsigned int size, unsigned int alignment);
|
||||
|
||||
@@ -37,35 +37,38 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define VITA_GXM_SCREEN_WIDTH 960
|
||||
#define VITA_GXM_SCREEN_HEIGHT 544
|
||||
#define VITA_GXM_SCREEN_STRIDE 960
|
||||
#define VITA_GXM_SCREEN_WIDTH 960
|
||||
#define VITA_GXM_SCREEN_HEIGHT 544
|
||||
#define VITA_GXM_SCREEN_STRIDE 960
|
||||
|
||||
#define VITA_GXM_COLOR_FORMAT SCE_GXM_COLOR_FORMAT_A8B8G8R8
|
||||
#define VITA_GXM_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8
|
||||
#define VITA_GXM_COLOR_FORMAT SCE_GXM_COLOR_FORMAT_A8B8G8R8
|
||||
#define VITA_GXM_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8
|
||||
|
||||
#define VITA_GXM_BUFFERS 3
|
||||
#define VITA_GXM_PENDING_SWAPS 2
|
||||
#define VITA_GXM_POOL_SIZE 2 * 1024 * 1024
|
||||
#define VITA_GXM_BUFFERS 3
|
||||
#define VITA_GXM_PENDING_SWAPS 2
|
||||
#define VITA_GXM_POOL_SIZE 2 * 1024 * 1024
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *address;
|
||||
Uint8 wait_vblank;
|
||||
void *address;
|
||||
Uint8 wait_vblank;
|
||||
} VITA_GXM_DisplayData;
|
||||
|
||||
typedef struct clear_vertex {
|
||||
typedef struct clear_vertex
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
} clear_vertex;
|
||||
|
||||
typedef struct color_vertex {
|
||||
typedef struct color_vertex
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
SDL_Color color;
|
||||
} color_vertex;
|
||||
|
||||
typedef struct texture_vertex {
|
||||
typedef struct texture_vertex
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float u;
|
||||
@@ -73,7 +76,8 @@ typedef struct texture_vertex {
|
||||
SDL_Color color;
|
||||
} texture_vertex;
|
||||
|
||||
typedef struct gxm_texture {
|
||||
typedef struct gxm_texture
|
||||
{
|
||||
SceGxmTexture gxm_tex;
|
||||
SceUID data_UID;
|
||||
SceGxmRenderTarget *gxm_rendertarget;
|
||||
@@ -83,12 +87,14 @@ typedef struct gxm_texture {
|
||||
SDL_bool cdram;
|
||||
} gxm_texture;
|
||||
|
||||
typedef struct fragment_programs {
|
||||
typedef struct fragment_programs
|
||||
{
|
||||
SceGxmFragmentProgram *color;
|
||||
SceGxmFragmentProgram *texture;
|
||||
} fragment_programs;
|
||||
|
||||
typedef struct blend_fragment_programs {
|
||||
typedef struct blend_fragment_programs
|
||||
{
|
||||
fragment_programs blend_mode_none;
|
||||
fragment_programs blend_mode_blend;
|
||||
fragment_programs blend_mode_add;
|
||||
@@ -119,13 +125,13 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SDL_bool initialized;
|
||||
SDL_bool drawing;
|
||||
SDL_bool initialized;
|
||||
SDL_bool drawing;
|
||||
|
||||
unsigned int psm;
|
||||
unsigned int bpp;
|
||||
unsigned int psm;
|
||||
unsigned int bpp;
|
||||
|
||||
int currentBlendMode;
|
||||
int currentBlendMode;
|
||||
|
||||
VITA_GXM_DisplayData displayData;
|
||||
|
||||
@@ -150,12 +156,12 @@ typedef struct
|
||||
unsigned int backBufferIndex;
|
||||
unsigned int frontBufferIndex;
|
||||
|
||||
void* pool_addr[2];
|
||||
void *pool_addr[2];
|
||||
SceUID poolUid[2];
|
||||
unsigned int pool_index;
|
||||
unsigned int current_pool;
|
||||
|
||||
float ortho_matrix[4*4];
|
||||
float ortho_matrix[4 * 4];
|
||||
|
||||
SceGxmVertexProgram *colorVertexProgram;
|
||||
SceGxmFragmentProgram *colorFragmentProgram;
|
||||
@@ -194,13 +200,13 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gxm_texture *tex;
|
||||
gxm_texture *tex;
|
||||
unsigned int pitch;
|
||||
unsigned int w;
|
||||
unsigned int h;
|
||||
float wscale;
|
||||
SDL_bool yuv;
|
||||
SDL_bool nv12;
|
||||
SDL_bool yuv;
|
||||
SDL_bool nv12;
|
||||
} VITA_GXM_TextureData;
|
||||
|
||||
#endif /* SDL_RENDER_VITA_GXM_TYPES_H */
|
||||
|
||||
Reference in New Issue
Block a user