Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Updated to compile on Windows

  • Loading branch information
slouken committed Dec 24, 2009
1 parent 43a8dbf commit 5512c2e76d2f6c52aaa1471ed3603ea1cf803bb3
@@ -1225,7 +1225,6 @@ GL_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
{
GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
int i, x, y;
SDL_Point points[4];

GL_SetBlendMode(data, renderer->blendMode, 1);

@@ -698,6 +698,7 @@ SW_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
}

for (i = 0; i < count; ++i) {
/* FIXME: We don't want to draw clipped edges */
if (!SDL_IntersectRect(rects[i], &clip, &rect)) {
/* Nothing to draw */
continue;
@@ -2673,6 +2673,7 @@ SDL_RenderFillRects(const SDL_Rect ** rects, int count)
return renderer->RenderFillRects(renderer, rects, count);
}

#if 0
int
SDL_RenderDrawCircle(int x, int y, int radius)
{
@@ -2714,6 +2715,7 @@ int SDL_RenderFillEllipse(int x, int y, int w, int h)
}
return renderer->RenderFillEllipse(renderer, x, y, w, h);
}
#endif // 0

int
SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect,
@@ -118,12 +118,14 @@ static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
int numrects, const SDL_Rect * rects);
static int D3D_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points,
int count);
static int D3D_RenderLines(SDL_Renderer * renderer, const SDL_Point * points,
int count);
static int D3D_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
int count);
static int D3D_RenderDrawPoints(SDL_Renderer * renderer,
const SDL_Point * points, int count);
static int D3D_RenderDrawLines(SDL_Renderer * renderer,
const SDL_Point * points, int count);
static int D3D_RenderDrawRects(SDL_Renderer * renderer,
const SDL_Rect ** rects, int count);
static int D3D_RenderFillRects(SDL_Renderer * renderer,
const SDL_Rect ** rects, int count);
static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * srcrect, const SDL_Rect * dstrect);
static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
@@ -462,9 +464,9 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->LockTexture = D3D_LockTexture;
renderer->UnlockTexture = D3D_UnlockTexture;
renderer->DirtyTexture = D3D_DirtyTexture;
renderer->RenderPoints = D3D_RenderPoints;
renderer->RenderLines = D3D_RenderLines;
renderer->RenderRects = D3D_RenderRects;
renderer->RenderDrawPoints = D3D_RenderDrawPoints;
renderer->RenderDrawLines = D3D_RenderDrawLines;
renderer->RenderDrawRects = D3D_RenderDrawRects;
renderer->RenderCopy = D3D_RenderCopy;
renderer->RenderReadPixels = D3D_RenderReadPixels;
renderer->RenderWritePixels = D3D_RenderWritePixels;
@@ -1021,7 +1023,8 @@ D3D_SetBlendMode(D3D_RenderData * data, int blendMode)
}

static int
D3D_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count)
D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
int count)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
DWORD color;
@@ -1068,7 +1071,8 @@ D3D_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count)
}

static int
D3D_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count)
D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
int count)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
DWORD color;
@@ -1124,7 +1128,73 @@ D3D_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count)
}

static int
D3D_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
D3D_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
int count)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
DWORD color;
int i;
Vertex vertices[5];
HRESULT result;

if (data->beginScene) {
IDirect3DDevice9_BeginScene(data->device);
data->beginScene = SDL_FALSE;
}

D3D_SetBlendMode(data, renderer->blendMode);

result =
IDirect3DDevice9_SetTexture(data->device, 0,
(IDirect3DBaseTexture9 *) 0);
if (FAILED(result)) {
D3D_SetError("SetTexture()", result);
return -1;
}

color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);

for (i = 0; i < SDL_arraysize(vertices); ++i) {
vertices[i].z = 0.0f;
vertices[i].rhw = 1.0f;
vertices[i].color = color;
vertices[i].u = 0.0f;
vertices[i].v = 0.0f;
}

for (i = 0; i < count; ++i) {
const SDL_Rect *rect = rects[i];

vertices[0].x = (float) rect->x;
vertices[0].y = (float) rect->y;

vertices[1].x = (float) rect->x+rect->w-1;
vertices[1].y = (float) rect->y;

vertices[2].x = (float) rect->x+rect->w-1;
vertices[2].y = (float) rect->y+rect->h-1;

vertices[3].x = (float) rect->x;
vertices[3].y = (float) rect->y+rect->h-1;

vertices[4].x = (float) rect->x;
vertices[4].y = (float) rect->y;

result =
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, 4,
vertices, sizeof(*vertices));

if (FAILED(result)) {
D3D_SetError("DrawPrimitiveUP()", result);
return -1;
}
}
return 0;
}

static int
D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
int count)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
DWORD color;
@@ -61,12 +61,14 @@ static int GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
void **pixels, int *pitch);
static void GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
static int GDI_SetDrawBlendMode(SDL_Renderer * renderer);
static int GDI_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points,
int count);
static int GDI_RenderLines(SDL_Renderer * renderer, const SDL_Point * points,
int count);
static int GDI_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
int count);
static int GDI_RenderDrawPoints(SDL_Renderer * renderer,
const SDL_Point * points, int count);
static int GDI_RenderDrawLines(SDL_Renderer * renderer,
const SDL_Point * points, int count);
static int GDI_RenderDrawRects(SDL_Renderer * renderer,
const SDL_Rect ** rects, int count);
static int GDI_RenderFillRects(SDL_Renderer * renderer,
const SDL_Rect ** rects, int count);
static int GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * srcrect, const SDL_Rect * dstrect);
static int GDI_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
@@ -194,9 +196,10 @@ GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->LockTexture = GDI_LockTexture;
renderer->UnlockTexture = GDI_UnlockTexture;
renderer->SetDrawBlendMode = GDI_SetDrawBlendMode;
renderer->RenderPoints = GDI_RenderPoints;
renderer->RenderLines = GDI_RenderLines;
renderer->RenderRects = GDI_RenderRects;
renderer->RenderDrawPoints = GDI_RenderDrawPoints;
renderer->RenderDrawLines = GDI_RenderDrawLines;
renderer->RenderDrawRects = GDI_RenderDrawRects;
renderer->RenderFillRects = GDI_RenderFillRects;
renderer->RenderCopy = GDI_RenderCopy;
renderer->RenderReadPixels = GDI_RenderReadPixels;
renderer->RenderWritePixels = GDI_RenderWritePixels;
@@ -687,7 +690,8 @@ GDI_SetDrawBlendMode(SDL_Renderer * renderer)
}

static int
GDI_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count)
GDI_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
int count)
{
GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
int i;
@@ -719,7 +723,8 @@ GDI_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count)
}

static int
GDI_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count)
GDI_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
int count)
{
GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
HPEN pen;
@@ -773,7 +778,65 @@ GDI_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count)
}

static int
GDI_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
GDI_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
int count)
{
GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
HPEN pen;
POINT vertices[5];
int i, status = 1;

if (data->makedirty) {
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
SDL_Rect clip, rect;

clip.x = 0;
clip.y = 0;
clip.w = window->w;
clip.h = window->h;

for (i = 0; i < count; ++i) {
if (SDL_IntersectRect(rects[i], &clip, &rect)) {
SDL_AddDirtyRect(&data->dirty, &rect);
}
}
}

/* Should we cache the pen? .. it looks like GDI does for us. :) */
pen = CreatePen(PS_SOLID, 1, RGB(renderer->r, renderer->g, renderer->b));
SelectObject(data->current_hdc, pen);
for (i = 0; i < count; ++i) {
const SDL_Rect *rect = rects[i];

vertices[0].x = rect->x;
vertices[0].y = rect->y;

vertices[1].x = rect->x+rect->w-1;
vertices[1].y = rect->y;

vertices[2].x = rect->x+rect->w-1;
vertices[2].y = rect->y+rect->h-1;

vertices[3].x = rect->x;
vertices[3].y = rect->y+rect->h-1;

vertices[4].x = rect->x;
vertices[4].y = rect->y;

status &= Polyline(data->current_hdc, vertices, 5);
}
DeleteObject(pen);

if (!status) {
WIN_SetError("Polyline()");
return -1;
}
return 0;
}

static int
GDI_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
int count)
{
GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
RECT rc;

0 comments on commit 5512c2e

Please sign in to comment.