Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
OpenGL renderer in progress --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401965
This commit is contained in:
parent
2b538200ba
commit
2fe561616a
9 changed files with 218 additions and 212 deletions
|
@ -191,7 +191,7 @@ typedef struct SDL_RendererInfo
|
||||||
Uint32 blend_modes; /**< A mask of supported blend modes */
|
Uint32 blend_modes; /**< A mask of supported blend modes */
|
||||||
Uint32 scale_modes; /**< A mask of supported scale modes */
|
Uint32 scale_modes; /**< A mask of supported scale modes */
|
||||||
Uint32 num_texture_formats; /**< The number of available texture formats */
|
Uint32 num_texture_formats; /**< The number of available texture formats */
|
||||||
Uint32 texture_formats[16]; /**< The available texture formats */
|
Uint32 texture_formats[20]; /**< The available texture formats */
|
||||||
int max_texture_width; /**< The maximimum texture width */
|
int max_texture_width; /**< The maximimum texture width */
|
||||||
int max_texture_height; /**< The maximimum texture height */
|
int max_texture_height; /**< The maximimum texture height */
|
||||||
} SDL_RendererInfo;
|
} SDL_RendererInfo;
|
||||||
|
|
|
@ -346,12 +346,11 @@ SDL_AllocFormat(int bpp,
|
||||||
Uint32 mask;
|
Uint32 mask;
|
||||||
|
|
||||||
/* Allocate an empty pixel format structure */
|
/* Allocate an empty pixel format structure */
|
||||||
format = SDL_malloc(sizeof(*format));
|
format = SDL_calloc(1, sizeof(*format));
|
||||||
if (format == NULL) {
|
if (format == NULL) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
SDL_memset(format, 0, sizeof(*format));
|
|
||||||
format->alpha = SDL_ALPHA_OPAQUE;
|
format->alpha = SDL_ALPHA_OPAQUE;
|
||||||
|
|
||||||
/* Set up the format */
|
/* Set up the format */
|
||||||
|
@ -714,22 +713,20 @@ SDL_AllocBlitMap(void)
|
||||||
SDL_BlitMap *map;
|
SDL_BlitMap *map;
|
||||||
|
|
||||||
/* Allocate the empty map */
|
/* Allocate the empty map */
|
||||||
map = (SDL_BlitMap *) SDL_malloc(sizeof(*map));
|
map = (SDL_BlitMap *) SDL_calloc(1, sizeof(*map));
|
||||||
if (map == NULL) {
|
if (map == NULL) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
SDL_memset(map, 0, sizeof(*map));
|
|
||||||
|
|
||||||
/* Allocate the software blit data */
|
/* Allocate the software blit data */
|
||||||
map->sw_data =
|
map->sw_data =
|
||||||
(struct private_swaccel *) SDL_malloc(sizeof(*map->sw_data));
|
(struct private_swaccel *) SDL_calloc(1, sizeof(*map->sw_data));
|
||||||
if (map->sw_data == NULL) {
|
if (map->sw_data == NULL) {
|
||||||
SDL_FreeBlitMap(map);
|
SDL_FreeBlitMap(map);
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
SDL_memset(map->sw_data, 0, sizeof(*map->sw_data));
|
|
||||||
|
|
||||||
/* It's ready to go */
|
/* It's ready to go */
|
||||||
return (map);
|
return (map);
|
||||||
|
|
|
@ -22,8 +22,13 @@
|
||||||
#include "SDL_config.h"
|
#include "SDL_config.h"
|
||||||
|
|
||||||
#if SDL_VIDEO_OPENGL
|
#if SDL_VIDEO_OPENGL
|
||||||
#if 0
|
|
||||||
#include "SDL_win32video.h"
|
#include "SDL_video.h"
|
||||||
|
#include "SDL_opengl.h"
|
||||||
|
#include "SDL_sysvideo.h"
|
||||||
|
#include "SDL_pixels_c.h"
|
||||||
|
#include "SDL_rect_c.h"
|
||||||
|
#include "SDL_yuv_sw_c.h"
|
||||||
|
|
||||||
/* OpenGL renderer implementation */
|
/* OpenGL renderer implementation */
|
||||||
|
|
||||||
|
@ -66,8 +71,10 @@ SDL_RenderDriver GL_RenderDriver = {
|
||||||
SDL_TextureBlendMode_Mod),
|
SDL_TextureBlendMode_Mod),
|
||||||
(SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast |
|
(SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast |
|
||||||
SDL_TextureScaleMode_Best),
|
SDL_TextureScaleMode_Best),
|
||||||
12,
|
18,
|
||||||
{
|
{
|
||||||
|
SDL_PixelFormat_Index1LSB,
|
||||||
|
SDL_PixelFormat_Index1MSB,
|
||||||
SDL_PixelFormat_Index8,
|
SDL_PixelFormat_Index8,
|
||||||
SDL_PixelFormat_RGB332,
|
SDL_PixelFormat_RGB332,
|
||||||
SDL_PixelFormat_RGB444,
|
SDL_PixelFormat_RGB444,
|
||||||
|
@ -75,11 +82,15 @@ SDL_RenderDriver GL_RenderDriver = {
|
||||||
SDL_PixelFormat_ARGB4444,
|
SDL_PixelFormat_ARGB4444,
|
||||||
SDL_PixelFormat_ARGB1555,
|
SDL_PixelFormat_ARGB1555,
|
||||||
SDL_PixelFormat_RGB565,
|
SDL_PixelFormat_RGB565,
|
||||||
|
SDL_PixelFormat_RGB24,
|
||||||
|
SDL_PixelFormat_BGR24,
|
||||||
SDL_PixelFormat_RGB888,
|
SDL_PixelFormat_RGB888,
|
||||||
|
SDL_PixelFormat_BGR888,
|
||||||
SDL_PixelFormat_ARGB8888,
|
SDL_PixelFormat_ARGB8888,
|
||||||
SDL_PixelFormat_ARGB2101010,
|
SDL_PixelFormat_RGBA8888,
|
||||||
SDL_PixelFormat_UYVY,
|
SDL_PixelFormat_ABGR8888,
|
||||||
SDL_PixelFormat_YUY2},
|
SDL_PixelFormat_BGRA8888,
|
||||||
|
SDL_PixelFormat_ARGB2101010}, /* FIXME: YUV texture support */
|
||||||
0,
|
0,
|
||||||
0}
|
0}
|
||||||
};
|
};
|
||||||
|
@ -87,57 +98,26 @@ SDL_RenderDriver GL_RenderDriver = {
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
SDL_GLContext context;
|
SDL_GLContext context;
|
||||||
SDL_bool beginScene;
|
|
||||||
} GL_RenderData;
|
} GL_RenderData;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GLuint texture;
|
GLuint texture;
|
||||||
|
GLenum type;
|
||||||
GLfloat texw;
|
GLfloat texw;
|
||||||
GLfloat texh;
|
GLfloat texh;
|
||||||
|
GLenum format;
|
||||||
|
GLenum formattype;
|
||||||
void *pixels;
|
void *pixels;
|
||||||
int pitch;
|
int pitch;
|
||||||
|
SDL_DirtyRectList dirty;
|
||||||
} GL_TextureData;
|
} GL_TextureData;
|
||||||
|
|
||||||
static GLFORMAT
|
|
||||||
PixelFormatToOpenGL(Uint32 format,)
|
|
||||||
{
|
|
||||||
switch (format) {
|
|
||||||
case SDL_PixelFormat_Index8:
|
|
||||||
return GLFMT_P8;
|
|
||||||
case SDL_PixelFormat_RGB332:
|
|
||||||
return GLFMT_R3G3B2;
|
|
||||||
case SDL_PixelFormat_RGB444:
|
|
||||||
return GLFMT_X4R4G4B4;
|
|
||||||
case SDL_PixelFormat_RGB555:
|
|
||||||
return GLFMT_X1R5G5B5;
|
|
||||||
case SDL_PixelFormat_ARGB4444:
|
|
||||||
return GLFMT_A4R4G4B4;
|
|
||||||
case SDL_PixelFormat_ARGB1555:
|
|
||||||
return GLFMT_A1R5G5B5;
|
|
||||||
case SDL_PixelFormat_RGB565:
|
|
||||||
return GLFMT_R5G6B5;
|
|
||||||
case SDL_PixelFormat_RGB888:
|
|
||||||
return GLFMT_X8R8G8B8;
|
|
||||||
case SDL_PixelFormat_ARGB8888:
|
|
||||||
return GLFMT_A8R8G8B8;
|
|
||||||
case SDL_PixelFormat_ARGB2101010:
|
|
||||||
return GLFMT_A2R10G10B10;
|
|
||||||
case SDL_PixelFormat_UYVY:
|
|
||||||
return GLFMT_UYVY;
|
|
||||||
case SDL_PixelFormat_YUY2:
|
|
||||||
return GLFMT_YUY2;
|
|
||||||
default:
|
|
||||||
return GLFMT_UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GL_AddRenderDriver(_THIS)
|
GL_AddRenderDriver(_THIS)
|
||||||
{
|
{
|
||||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
if (_this->GL_CreateContext) {
|
||||||
|
|
||||||
if (data->d3d) {
|
|
||||||
SDL_AddRenderDriver(0, &GL_RenderDriver);
|
SDL_AddRenderDriver(0, &GL_RenderDriver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,14 +125,8 @@ GL_AddRenderDriver(_THIS)
|
||||||
SDL_Renderer *
|
SDL_Renderer *
|
||||||
GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
{
|
{
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
|
|
||||||
SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata;
|
|
||||||
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
|
|
||||||
SDL_Renderer *renderer;
|
SDL_Renderer *renderer;
|
||||||
GL_RenderData *data;
|
GL_RenderData *data;
|
||||||
HRESULT result;
|
|
||||||
GLPRESENT_PARAMETERS pparams;
|
|
||||||
IDirect3DSwapChain9 *chain;
|
|
||||||
|
|
||||||
if (!(window->flags & SDL_WINDOW_OPENGL)) {
|
if (!(window->flags & SDL_WINDOW_OPENGL)) {
|
||||||
SDL_SetError
|
SDL_SetError
|
||||||
|
@ -160,20 +134,18 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer));
|
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||||
if (!renderer) {
|
if (!renderer) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SDL_zerop(renderer);
|
|
||||||
|
|
||||||
data = (GL_RenderData *) SDL_malloc(sizeof(*data));
|
data = (GL_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||||
if (!data) {
|
if (!data) {
|
||||||
GL_DestroyRenderer(renderer);
|
GL_DestroyRenderer(renderer);
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SDL_zerop(data);
|
|
||||||
|
|
||||||
renderer->CreateTexture = GL_CreateTexture;
|
renderer->CreateTexture = GL_CreateTexture;
|
||||||
renderer->SetTexturePalette = GL_SetTexturePalette;
|
renderer->SetTexturePalette = GL_SetTexturePalette;
|
||||||
|
@ -203,7 +175,6 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
GL_DestroyRenderer(renderer);
|
GL_DestroyRenderer(renderer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
data->beginScene = SDL_TRUE;
|
|
||||||
|
|
||||||
if (flags & SDL_Renderer_PresentVSync) {
|
if (flags & SDL_Renderer_PresentVSync) {
|
||||||
SDL_GL_SetSwapInterval(1);
|
SDL_GL_SetSwapInterval(1);
|
||||||
|
@ -214,67 +185,147 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
renderer->info.flags |= SDL_Renderer_PresentVSync;
|
renderer->info.flags |= SDL_Renderer_PresentVSync;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME: Add a function to make the rendering context current when selecting the renderer */
|
||||||
|
|
||||||
|
/* FIXME: Query maximum texture size */
|
||||||
|
|
||||||
|
/* FIXME: Check for GL_ARB_texture_rectangle and GL_EXT_texture_rectangle */
|
||||||
|
|
||||||
/* Set up parameters for rendering */
|
/* Set up parameters for rendering */
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glEnable(GL_TEXTURE_RECTANGLE_ARB);
|
||||||
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glViewport(0, 0, window->w, window->h);
|
glViewport(0, 0, window->w, window->h);
|
||||||
glOrtho(0.0, (GLdouble) window->w, (GLdouble) window->h, 0.0, 0.0, 1.0);
|
glOrtho(0.0, (GLdouble) window->w, (GLdouble) window->h, 0.0, 0.0, 1.0);
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
|
||||||
|
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Quick utility function for texture creation */
|
|
||||||
static int
|
|
||||||
power_of_two(int input)
|
|
||||||
{
|
|
||||||
int value = 1;
|
|
||||||
|
|
||||||
while (value < input) {
|
|
||||||
value <<= 1;
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||||
{
|
{
|
||||||
GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
|
GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
|
||||||
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
|
|
||||||
GL_TextureData *data;
|
GL_TextureData *data;
|
||||||
GLPOOL pool;
|
GLint internalFormat;
|
||||||
HRESULT result;
|
GLenum format, type;
|
||||||
|
|
||||||
data = (GL_TextureData *) SDL_malloc(sizeof(*data));
|
switch (texture->format) {
|
||||||
|
case SDL_PixelFormat_Index1LSB:
|
||||||
|
case SDL_PixelFormat_Index1MSB:
|
||||||
|
internalFormat = GL_RGB;
|
||||||
|
format = GL_COLOR_INDEX;
|
||||||
|
type = GL_BITMAP;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_Index8:
|
||||||
|
internalFormat = GL_RGB;
|
||||||
|
format = GL_COLOR_INDEX;
|
||||||
|
type = GL_UNSIGNED_BYTE;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_RGB332:
|
||||||
|
internalFormat = GL_R3_G3_B2;
|
||||||
|
format = GL_RGB;
|
||||||
|
type = GL_UNSIGNED_BYTE_3_3_2;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_RGB444:
|
||||||
|
internalFormat = GL_RGB4;
|
||||||
|
format = GL_RGB;
|
||||||
|
type = GL_UNSIGNED_SHORT_4_4_4_4;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_RGB555:
|
||||||
|
internalFormat = GL_RGB5;
|
||||||
|
format = GL_RGB;
|
||||||
|
type = GL_UNSIGNED_SHORT_5_5_5_1;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_ARGB4444:
|
||||||
|
internalFormat = GL_RGBA4;
|
||||||
|
format = GL_BGRA;
|
||||||
|
type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_ARGB1555:
|
||||||
|
internalFormat = GL_RGB5_A1;
|
||||||
|
format = GL_BGRA;
|
||||||
|
type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_RGB565:
|
||||||
|
internalFormat = GL_RGB8;
|
||||||
|
format = GL_RGB;
|
||||||
|
type = GL_UNSIGNED_SHORT_5_6_5;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_RGB24:
|
||||||
|
internalFormat = GL_RGB8;
|
||||||
|
format = GL_RGB;
|
||||||
|
type = GL_UNSIGNED_BYTE;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_RGB888:
|
||||||
|
internalFormat = GL_RGB8;
|
||||||
|
format = GL_RGB;
|
||||||
|
type = GL_UNSIGNED_INT_8_8_8_8;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_BGR24:
|
||||||
|
internalFormat = GL_RGB8;
|
||||||
|
format = GL_BGR;
|
||||||
|
type = GL_UNSIGNED_BYTE;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_BGR888:
|
||||||
|
internalFormat = GL_RGB8;
|
||||||
|
format = GL_BGR;
|
||||||
|
type = GL_UNSIGNED_INT_8_8_8_8;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_ARGB8888:
|
||||||
|
internalFormat = GL_RGBA8;
|
||||||
|
format = GL_BGRA;
|
||||||
|
type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_RGBA8888:
|
||||||
|
internalFormat = GL_RGBA8;
|
||||||
|
format = GL_BGRA;
|
||||||
|
type = GL_UNSIGNED_INT_8_8_8_8;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_ABGR8888:
|
||||||
|
internalFormat = GL_RGBA8;
|
||||||
|
format = GL_RGBA;
|
||||||
|
type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_BGRA8888:
|
||||||
|
internalFormat = GL_RGBA8;
|
||||||
|
format = GL_BGRA;
|
||||||
|
type = GL_UNSIGNED_INT_8_8_8_8;
|
||||||
|
break;
|
||||||
|
case SDL_PixelFormat_ARGB2101010:
|
||||||
|
internalFormat = GL_RGB10_A2;
|
||||||
|
format = GL_BGRA;
|
||||||
|
type = GL_UNSIGNED_INT_2_10_10_10_REV;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SDL_SetError("Unsupported texture format");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = (GL_TextureData *) SDL_calloc(1, sizeof(*data));
|
||||||
if (!data) {
|
if (!data) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
SDL_zerop(data);
|
|
||||||
|
|
||||||
texture->driverdata = data;
|
texture->driverdata = data;
|
||||||
|
|
||||||
if (texture->access == SDL_TextureAccess_Local) {
|
/* FIXME: Check for GL_ARB_texture_rectangle and GL_EXT_texture_rectangle */
|
||||||
pool = GLPOOL_MANAGED;
|
glGenTextures(1, &data->texture);
|
||||||
} else {
|
data->type = GL_TEXTURE_RECTANGLE_ARB;
|
||||||
pool = GLPOOL_DEFAULT;
|
data->texw = (GLfloat) texture->w;
|
||||||
}
|
data->texh = (GLfloat) texture->h;
|
||||||
result =
|
data->format = format;
|
||||||
IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
|
data->formattype = type;
|
||||||
texture->h, 1, 0,
|
glBindTexture(data->type, data->texture);
|
||||||
PixelFormatToGLFMT(texture->format),
|
glTexImage2D(data->type, 0, internalFormat, texture->w, texture->h, 0,
|
||||||
pool, &data->texture, NULL);
|
format, type, NULL);
|
||||||
if (FAILED(result)) {
|
|
||||||
SDL_free(data);
|
|
||||||
GL_SetError("CreateTexture()", result);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -303,57 +354,14 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
const SDL_Rect * rect, const void *pixels, int pitch)
|
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||||
{
|
{
|
||||||
GL_TextureData *data = (GL_TextureData *) texture->driverdata;
|
GL_TextureData *data = (GL_TextureData *) texture->driverdata;
|
||||||
GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
|
|
||||||
IDirect3DTexture9 *temp;
|
|
||||||
RECT d3drect;
|
|
||||||
GLLOCKED_RECT locked;
|
|
||||||
const Uint8 *src;
|
|
||||||
Uint8 *dst;
|
|
||||||
int row, length;
|
|
||||||
HRESULT result;
|
|
||||||
|
|
||||||
result =
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); /* FIXME, what to use for RGB 4 byte formats? */
|
||||||
IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
|
glPixelStorei(GL_UNPACK_ROW_LENGTH,
|
||||||
texture->h, 1, 0,
|
pitch / SDL_BYTESPERPIXEL(texture->format));
|
||||||
PixelFormatToGLFMT(texture->format),
|
glBindTexture(data->type, data->texture);
|
||||||
GLPOOL_SYSTEMMEM, &temp, NULL);
|
glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w, rect->h,
|
||||||
if (FAILED(result)) {
|
data->format, data->formattype, pixels);
|
||||||
GL_SetError("CreateTexture()", result);
|
/* FIXME: check for errors */
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
d3drect.left = rect->x;
|
|
||||||
d3drect.right = rect->x + rect->w;
|
|
||||||
d3drect.top = rect->y;
|
|
||||||
d3drect.bottom = rect->y + rect->h;
|
|
||||||
|
|
||||||
result = IDirect3DTexture9_LockRect(temp, 0, &locked, &d3drect, 0);
|
|
||||||
if (FAILED(result)) {
|
|
||||||
IDirect3DTexture9_Release(temp);
|
|
||||||
GL_SetError("LockRect()", result);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
src = pixels;
|
|
||||||
dst = locked.pBits;
|
|
||||||
length = rect->w * SDL_BYTESPERPIXEL(texture->format);
|
|
||||||
for (row = 0; row < rect->h; ++row) {
|
|
||||||
SDL_memcpy(dst, src, length);
|
|
||||||
src += pitch;
|
|
||||||
dst += locked.Pitch;
|
|
||||||
}
|
|
||||||
IDirect3DTexture9_UnlockRect(temp, 0);
|
|
||||||
|
|
||||||
result =
|
|
||||||
IDirect3DDevice9_UpdateTexture(renderdata->device,
|
|
||||||
(IDirect3DBaseTexture9 *) temp,
|
|
||||||
(IDirect3DBaseTexture9 *) data->
|
|
||||||
texture);
|
|
||||||
IDirect3DTexture9_Release(temp);
|
|
||||||
if (FAILED(result)) {
|
|
||||||
GL_SetError("UpdateTexture()", result);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,38 +371,30 @@ GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
int *pitch)
|
int *pitch)
|
||||||
{
|
{
|
||||||
GL_TextureData *data = (GL_TextureData *) texture->driverdata;
|
GL_TextureData *data = (GL_TextureData *) texture->driverdata;
|
||||||
RECT d3drect;
|
|
||||||
GLLOCKED_RECT locked;
|
|
||||||
HRESULT result;
|
|
||||||
|
|
||||||
if (texture->access != SDL_TextureAccess_Local) {
|
if (!data->pixels) {
|
||||||
SDL_SetError("Can't lock remote video memory");
|
data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
|
||||||
return -1;
|
data->pixels = SDL_malloc(texture->h * data->pitch);
|
||||||
|
if (!data->pixels) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d3drect.left = rect->x;
|
if (markDirty) {
|
||||||
d3drect.right = rect->x + rect->w;
|
SDL_AddDirtyRect(&data->dirty, rect);
|
||||||
d3drect.top = rect->y;
|
|
||||||
d3drect.bottom = rect->y + rect->h;
|
|
||||||
|
|
||||||
result =
|
|
||||||
IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
|
|
||||||
markDirty ? 0 : GLLOCK_NO_DIRTY_UPDATE);
|
|
||||||
if (FAILED(result)) {
|
|
||||||
GL_SetError("LockRect()", result);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
*pixels = locked.pBits;
|
|
||||||
*pitch = locked.Pitch;
|
*pixels =
|
||||||
|
(void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
|
||||||
|
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||||
|
*pitch = data->pitch;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||||
{
|
{
|
||||||
GL_TextureData *data = (GL_TextureData *) texture->driverdata;
|
|
||||||
|
|
||||||
IDirect3DTexture9_UnlockRect(data->texture, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -402,18 +402,10 @@ GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
|
||||||
const SDL_Rect * rects)
|
const SDL_Rect * rects)
|
||||||
{
|
{
|
||||||
GL_TextureData *data = (GL_TextureData *) texture->driverdata;
|
GL_TextureData *data = (GL_TextureData *) texture->driverdata;
|
||||||
RECT d3drect;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < numrects; ++i) {
|
for (i = 0; i < numrects; ++i) {
|
||||||
const SDL_Rect *rect = &rects[i];
|
SDL_AddDirtyRect(&data->dirty, &rects[i]);
|
||||||
|
|
||||||
d3drect.left = rect->x;
|
|
||||||
d3drect.right = rect->x + rect->w;
|
|
||||||
d3drect.top = rect->y;
|
|
||||||
d3drect.bottom = rect->y + rect->h;
|
|
||||||
|
|
||||||
IDirect3DTexture9_AddDirtyRect(data->texture, &d3drect);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,17 +438,43 @@ GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
int minx, miny, maxx, maxy;
|
int minx, miny, maxx, maxy;
|
||||||
GLfloat minu, maxu, minv, maxv;
|
GLfloat minu, maxu, minv, maxv;
|
||||||
|
|
||||||
|
if (texturedata->dirty.count > 0) {
|
||||||
|
SDL_DirtyRect *dirty;
|
||||||
|
void *pixels;
|
||||||
|
int bpp = SDL_BYTESPERPIXEL(texture->format);
|
||||||
|
int pitch = texturedata->pitch;
|
||||||
|
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); /* FIXME, what to use for RGB 4 byte formats? */
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH,
|
||||||
|
pitch / SDL_BYTESPERPIXEL(texture->format));
|
||||||
|
glBindTexture(texturedata->type, texturedata->texture);
|
||||||
|
for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
|
||||||
|
SDL_Rect *rect = &dirty->rect;
|
||||||
|
pixels =
|
||||||
|
(void *) ((Uint8 *) texturedata->pixels + rect->y * pitch +
|
||||||
|
rect->x * bpp);
|
||||||
|
glTexSubImage2D(texturedata->type, 0, rect->x, rect->y, rect->w,
|
||||||
|
rect->h, texturedata->format,
|
||||||
|
texturedata->formattype, pixels);
|
||||||
|
}
|
||||||
|
SDL_ClearDirtyRects(&texturedata->dirty);
|
||||||
|
}
|
||||||
|
|
||||||
minx = dstrect->x;
|
minx = dstrect->x;
|
||||||
miny = dstrect->y;
|
miny = dstrect->y;
|
||||||
maxx = dstrect->x + dstrect->w;
|
maxx = dstrect->x + dstrect->w;
|
||||||
maxy = dstrect->y + dstrect->h;
|
maxy = dstrect->y + dstrect->h;
|
||||||
|
|
||||||
minu = (GLfloat) srcrect->x / texture->w;
|
minu = (GLfloat) srcrect->x / texture->w;
|
||||||
|
minu *= texturedata->texw;
|
||||||
maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
|
maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
|
||||||
|
maxu *= texturedata->texw;
|
||||||
minv = (GLfloat) srcrect->y / texture->h;
|
minv = (GLfloat) srcrect->y / texture->h;
|
||||||
|
minv *= texturedata->texh;
|
||||||
maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
|
maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
|
||||||
|
maxv *= texturedata->texh;
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texturedata->texture);
|
glBindTexture(texturedata->type, texturedata->texture);
|
||||||
|
|
||||||
switch (blendMode) {
|
switch (blendMode) {
|
||||||
case SDL_TextureBlendMode_None:
|
case SDL_TextureBlendMode_None:
|
||||||
|
@ -480,13 +498,13 @@ GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
switch (scaleMode) {
|
switch (scaleMode) {
|
||||||
case SDL_TextureScaleMode_None:
|
case SDL_TextureScaleMode_None:
|
||||||
case SDL_TextureScaleMode_Fast:
|
case SDL_TextureScaleMode_Fast:
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
break;
|
break;
|
||||||
case SDL_TextureScaleMode_Slow:
|
case SDL_TextureScaleMode_Slow:
|
||||||
case SDL_TextureScaleMode_Best:
|
case SDL_TextureScaleMode_Best:
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,8 +537,12 @@ GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data->texture) {
|
if (data->texture) {
|
||||||
IDirect3DTexture9_Release(data->texture);
|
glDeleteTextures(1, &data->texture);
|
||||||
}
|
}
|
||||||
|
if (data->pixels) {
|
||||||
|
SDL_free(data->pixels);
|
||||||
|
}
|
||||||
|
SDL_FreeDirtyRects(&data->dirty);
|
||||||
SDL_free(data);
|
SDL_free(data);
|
||||||
texture->driverdata = NULL;
|
texture->driverdata = NULL;
|
||||||
}
|
}
|
||||||
|
@ -531,15 +553,15 @@ GL_DestroyRenderer(SDL_Renderer * renderer)
|
||||||
GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
|
GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data->device) {
|
if (data->context) {
|
||||||
IDirect3DDevice9_Release(data->device);
|
SDL_GL_MakeCurrent(0, NULL);
|
||||||
|
SDL_GL_DeleteContext(data->context);
|
||||||
}
|
}
|
||||||
SDL_free(data);
|
SDL_free(data);
|
||||||
}
|
}
|
||||||
SDL_free(renderer);
|
SDL_free(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* 0 */
|
|
||||||
#endif /* SDL_VIDEO_OPENGL */
|
#endif /* SDL_VIDEO_OPENGL */
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -105,13 +105,12 @@ CreateTexture(SDL_Renderer * renderer, Uint32 format, int w, int h)
|
||||||
{
|
{
|
||||||
SDL_Texture *texture;
|
SDL_Texture *texture;
|
||||||
|
|
||||||
texture = (SDL_Texture *) SDL_malloc(sizeof(*texture));
|
texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_zerop(texture);
|
|
||||||
texture->format = format;
|
texture->format = format;
|
||||||
texture->access = SDL_TextureAccess_Local;
|
texture->access = SDL_TextureAccess_Local;
|
||||||
texture->w = w;
|
texture->w = w;
|
||||||
|
@ -173,13 +172,12 @@ SW_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = (SW_RenderData *) SDL_malloc(sizeof(*data));
|
data = (SW_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||||
if (!data) {
|
if (!data) {
|
||||||
SW_DestroyRenderer(renderer);
|
SW_DestroyRenderer(renderer);
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SDL_zerop(data);
|
|
||||||
|
|
||||||
renderer->CreateTexture = SW_CreateTexture;
|
renderer->CreateTexture = SW_CreateTexture;
|
||||||
renderer->QueryTexturePixels = SW_QueryTexturePixels;
|
renderer->QueryTexturePixels = SW_QueryTexturePixels;
|
||||||
|
|
|
@ -42,12 +42,11 @@ SDL_CreateRGBSurface(Uint32 flags,
|
||||||
SDL_Surface *surface;
|
SDL_Surface *surface;
|
||||||
|
|
||||||
/* Allocate the surface */
|
/* Allocate the surface */
|
||||||
surface = (SDL_Surface *) SDL_malloc(sizeof(*surface));
|
surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface));
|
||||||
if (surface == NULL) {
|
if (surface == NULL) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SDL_zerop(surface);
|
|
||||||
|
|
||||||
surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask);
|
surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask);
|
||||||
if (!surface->format) {
|
if (!surface->format) {
|
||||||
|
|
|
@ -279,10 +279,10 @@ SDL_VideoInit(const char *driver_name, Uint32 flags)
|
||||||
|
|
||||||
/* The software renderer is always available */
|
/* The software renderer is always available */
|
||||||
for (i = 0; i < _this->num_displays; ++i) {
|
for (i = 0; i < _this->num_displays; ++i) {
|
||||||
if (_this->displays[i].num_render_drivers > 0) {
|
#if SDL_VIDEO_OPENGL
|
||||||
#if 0 //SDL_VIDEO_OPENGL
|
SDL_AddRenderDriver(i, &GL_RenderDriver);
|
||||||
SDL_AddRenderDriver(i, &GL_RenderDriver);
|
|
||||||
#endif
|
#endif
|
||||||
|
if (_this->displays[i].num_render_drivers > 0) {
|
||||||
SDL_AddRenderDriver(i, &SW_RenderDriver);
|
SDL_AddRenderDriver(i, &SW_RenderDriver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1403,13 +1403,12 @@ SDL_CreateTexture(Uint32 format, int access, int w, int h)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
texture = (SDL_Texture *) SDL_malloc(sizeof(*texture));
|
texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_zerop(texture);
|
|
||||||
texture->id = _this->next_object_id++;
|
texture->id = _this->next_object_id++;
|
||||||
texture->format = format;
|
texture->format = format;
|
||||||
texture->access = access;
|
texture->access = access;
|
||||||
|
|
|
@ -1054,12 +1054,11 @@ SDL_SW_CreateYUVTexture(SDL_Texture * texture)
|
||||||
int i;
|
int i;
|
||||||
int CR, CB;
|
int CR, CB;
|
||||||
|
|
||||||
swdata = (SDL_SW_YUVTexture *) SDL_malloc(sizeof(*swdata));
|
swdata = (SDL_SW_YUVTexture *) SDL_calloc(1, sizeof(*swdata));
|
||||||
if (!swdata) {
|
if (!swdata) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SDL_zerop(swdata);
|
|
||||||
|
|
||||||
switch (texture->format) {
|
switch (texture->format) {
|
||||||
case SDL_PixelFormat_YV12:
|
case SDL_PixelFormat_YV12:
|
||||||
|
|
|
@ -239,20 +239,18 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
D3DPRESENT_PARAMETERS pparams;
|
D3DPRESENT_PARAMETERS pparams;
|
||||||
IDirect3DSwapChain9 *chain;
|
IDirect3DSwapChain9 *chain;
|
||||||
|
|
||||||
renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer));
|
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||||
if (!renderer) {
|
if (!renderer) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SDL_zerop(renderer);
|
|
||||||
|
|
||||||
data = (D3D_RenderData *) SDL_malloc(sizeof(*data));
|
data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||||
if (!data) {
|
if (!data) {
|
||||||
D3D_DestroyRenderer(renderer);
|
D3D_DestroyRenderer(renderer);
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SDL_zerop(data);
|
|
||||||
|
|
||||||
renderer->CreateTexture = D3D_CreateTexture;
|
renderer->CreateTexture = D3D_CreateTexture;
|
||||||
renderer->SetTexturePalette = D3D_SetTexturePalette;
|
renderer->SetTexturePalette = D3D_SetTexturePalette;
|
||||||
|
@ -379,12 +377,11 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||||
D3DPOOL pool;
|
D3DPOOL pool;
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
|
|
||||||
data = (D3D_TextureData *) SDL_malloc(sizeof(*data));
|
data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data));
|
||||||
if (!data) {
|
if (!data) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
SDL_zerop(data);
|
|
||||||
|
|
||||||
texture->driverdata = data;
|
texture->driverdata = data;
|
||||||
|
|
||||||
|
|
|
@ -142,20 +142,18 @@ GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
HBITMAP hbm;
|
HBITMAP hbm;
|
||||||
int i, n;
|
int i, n;
|
||||||
|
|
||||||
renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer));
|
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||||
if (!renderer) {
|
if (!renderer) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SDL_zerop(renderer);
|
|
||||||
|
|
||||||
data = (GDI_RenderData *) SDL_malloc(sizeof(*data));
|
data = (GDI_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||||
if (!data) {
|
if (!data) {
|
||||||
GDI_DestroyRenderer(renderer);
|
GDI_DestroyRenderer(renderer);
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SDL_zerop(data);
|
|
||||||
|
|
||||||
renderer->CreateTexture = GDI_CreateTexture;
|
renderer->CreateTexture = GDI_CreateTexture;
|
||||||
renderer->QueryTexturePixels = GDI_QueryTexturePixels;
|
renderer->QueryTexturePixels = GDI_QueryTexturePixels;
|
||||||
|
@ -183,13 +181,12 @@ GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
|
|
||||||
/* Fill in the compatible bitmap info */
|
/* Fill in the compatible bitmap info */
|
||||||
bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
|
bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
|
||||||
data->bmi = (LPBITMAPINFO) SDL_malloc(bmi_size);
|
data->bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size);
|
||||||
if (!data->bmi) {
|
if (!data->bmi) {
|
||||||
GDI_DestroyRenderer(renderer);
|
GDI_DestroyRenderer(renderer);
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SDL_memset(data->bmi, 0, bmi_size);
|
|
||||||
data->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
data->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
|
||||||
hbm = CreateCompatibleBitmap(data->window_hdc, 1, 1);
|
hbm = CreateCompatibleBitmap(data->window_hdc, 1, 1);
|
||||||
|
@ -241,12 +238,11 @@ GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
|
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
|
||||||
GDI_TextureData *data;
|
GDI_TextureData *data;
|
||||||
|
|
||||||
data = (GDI_TextureData *) SDL_malloc(sizeof(*data));
|
data = (GDI_TextureData *) SDL_calloc(1, sizeof(*data));
|
||||||
if (!data) {
|
if (!data) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
SDL_zerop(data);
|
|
||||||
|
|
||||||
texture->driverdata = data;
|
texture->driverdata = data;
|
||||||
|
|
||||||
|
@ -268,13 +264,12 @@ GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||||
LPBITMAPINFO bmi;
|
LPBITMAPINFO bmi;
|
||||||
|
|
||||||
bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
|
bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
|
||||||
bmi = (LPBITMAPINFO) SDL_malloc(bmi_size);
|
bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size);
|
||||||
if (!bmi) {
|
if (!bmi) {
|
||||||
GDI_DestroyTexture(renderer, texture);
|
GDI_DestroyTexture(renderer, texture);
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
SDL_memset(bmi, 0, bmi_size);
|
|
||||||
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
bmi->bmiHeader.biWidth = texture->w;
|
bmi->bmiHeader.biWidth = texture->w;
|
||||||
bmi->bmiHeader.biHeight = -texture->h; /* topdown bitmap */
|
bmi->bmiHeader.biHeight = -texture->h; /* topdown bitmap */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue