summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/chibi/cp_loader_s3m.cpp2
-rw-r--r--drivers/gles1/rasterizer_gles1.cpp10
-rw-r--r--drivers/gles1/rasterizer_gles1.h3
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp49
-rw-r--r--drivers/gles2/rasterizer_gles2.h3
5 files changed, 65 insertions, 2 deletions
diff --git a/drivers/chibi/cp_loader_s3m.cpp b/drivers/chibi/cp_loader_s3m.cpp
index c5f0830ae6..8b9871463f 100644
--- a/drivers/chibi/cp_loader_s3m.cpp
+++ b/drivers/chibi/cp_loader_s3m.cpp
@@ -162,7 +162,7 @@ CPLoader::Error CPLoader_S3M::load_sample(CPSample *p_sample) {
p_sample->set_default_volume(def_volume);
p_sample->set_name(name);
- char scrs[4];
+ char scrs[5];
file->get_byte_array((uint8_t*)scrs,4);
scrs[4]=0;
diff --git a/drivers/gles1/rasterizer_gles1.cpp b/drivers/gles1/rasterizer_gles1.cpp
index 00fc85c41c..902c105d64 100644
--- a/drivers/gles1/rasterizer_gles1.cpp
+++ b/drivers/gles1/rasterizer_gles1.cpp
@@ -1021,6 +1021,16 @@ void RasterizerGLES1::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_
}
+
+void RasterizerGLES1::shader_set_default_texture_param(RID p_shader, const StringName& p_name, RID p_texture) {
+
+}
+
+RID RasterizerGLES1::shader_get_default_texture_param(RID p_shader, const StringName& p_name) const {
+
+ return RID();
+}
+
/* COMMON MATERIAL API */
diff --git a/drivers/gles1/rasterizer_gles1.h b/drivers/gles1/rasterizer_gles1.h
index 0995089dd7..d3e38f3ded 100644
--- a/drivers/gles1/rasterizer_gles1.h
+++ b/drivers/gles1/rasterizer_gles1.h
@@ -875,6 +875,9 @@ public:
virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const;
+ virtual void shader_set_default_texture_param(RID p_shader, const StringName& p_name, RID p_texture);
+ virtual RID shader_get_default_texture_param(RID p_shader, const StringName& p_name) const;
+
/* COMMON MATERIAL API */
virtual RID material_create();
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 9f2fd032fa..9d47084c1c 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -1539,6 +1539,29 @@ void RasterizerGLES2::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_
}
+void RasterizerGLES2::shader_set_default_texture_param(RID p_shader, const StringName& p_name, RID p_texture) {
+
+ Shader *shader=shader_owner.get(p_shader);
+ ERR_FAIL_COND(!shader);
+ ERR_FAIL_COND(!texture_owner.owns(p_texture));
+
+ if (p_texture.is_valid())
+ shader->default_textures[p_name]=p_texture;
+ else
+ shader->default_textures.erase(p_name);
+
+}
+
+RID RasterizerGLES2::shader_get_default_texture_param(RID p_shader, const StringName& p_name) const{
+ const Shader *shader=shader_owner.get(p_shader);
+
+ const Map<StringName,RID>::Element *E=shader->default_textures.find(p_name);
+ if (!E)
+ return RID();
+ return E->get();
+}
+
+
/* COMMON MATERIAL API */
@@ -4991,9 +5014,26 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material
Texture *t=NULL;
if (rid.is_valid()) {
+
t=texture_owner.get(rid);
- if (!t)
+ if (!t) {
E->get().value=RID(); //nullify, invalid texture
+ rid=RID();
+ }
+ } else {
+
+
+ }
+
+ if (!rid.is_valid()) {
+ //use from default textures
+ Map<StringName,RID>::Element *F=p_material->shader_cache->default_textures.find(E->key());
+ if (F) {
+ t=texture_owner.get(F->get());
+ if (!t) {
+ p_material->shader_cache->default_textures.erase(E->key());
+ }
+ }
}
@@ -5020,6 +5060,13 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material
}
+ for (Map<StringName,RID>::Element *E=p_material->shader_cache->default_textures.front();E;E=E->next()) {
+ if (p_material->shader_params.has(E->key()))
+ continue;
+
+
+ }
+
if (p_material->shader_cache->has_texscreen && framebuffer.active) {
material_shader.set_uniform(MaterialShaderGLES2::TEXSCREEN_SCREEN_MULT,Vector2(float(viewport.width)/framebuffer.width,float(viewport.height)/framebuffer.height));
material_shader.set_uniform(MaterialShaderGLES2::TEXSCREEN_TEX,texcoord);
diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h
index 27f7848b13..dc596f9f6c 100644
--- a/drivers/gles2/rasterizer_gles2.h
+++ b/drivers/gles2/rasterizer_gles2.h
@@ -195,6 +195,7 @@ class RasterizerGLES2 : public Rasterizer {
Map<StringName,ShaderLanguage::Uniform> uniforms;
StringName first_texture;
+ Map<StringName,RID> default_textures;
SelfList<Shader> dirty_list;
@@ -1255,6 +1256,8 @@ public:
virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const;
+ virtual void shader_set_default_texture_param(RID p_shader, const StringName& p_name, RID p_texture);
+ virtual RID shader_get_default_texture_param(RID p_shader, const StringName& p_name) const;
/* COMMON MATERIAL API */