diff --git a/include/reign.h b/include/reign.h index d18cbbd..7537850 100644 --- a/include/reign.h +++ b/include/reign.h @@ -47,6 +47,12 @@ enum RE_fog_type { RE_FOG_LIGHT_SCATTERING = 2, }; +enum RE_draw_type { + RE_DRAW_TYPE_NORMAL = 0, + RE_DRAW_TYPE_ADDITIVE = 1, + RE_DRAW_TYPE_MAX = RE_DRAW_TYPE_ADDITIVE +}; + struct RE_options { int anti_aliasing; int wait_vsync; @@ -146,6 +152,9 @@ struct RE_instance { float column_radius; float column_angle; // around the Y axis, in degrees + // Billboards + enum RE_draw_type draw_type; + // Lights vec3 vec; vec3 diffuse; diff --git a/src/3d/renderer.c b/src/3d/renderer.c index 996faff..570e4e7 100644 --- a/src/3d/renderer.c +++ b/src/3d/renderer.c @@ -314,6 +314,8 @@ static void render_model(struct RE_instance *inst, struct RE_renderer *r, enum d glUniform1i(r->use_shadow_map, GL_FALSE); } + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); + for (int i = 0; i < model->nr_meshes; i++) { struct mesh *mesh = &model->meshes[i]; struct material *material = &model->materials[mesh->material]; @@ -453,6 +455,14 @@ static void render_billboard(struct RE_instance *inst, struct RE_renderer *r, ma glUniform1i(r->use_shadow_map, GL_FALSE); glUniform1i(r->alpha_mode, ALPHA_BLEND); glUniform1i(r->fog_type, inst->plugin->fog_mode ? inst->plugin->fog_type : 0); + switch (inst->draw_type) { + case RE_DRAW_TYPE_NORMAL: + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); + break; + case RE_DRAW_TYPE_ADDITIVE: + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE); + break; + } glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, bt->texture); @@ -589,7 +599,6 @@ static void render_particle_effect(struct RE_instance *inst, struct RE_renderer break; } } - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); glDepthMask(GL_TRUE); } @@ -832,7 +841,6 @@ void RE_render(struct sact_sprite *sp) } glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); setup_lights(plugin); diff --git a/src/hll/ReignEngine.c b/src/hll/ReignEngine.c index e2836b7..1c849bd 100644 --- a/src/hll/ReignEngine.c +++ b/src/hll/ReignEngine.c @@ -369,8 +369,26 @@ static bool ReignEngine_GetInstanceDrawBump(int plugin, int instance) return ri->draw_bump; } -//int ReignEngine_GetInstanceDrawType(int plugin, int instance); -HLL_WARN_UNIMPLEMENTED(false, bool, ReignEngine, SetInstanceDrawType, int plugin, int instance, int draw_type); +static int ReignEngine_GetInstanceDrawType(int plugin, int instance) +{ + struct RE_instance *ri = get_instance(plugin, instance); + if (!ri) + return 0; + return ri->draw_type; +} + +static bool ReignEngine_SetInstanceDrawType(int plugin, int instance, int draw_type) +{ + struct RE_instance *ri = get_instance(plugin, instance); + if (!ri) + return false; + if (draw_type < 0 || draw_type > RE_DRAW_TYPE_MAX) { + WARNING("unknown draw type %d", draw_type); + return false; + } + ri->draw_type = draw_type; + return true; +} bool ReignEngine_LoadInstanceMotion(int plugin, int instance, struct string *name) { @@ -1771,7 +1789,7 @@ HLL_WARN_UNIMPLEMENTED(false, bool, ReignEngine, SetGlareBrightnessParam, int pl //float ReignEngine_GetSSAOParam(int plugin, int type); HLL_WARN_UNIMPLEMENTED(false, bool, ReignEngine, SetSSAOParam, int plugin, int type, float param); //bool ReignEngine_CalcIntersectEyeVec(int plugin, int instance, int nMouseX, int nMouseY, float *pfX, float *pfY, float *pfZ); -HLL_WARN_UNIMPLEMENTED(false, bool, ReignEngine, IsLoading, int plugin); +HLL_QUIET_UNIMPLEMENTED(false, bool, ReignEngine, IsLoading, int plugin); //int ReignEngine_GetDebugInfoMode(int plugin); //bool ReignEngine_SetDebugInfoMode(int plugin, int nMode); HLL_WARN_UNIMPLEMENTED(30, int, ReignEngine, GetVertexShaderVersion, void); @@ -1824,7 +1842,7 @@ HLL_LIBRARY(ReignEngine, HLL_TODO_EXPORT(GetInstanceDrawBackShadow, ReignEngine_GetInstanceDrawBackShadow), HLL_EXPORT(GetInstanceDrawMakeShadow, ReignEngine_GetInstanceDrawMakeShadow), HLL_EXPORT(GetInstanceDrawBump, ReignEngine_GetInstanceDrawBump), - HLL_TODO_EXPORT(GetInstanceDrawType, ReignEngine_GetInstanceDrawType), + HLL_EXPORT(GetInstanceDrawType, ReignEngine_GetInstanceDrawType), HLL_EXPORT(SetInstanceDrawType, ReignEngine_SetInstanceDrawType), HLL_EXPORT(LoadInstanceMotion, ReignEngine_LoadInstanceMotion), HLL_EXPORT(GetInstanceMotionState, ReignEngine_GetInstanceMotionState),