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

Commit

Permalink
Dummy video driver works again in high color video modes. Yay!
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jun 14, 2006
1 parent 61cea60 commit b4cdcb8
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 17 deletions.
6 changes: 6 additions & 0 deletions src/SDL_compat.c
Expand Up @@ -581,6 +581,12 @@ SDL_WM_GrabInput(SDL_GrabMode mode)
return (SDL_GrabMode) SDL_GetWindowGrab(SDL_VideoWindow);
}

void
SDL_WarpMouse(Uint16 x, Uint16 y)
{
SDL_WarpMouseInWindow(SDL_VideoWindow, x, y);
}

Uint8
SDL_GetAppState(void)
{
Expand Down
42 changes: 28 additions & 14 deletions src/video/SDL_renderer_sw.c
Expand Up @@ -33,6 +33,9 @@ static int SDL_SW_CreateTexture(SDL_Renderer * renderer,
static int SDL_SW_QueryTexturePixels(SDL_Renderer * renderer,
SDL_Texture * texture, void **pixels,
int *pitch);
static int SDL_SW_SetTexturePalette(SDL_Renderer * renderer,
SDL_Texture * texture, SDL_Color * colors,
int firstcolor, int ncolors);
static int SDL_SW_UpdateTexture(SDL_Renderer * renderer,
SDL_Texture * texture, SDL_Rect * rect,
const void *pixels, int pitch);
Expand Down Expand Up @@ -130,6 +133,7 @@ SDL_SW_CreateRenderer(SDL_Window * window, Uint32 flags)

renderer->CreateTexture = SDL_SW_CreateTexture;
renderer->QueryTexturePixels = SDL_SW_QueryTexturePixels;
renderer->SetTexturePalette = SDL_SW_SetTexturePalette;
renderer->UpdateTexture = SDL_SW_UpdateTexture;
renderer->LockTexture = SDL_SW_LockTexture;
renderer->UnlockTexture = SDL_SW_UnlockTexture;
Expand Down Expand Up @@ -189,7 +193,7 @@ SDL_SW_CreateRenderer(SDL_Window * window, Uint32 flags)
return renderer;
}

int
static int
SDL_SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
SDL_Surface *surface;
Expand Down Expand Up @@ -218,7 +222,7 @@ SDL_SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
return 0;
}

int
static int
SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
void **pixels, int *pitch)
{
Expand All @@ -229,7 +233,17 @@ SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
return 0;
}

int
static int
SDL_SW_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
SDL_Color * colors, int firstcolor, int ncolors)
{
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;

SDL_SetColors(surface, colors, firstcolor, ncolors);
return 0;
}

static int
SDL_SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
SDL_Rect * rect, const void *pixels, int pitch)
{
Expand All @@ -251,7 +265,7 @@ SDL_SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
return 0;
}

int
static int
SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
SDL_Rect * rect, int markDirty, void **pixels, int *pitch)
{
Expand All @@ -264,25 +278,25 @@ SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
return 0;
}

void
static void
SDL_SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
}

void
static void
SDL_SW_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
int numrects, SDL_Rect * rects)
{
}

void
static void
SDL_SW_SelectRenderTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
data->target = (SDL_Surface *) texture->driverdata;
}

void
static void
SDL_SW_RenderFill(SDL_Renderer * renderer, SDL_Rect * rect, Uint32 color)
{
SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
Expand All @@ -297,7 +311,7 @@ SDL_SW_RenderFill(SDL_Renderer * renderer, SDL_Rect * rect, Uint32 color)
SDL_FillRect(data->target, rect, color);
}

int
static int
SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
SDL_Rect * srcrect, SDL_Rect * dstrect, int blendMode,
int scaleMode)
Expand All @@ -318,7 +332,7 @@ SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
}
}

int
static int
SDL_SW_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect,
void *pixels, int pitch)
{
Expand All @@ -341,7 +355,7 @@ SDL_SW_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect,
return 0;
}

int
static int
SDL_SW_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect,
const void *pixels, int pitch)
{
Expand All @@ -364,7 +378,7 @@ SDL_SW_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect,
return 0;
}

void
static void
SDL_SW_RenderPresent(SDL_Renderer * renderer)
{
SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
Expand Down Expand Up @@ -396,15 +410,15 @@ SDL_SW_RenderPresent(SDL_Renderer * renderer)
data->current_screen = new_screen;
}

void
static void
SDL_SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;

SDL_FreeSurface(surface);
}

void
static void
SDL_SW_DestroyRenderer(SDL_Renderer * renderer)
{
SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
Expand Down
3 changes: 3 additions & 0 deletions src/video/SDL_sysvideo.h
Expand Up @@ -69,6 +69,9 @@ struct SDL_Renderer
int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture,
void **pixels, int *pitch);
int (*SetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
SDL_Color * colors, int firstcolor,
int ncolors);
int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
SDL_Rect * rect, const void *pixels, int pitch);
int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
Expand Down
37 changes: 35 additions & 2 deletions src/video/SDL_video.c
Expand Up @@ -1029,8 +1029,15 @@ SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags)
if (index < 0) {
int n = SDL_GetNumRenderers();
for (index = 0; index < n; ++index) {
if ((SDL_CurrentDisplay.render_drivers[index].info.
flags & flags) == flags) {
SDL_RenderDriver *driver =
&SDL_CurrentDisplay.render_drivers[index];

/* Skip minimal drivers in automatic scans */
if (!(flags & SDL_Renderer_Minimal)
&& (driver->info.flags & SDL_Renderer_Minimal)) {
continue;
}
if ((driver->info.flags & flags) == flags) {
break;
}
}
Expand Down Expand Up @@ -1076,6 +1083,7 @@ SDL_SelectRenderer(SDL_WindowID windowID)
SDL_TextureID
SDL_CreateTexture(Uint32 format, int access, int w, int h)
{
int hash;
SDL_Renderer *renderer;
SDL_Texture *texture;

Expand Down Expand Up @@ -1106,6 +1114,12 @@ SDL_CreateTexture(Uint32 format, int access, int w, int h)
SDL_free(texture);
return 0;
}

hash = (texture->id % SDL_arraysize(SDL_CurrentDisplay.textures));
texture->next = SDL_CurrentDisplay.textures[hash];
SDL_CurrentDisplay.textures[hash] = texture;

return texture->id;
}

SDL_TextureID
Expand Down Expand Up @@ -1302,6 +1316,25 @@ SDL_QueryTexturePixels(SDL_TextureID textureID, void **pixels, int *pitch)
return renderer->QueryTexturePixels(renderer, texture, pixels, pitch);
}

int
SDL_SetTexturePalette(SDL_TextureID textureID, SDL_Color * colors,
int firstcolor, int ncolors)
{
SDL_Texture *texture = SDL_GetTextureFromID(textureID);
SDL_Renderer *renderer;

if (!texture) {
return -1;
}

renderer = texture->renderer;
if (!renderer->SetTexturePalette) {
return -1;
}
return renderer->SetTexturePalette(renderer, texture, colors, firstcolor,
ncolors);
}

int
SDL_UpdateTexture(SDL_TextureID textureID, SDL_Rect * rect,
const void *pixels, int pitch)
Expand Down
2 changes: 1 addition & 1 deletion src/video/SDL_yuv_sw.c
Expand Up @@ -21,7 +21,7 @@
*/
#include "SDL_config.h"

#if 0 /* TODO */
#if 0 /* TODO */
/* This is the software implementation of the YUV video overlay support */

/* This code was derived from code carrying the following copyright notices:
Expand Down

0 comments on commit b4cdcb8

Please sign in to comment.