mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-12 00:58:20 +03:00
Use texture for empty textures
This commit is contained in:
@@ -965,8 +965,8 @@ namespace Glitter {
|
||||
gl_state_set_blend_func(blend_src, blend_dst);
|
||||
gl_state_set_blend_equation(GL_FUNC_ADD);
|
||||
|
||||
GLuint texture = rctx_ptr->empty_texture_2d;
|
||||
GLuint mask_texture = rctx_ptr->empty_texture_2d;
|
||||
GLuint texture = rctx_ptr->empty_texture_2d->glid;
|
||||
GLuint mask_texture = rctx_ptr->empty_texture_2d->glid;
|
||||
if (rend_group->type != PARTICLE_LINE && rend_group->texture) {
|
||||
texture = rend_group->texture;
|
||||
if (rend_group->mask_texture) {
|
||||
@@ -2077,8 +2077,8 @@ namespace Glitter {
|
||||
gl_state_set_blend_func(blend_src, blend_dst);
|
||||
gl_state_set_blend_equation(GL_FUNC_ADD);
|
||||
|
||||
GLuint texture = rctx_ptr->empty_texture_2d;
|
||||
GLuint mask_texture = rctx_ptr->empty_texture_2d;
|
||||
GLuint texture = rctx_ptr->empty_texture_2d->glid;
|
||||
GLuint mask_texture = rctx_ptr->empty_texture_2d->glid;
|
||||
if (rend_group->type != PARTICLE_LINE && rend_group->texture) {
|
||||
texture = rend_group->texture;
|
||||
if (rend_group->mask_texture) {
|
||||
|
||||
@@ -2009,8 +2009,8 @@ namespace mdl {
|
||||
void(*func)(render_context * rctx, const ObjSubMeshArgs * args) = draw_sub_mesh_default;
|
||||
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
gl_state_active_bind_texture_2d(i, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_cube_map(5, rctx->empty_texture_cube_map);
|
||||
gl_state_active_bind_texture_2d(i, rctx->empty_texture_2d->glid);
|
||||
gl_state_active_bind_texture_cube_map(5, rctx->empty_texture_cube_map->glid);
|
||||
gl_state_active_texture(0);
|
||||
gl_state_set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
uniform_value_reset();
|
||||
@@ -2171,8 +2171,8 @@ namespace mdl {
|
||||
void(*func)(render_context * rctx, const ObjSubMeshArgs * args) = draw_sub_mesh_default;
|
||||
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
gl_state_active_bind_texture_2d(i, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_cube_map(5, rctx->empty_texture_cube_map);
|
||||
gl_state_active_bind_texture_2d(i, rctx->empty_texture_2d->glid);
|
||||
gl_state_active_bind_texture_cube_map(5, rctx->empty_texture_cube_map->glid);
|
||||
gl_state_active_texture(0);
|
||||
gl_state_set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
uniform_value_reset();
|
||||
|
||||
@@ -463,7 +463,7 @@ namespace mdl {
|
||||
tex_id = (*textures)[texdata->texture_index];
|
||||
|
||||
if (tex_id == -1)
|
||||
tex_id = rctx->empty_texture_2d;;
|
||||
tex_id = rctx->empty_texture_2d->glid;
|
||||
|
||||
gl_state_active_bind_texture_2d(tex_index, tex_id);
|
||||
|
||||
@@ -500,7 +500,7 @@ namespace mdl {
|
||||
sub_mesh->index_offset);
|
||||
|
||||
if (tex_id != -1)
|
||||
gl_state_active_bind_texture_2d(tex_index, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(tex_index, rctx->empty_texture_2d->glid);
|
||||
|
||||
gl_state_enable_cull_face();
|
||||
draw_object_vertex_attrib_reset_default(args);
|
||||
@@ -643,7 +643,7 @@ static void draw_object_material_reset_default(const obj_material_data* mat_data
|
||||
}
|
||||
|
||||
static void draw_object_material_reset_reflect(render_context* rctx) {
|
||||
gl_state_active_bind_texture_2d(0, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(0, rctx->empty_texture_2d->glid);
|
||||
gl_state_enable_cull_face();
|
||||
uniform_value_reset();
|
||||
}
|
||||
@@ -915,7 +915,7 @@ static void draw_object_material_set_reflect(render_context* rctx, const mdl::Ob
|
||||
tex_id = (*textures)[texdata->texture_index];
|
||||
|
||||
if (tex_id == -1)
|
||||
tex_id = rctx->empty_texture_2d;;
|
||||
tex_id = rctx->empty_texture_2d->glid;
|
||||
|
||||
gl_state_active_bind_texture_2d(i, tex_id);
|
||||
|
||||
|
||||
+4
-4
@@ -1655,7 +1655,7 @@ namespace rndr {
|
||||
shader_data.g_texcoord_transforms[7] = mat.row1;
|
||||
}
|
||||
else {
|
||||
gl_state_active_bind_texture_2d(5, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(5, rctx->empty_texture_2d->glid);
|
||||
gl_state_bind_sampler(5, rctx->render_samplers[2]);
|
||||
|
||||
shader_data.g_texcoord_transforms[6] = { 1.0f, 0.0f, 0.0f, 0.0f };
|
||||
@@ -1663,9 +1663,9 @@ namespace rndr {
|
||||
}
|
||||
}
|
||||
else {
|
||||
gl_state_active_bind_texture_2d(4, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(4, rctx->empty_texture_2d->glid);
|
||||
gl_state_bind_sampler(4, rctx->render_samplers[2]);
|
||||
gl_state_active_bind_texture_2d(5, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(5, rctx->empty_texture_2d->glid);
|
||||
gl_state_bind_sampler(5, rctx->render_samplers[2]);
|
||||
|
||||
shader_data.g_texcoord_transforms[4] = { 1.0f, 0.0f, 0.0f, 0.0f };
|
||||
@@ -1688,7 +1688,7 @@ namespace rndr {
|
||||
shader_data.g_flare_coef.z = 1.0f;
|
||||
}
|
||||
else {
|
||||
gl_state_active_bind_texture_2d(7, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(7, rctx->empty_texture_2d->glid);
|
||||
gl_state_bind_sampler(7, rctx->render_samplers[2]);
|
||||
}
|
||||
|
||||
|
||||
+17
-19
@@ -506,26 +506,24 @@ sprite_width(), sprite_height(), screen_x_offset(), screen_y_offset(), screen_wi
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static const GLenum target_cube_map_array[] = {
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
|
||||
static const void* empty_texture_2d_array[] = {
|
||||
empty_texture_data,
|
||||
};
|
||||
|
||||
glGenTextures(1, &empty_texture_2d);
|
||||
gl_state_bind_texture_2d(empty_texture_2d);
|
||||
texture_set_params(GL_TEXTURE_2D, 0, false);
|
||||
glCompressedTexImage2D(GL_TEXTURE_2D, 0,
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 4, 4, 0, 8, empty_texture_data);
|
||||
gl_state_bind_texture_2d(0);
|
||||
empty_texture_2d = texture_load_tex_2d(texture_id(0x2F, 0),
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 4, 4, 0, empty_texture_2d_array, false);
|
||||
|
||||
glGenTextures(1, &empty_texture_cube_map);
|
||||
gl_state_bind_texture_cube_map(empty_texture_cube_map);
|
||||
texture_set_params(GL_TEXTURE_CUBE_MAP, 0, false);
|
||||
for (int32_t side = 0; side < 6; side++)
|
||||
glCompressedTexImage2D(target_cube_map_array[side], 0,
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 4, 4, 0, 8, empty_texture_data);
|
||||
gl_state_bind_texture_cube_map(0);
|
||||
static const void* empty_texture_cube_map_array[] = {
|
||||
empty_texture_data,
|
||||
empty_texture_data,
|
||||
empty_texture_data,
|
||||
empty_texture_data,
|
||||
empty_texture_data,
|
||||
empty_texture_data,
|
||||
};
|
||||
|
||||
empty_texture_cube_map = texture_load_tex_cube_map(texture_id(0x2F, 1),
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 4, 4, 0, empty_texture_cube_map_array);
|
||||
|
||||
static const vec4 border_color = 0.0f;
|
||||
|
||||
@@ -625,8 +623,8 @@ render_context::~render_context() {
|
||||
glDeleteSamplers(4, render_samplers);
|
||||
glDeleteSamplers(18, samplers);
|
||||
|
||||
glDeleteTextures(1, &empty_texture_cube_map);
|
||||
glDeleteTextures(1, &empty_texture_2d);
|
||||
texture_release(empty_texture_cube_map);
|
||||
texture_release(empty_texture_2d);
|
||||
|
||||
obj_skinning_ubo.Destroy();
|
||||
obj_batch_ubo.Destroy();
|
||||
|
||||
@@ -449,8 +449,8 @@ struct render_context {
|
||||
GL::UniformBuffer obj_batch_ubo;
|
||||
GL::UniformBuffer obj_skinning_ubo;
|
||||
|
||||
GLuint empty_texture_2d;
|
||||
GLuint empty_texture_cube_map;
|
||||
texture* empty_texture_2d;
|
||||
texture* empty_texture_cube_map;
|
||||
|
||||
GLuint samplers[18];
|
||||
GLuint render_samplers[4];
|
||||
|
||||
@@ -790,7 +790,7 @@ namespace rndr {
|
||||
if (effect_texture)
|
||||
gl_state_active_bind_texture_2d(14, effect_texture->glid);
|
||||
else
|
||||
gl_state_active_bind_texture_2d(14, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(14, rctx->empty_texture_2d->glid);
|
||||
|
||||
if (pass_sw[RND_PASSID_REFLECT] && reflect) {
|
||||
RenderTexture& refl_tex = get_render_texture(0);
|
||||
@@ -798,7 +798,7 @@ namespace rndr {
|
||||
uniform_value[U_WATER_REFLECT] = 1;
|
||||
}
|
||||
else {
|
||||
gl_state_active_bind_texture_2d(15, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(15, rctx->empty_texture_2d->glid);
|
||||
uniform_value[U_WATER_REFLECT] = 0;
|
||||
}
|
||||
|
||||
@@ -1084,7 +1084,7 @@ namespace rndr {
|
||||
if (effect_texture)
|
||||
gl_state_active_bind_texture_2d(14, effect_texture->glid);
|
||||
else
|
||||
gl_state_active_bind_texture_2d(14, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(14, rctx->empty_texture_2d->glid);
|
||||
gl_state_bind_sampler(14, rctx->render_samplers[0]);
|
||||
gl_state_set_color_mask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
gl_state_enable_depth_test();
|
||||
@@ -1619,8 +1619,8 @@ static void draw_pass_3d_shadow_set(Shadow* shad, render_context* rctx) {
|
||||
rctx->draw_state->self_shadow = true;
|
||||
}
|
||||
else {
|
||||
gl_state_active_bind_texture_2d(19, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(20, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(19, rctx->empty_texture_2d->glid);
|
||||
gl_state_active_bind_texture_2d(20, rctx->empty_texture_2d->glid);
|
||||
gl_state_active_texture(0);
|
||||
rctx->draw_state->self_shadow = false;
|
||||
}
|
||||
@@ -1674,7 +1674,7 @@ static void draw_pass_3d_shadow_set(Shadow* shad, render_context* rctx) {
|
||||
}
|
||||
|
||||
for (; j < 2; j++)
|
||||
gl_state_active_bind_texture_2d(6 + j, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(6 + j, rctx->empty_texture_2d->glid);
|
||||
gl_state_active_texture(0);
|
||||
|
||||
light_set* set = &rctx->light_set[LIGHT_SET_MAIN];
|
||||
|
||||
+5
-5
@@ -894,13 +894,13 @@ namespace spr {
|
||||
gl_state_bind_sampler(1, j.sampler);
|
||||
}
|
||||
else if (!gl_state.texture_binding_2d[1])
|
||||
gl_state_active_bind_texture_2d(1, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(1, rctx->empty_texture_2d->glid);
|
||||
}
|
||||
else {
|
||||
if (!gl_state.texture_binding_2d[0])
|
||||
gl_state_active_bind_texture_2d(0, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(0, rctx->empty_texture_2d->glid);
|
||||
if (!gl_state.texture_binding_2d[1])
|
||||
gl_state_active_bind_texture_2d(1, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(1, rctx->empty_texture_2d->glid);
|
||||
}
|
||||
|
||||
shaders_ft.set(j.shader);
|
||||
@@ -1843,9 +1843,9 @@ namespace spr {
|
||||
|
||||
static void draw_sprite_begin(render_context* rctx) {
|
||||
gl_state_disable_blend();
|
||||
gl_state_active_bind_texture_2d(0, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(0, rctx->empty_texture_2d->glid);
|
||||
gl_state_bind_sampler(0, 0);
|
||||
gl_state_active_bind_texture_2d(1, rctx->empty_texture_2d);
|
||||
gl_state_active_bind_texture_2d(1, rctx->empty_texture_2d->glid);
|
||||
gl_state_bind_sampler(1, 0);
|
||||
gl_state_bind_sampler(7, 0);
|
||||
gl_state_set_blend_func_separate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO);
|
||||
|
||||
Reference in New Issue
Block a user