Skip to content
Snippets Groups Projects
Commit 57cfd4f9 authored by Jim's avatar Jim
Browse files

Implement function to reset blend state

I was implementing a pushing/popping attributes function like with GL,
but I realized that for our particular purposes (and actually for most
purposes) its usage was somewhat..  niche.  I may still implement
pushing/popping of attributes in the future, though right now I feel
using a function to reset the state is sufficient for our purposes.
parent e4772a50
No related branches found
No related tags found
No related merge requests found
......@@ -208,6 +208,12 @@ struct gs_exports {
#endif
};
struct blend_state {
bool enabled;
enum gs_blend_type src;
enum gs_blend_type dest;
};
struct graphics_subsystem {
void *module;
device_t device;
......@@ -233,4 +239,6 @@ struct graphics_subsystem {
pthread_mutex_t mutex;
volatile long ref;
struct blend_state cur_blend_state;
};
......@@ -912,6 +912,19 @@ void gs_perspective(float angle, float aspect, float near, float far)
ymin, ymax, near, far);
}
void gs_reset_blend_state(void)
{
graphics_t graphics = thread_graphics;
if (!graphics) return;
if (!graphics->cur_blend_state.enabled)
gs_enable_blending(true);
if (graphics->cur_blend_state.src != GS_BLEND_SRCALPHA ||
graphics->cur_blend_state.dest != GS_BLEND_INVSRCALPHA)
gs_blendfunction(GS_BLEND_SRCALPHA, GS_BLEND_INVSRCALPHA);
}
/* ------------------------------------------------------------------------- */
const char *gs_preprocessor_name(void)
......@@ -1341,6 +1354,7 @@ void gs_enable_blending(bool enable)
graphics_t graphics = thread_graphics;
if (!graphics) return;
graphics->cur_blend_state.enabled = enable;
graphics->exports.device_enable_blending(graphics->device, enable);
}
......@@ -1382,6 +1396,8 @@ void gs_blendfunction(enum gs_blend_type src, enum gs_blend_type dest)
graphics_t graphics = thread_graphics;
if (!graphics) return;
graphics->cur_blend_state.src = src;
graphics->cur_blend_state.dest = dest;
graphics->exports.device_blendfunction(graphics->device, src, dest);
}
......
......@@ -502,6 +502,8 @@ EXPORT void cubetexture_setimage(texture_t cubetex, uint32_t side,
EXPORT void gs_perspective(float fovy, float aspect, float znear, float zfar);
EXPORT void gs_reset_blend_state(void);
/* -------------------------- */
/* library-specific functions */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment