void gr_opengl_clear_states() { gr_zbias(0); gr_zbuffer_set(ZBUFFER_TYPE_READ); gr_set_cull(0); gr_set_fill_mode(GR_FILL_MODE_SOLID); opengl_shader_set_current(); }
void CJumpNode::Render(vec3d *pos, vec3d *view_pos) { draw_list scene; Render(&scene, pos, view_pos); scene.render_all(); gr_set_fill_mode(GR_FILL_MODE_SOLID); gr_clear_states(); gr_set_buffer(-1); }
void gr_opengl_clear_states() { GL_state.Texture.DisableAll(); gr_zbias(0); gr_zbuffer_set(ZBUFFER_TYPE_READ); gr_set_cull(0); gr_set_fill_mode(GR_FILL_MODE_SOLID); gr_reset_lighting(); gr_set_lighting(false, false); opengl_shader_set_current(); }
void opengl_tnl_set_material(material* material_info, bool set_base_map) { int shader_handle = material_info->get_shader_handle(); int base_map = material_info->get_texture_map(TM_BASE_TYPE); vec4 clr = material_info->get_color(); Assert(shader_handle >= 0); opengl_shader_set_current(shader_handle); if ( Current_shader->shader == SDR_TYPE_PASSTHROUGH_RENDER ) { opengl_shader_set_passthrough(base_map >= 0, material_info->get_texture_type() == TCACHE_TYPE_AABITMAP, &clr, material_info->get_color_scale()); } GL_state.SetAlphaBlendMode(material_info->get_blend_mode()); GL_state.SetZbufferType(material_info->get_depth_mode()); gr_set_cull(material_info->get_cull_mode() ? 1 : 0); gr_zbias(material_info->get_depth_bias()); gr_set_fill_mode(material_info->get_fill_mode()); material::fog &fog_params = material_info->get_fog(); if ( fog_params.enabled ) { gr_fog_set(GR_FOGMODE_FOG, fog_params.r, fog_params.g, fog_params.b, fog_params.dist_near, fog_params.dist_far); } else { gr_fog_set(GR_FOGMODE_NONE, 0, 0, 0); } gr_set_texture_addressing(material_info->get_texture_addressing()); material::clip_plane &clip_params = material_info->get_clip_plane(); if ( clip_params.enabled ) { gr_opengl_set_clip_plane(&clip_params.normal, &clip_params.position); } else { gr_opengl_set_clip_plane(NULL, NULL); } if ( set_base_map && base_map >= 0 ) { float u_scale, v_scale; if ( !gr_opengl_tcache_set(base_map, material_info->get_texture_type(), &u_scale, &v_scale) ) { mprintf(("WARNING: Error setting bitmap texture (%i)!\n", base_map)); } } }
void gr_opengl_clear_states() { if ( GL_version >= 30 ) { glBindVertexArray(GL_vao); } gr_zbias(0); gr_zbuffer_set(ZBUFFER_TYPE_READ); gr_set_cull(0); gr_set_fill_mode(GR_FILL_MODE_SOLID); gr_reset_lighting(); gr_set_lighting(false, false); opengl_shader_set_current(); }
void opengl_tnl_set_material(material* material_info, bool set_base_map, bool set_clipping) { int shader_handle = material_info->get_shader_handle(); int base_map = material_info->get_texture_map(TM_BASE_TYPE); vec4 clr = material_info->get_color(); Assert(shader_handle >= 0); opengl_shader_set_current(shader_handle); if (material_info->has_buffer_blend_modes()) { Assertion(GLAD_GL_ARB_draw_buffers_blend != 0, "Buffer blend modes are not supported at the moment! Query the capability before using this feature."); auto enable_blend = false; for (auto i = 0; i < (int) material::NUM_BUFFER_BLENDS; ++i) { auto mode = material_info->get_blend_mode(i); GL_state.SetAlphaBlendModei(i, mode); enable_blend = enable_blend || mode != ALPHA_BLEND_NONE; } GL_state.Blend(enable_blend ? GL_TRUE : GL_FALSE); } else { GL_state.SetAlphaBlendMode(material_info->get_blend_mode()); } GL_state.SetZbufferType(material_info->get_depth_mode()); gr_set_cull(material_info->get_cull_mode() ? 1 : 0); gr_zbias(material_info->get_depth_bias()); gr_set_fill_mode(material_info->get_fill_mode()); gr_set_texture_addressing(material_info->get_texture_addressing()); if (set_clipping) { // Only set the clipping state if explicitly requested by the caller to avoid unnecessary state changes auto& clip_params = material_info->get_clip_plane(); if (!clip_params.enabled) { GL_state.ClipDistance(0, false); } else { Assertion(Current_shader != NULL && (Current_shader->shader == SDR_TYPE_MODEL || Current_shader->shader == SDR_TYPE_PASSTHROUGH_RENDER || Current_shader->shader == SDR_TYPE_DEFAULT_MATERIAL), "Clip planes are not supported by this shader!"); GL_state.ClipDistance(0, true); } } GL_state.StencilMask(material_info->get_stencil_mask()); auto& stencilFunc = material_info->get_stencil_func(); GL_state.StencilFunc(convertComparisionFunction(stencilFunc.compare), stencilFunc.ref, stencilFunc.mask); auto& frontStencilOp = material_info->get_front_stencil_op(); GL_state.StencilOpSeparate(GL_FRONT, convertStencilOp(frontStencilOp.stencilFailOperation), convertStencilOp(frontStencilOp.depthFailOperation), convertStencilOp(frontStencilOp.successOperation)); auto& backStencilOp = material_info->get_back_stencil_op(); GL_state.StencilOpSeparate(GL_BACK, convertStencilOp(backStencilOp.stencilFailOperation), convertStencilOp(backStencilOp.depthFailOperation), convertStencilOp(backStencilOp.successOperation)); GL_state.StencilTest(material_info->is_stencil_enabled() ? GL_TRUE : GL_FALSE); auto& color_mask = material_info->get_color_mask(); GL_state.ColorMask(color_mask.x, color_mask.y, color_mask.z, color_mask.w); // This is only needed for the passthrough shader uint32_t array_index = 0; if ( set_base_map && base_map >= 0 ) { float u_scale, v_scale; if ( !gr_opengl_tcache_set(base_map, material_info->get_texture_type(), &u_scale, &v_scale, &array_index) ) { mprintf(("WARNING: Error setting bitmap texture (%i)!\n", base_map)); } } if ( Current_shader->shader == SDR_TYPE_DEFAULT_MATERIAL ) { opengl_shader_set_default_material(base_map >= 0, material_info->get_texture_type() == TCACHE_TYPE_AABITMAP, &clr, material_info->get_color_scale(), array_index, material_info->get_clip_plane()); } }