fill in the texture_setimage function, fill in a few other functions, and change certain names to be a little more consistent
This commit is contained in:
@@ -282,12 +282,6 @@ void effect_setint(effect_t effect, eparam_t param, int val)
|
||||
effect_setval_inline(effect, param, &val, sizeof(int));
|
||||
}
|
||||
|
||||
void effect_setmatrix3(effect_t effect, eparam_t param,
|
||||
const struct matrix3 *val)
|
||||
{
|
||||
effect_setval_inline(effect, param, val, sizeof(struct matrix3));
|
||||
}
|
||||
|
||||
void effect_setmatrix4(effect_t effect, eparam_t param,
|
||||
const struct matrix4 *val)
|
||||
{
|
||||
|
@@ -138,7 +138,7 @@ struct gs_exports {
|
||||
uint32_t (*texture_getheight)(texture_t tex);
|
||||
enum gs_color_format (*texture_getcolorformat)(texture_t tex);
|
||||
bool (*texture_map)(texture_t tex, void **ptr,
|
||||
uint32_t *byte_width);
|
||||
uint32_t *row_bytes);
|
||||
void (*texture_unmap)(texture_t tex);
|
||||
|
||||
void (*cubetexture_destroy)(texture_t cubetex);
|
||||
@@ -157,7 +157,7 @@ struct gs_exports {
|
||||
enum gs_color_format (*stagesurface_getcolorformat)(
|
||||
stagesurf_t stagesurf);
|
||||
bool (*stagesurface_map)(stagesurf_t stagesurf, const void **data,
|
||||
uint32_t *byte_width);
|
||||
uint32_t *row_bytes);
|
||||
void (*stagesurface_unmap)(stagesurf_t stagesurf);
|
||||
|
||||
void (*zstencil_destroy)(zstencil_t zstencil);
|
||||
|
@@ -722,13 +722,39 @@ void gs_viewport_pop(void)
|
||||
da_pop_back(thread_graphics->viewport_stack);
|
||||
}
|
||||
|
||||
void texture_setimage(texture_t tex, const void *data, uint32_t byte_width)
|
||||
void texture_setimage(texture_t tex, const void *data, uint32_t row_bytes,
|
||||
bool flip)
|
||||
{
|
||||
/* TODO */
|
||||
void *ptr;
|
||||
uint32_t row_bytes_out;
|
||||
uint32_t row_copy;
|
||||
int32_t height = (int32_t)texture_getheight(tex);
|
||||
int32_t y;
|
||||
|
||||
if (!texture_map(tex, &ptr, &row_bytes_out))
|
||||
return;
|
||||
|
||||
row_copy = (row_bytes < row_bytes_out) ? row_bytes : row_bytes_out;
|
||||
|
||||
if (flip) {
|
||||
for (y = height-1; y >= 0; y--)
|
||||
memcpy((uint8_t*)ptr + (uint32_t)y * row_bytes_out,
|
||||
(uint8_t*)data + (uint32_t)y * row_bytes,
|
||||
row_copy);
|
||||
|
||||
} else if (row_bytes == row_bytes_out) {
|
||||
memcpy(ptr, data, row_copy * height);
|
||||
|
||||
} else {
|
||||
for (y = 0; y < height; y++)
|
||||
memcpy((uint8_t*)ptr + (uint32_t)y * row_bytes_out,
|
||||
(uint8_t*)data + (uint32_t)y * row_bytes,
|
||||
row_copy);
|
||||
}
|
||||
}
|
||||
|
||||
void cubetexture_setimage(texture_t cubetex, uint32_t side, const void *data,
|
||||
uint32_t byte_width)
|
||||
uint32_t row_bytes, bool invert)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
@@ -1347,10 +1373,10 @@ 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 *byte_width)
|
||||
bool texture_map(texture_t tex, void **ptr, uint32_t *row_bytes)
|
||||
{
|
||||
graphics_t graphics = thread_graphics;
|
||||
return graphics->exports.texture_map(tex, ptr, byte_width);
|
||||
return graphics->exports.texture_map(tex, ptr, row_bytes);
|
||||
}
|
||||
|
||||
void texture_unmap(texture_t tex)
|
||||
@@ -1432,10 +1458,10 @@ enum gs_color_format stagesurface_getcolorformat(stagesurf_t stagesurf)
|
||||
}
|
||||
|
||||
bool stagesurface_map(stagesurf_t stagesurf, const void **data,
|
||||
uint32_t *byte_width)
|
||||
uint32_t *row_bytes)
|
||||
{
|
||||
graphics_t graphics = thread_graphics;
|
||||
return graphics->exports.stagesurface_map(stagesurf, data, byte_width);
|
||||
return graphics->exports.stagesurface_map(stagesurf, data, row_bytes);
|
||||
}
|
||||
|
||||
void stagesurface_unmap(stagesurf_t stagesurf)
|
||||
|
@@ -366,8 +366,6 @@ EXPORT eparam_t effect_getworldmatrix(effect_t effect);
|
||||
EXPORT void effect_setbool(effect_t effect, eparam_t param, bool val);
|
||||
EXPORT void effect_setfloat(effect_t effect, eparam_t param, float val);
|
||||
EXPORT void effect_setint(effect_t effect, eparam_t param, int val);
|
||||
EXPORT void effect_setmatrix3(effect_t effect, eparam_t param,
|
||||
const struct matrix3 *val);
|
||||
EXPORT void effect_setmatrix4(effect_t effect, eparam_t param,
|
||||
const struct matrix4 *val);
|
||||
EXPORT void effect_setvec2(effect_t effect, eparam_t param,
|
||||
@@ -377,7 +375,7 @@ EXPORT void effect_setvec3(effect_t effect, eparam_t param,
|
||||
EXPORT void effect_setvec4(effect_t effect, eparam_t param,
|
||||
const struct vec4 *val);
|
||||
EXPORT void effect_settexture(effect_t effect, eparam_t param, texture_t val);
|
||||
EXPORT void effect_setval(effect_t shader, eparam_t param, const void *val,
|
||||
EXPORT void effect_setval(effect_t effect, eparam_t param, const void *val,
|
||||
size_t size);
|
||||
EXPORT void effect_setdefault(effect_t effect, eparam_t param);
|
||||
|
||||
@@ -498,9 +496,9 @@ EXPORT void gs_viewport_push(void);
|
||||
EXPORT void gs_viewport_pop(void);
|
||||
|
||||
EXPORT void texture_setimage(texture_t tex, const void *data,
|
||||
uint32_t byte_width);
|
||||
uint32_t row_bytes, bool invert);
|
||||
EXPORT void cubetexture_setimage(texture_t cubetex, uint32_t side,
|
||||
const void *data, uint32_t byte_width);
|
||||
const void *data, uint32_t row_bytes, bool invert);
|
||||
|
||||
EXPORT void gs_perspective(float fovy, float aspect, float znear, float zfar);
|
||||
|
||||
@@ -623,7 +621,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 *byte_width);
|
||||
EXPORT bool texture_map(texture_t tex, void **ptr, uint32_t *row_bytes);
|
||||
EXPORT void texture_unmap(texture_t tex);
|
||||
|
||||
EXPORT void cubetexture_destroy(texture_t cubetex);
|
||||
@@ -641,7 +639,7 @@ EXPORT uint32_t stagesurface_getwidth(stagesurf_t stagesurf);
|
||||
EXPORT uint32_t stagesurface_getheight(stagesurf_t stagesurf);
|
||||
EXPORT enum gs_color_format stagesurface_getcolorformat(stagesurf_t stagesurf);
|
||||
EXPORT bool stagesurface_map(stagesurf_t stagesurf, const void **data,
|
||||
uint32_t *byte_width);
|
||||
uint32_t *row_bytes);
|
||||
EXPORT void stagesurface_unmap(stagesurf_t stagesurf);
|
||||
|
||||
EXPORT void zstencil_destroy(zstencil_t zstencil);
|
||||
|
Reference in New Issue
Block a user