Created
October 9, 2012 06:40
-
-
Save KapLex/3857008 to your computer and use it in GitHub Desktop.
psp render framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Simple DirectMedia Layer | |
Copyright (C) 1997-2012 Sam Lantinga <[email protected]> | |
This software is provided 'as-is', without any express or implied | |
warranty. In no event will the authors be held liable for any damages | |
arising from the use of this software. | |
Permission is granted to anyone to use this software for any purpose, | |
including commercial applications, and to alter it and redistribute it | |
freely, subject to the following restrictions: | |
1. The origin of this software must not be misrepresented; you must not | |
claim that you wrote the original software. If you use this software | |
in a product, an acknowledgment in the product documentation would be | |
appreciated but is not required. | |
2. Altered source versions must be plainly marked as such, and must not be | |
misrepresented as being the original software. | |
3. This notice may not be removed or altered from any source distribution. | |
*/ | |
#include "SDL_config.h" | |
#if SDL_VIDEO_RENDER_PSP | |
#include "SDL_hints.h" | |
#include "../SDL_sysrender.h" | |
#endif | |
/* PSP renderer implementation, based on the PGE */ | |
extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); | |
static const float inv255f = 1.0f / 255.0f; | |
static SDL_Renderer *PSP_CreateRenderer(SDL_Window * window, Uint32 flags); | |
static void PSP_WindowEvent(SDL_Renderer * renderer, | |
const SDL_WindowEvent *event); | |
static int PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); | |
static int PSP_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
const SDL_Rect * rect, const void *pixels, | |
int pitch); | |
static int PSP_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
const SDL_Rect * rect, void **pixels, int *pitch); | |
static void PSP_UnlockTexture(SDL_Renderer * renderer, | |
SDL_Texture * texture); | |
static int PSP_SetRenderTarget(SDL_Renderer * renderer, | |
SDL_Texture * texture); | |
static int PSP_UpdateViewport(SDL_Renderer * renderer); | |
static int PSP_RenderClear(SDL_Renderer * renderer); | |
static int PSP_RenderDrawPoints(SDL_Renderer * renderer, | |
const SDL_Point * points, int count); | |
static int PSP_RenderDrawLines(SDL_Renderer * renderer, | |
const SDL_Point * points, int count); | |
static int PSP_RenderFillRects(SDL_Renderer * renderer, | |
const SDL_Rect * rects, int count); | |
static int PSP_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, | |
const SDL_Rect * srcrect, | |
const SDL_Rect * dstrect); | |
static int PSP_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, | |
Uint32 pixel_format, void * pixels, int pitch); | |
static int PSP_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, | |
const SDL_Rect * srcrect, const SDL_Rect * dstrect, | |
const double angle, const SDL_Point *center, const SDL_RendererFlip flip); | |
static void PSP_RenderPresent(SDL_Renderer * renderer); | |
static void PSP_DestroyTexture(SDL_Renderer * renderer, | |
SDL_Texture * texture); | |
static void PSP_DestroyRenderer(SDL_Renderer * renderer); | |
SDL_RenderDriver PSP_RenderDriver = { | |
PSP_CreateRenderer, | |
{ | |
"PSP", | |
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), | |
1, | |
{SDL_PIXELFORMAT_ABGR8888}, | |
0, | |
0} | |
}; | |
typedef struct | |
{ | |
} PSP_RenderData; | |
typedef struct | |
{ | |
} PSP_TextureData; | |
/*private functions */ | |
static void | |
PSP_SetError(const char *prefix, GLenum result) | |
{ | |
} | |
static int | |
PSP_ActivateRenderer(SDL_Renderer * renderer) | |
{ | |
return 0; | |
} | |
/* This is called if we need to invalidate all of the SDL OpenGL state */ | |
static void | |
PSP_ResetState(SDL_Renderer *renderer) | |
{ | |
} | |
/*end private functions*/ | |
SDL_Renderer * | |
PSP_CreateRenderer(SDL_Window * window, Uint32 flags) | |
{ | |
SDL_Renderer *renderer; | |
PSP_RenderData *data; | |
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); | |
if (!renderer) { | |
SDL_OutOfMemory(); | |
return NULL; | |
} | |
data = (PSP_RenderData *) SDL_calloc(1, sizeof(*data)); | |
if (!data) { | |
PSP_DestroyRenderer(renderer); | |
SDL_OutOfMemory(); | |
return NULL; | |
} | |
renderer->WindowEvent = PSP_WindowEvent; | |
renderer->CreateTexture = PSP_CreateTexture; | |
renderer->UpdateTexture = PSP_UpdateTexture; | |
renderer->LockTexture = PSP_LockTexture; | |
renderer->UnlockTexture = PSP_UnlockTexture; | |
renderer->SetRenderTarget = PSP_SetRenderTarget; | |
renderer->UpdateViewport = PSP_UpdateViewport; | |
renderer->RenderClear = PSP_RenderClear; | |
renderer->RenderDrawPoints = PSP_RenderDrawPoints; | |
renderer->RenderDrawLines = PSP_RenderDrawLines; | |
renderer->RenderFillRects = PSP_RenderFillRects; | |
renderer->RenderCopy = PSP_RenderCopy; | |
renderer->RenderReadPixels = PSP_RenderReadPixels; | |
renderer->RenderCopyEx = PSP_RenderCopyEx; | |
renderer->RenderPresent = PSP_RenderPresent; | |
renderer->DestroyTexture = PSP_DestroyTexture; | |
renderer->DestroyRenderer = PSP_DestroyRenderer; | |
renderer->info = PSP_RenderDriver.info; | |
renderer->info.flags = SDL_RENDERER_ACCELERATED; | |
renderer->driverdata = data; | |
renderer->window = window; | |
return renderer; | |
} | |
static void | |
PSP_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) | |
{ | |
} | |
static __inline__ int | |
power_of_2(int input) | |
{ | |
int value = 1; | |
while (value < input) { | |
value <<= 1; | |
} | |
return value; | |
} | |
static GLenum | |
GetScaleQuality(void) | |
{ | |
} | |
static int | |
PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) | |
{ | |
return 0; | |
} | |
static int | |
PSP_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
const SDL_Rect * rect, const void *pixels, int pitch) | |
{ | |
return 0; | |
} | |
static int | |
PSP_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
const SDL_Rect * rect, void **pixels, int *pitch) | |
{ | |
return 0; | |
} | |
static void | |
PSP_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) | |
{ | |
} | |
static int | |
PSP_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) | |
{ | |
return 0; | |
} | |
static int | |
PSP_UpdateViewport(SDL_Renderer * renderer) | |
{ | |
return 0; | |
} | |
static void | |
PSP_SetColor(PSP_RenderData * data, Uint8 r, Uint8 g, Uint8 b, Uint8 a) | |
{ | |
} | |
/*private */ | |
static void | |
PSP_SetBlendMode(PSP_RenderData * data, int blendMode) | |
{ | |
} | |
/*private */ | |
static void | |
PSP_SetTexCoords(PSP_RenderData * data, SDL_bool enabled) | |
{ | |
} | |
static void | |
PSP_SetDrawingState(SDL_Renderer * renderer) | |
{ | |
} | |
static int | |
PSP_RenderClear(SDL_Renderer * renderer) | |
{ | |
return 0; | |
} | |
static int | |
PSP_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, | |
int count) | |
{ | |
return 0; | |
} | |
static int | |
PSP_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, | |
int count) | |
{ | |
return 0; | |
} | |
static int | |
PSP_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects, | |
int count) | |
{ | |
return 0; | |
} | |
static int | |
PSP_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, | |
const SDL_Rect * srcrect, const SDL_Rect * dstrect) | |
{ | |
return 0; | |
} | |
static int | |
PSP_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, | |
Uint32 pixel_format, void * pixels, int pitch) | |
{ | |
} | |
static int | |
PSP_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, | |
const SDL_Rect * srcrect, const SDL_Rect * dstrect, | |
const double angle, const SDL_Point *center, const SDL_RendererFlip flip) | |
{ | |
return 0; | |
} | |
static void | |
PSP_RenderPresent(SDL_Renderer * renderer) | |
{ | |
} | |
static void | |
PSP_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) | |
{ | |
} | |
static void | |
PSP_DestroyRenderer(SDL_Renderer * renderer) | |
{ | |
} | |
#endif /* SDL_VIDEO_RENDER_PSP */ | |
/* vi: set ts=4 sw=4 expandtab: */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment