Use uint8_t* instead of void* for texture data
NOTE: In texture_setimage, I had to move variables to the top of the scope because microsoft's C compiler will give the legacy C90 error of: 'illegal use of this type as an expression'. To sum it up, microsoft's C compiler is still utter garbage.
This commit is contained in:
@@ -36,14 +36,14 @@ EXPORT uint32_t device_getwidth(device_t device);
|
||||
EXPORT uint32_t device_getheight(device_t device);
|
||||
EXPORT texture_t device_create_texture(device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_color_format color_format,
|
||||
uint32_t levels, const void **data, uint32_t flags);
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags);
|
||||
EXPORT texture_t device_create_cubetexture(device_t device, uint32_t size,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags);
|
||||
const uint8_t **data, uint32_t flags);
|
||||
EXPORT texture_t device_create_volumetexture(device_t device, uint32_t width,
|
||||
uint32_t height, uint32_t depth,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags);
|
||||
const uint8_t **data, uint32_t flags);
|
||||
EXPORT zstencil_t device_create_zstencil(device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_zstencil_format format);
|
||||
EXPORT stagesurf_t device_create_stagesurface(device_t device, uint32_t width,
|
||||
|
@@ -37,14 +37,14 @@ struct gs_exports {
|
||||
uint32_t (*device_getheight)(device_t device);
|
||||
texture_t (*device_create_texture)(device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_color_format color_format,
|
||||
uint32_t levels, const void **data, uint32_t flags);
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags);
|
||||
texture_t (*device_create_cubetexture)(device_t device, uint32_t size,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags);
|
||||
const uint8_t **data, uint32_t flags);
|
||||
texture_t (*device_create_volumetexture)(device_t device,
|
||||
uint32_t width, uint32_t height, uint32_t depth,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags);
|
||||
const uint8_t **data, uint32_t flags);
|
||||
zstencil_t (*device_create_zstencil)(device_t device,
|
||||
uint32_t width, uint32_t height,
|
||||
enum gs_zstencil_format format);
|
||||
@@ -134,7 +134,7 @@ struct gs_exports {
|
||||
uint32_t (*texture_getwidth)(texture_t tex);
|
||||
uint32_t (*texture_getheight)(texture_t tex);
|
||||
enum gs_color_format (*texture_getcolorformat)(texture_t tex);
|
||||
bool (*texture_map)(texture_t tex, void **ptr,
|
||||
bool (*texture_map)(texture_t tex, uint8_t **ptr,
|
||||
uint32_t *linesize);
|
||||
void (*texture_unmap)(texture_t tex);
|
||||
bool (*texture_isrect)(texture_t tex);
|
||||
|
@@ -845,17 +845,19 @@ void gs_viewport_pop(void)
|
||||
da_pop_back(thread_graphics->viewport_stack);
|
||||
}
|
||||
|
||||
void texture_setimage(texture_t tex, const void *data, uint32_t linesize,
|
||||
void texture_setimage(texture_t tex, const uint8_t *data, uint32_t linesize,
|
||||
bool flip)
|
||||
{
|
||||
uint8_t *ptr;
|
||||
uint32_t linesize_out;
|
||||
uint32_t row_copy;
|
||||
int32_t height;
|
||||
int32_t y;
|
||||
|
||||
if (!thread_graphics || !tex)
|
||||
return;
|
||||
|
||||
void *ptr;
|
||||
uint32_t linesize_out;
|
||||
uint32_t row_copy;
|
||||
int32_t height = (int32_t)texture_getheight(tex);
|
||||
int32_t y;
|
||||
height = (int32_t)texture_getheight(tex);
|
||||
|
||||
if (!texture_map(tex, &ptr, &linesize_out))
|
||||
return;
|
||||
@@ -864,8 +866,8 @@ void texture_setimage(texture_t tex, const void *data, uint32_t linesize,
|
||||
|
||||
if (flip) {
|
||||
for (y = height-1; y >= 0; y--)
|
||||
memcpy((uint8_t*)ptr + (uint32_t)y * linesize_out,
|
||||
(uint8_t*)data + (uint32_t)y * linesize,
|
||||
memcpy(ptr + (uint32_t)y * linesize_out,
|
||||
data + (uint32_t)y * linesize,
|
||||
row_copy);
|
||||
|
||||
} else if (linesize == linesize_out) {
|
||||
@@ -873,8 +875,8 @@ void texture_setimage(texture_t tex, const void *data, uint32_t linesize,
|
||||
|
||||
} else {
|
||||
for (y = 0; y < height; y++)
|
||||
memcpy((uint8_t*)ptr + (uint32_t)y * linesize_out,
|
||||
(uint8_t*)data + (uint32_t)y * linesize,
|
||||
memcpy(ptr + (uint32_t)y * linesize_out,
|
||||
data + (uint32_t)y * linesize,
|
||||
row_copy);
|
||||
}
|
||||
|
||||
@@ -967,7 +969,7 @@ static inline bool is_pow2(uint32_t size)
|
||||
|
||||
texture_t gs_create_texture(uint32_t width, uint32_t height,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags)
|
||||
const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
graphics_t graphics = thread_graphics;
|
||||
bool pow2tex = is_pow2(width) && is_pow2(height);
|
||||
@@ -999,7 +1001,7 @@ texture_t gs_create_texture(uint32_t width, uint32_t height,
|
||||
|
||||
texture_t gs_create_cubetexture(uint32_t size,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags)
|
||||
const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
graphics_t graphics = thread_graphics;
|
||||
bool pow2tex = is_pow2(size);
|
||||
@@ -1032,7 +1034,7 @@ texture_t gs_create_cubetexture(uint32_t size,
|
||||
|
||||
texture_t gs_create_volumetexture(uint32_t width, uint32_t height,
|
||||
uint32_t depth, enum gs_color_format color_format,
|
||||
uint32_t levels, const void **data, uint32_t flags)
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
graphics_t graphics = thread_graphics;
|
||||
if (!graphics) return NULL;
|
||||
@@ -1653,7 +1655,7 @@ enum gs_color_format texture_getcolorformat(texture_t tex)
|
||||
return graphics->exports.texture_getcolorformat(tex);
|
||||
}
|
||||
|
||||
bool texture_map(texture_t tex, void **ptr, uint32_t *linesize)
|
||||
bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize)
|
||||
{
|
||||
graphics_t graphics = thread_graphics;
|
||||
if (!graphics || !tex) return false;
|
||||
|
@@ -495,7 +495,7 @@ EXPORT void gs_set3dmode(double fovy, double znear, double zvar);
|
||||
EXPORT void gs_viewport_push(void);
|
||||
EXPORT void gs_viewport_pop(void);
|
||||
|
||||
EXPORT void texture_setimage(texture_t tex, const void *data,
|
||||
EXPORT void texture_setimage(texture_t tex, const uint8_t *data,
|
||||
uint32_t linesize, bool invert);
|
||||
EXPORT void cubetexture_setimage(texture_t cubetex, uint32_t side,
|
||||
const void *data, uint32_t linesize, bool invert);
|
||||
@@ -514,13 +514,13 @@ EXPORT uint32_t gs_getheight(void);
|
||||
|
||||
EXPORT texture_t gs_create_texture(uint32_t width, uint32_t height,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags);
|
||||
const uint8_t **data, uint32_t flags);
|
||||
EXPORT texture_t gs_create_cubetexture(uint32_t size,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags);
|
||||
const uint8_t **data, uint32_t flags);
|
||||
EXPORT texture_t gs_create_volumetexture(uint32_t width, uint32_t height,
|
||||
uint32_t depth, enum gs_color_format color_format,
|
||||
uint32_t levels, const void **data, uint32_t flags);
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags);
|
||||
|
||||
EXPORT zstencil_t gs_create_zstencil(uint32_t width, uint32_t height,
|
||||
enum gs_zstencil_format format);
|
||||
@@ -618,7 +618,7 @@ EXPORT void texture_destroy(texture_t tex);
|
||||
EXPORT uint32_t texture_getwidth(texture_t tex);
|
||||
EXPORT uint32_t texture_getheight(texture_t tex);
|
||||
EXPORT enum gs_color_format texture_getcolorformat(texture_t tex);
|
||||
EXPORT bool texture_map(texture_t tex, void **ptr, uint32_t *linesize);
|
||||
EXPORT bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize);
|
||||
EXPORT void texture_unmap(texture_t tex);
|
||||
/** special-case function (GL only) - specifies whether the texture is a
|
||||
* GL_TEXTURE_RECTANGLE type, which doesn't use normalized texture
|
||||
|
@@ -909,7 +909,7 @@ static bool update_async_texture(struct obs_source *source,
|
||||
texture_t tex = source->async_texture;
|
||||
texrender_t texrender = source->async_convert_texrender;
|
||||
enum convert_type type = get_convert_type(frame->format);
|
||||
void *ptr;
|
||||
uint8_t *ptr;
|
||||
uint32_t linesize;
|
||||
|
||||
source->async_format = frame->format;
|
||||
|
Reference in New Issue
Block a user