Merge branch 'master' of https://github.com/okamstudio/godot into shadow_color

Conflicts:
	drivers/gles2/shader_compiler_gles2.cpp
This commit is contained in:
Saracen 2015-11-18 23:18:10 +00:00
commit dd00452997
243 changed files with 4207 additions and 1998 deletions

View File

@ -59,7 +59,7 @@ platform_arg = ARGUMENTS.get("platform", False)
if (os.name=="posix"):
pass
elif (os.name=="nt"):
if (os.getenv("VSINSTALLDIR")==None or platform_arg=="android"):
if (os.getenv("VSINSTALLDIR")==None or platform_arg=="android"):
custom_tools=['mingw']
env_base=Environment(tools=custom_tools,ENV = {'PATH' : os.environ['PATH']});
@ -185,7 +185,7 @@ if selected_platform in platform_list:
if env['vsproj']=="yes":
env.vs_incs = []
env.vs_srcs = []
def AddToVSProject( sources ):
for x in sources:
if type(x) == type(""):
@ -197,12 +197,12 @@ if selected_platform in platform_list:
basename = pieces[0]
basename = basename.replace('\\\\','/')
env.vs_srcs = env.vs_srcs + [basename + ".cpp"]
env.vs_incs = env.vs_incs + [basename + ".h"]
#print basename
env.AddToVSProject = AddToVSProject
env.vs_incs = env.vs_incs + [basename + ".h"]
#print basename
env.AddToVSProject = AddToVSProject
env.extra_suffix=""
if env["extra_suffix"] != '' :
env.extra_suffix += '.'+env["extra_suffix"]
@ -229,7 +229,7 @@ if selected_platform in platform_list:
#must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11)
detect.configure(env)
#env['platform_libsuffix'] = env['LIBSUFFIX']
#env['platform_libsuffix'] = env['LIBSUFFIX']
suffix="."+selected_platform
@ -284,10 +284,11 @@ if selected_platform in platform_list:
if (env['musepack']=='yes'):
env.Append(CPPFLAGS=['-DMUSEPACK_ENABLED']);
if (env['openssl']!='no'):
env.Append(CPPFLAGS=['-DOPENSSL_ENABLED']);
if (env['openssl']=="builtin"):
env.Append(CPPPATH=['#drivers/builtin_openssl2'])
if (env['openssl']!='no'):
env.Append(CPPFLAGS=['-DOPENSSL_ENABLED']);
if (env['openssl']=="builtin"):
env.Append(CPPPATH=['#drivers/builtin_openssl2'])
if (env["builtin_zlib"]=='yes'):
env.Append(CPPPATH=['#drivers/builtin_zlib/zlib'])
@ -337,7 +338,7 @@ if selected_platform in platform_list:
if (env['colored']=='yes'):
methods.colored(sys,env)
if (env['etc1']=='yes'):
env.Append(CPPFLAGS=['-DETC1_ENABLED'])
@ -356,22 +357,22 @@ if selected_platform in platform_list:
SConscript("main/SCsub")
SConscript("platform/"+selected_platform+"/SCsub"); # build selected platform
# Microsoft Visual Studio Project Generation
if (env['vsproj'])=="yes":
# Microsoft Visual Studio Project Generation
if (env['vsproj'])=="yes":
AddToVSProject(env.core_sources)
AddToVSProject(env.main_sources)
AddToVSProject(env.modules_sources)
AddToVSProject(env.modules_sources)
AddToVSProject(env.scene_sources)
AddToVSProject(env.servers_sources)
AddToVSProject(env.tool_sources)
#env['MSVS_VERSION']='9.0'
env['MSVSBUILDCOM'] = "scons platform=" + selected_platform + " target=" + env["target"] + " bits=" + env["bits"] + " tools=yes"
env['MSVSREBUILDCOM'] = "scons platform=" + selected_platform + " target=" + env["target"] + " bits=" + env["bits"] + " tools=yes vsproj=true"
env['MSVSCLEANCOM'] = "scons --clean platform=" + selected_platform + " target=" + env["target"] + " bits=" + env["bits"] + " tools=yes"
debug_variants = ['Debug|Win32']+['Debug|x64']
release_variants = ['Release|Win32']+['Release|x64']
release_debug_variants = ['Release_Debug|Win32']+['Release_Debug|x64']
@ -382,11 +383,11 @@ if selected_platform in platform_list:
targets = debug_targets + release_targets + release_debug_targets
msvproj = env.MSVSProject(target = ['#godot' + env['MSVSPROJECTSUFFIX'] ],
incs = env.vs_incs,
srcs = env.vs_srcs,
runfile = targets,
buildtarget = targets,
auto_build_solution=1,
variant = variants)
srcs = env.vs_srcs,
runfile = targets,
buildtarget = targets,
auto_build_solution=1,
variant = variants)
else:

View File

@ -10,5 +10,3 @@ Export('env')
lib = env.Library("tests",env.tests_sources)
env.Prepend(LIBS=[lib])

View File

@ -63,5 +63,3 @@ SConscript('bind/SCsub');
lib = env.Library("core",env.core_sources)
env.Prepend(LIBS=[lib])

View File

@ -3,5 +3,3 @@ Import('env')
env.add_source_files(env.core_sources,"*.cpp")
Export('env')

View File

@ -5,5 +5,3 @@ env.add_source_files(env.core_sources,"*.c")
#env.core_sources.append("io/fastlz.c")
Export('env')

View File

@ -177,9 +177,6 @@ Error JSON::_get_token(const CharType *p_str, int &idx, int p_len, Token& r_toke
case 'n': res=10; break;
case 'f': res=12; break;
case 'r': res=13; break;
case '\"': res='\"'; break;
case '\\': res='\\'; break;
case '/': res='/'; break; //wtf
case 'u': {
//hexnumbarh - oct is deprecated
@ -218,10 +215,13 @@ Error JSON::_get_token(const CharType *p_str, int &idx, int p_len, Token& r_toke
} break;
//case '\"': res='\"'; break;
//case '\\': res='\\'; break;
//case '/': res='/'; break;
default: {
r_err_str="Invalid escape sequence";
return ERR_PARSE_ERROR;
res = next;
//r_err_str="Invalid escape sequence";
//return ERR_PARSE_ERROR;
} break;
}

View File

@ -3,5 +3,3 @@ Import('env')
env.add_source_files(env.core_sources,"*.cpp")
Export('env')

View File

@ -73,7 +73,7 @@ public:
-x * v.x - y * v.y - z * v.z);
}
_FORCE_INLINE_ Vector3 xform(const Vector3& v) {
_FORCE_INLINE_ Vector3 xform(const Vector3& v) const {
Quat q = *this * v;
q *= this->inverse();

View File

@ -3,5 +3,3 @@ Import('env')
env.add_source_files(env.core_sources,"*.cpp")
Export('env')

View File

@ -61,9 +61,16 @@ void OS::debug_break() {
void OS::print_error(const char* p_function,const char* p_file,int p_line,const char *p_code,const char*p_rationale,ErrorType p_type) {
const char* err_type;
switch(p_type) {
case ERR_ERROR: err_type="**ERROR**"; break;
case ERR_WARNING: err_type="**WARNING**"; break;
case ERR_SCRIPT: err_type="**SCRIPT ERROR**"; break;
}
if (p_rationale && *p_rationale)
print("**ERROR**: %s\n ",p_rationale);
print("**ERROR**: At: %s:%i:%s() - %s\n",p_file,p_line,p_function,p_code);
print("%s: %s\n ",err_type,p_rationale);
print("%s: At: %s:%i:%s() - %s\n",err_type,p_file,p_line,p_function,p_code);
}
void OS::print(const char* p_format, ...) {

View File

@ -409,6 +409,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM0R(Quat,normalized);
VCALL_LOCALMEM0R(Quat,inverse);
VCALL_LOCALMEM1R(Quat,dot);
VCALL_LOCALMEM1R(Quat,xform);
VCALL_LOCALMEM2R(Quat,slerp);
VCALL_LOCALMEM2R(Quat,slerpni);
VCALL_LOCALMEM4R(Quat,cubic_slerp);
@ -1361,6 +1362,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(QUAT,QUAT,Quat,normalized,varray());
ADDFUNC0(QUAT,QUAT,Quat,inverse,varray());
ADDFUNC1(QUAT,REAL,Quat,dot,QUAT,"b",varray());
ADDFUNC1(QUAT,VECTOR3,Quat,xform,VECTOR3,"v",varray());
ADDFUNC2(QUAT,QUAT,Quat,slerp,QUAT,"b",REAL,"t",varray());
ADDFUNC2(QUAT,QUAT,Quat,slerpni,QUAT,"b",REAL,"t",varray());
ADDFUNC4(QUAT,QUAT,Quat,cubic_slerp,QUAT,"b",QUAT,"pre_a",QUAT,"post_b",REAL,"t",varray());

View File

@ -586,7 +586,21 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
} break;
DEFAULT_OP_LOCALMEM_NUM(*,VECTOR3,Vector3);
DEFAULT_OP_FAIL(PLANE);
DEFAULT_OP_FAIL(QUAT);
case QUAT: {
switch(p_b.type) {
case VECTOR3: {
_RETURN( reinterpret_cast<const Quat*>(p_a._data._mem)->xform( *(const Vector3*)p_b._data._mem) );
} break;
case QUAT: {
_RETURN( *reinterpret_cast<const Quat*>(p_a._data._mem) * *reinterpret_cast<const Quat*>(p_b._data._mem) );
} break;
};
r_valid=false;
return;
} break;
DEFAULT_OP_FAIL(_AABB);
case MATRIX3: {
@ -2573,7 +2587,7 @@ bool Variant::in(const Variant& p_index, bool *r_valid) const {
String idx=p_index;
const String *str=reinterpret_cast<const String*>(_data._mem);
return str->find("idx")!=-1;
return str->find(idx)!=-1;
}
} break;

View File

@ -2,3 +2,4 @@
name="Area 2D Input Events"
main_scene="res://input.scn"
icon="res://icon.png"

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -2,3 +2,4 @@
name="Run-Time CollisionShape"
main_scene="res://dynamic_colobjs.scn"
icon="res://icon.png"

Binary file not shown.

After

Width:  |  Height:  |  Size: 844 B

View File

@ -2,7 +2,7 @@
name="Fog of War"
main_scene="res://fog.scn"
icon="icon.png"
icon="res://icon.png"
[input]

View File

@ -2,6 +2,7 @@
name="HDR for 2D"
main_scene="res://beach_cave.scn"
icon="res://icon.png"
[display]

BIN
demos/2d/hdr/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -2,6 +2,7 @@
name="Isometric 2D + Lighting"
main_scene="res://map.scn"
icon="res://icon.png"
[input]

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -2,6 +2,7 @@
name="Using Lights As Mask"
main_scene="res://lightmask.scn"
icon="res://icon.png"
[rasterizer]

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -2,6 +2,7 @@
name="2D Lighting"
main_scene="res://light_shadows.scn"
icon="res://icon.png"
[display]

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -2,6 +2,7 @@
name="Navigation Polygon (2D)"
main_scene="res://navigation.scn"
icon="res://icon.png"
[display]

BIN
demos/2d/navpoly/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -2,6 +2,7 @@
name="2D Normal Mapping"
main_scene="res://normalmap.scn"
icon="res://icon.png"
[display]

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -2,4 +2,4 @@
name="polygon_path_finder_demo"
main_scene="res://new_scene_poly_with_holes.scn"
icon="icon.png"
icon="res://icon.png"

View File

@ -2,6 +2,7 @@
name="Screen-Space Shaders"
main_scene="res://screen_shaders.scn"
icon="res://icon.png"
[display]

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -2,3 +2,4 @@
name="Signed Distance Field Font"
main_scene="res://sdf.scn"
icon="res://icon.png"

BIN
demos/2d/sdf_font/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -2,6 +2,7 @@
name="Splash Screen"
main_scene="res://splash.xml"
icon="res://icon.png"
[display]

BIN
demos/2d/splash/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -2,3 +2,4 @@
name="2D Shaders for Sprites"
main_scene="res://sprite_shaders.scn"
icon="res://icon.png"

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
demos/3d/navmesh/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -2,3 +2,4 @@
name="SAT Collision Test"
main_scene="res://sat_test.xml"
icon="res://icon.png"

BIN
demos/3d/sat_test/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -2,7 +2,6 @@
name="Input Mapping GUI"
main_scene="res://controls.scn"
icon="icon.png"
[display]

View File

@ -2,3 +2,4 @@
name="Rich Text Label (BBCode)"
main_scene="res://rich_text_bbcode.scn"
icon="res://icon.png"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -2,6 +2,7 @@
name="Scene Instancing Demo"
main_scene="res://container.scn"
icon="res://icon.png"
[physics_2d]

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -2,21 +2,23 @@ extends VBoxContainer
var regex = RegEx.new()
func update_expression():
regex.compile(get_node("Expression").get_text())
func update_expression(text):
regex.compile(text)
update_text()
func update_text():
var text = get_node("Text").get_text()
regex.find(text)
var list = get_node("List")
for child in list.get_children():
child.queue_free()
for res in regex.get_captures():
var label = Label.new()
label.set_text(res)
list.add_child(label)
if regex.is_valid():
regex.find(text)
for res in regex.get_captures():
var label = Label.new()
label.set_text(res)
list.add_child(label)
func _ready():
get_node("Text").set_text("They asked me \"What's going on \\\"in the manor\\\"?\"")
update_expression()
update_expression(get_node("Expression").get_text())

Binary file not shown.

View File

@ -2,7 +2,7 @@
name="Tween Demo"
main_scene="res://main.xml"
icon="icon.png"
icon="res://icon.png"
target_fps=60
[display]

View File

@ -2,7 +2,7 @@
name="Window Management"
main_scene="res://window_management.scn"
icon="icon.png"
icon="res://icon.png"
[display]

View File

@ -69,21 +69,27 @@ for f in env.drivers_sources:
fname = env.File(f).path
else:
fname = env.File(f)[0].path
#base = string.join(fname.split("/")[:-1], "/")
fname = fname.replace("\\", "/")
base = string.join(fname.split("/")[:2], "/")
if base != cur_base and len(list) > max_src:
lib = env.Library("drivers"+str(num), list)
lib_list.append(lib)
list = []
if num > 0:
lib = env.Library("drivers"+str(num), list)
lib_list.append(lib)
list = []
num = num+1
cur_base = base
list.append(f)
if len(list) > 0:
lib = env.Library("drivers"+str(num), list)
lib_list.append(lib)
lib = env.Library("drivers"+str(num), list)
lib_list.append(lib)
if len(lib_list) > 0:
import os, sys
if os.name=='posix' and sys.platform=='msys':
env.Replace(ARFLAGS=['rcsT'])
lib = env.Library("drivers_collated", lib_list)
lib_list = [lib]
drivers_base=[]
env.add_source_files(drivers_base,"*.cpp")
@ -93,4 +99,3 @@ env.Prepend(LIBS=lib_list)
#lib = env.Library("drivers",env.drivers_sources)
#env.Prepend(LIBS=[lib])

View File

@ -3,5 +3,3 @@ Import('env')
env.add_source_files(env.drivers_sources,"*.cpp")
Export('env')

View File

@ -1,7 +1,7 @@
Import('env')
zlib_sources = [
"builtin_zlib/zlib/adler32.c",
"builtin_zlib/zlib/compress.c",
"builtin_zlib/zlib/crc32.c",

View File

@ -3,5 +3,3 @@ Import('env')
env.add_source_files(env.drivers_sources,"*.cpp")
Export('env')

View File

@ -8,4 +8,3 @@ dds_sources = [
env.drivers_sources+=dds_sources
#env.add_source_files(env.drivers_sources, dds_sources)

View File

@ -12,4 +12,3 @@ if (env["etc1"] != "no"):
#env.add_source_files(env.drivers_sources, etc_sources)
Export('env')

View File

@ -3,4 +3,3 @@ Export('env');
env.add_source_files(env.drivers_sources,"*.cpp")
env.add_source_files(env.drivers_sources,"*.c")

View File

@ -4075,6 +4075,8 @@ void RasterizerGLES2::render_target_set_size(RID p_render_target,int p_width,int
glDeleteTextures(1,&rt->color);
rt->fbo=0;
rt->depth=0;
rt->color=0;
rt->width=0;
rt->height=0;
rt->texture_ptr->tex_id=0;
@ -4094,12 +4096,14 @@ void RasterizerGLES2::render_target_set_size(RID p_render_target,int p_width,int
glBindFramebuffer(GL_FRAMEBUFFER, rt->fbo);
//depth
glGenRenderbuffers(1, &rt->depth);
glBindRenderbuffer(GL_RENDERBUFFER, rt->depth );
if (!low_memory_2d) {
glGenRenderbuffers(1, &rt->depth);
glBindRenderbuffer(GL_RENDERBUFFER, rt->depth );
glRenderbufferStorage(GL_RENDERBUFFER, use_depth24?_DEPTH_COMPONENT24_OES:GL_DEPTH_COMPONENT16, rt->width,rt->height);
glRenderbufferStorage(GL_RENDERBUFFER, use_depth24?_DEPTH_COMPONENT24_OES:GL_DEPTH_COMPONENT16, rt->width,rt->height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
}
//color
glGenTextures(1, &rt->color);
@ -4644,6 +4648,9 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
enablers.push_back("#define USE_TIME\n");
uses_time=true;
}
if (vertex_flags.vertex_code_writes_position) {
enablers.push_back("#define VERTEX_SHADER_WRITE_POSITION\n");
}
material_shader.set_custom_shader_code(p_shader->custom_code_id,vertex_code, vertex_globals,fragment_code, light_code, fragment_globals,uniform_names,enablers);
} else if (p_shader->mode==VS::SHADER_CANVAS_ITEM) {
@ -6529,80 +6536,84 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP,false);
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_DP_SAMPLER,false);
if (e->instance->sampled_light.is_valid()) {
if (material->flags[VS::MATERIAL_FLAG_UNSHADED] == false && current_debug != VS::SCENARIO_DEBUG_SHADELESS) {
SampledLight *sl = sampled_light_owner.get(e->instance->sampled_light);
if (sl) {
if (e->instance->sampled_light.is_valid()) {
baked_light=NULL; //can't mix
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_DP_SAMPLER,true);
glActiveTexture(GL_TEXTURE0+max_texture_units-3);
glBindTexture(GL_TEXTURE_2D,sl->texture); //bind the texture
sampled_light_dp_multiplier=sl->multiplier;
bind_dp_sampler=true;
}
}
if (!additive && baked_light) {
if (baked_light->mode==VS::BAKED_LIGHT_OCTREE && baked_light->octree_texture.is_valid() && e->instance->baked_light_octree_xform) {
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_OCTREE,true);
bind_baked_light_octree=true;
if (prev_baked_light!=baked_light) {
Texture *tex=texture_owner.get(baked_light->octree_texture);
if (tex) {
glActiveTexture(GL_TEXTURE0+max_texture_units-3);
glBindTexture(tex->target,tex->tex_id); //bind the texture
}
if (baked_light->light_texture.is_valid()) {
Texture *texl=texture_owner.get(baked_light->light_texture);
if (texl) {
glActiveTexture(GL_TEXTURE0+max_texture_units-4);
glBindTexture(texl->target,texl->tex_id); //bind the light texture
}
}
SampledLight *sl = sampled_light_owner.get(e->instance->sampled_light);
if (sl) {
baked_light = NULL; //can't mix
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_DP_SAMPLER, true);
glActiveTexture(GL_TEXTURE0 + max_texture_units - 3);
glBindTexture(GL_TEXTURE_2D, sl->texture); //bind the texture
sampled_light_dp_multiplier = sl->multiplier;
bind_dp_sampler = true;
}
} else if (baked_light->mode==VS::BAKED_LIGHT_LIGHTMAPS) {
}
int lightmap_idx = e->instance->baked_lightmap_id;
if (!additive && baked_light) {
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP,false);
bind_baked_lightmap=false;
if (baked_light->lightmaps.has(lightmap_idx)) {
RID texid = baked_light->lightmaps[lightmap_idx];
if (prev_baked_light!=baked_light || texid!=prev_baked_light_texture) {
Texture *tex = texture_owner.get(texid);
if (baked_light->mode == VS::BAKED_LIGHT_OCTREE && baked_light->octree_texture.is_valid() && e->instance->baked_light_octree_xform) {
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_OCTREE, true);
bind_baked_light_octree = true;
if (prev_baked_light != baked_light) {
Texture *tex = texture_owner.get(baked_light->octree_texture);
if (tex) {
glActiveTexture(GL_TEXTURE0+max_texture_units-3);
glBindTexture(tex->target,tex->tex_id); //bind the texture
glActiveTexture(GL_TEXTURE0 + max_texture_units - 3);
glBindTexture(tex->target, tex->tex_id); //bind the texture
}
if (baked_light->light_texture.is_valid()) {
Texture *texl = texture_owner.get(baked_light->light_texture);
if (texl) {
glActiveTexture(GL_TEXTURE0 + max_texture_units - 4);
glBindTexture(texl->target, texl->tex_id); //bind the light texture
}
}
prev_baked_light_texture=texid;
}
}
else if (baked_light->mode == VS::BAKED_LIGHT_LIGHTMAPS) {
int lightmap_idx = e->instance->baked_lightmap_id;
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP, false);
bind_baked_lightmap = false;
if (baked_light->lightmaps.has(lightmap_idx)) {
RID texid = baked_light->lightmaps[lightmap_idx];
if (prev_baked_light != baked_light || texid != prev_baked_light_texture) {
Texture *tex = texture_owner.get(texid);
if (tex) {
glActiveTexture(GL_TEXTURE0 + max_texture_units - 3);
glBindTexture(tex->target, tex->tex_id); //bind the texture
}
prev_baked_light_texture = texid;
}
if (texid.is_valid()) {
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP, true);
bind_baked_lightmap = true;
}
if (texid.is_valid()) {
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP,true);
bind_baked_lightmap=true;
}
}
}
}
if (int(prev_baked_light!=NULL) ^ int(baked_light!=NULL)) {
rebind=true;
if (int(prev_baked_light != NULL) ^ int(baked_light != NULL)) {
rebind = true;
}
}
}
@ -10296,7 +10307,11 @@ void RasterizerGLES2::_update_framebuffer() {
framebuffer.fbo=0;
}
#ifdef TOOLS_ENABLED
framebuffer.active=use_fbo;
#else
framebuffer.active=use_fbo && !low_memory_2d;
#endif
framebuffer.width=dwidth;
framebuffer.height=dheight;
framebuffer.scale=scale;
@ -11206,6 +11221,7 @@ RasterizerGLES2::RasterizerGLES2(bool p_compress_arrays,bool p_keep_ram_copy,boo
use_fp16_fb=bool(GLOBAL_DEF("rasterizer/fp16_framebuffer",true));
use_shadow_mapping=true;
use_fast_texture_filter=!bool(GLOBAL_DEF("rasterizer/trilinear_mipmap_filter",true));
low_memory_2d=bool(GLOBAL_DEF("rasterizer/low_memory_2d_mode",false));
skel_default.resize(1024*4);
for(int i=0;i<1024/3;i++) {

View File

@ -105,13 +105,13 @@ class RasterizerGLES2 : public Rasterizer {
float anisotropic_level;
bool use_half_float;
bool low_memory_2d;
Vector<float> skel_default;
Image _get_gl_image_and_format(const Image& p_image, Image::Format p_format, uint32_t p_flags,GLenum& r_gl_format,GLenum& r_gl_internal_format,int &r_gl_components,bool &r_has_alpha_cache,bool &r_compressed);
class RenderTarget;
struct RenderTarget;
struct Texture {
@ -305,7 +305,7 @@ class RasterizerGLES2 : public Rasterizer {
virtual ~GeometryOwner() {}
};
class Mesh;
struct Mesh;
struct Surface : public Geometry {

View File

@ -154,6 +154,9 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
if (vnode->name==vname_vertex && p_assign_left) {
vertex_code_writes_vertex=true;
}
if (vnode->name == vname_position && p_assign_left) {
vertex_code_writes_position = true;
}
if (vnode->name==vname_color_interp) {
flags->use_color_interp=true;
}
@ -663,6 +666,7 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT
uses_texpixel_size=false;
uses_worldvec=false;
vertex_code_writes_vertex=false;
vertex_code_writes_position = false;
uses_shadow_color=false;
uniforms=r_uniforms;
flags=&r_flags;
@ -694,6 +698,7 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT
r_flags.uses_texscreen=uses_texscreen;
r_flags.uses_texpos=uses_texpos;
r_flags.vertex_code_writes_vertex=vertex_code_writes_vertex;
r_flags.vertex_code_writes_position=vertex_code_writes_position;
r_flags.uses_discard=uses_discard;
r_flags.uses_screen_uv=uses_screen_uv;
r_flags.uses_light=uses_light;
@ -782,127 +787,129 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
replace_table["texscreen"]= "texscreen";
replace_table["texpos"]= "texpos";
mode_replace_table[0]["SRC_VERTEX"]="vertex_in.xyz";
mode_replace_table[0]["SRC_NORMAL"]="normal_in";
mode_replace_table[0]["SRC_TANGENT"]="tangent_in";
mode_replace_table[0]["SRC_BINORMALF"]="binormalf";
mode_replace_table[0]["VERTEX"]="vertex_interp";
mode_replace_table[0]["NORMAL"]="normal_interp";
mode_replace_table[0]["TANGENT"]="tangent_interp";
mode_replace_table[0]["BINORMAL"]="binormal_interp";
mode_replace_table[0]["UV"]="uv_interp.xy";
mode_replace_table[0]["UV2"]="uv_interp.zw";
mode_replace_table[0]["COLOR"]="color_interp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_VERTEX"] = "vertex_in.xyz";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_NORMAL"] = "normal_in";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_TANGENT"]="tangent_in";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_BINORMALF"]="binormalf";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["POSITION"] = "gl_Position";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VERTEX"]="vertex_interp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["NORMAL"]="normal_interp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["TANGENT"]="tangent_interp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["BINORMAL"]="binormal_interp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["UV"]="uv_interp.xy";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["UV2"]="uv_interp.zw";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["COLOR"]="color_interp";
//@TODO convert to glsl stuff
mode_replace_table[0]["SPEC_EXP"]="vertex_specular_exp";
mode_replace_table[0]["WORLD_MATRIX"]="world_transform";
mode_replace_table[0]["INV_CAMERA_MATRIX"]="camera_inverse_transform";
mode_replace_table[0]["PROJECTION_MATRIX"]="projection_transform";
mode_replace_table[0]["MODELVIEW_MATRIX"]="modelview";
mode_replace_table[0]["POINT_SIZE"]="gl_PointSize";
mode_replace_table[0]["VAR1"]="var1_interp";
mode_replace_table[0]["VAR2"]="var2_interp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SPEC_EXP"]="vertex_specular_exp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["WORLD_MATRIX"]="world_transform";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["INV_CAMERA_MATRIX"]="camera_inverse_transform";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["PROJECTION_MATRIX"]="projection_transform";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["MODELVIEW_MATRIX"]="modelview";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["POINT_SIZE"]="gl_PointSize";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VAR1"]="var1_interp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VAR2"]="var2_interp";
// mode_replace_table[0]["SCREEN_POS"]="SCREEN_POS";
// mode_replace_table[0]["SCREEN_SIZE"]="SCREEN_SIZE";
mode_replace_table[0]["INSTANCE_ID"]="instance_id";
mode_replace_table[0]["TIME"]="time";
// mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SCREEN_POS"]="SCREEN_POS";
// mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SCREEN_SIZE"]="SCREEN_SIZE";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["INSTANCE_ID"]="instance_id";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["TIME"]="time";
mode_replace_table[1]["VERTEX"]="vertex";
//mode_replace_table[1]["POSITION"]="IN_POSITION";
mode_replace_table[1]["NORMAL"]="normal";
mode_replace_table[1]["TANGENT"]="tangent";
mode_replace_table[1]["POSITION"]="gl_Position";
mode_replace_table[1]["BINORMAL"]="binormal";
mode_replace_table[1]["NORMALMAP"]="normalmap";
mode_replace_table[1]["NORMALMAP_DEPTH"]="normaldepth";
mode_replace_table[1]["VAR1"]="var1_interp";
mode_replace_table[1]["VAR2"]="var2_interp";
mode_replace_table[1]["UV"]="uv";
mode_replace_table[1]["UV2"]="uv2";
mode_replace_table[1]["SCREEN_UV"]="screen_uv";
mode_replace_table[1]["VAR1"]="var1_interp";
mode_replace_table[1]["VAR2"]="var2_interp";
mode_replace_table[1]["COLOR"]="color";
mode_replace_table[1]["DIFFUSE"]="diffuse.rgb";
mode_replace_table[1]["DIFFUSE_ALPHA"]="diffuse";
mode_replace_table[1]["SPECULAR"]="specular";
mode_replace_table[1]["EMISSION"]="emission";
mode_replace_table[1]["SHADE_PARAM"]="shade_param";
mode_replace_table[1]["SPEC_EXP"]="specular_exp";
mode_replace_table[1]["GLOW"]="glow";
mode_replace_table[1]["DISCARD"]="discard_";
mode_replace_table[1]["POINT_COORD"]="gl_PointCoord";
mode_replace_table[1]["INV_CAMERA_MATRIX"]="camera_inverse_transform";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VERTEX"]="vertex";
//mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POSITION"]="IN_POSITION";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMAL"]="normal";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["TANGENT"]="tangent";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POSITION"]="gl_Position";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["BINORMAL"]="binormal";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMALMAP"]="normalmap";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMALMAP_DEPTH"]="normaldepth";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR1"]="var1_interp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR2"]="var2_interp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["UV"]="uv";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["UV2"]="uv2";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SCREEN_UV"]="screen_uv";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR1"]="var1_interp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR2"]="var2_interp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["COLOR"]="color";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DIFFUSE"]="diffuse.rgb";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DIFFUSE_ALPHA"]="diffuse";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SPECULAR"]="specular";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["EMISSION"]="emission";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SHADE_PARAM"]="shade_param";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SPEC_EXP"]="specular_exp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["GLOW"]="glow";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DISCARD"]="discard_";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POINT_COORD"]="gl_PointCoord";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["INV_CAMERA_MATRIX"]="camera_inverse_transform";
//mode_replace_table[1]["SCREEN_POS"]="SCREEN_POS";
//mode_replace_table[1]["SCREEN_TEXEL_SIZE"]="SCREEN_TEXEL_SIZE";
mode_replace_table[1]["TIME"]="time";
//mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SCREEN_POS"]="SCREEN_POS";
//mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SCREEN_TEXEL_SIZE"]="SCREEN_TEXEL_SIZE";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["TIME"]="time";
//////////////
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["NORMAL"]="normal";
//mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["POSITION"]="IN_POSITION";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_DIR"]="light_dir";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_DIFFUSE"]="light_diffuse";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_SPECULAR"]="light_specular";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["EYE_VEC"]="eye_vec";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["DIFFUSE"]="mdiffuse";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SPECULAR"]="specular";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SPECULAR_EXP"]="specular_exp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SHADE_PARAM"]="shade_param";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT"]="light";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["POINT_COORD"]="gl_PointCoord";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["TIME"]="time";
mode_replace_table[2]["NORMAL"]="normal";
//mode_replace_table[2]["POSITION"]="IN_POSITION";
mode_replace_table[2]["LIGHT_DIR"]="light_dir";
mode_replace_table[2]["LIGHT_DIFFUSE"]="light_diffuse";
mode_replace_table[2]["LIGHT_SPECULAR"]="light_specular";
mode_replace_table[2]["EYE_VEC"]="eye_vec";
mode_replace_table[2]["DIFFUSE"]="mdiffuse";
mode_replace_table[2]["SPECULAR"]="specular";
mode_replace_table[2]["SPECULAR_EXP"]="specular_exp";
mode_replace_table[2]["SHADE_PARAM"]="shade_param";
mode_replace_table[2]["LIGHT"]="light";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SHADOW"]="shadow_color";
mode_replace_table[2]["POINT_COORD"]="gl_PointCoord";
mode_replace_table[2]["TIME"]="time";
mode_replace_table[3]["SRC_VERTEX"]="src_vtx";
mode_replace_table[3]["VERTEX"]="outvec.xy";
mode_replace_table[3]["WORLD_VERTEX"]="outvec.xy";
mode_replace_table[3]["UV"]="uv_interp";
mode_replace_table[3]["COLOR"]="color_interp";
mode_replace_table[3]["VAR1"]="var1_interp";
mode_replace_table[3]["VAR2"]="var2_interp";
mode_replace_table[3]["POINT_SIZE"]="gl_PointSize";
mode_replace_table[3]["WORLD_MATRIX"]="modelview_matrix";
mode_replace_table[3]["PROJECTION_MATRIX"]="projection_matrix";
mode_replace_table[3]["EXTRA_MATRIX"]="extra_matrix";
mode_replace_table[3]["TIME"]="time";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["SRC_VERTEX"]="src_vtx";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VERTEX"]="outvec.xy";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["WORLD_VERTEX"]="outvec.xy";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["UV"]="uv_interp";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["COLOR"]="color_interp";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VAR1"]="var1_interp";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VAR2"]="var2_interp";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["POINT_SIZE"]="gl_PointSize";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["WORLD_MATRIX"]="modelview_matrix";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["PROJECTION_MATRIX"]="projection_matrix";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["EXTRA_MATRIX"]="extra_matrix";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["TIME"]="time";
mode_replace_table[4]["POSITION"]="gl_Position";
mode_replace_table[4]["NORMAL"]="normal";
mode_replace_table[4]["NORMALMAP"]="normal_map";
mode_replace_table[4]["NORMALMAP_DEPTH"]="normal_depth";
mode_replace_table[4]["UV"]="uv_interp";
mode_replace_table[4]["SRC_COLOR"]="color_interp";
mode_replace_table[4]["COLOR"]="color";
mode_replace_table[4]["TEXTURE"]="texture";
mode_replace_table[4]["TEXTURE_PIXEL_SIZE"]="texpixel_size";
mode_replace_table[4]["VAR1"]="var1_interp";
mode_replace_table[4]["VAR2"]="var2_interp";
mode_replace_table[4]["SCREEN_UV"]="screen_uv";
mode_replace_table[4]["POINT_COORD"]="gl_PointCoord";
mode_replace_table[4]["TIME"]="time";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["POSITION"]="gl_Position";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMAL"]="normal";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMALMAP"]="normal_map";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMALMAP_DEPTH"]="normal_depth";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["UV"]="uv_interp";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["SRC_COLOR"]="color_interp";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["COLOR"]="color";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TEXTURE"]="texture";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TEXTURE_PIXEL_SIZE"]="texpixel_size";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["VAR1"]="var1_interp";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["VAR2"]="var2_interp";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["SCREEN_UV"]="screen_uv";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["POINT_COORD"]="gl_PointCoord";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TIME"]="time";
mode_replace_table[5]["POSITION"]="gl_Position";
mode_replace_table[5]["NORMAL"]="normal";
mode_replace_table[5]["UV"]="uv_interp";
mode_replace_table[5]["COLOR"]="color";
mode_replace_table[5]["TEXTURE"]="texture";
mode_replace_table[5]["TEXTURE_PIXEL_SIZE"]="texpixel_size";
mode_replace_table[5]["VAR1"]="var1_interp";
mode_replace_table[5]["VAR2"]="var2_interp";
mode_replace_table[5]["LIGHT_VEC"]="light_vec";
mode_replace_table[5]["LIGHT_HEIGHT"]="light_height";
mode_replace_table[5]["LIGHT_COLOR"]="light";
mode_replace_table[5]["LIGHT_UV"]="light_uv";
mode_replace_table[5]["LIGHT"]="light_out";
mode_replace_table[5]["SHADOW"]="shadow_color";
mode_replace_table[5]["SCREEN_UV"]="screen_uv";
mode_replace_table[5]["POINT_COORD"]="gl_PointCoord";
mode_replace_table[5]["TIME"]="time";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["POSITION"]="gl_Position";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["NORMAL"]="normal";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["UV"]="uv_interp";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["COLOR"]="color";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TEXTURE"]="texture";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TEXTURE_PIXEL_SIZE"]="texpixel_size";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["VAR1"]="var1_interp";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["VAR2"]="var2_interp";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_VEC"]="light_vec";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_HEIGHT"]="light_height";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_COLOR"]="light";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_UV"]="light_uv";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT"]="light_out";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["SHADOW"]="shadow_color";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["SCREEN_UV"]="screen_uv";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["POINT_COORD"]="gl_PointCoord";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TIME"]="time";
@ -923,6 +930,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
vname_var1_interp="VAR1";
vname_var2_interp="VAR2";
vname_vertex="VERTEX";
vname_position = "POSITION";
vname_light="LIGHT";
vname_time="TIME";
vname_normalmap="NORMALMAP";

View File

@ -34,7 +34,7 @@ class ShaderCompilerGLES2 {
class Uniform;
public:
class Flags;
struct Flags;
private:
ShaderLanguage::ProgramNode *program_node;
@ -55,6 +55,7 @@ private:
bool uses_texpixel_size;
bool uses_worldvec;
bool vertex_code_writes_vertex;
bool vertex_code_writes_position;
bool uses_shadow_color;
bool sinh_used;
@ -76,6 +77,7 @@ private:
StringName vname_var1_interp;
StringName vname_var2_interp;
StringName vname_vertex;
StringName vname_position;
StringName vname_light;
StringName vname_time;
StringName vname_normalmap;
@ -107,6 +109,7 @@ public:
bool uses_texpos;
bool uses_normalmap;
bool vertex_code_writes_vertex;
bool vertex_code_writes_position;
bool uses_discard;
bool uses_screen_uv;
bool use_color_interp;

View File

@ -6,5 +6,3 @@ if env['BUILDERS'].has_key('GLSL120GLES'):
env.GLSL120GLES('canvas_shadow.glsl');
env.GLSL120GLES('blur.glsl');
env.GLSL120GLES('copy.glsl');

View File

@ -10,4 +10,3 @@ jpg_sources = [
env.drivers_sources+=jpg_sources
#env.add_source_files(env.drivers_sources, jpg_sources)

View File

@ -19,4 +19,3 @@ env.add_source_files(env.drivers_sources,"*.cpp")
#env.add_source_files(env.drivers_sources, mpc_sources)
Export('env')

View File

@ -3,4 +3,3 @@ Export('env');
env.add_source_files(env.drivers_sources,"*.cpp")
#env.add_source_files(env.drivers_sources,"*.c")

View File

@ -18,47 +18,42 @@ More details about its use is documented in `nrex.hpp`
Currently supported features:
* Capturing `()` and non-capturing `(?:)` groups
* Any character `.`
* Any character `.` (includes newlines)
* Shorthand caracter classes `\w\W\s\S\d\D`
* User-defined character classes such as `[A-Za-z]`
* POSIX character classes such as `[[:alnum:]]`
* Bracket expressions such as `[A-Za-z]`
* Simple quantifiers `?`, `*` and `+`
* Range quantifiers `{0,1}`
* Lazy (non-greedy) quantifiers `*?`
* Begining `^` and end `$` anchors
* Word boundaries `\b`
* Alternation `|`
* Backreferences `\1` to `\99`
To do list:
* ASCII `\xFF` code points
* Unicode `\uFFFF` code points
* Positive `(?=)` and negative `(?!)` lookahead
* Positive `(?<=)` and negative `(?<!)` lookbehind (fixed length and no alternations)
* Backreferences `\1` to `\9` (with option to expand to `\99`)
## License
Copyright (c) 2015, Zher Huei Lee
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would
be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.

View File

@ -1,4 +1,3 @@
Import('env')
sources = [
@ -6,4 +5,3 @@ sources = [
'regex.cpp',
]
env.add_source_files(env.drivers_sources, sources)

File diff suppressed because it is too large Load Diff

View File

@ -79,7 +79,8 @@ class nrex
* This is used to provide the array size of the captures needed for
* nrex::match() to work. The size is actually the number of capture
* groups + one for the matching of the entire pattern. The result is
* always capped at 100.
* always capped at 10 or 100, depending on the extend option given in
* nrex::compile() (default 10).
*
* \return The number of captures
*/
@ -95,10 +96,13 @@ class nrex
* runtime error nrex_compile_error if it encounters a problem when
* parsing the pattern.
*
* \param The regex pattern
* \param pattern The regex pattern
* \param extended If true, raises the limit on number of capture
* groups and back-references to 99. Otherwise limited
* to 9. Defaults to false.
* \return True if the pattern was succesfully compiled
*/
bool compile(const nrex_char* pattern);
bool compile(const nrex_char* pattern, bool extended = false);
/*!
* \brief Uses the pattern to search through the provided string

View File

@ -15,7 +15,7 @@
void RegEx::_bind_methods() {
ObjectTypeDB::bind_method(_MD("compile","pattern"),&RegEx::compile);
ObjectTypeDB::bind_method(_MD("compile","pattern", "expanded"),&RegEx::compile, DEFVAL(true));
ObjectTypeDB::bind_method(_MD("find","text","start","end"),&RegEx::find, DEFVAL(0), DEFVAL(-1));
ObjectTypeDB::bind_method(_MD("clear"),&RegEx::clear);
ObjectTypeDB::bind_method(_MD("is_valid"),&RegEx::is_valid);
@ -54,7 +54,9 @@ bool RegEx::is_valid() const {
};
int RegEx::get_capture_count() const {
ERR_FAIL_COND_V( !exp.valid(), 0 );
return exp.capture_size();
}
@ -66,11 +68,11 @@ String RegEx::get_capture(int capture) const {
}
Error RegEx::compile(const String& p_pattern) {
Error RegEx::compile(const String& p_pattern, bool expanded) {
clear();
exp.compile(p_pattern.c_str());
exp.compile(p_pattern.c_str(), expanded);
ERR_FAIL_COND_V( !exp.valid(), FAILED );

View File

@ -36,7 +36,7 @@ public:
bool is_valid() const;
int get_capture_count() const;
String get_capture(int capture) const;
Error compile(const String& p_pattern);
Error compile(const String& p_pattern, bool expanded = false);
int find(const String& p_text, int p_start = 0, int p_end = -1) const;
RegEx();

View File

@ -8,4 +8,3 @@ ogg_sources = [
if env['theora'] != "yes" or env['use_theoraplayer_binary'] != "yes":
env.drivers_sources+=ogg_sources

View File

@ -4,5 +4,3 @@ env.add_source_files(env.drivers_sources,"*.cpp")
env.add_source_files(env.drivers_sources,"*.c")
Export('env')

View File

@ -7,12 +7,16 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
#if (!defined( _MSC_VER ) || ( _MSC_VER >= 1800 ))
/* Define to 1 if you have the `lrint' function. */
#define HAVE_LRINT 1
/* Define to 1 if you have the `lrintf' function. */
#define HAVE_LRINTF 1
#endif
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
@ -109,7 +113,11 @@
/* Define to the equivalent of the C99 'restrict' keyword, or to
nothing if this is not supported. Do not define if restrict is
supported directly. */
#if (!defined( _MSC_VER ) || ( _MSC_VER >= 1800 ))
#define restrict __restrict
#else
#undef restrict
#endif
/* Work around a bug in Sun C++: it does not support _Restrict or
__restrict__, even though the corresponding Sun C compiler ends up with
"#define restrict _Restrict" or "#define restrict __restrict__" in the

View File

@ -38,4 +38,3 @@ env.drivers_sources+=png_sources
#env.add_source_files(env.drivers_sources, png_sources)
Export('env')

View File

@ -21,4 +21,3 @@ if (env["tools"]=="yes"):
#env.add_source_files(env.drivers_sources, squish_sources)
Export('env')

View File

@ -1,4 +1,3 @@
Import('env')
sources = [
@ -34,5 +33,3 @@ sources = [
if env['use_theoraplayer_binary'] != "yes":
env.drivers_sources += sources

View File

@ -1611,28 +1611,35 @@ static void oc_filter_hedge(unsigned char *_dst,int _dst_ystride,
int sum1;
int bx;
int by;
int _rlimit1;
int _rlimit2;
rdst=_dst;
rsrc=_src;
for(bx=0;bx<8;bx++){
for(bx=0;bx<8;++bx){
cdst=rdst;
csrc=rsrc;
for(by=0;by<10;by++){
_rlimit1 = _rlimit2 = _flimit;
for(by=0;by<10;++by){
r[by]=*csrc;
csrc+=_src_ystride;
}
sum0=sum1=0;
for(by=0;by<4;by++){
sum0+=abs(r[by+1]-r[by]);
sum1+=abs(r[by+5]-r[by+6]);
for(by=0;by<4;++by){
int sumed = abs(r[by+1]-r[by]);
sum0+=sumed;
_rlimit1-=sumed;
sumed = abs(r[by+5]-r[by+6]);
sum1+=sumed;
_rlimit2-=sumed;
}
*_variance0+=OC_MINI(255,sum0);
*_variance1+=OC_MINI(255,sum1);
if(sum0<_flimit&&sum1<_flimit&&r[5]-r[4]<_qstep&&r[4]-r[5]<_qstep){
if(_rlimit1&&_rlimit2&&!(r[5]-r[4]-_qstep)&&!(r[4]-r[5]-_qstep)){
*cdst=(unsigned char)(r[0]*3+r[1]*2+r[2]+r[3]+r[4]+4>>3);
cdst+=_dst_ystride;
*cdst=(unsigned char)(r[0]*2+r[1]+r[2]*2+r[3]+r[4]+r[5]+4>>3);
cdst+=_dst_ystride;
for(by=0;by<4;by++){
for(by=0;by<4;++by){
*cdst=(unsigned char)(r[by]+r[by+1]+r[by+2]+r[by+3]*2+
r[by+4]+r[by+5]+r[by+6]+4>>3);
cdst+=_dst_ystride;
@ -1642,13 +1649,13 @@ static void oc_filter_hedge(unsigned char *_dst,int _dst_ystride,
*cdst=(unsigned char)(r[5]+r[6]+r[7]+r[8]*2+r[9]*3+4>>3);
}
else{
for(by=1;by<=8;by++){
for(by=1;by<=8;++by){
*cdst=(unsigned char)r[by];
cdst+=_dst_ystride;
}
}
rdst++;
rsrc++;
++rdst;
++rsrc;
}
}
@ -1663,19 +1670,26 @@ static void oc_filter_vedge(unsigned char *_dst,int _dst_ystride,
int sum1;
int bx;
int by;
int _rlimit1;
int _rlimit2;
cdst=_dst;
for(by=0;by<8;by++){
for(by=0;by<8;++by){
rsrc=cdst-1;
rdst=cdst;
for(bx=0;bx<10;bx++)r[bx]=*rsrc++;
for(bx=0;bx<10;++bx)r[bx]=*rsrc++;
sum0=sum1=0;
for(bx=0;bx<4;bx++){
sum0+=abs(r[bx+1]-r[bx]);
sum1+=abs(r[bx+5]-r[bx+6]);
_rlimit1 = _rlimit2 = _flimit;
for(bx=0;bx<4;++bx){
int sumed = abs(r[bx+1]-r[bx]);
sum0+=sumed;
_rlimit1-=sumed;
sumed = abs(r[bx+5]-r[bx+6]);
sum1+=sumed;
_rlimit2-=sumed;
}
_variances[0]+=OC_MINI(255,sum0);
_variances[1]+=OC_MINI(255,sum1);
if(sum0<_flimit&&sum1<_flimit&&r[5]-r[4]<_qstep&&r[4]-r[5]<_qstep){
if(_rlimit1&&_rlimit2&&!(r[5]-r[4]-_qstep)&&!(r[4]-r[5]-_qstep)){
*rdst++=(unsigned char)(r[0]*3+r[1]*2+r[2]+r[3]+r[4]+4>>3);
*rdst++=(unsigned char)(r[0]*2+r[1]+r[2]*2+r[3]+r[4]+r[5]+4>>3);
for(bx=0;bx<4;bx++){

View File

@ -243,7 +243,9 @@ void VideoStreamPlaybackTheora::set_file(const String& p_file) {
/* Only interested in Vorbis/Theora streams */
int stateflag = 0;
int audio_track_skip=audio_track;
int audio_track_skip=audio_track;
while(!stateflag){
int ret=buffer_data();
if(ret==0)break;
@ -269,15 +271,21 @@ void VideoStreamPlaybackTheora::set_file(const String& p_file) {
copymem(&to,&test,sizeof(test));
theora_p=1;
}else if(!vorbis_p && vorbis_synthesis_headerin(&vi,&vc,&op)>=0){
/* it is vorbis */
if (audio_track_skip) {
vorbis_info_clear(&vi);
vorbis_comment_clear(&vc);
audio_track_skip--;
} else {
copymem(&vo,&test,sizeof(test));
vorbis_p=1;
}
if (audio_track_skip) {
vorbis_info_clear(&vi);
vorbis_comment_clear(&vc);
ogg_stream_clear(&test);
vorbis_info_init(&vi);
vorbis_comment_init(&vc);
audio_track_skip--;
} else {
copymem(&vo,&test,sizeof(test));
vorbis_p=1;
}
}else{
/* whatever it is, we don't care about it */
ogg_stream_clear(&test);

View File

@ -3,5 +3,3 @@ Import('env')
env.add_source_files(env.drivers_sources,"*.cpp")
Export('env')

View File

@ -65,15 +65,25 @@ void OS_Unix::print_error(const char* p_function,const char* p_file,int p_line,c
if (!_print_error_enabled)
return;
if (p_rationale && p_rationale[0]) {
print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_rationale);
print("\E[0;31;40m At: %s:%i.\E[0;0;37m\n",p_file,p_line);
} else {
print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_code);
print("\E[0;31;40m At: %s:%i.\E[0;0;37m\n",p_file,p_line);
const char* err_details;
if (p_rationale && p_rationale[0])
err_details=p_rationale;
else
err_details=p_code;
switch(p_type) {
case ERR_ERROR:
print("\E[1;31mERROR: %s: \E[0m\E[1m%s\n",p_function,err_details);
print("\E[0;31m At: %s:%i.\E[0m\n",p_file,p_line);
break;
case ERR_WARNING:
print("\E[1;33mWARNING: %s: \E[0m\E[1m%s\n",p_function,err_details);
print("\E[0;33m At: %s:%i.\E[0m\n",p_file,p_line);
break;
case ERR_SCRIPT:
print("\E[1;35mSCRIPT ERROR: %s: \E[0m\E[1m%s\n",p_function,err_details);
print("\E[0;35m At: %s:%i.\E[0m\n",p_file,p_line);
break;
}
}

View File

@ -1,4 +1,3 @@
Import('env')
sources = [
@ -37,4 +36,3 @@ env.drivers_sources += sources
if env['theora'] != "yes" or env['use_theoraplayer_binary'] != "yes":
env.drivers_sources += sources_lib

View File

@ -85,7 +85,7 @@ public:
virtual void stop();
virtual bool is_playing() const;
virtual void set_loop_restart_time(float p_time) { loop_restart_time=0; }
virtual void set_loop_restart_time(float p_time) { loop_restart_time=p_time; }
virtual void set_paused(bool p_paused);
virtual bool is_paused(bool p_paused) const;

View File

@ -61,4 +61,3 @@ env.drivers_sources+=webp_sources
#env.add_source_files(env.drivers_sources, webp_sources)
Export('env')

View File

@ -3,5 +3,3 @@ Import('env')
env.add_source_files(env.drivers_sources,"*.cpp")
Export('env')

View File

@ -8,5 +8,3 @@ Export('env')
lib = env.Library("main",env.main_sources)
env.Prepend(LIBS=[lib])

View File

@ -796,7 +796,6 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
main_args.clear();
print_help(execpath);
if (performance)
memdelete(performance);
@ -812,6 +811,8 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
memdelete(packed_data);
if (file_access_network_client)
memdelete(file_access_network_client);
if(path_remap)
memdelete(path_remap);
// Note 1: *zip_packed_data live into *packed_data
// Note 2: PackedData::~PackedData destroy this.
@ -820,7 +821,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
// memdelete( zip_packed_data );
//#endif
unregister_core_driver_types();
unregister_core_types();
OS::get_singleton()->_cmdline.clear();
@ -1007,8 +1008,21 @@ bool Main::start() {
bool export_debug=false;
List<String> args = OS::get_singleton()->get_cmdline_args();
for (int i=0;i<args.size();i++) {
//parameters that do not have an argument to the right
if (args[i]=="-nodocbase") {
doc_base=false;
} else if (args[i]=="-noquit") {
noquit=true;
} else if (args[i]=="-convert_old") {
convert_old=true;
} else if (args[i]=="-editor" || args[i]=="-e") {
editor=true;
} else if (args[i].length() && args[i][0] != '-' && game_path == "") {
game_path=args[i];
}
//parameters that have an argument to the right
if (i < (args.size()-1)) {
else if (i < (args.size()-1)) {
bool parsed_pair=true;
if (args[i]=="-doctool") {
doc_tool=args[i+1];
} else if (args[i]=="-script" || args[i]=="-s") {
@ -1037,20 +1051,13 @@ bool Main::start() {
} else if (args[i]=="-dumpstrings") {
editor=true; //needs editor
dumpstrings=args[i+1];
} else {
// The parameter does not match anything known, don't skip the next argument
parsed_pair=false;
}
if (parsed_pair) {
i++;
}
i++;
}
//parameters that do not have an argument to the right
if (args[i]=="-nodocbase") {
doc_base=false;
} else if (args[i]=="-noquit") {
noquit=true;
} else if (args[i]=="-convert_old") {
convert_old=true;
} else if (args[i]=="-editor" || args[i]=="-e") {
editor=true;
} else if (args[i].length() && args[i][0] != '-' && game_path == "") {
game_path=args[i];
}
}

View File

@ -19,5 +19,3 @@ for x in env.module_list:
lib = env_modules.Library("modules",env.modules_sources)
env.Prepend(LIBS=[lib])

View File

@ -3,5 +3,3 @@ Import('env')
env.add_source_files(env.modules_sources,"*.cpp")
Export('env')

View File

@ -1940,9 +1940,15 @@ void GDParser::_parse_extends(ClassNode *p_class) {
p_class->extends_used=true;
//see if inheritance happens from a file
tokenizer->advance();
if (tokenizer->get_token()==GDTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token_type()==Variant::OBJECT) {
p_class->extends_class.push_back(Variant::get_type_name(Variant::OBJECT));
tokenizer->advance();
return;
}
// see if inheritance happens from a file
if (tokenizer->get_token()==GDTokenizer::TK_CONSTANT) {
Variant constant = tokenizer->get_token_constant();

View File

@ -276,7 +276,6 @@ public:
};
struct NewLineNode : public Node {
int line;
NewLineNode() { type=TYPE_NEWLINE; }
};

View File

@ -1,6 +1,3 @@
Import('env')
env.add_source_files(env.modules_sources,"*.cpp")

View File

@ -62,10 +62,10 @@ pp_baseout.write( manifest )
for x in env.android_source_files:
shutil.copy(x,abspath+"/java/src/com/android/godot")
shutil.copy(x,abspath+"/java/src/com/android/godot")
for x in env.android_module_libraries:
shutil.copy(x,abspath+"/java/libs")
shutil.copy(x,abspath+"/java/libs")
env_android.SharedLibrary("#bin/libgodot",[android_objects],SHLIBSUFFIX=env["SHLIBSUFFIX"])

View File

@ -1123,6 +1123,10 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
if (file=="lib/armeabi/libgodot_android.so" && !export_arm) {
skip=true;
}
if (file.begins_with("META-INF") && _signed) {
skip=true;
}
print_line("ADDING: "+file);

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="godot_project_name_string">godot-project-name-fa</string>
<string name="testuf8">سلام</string>
<string name="text_paused_cellular">آیا می خواهید بر روی اتصال داده همراه دانلود را شروع کنید؟ بر اساس نوع سطح داده شما این ممکن است برای شما هزینه مالی داشته باشد.</string>
<string name="text_paused_cellular_2">اگر نمی خواهید بر روی اتصال داده همراه دانلود را شروع کنید ، دانلود به صورت خودکار در زمان دسترسی به وای-فای شروع می شود.</string>
<string name="text_button_resume_cellular">ادامه دانلود</string>
<string name="text_button_wifi_settings">تنظیمات وای-فای</string>
<string name="text_verifying_download">درحال تایید دانلود</string>
<string name="text_validation_complete">تایید فایل XAPK تکمیل شد. برای خروج تایید کنید.</string>
<string name="text_validation_failed">اعتبارسنجی فایل XAPK ناموق.</string>
<string name="text_button_pause">توقف دانلود</string>
<string name="text_button_resume">ادامه دانلود</string>
<string name="text_button_cancel">انصراف</string>
<string name="text_button_cancel_verify">انصراف از تایید شدن</string>
</resources>

View File

@ -27,7 +27,7 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
activity.getPaymentsManager().requestPurchase(sku, transactionId);
}
});
};
}
/* public string requestPurchasedTicket(){
activity.getPaymentsManager()
@ -42,7 +42,7 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
public GodotPaymentV3(Activity p_activity) {
registerClass("GodotPayments", new String[] {"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases"});
registerClass("GodotPayments", new String[] {"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases", "requestPurchased", "setAutoConsume", "consume"});
activity=(Godot) p_activity;
}
@ -54,7 +54,6 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
activity.getPaymentsManager().consumeUnconsumedPurchases();
}
});
}
private String signature;
@ -63,25 +62,26 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
}
public void callbackSuccess(String ticket, String signature){
// Log.d(this.getClass().getName(), "PRE-Send callback to purchase success");
GodotLib.callobject(purchaseCallbackId, "purchase_success", new Object[]{ticket, signature});
// Log.d(this.getClass().getName(), "POST-Send callback to purchase success");
public void callbackSuccess(String ticket, String signature, String sku){
// Log.d(this.getClass().getName(), "PRE-Send callback to purchase success");
GodotLib.callobject(purchaseCallbackId, "purchase_success", new Object[]{ticket, signature, sku});
// Log.d(this.getClass().getName(), "POST-Send callback to purchase success");
}
public void callbackSuccessProductMassConsumed(String ticket, String signature, String sku){
// Log.d(this.getClass().getName(), "PRE-Send callback to consume success");
GodotLib.calldeferred(purchaseCallbackId, "consume_success", new Object[]{ticket, signature, sku});
// Log.d(this.getClass().getName(), "POST-Send callback to consume success");
// Log.d(this.getClass().getName(), "PRE-Send callback to consume success");
Log.d(this.getClass().getName(), "callbackSuccessProductMassConsumed > "+ticket+","+signature+","+sku);
GodotLib.calldeferred(purchaseCallbackId, "consume_success", new Object[]{ticket, signature, sku});
// Log.d(this.getClass().getName(), "POST-Send callback to consume success");
}
public void callbackSuccessNoUnconsumedPurchases(){
GodotLib.calldeferred(purchaseCallbackId, "no_validation_required", new Object[]{});
GodotLib.calldeferred(purchaseCallbackId, "no_validation_required", new Object[]{});
}
public void callbackFail(){
GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[]{});
// GodotLib.callobject(purchaseCallbackId, "purchase_fail", new Object[]{});
GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[]{});
// GodotLib.callobject(purchaseCallbackId, "purchase_fail", new Object[]{});
}
public void callbackCancel(){
@ -89,6 +89,10 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
// GodotLib.callobject(purchaseCallbackId, "purchase_cancel", new Object[]{});
}
public void callbackAlreadyOwned(String sku){
GodotLib.calldeferred(purchaseCallbackId, "purchase_owned", new Object[]{sku});
}
public int getPurchaseCallbackId() {
return purchaseCallbackId;
}
@ -97,8 +101,6 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
this.purchaseCallbackId = purchaseCallbackId;
}
public String getPurchaseValidationUrlPrefix(){
return this.purchaseValidationUrlPrefix ;
}
@ -107,12 +109,10 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
this.purchaseValidationUrlPrefix = url;
}
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
@ -125,4 +125,30 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
return this.transactionId;
}
// request purchased items are not consumed
public void requestPurchased(){
activity.getPaymentsManager().setBaseSingleton(this);
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
activity.getPaymentsManager().requestPurchased();
}
});
}
// callback for requestPurchased()
public void callbackPurchased(String receipt, String signature, String sku){
GodotLib.calldeferred(purchaseCallbackId, "has_purchased", new Object[]{receipt, signature, sku});
}
// consume item automatically after purchase. default is true.
public void setAutoConsume(boolean autoConsume){
activity.getPaymentsManager().setAutoConsume(autoConsume);
}
// consume a specific item
public void consume(String sku){
activity.getPaymentsManager().consume(sku);
}
}

View File

@ -25,10 +25,8 @@ import com.android.vending.billing.IInAppBillingService;
public class PaymentsManager {
public static final int BILLING_RESPONSE_RESULT_OK = 0;
public static final int REQUEST_CODE_FOR_PURCHASE = 0x1001;
private static boolean auto_consume = true;
private Activity activity;
IInAppBillingService mService;
@ -69,13 +67,12 @@ public class PaymentsManager {
}
@Override
public void onServiceConnected(ComponentName name,
IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
}
};
public void requestPurchase(String sku, String transactionId){
public void requestPurchase(final String sku, String transactionId){
new PurchaseTask(mService, Godot.getInstance()) {
@Override
@ -88,6 +85,12 @@ public class PaymentsManager {
protected void canceled() {
godotPaymentV3.callbackCancel();
}
@Override
protected void alreadyOwned() {
godotPaymentV3.callbackAlreadyOwned(sku);
}
}.purchase(sku, transactionId);
}
@ -114,26 +117,82 @@ public class PaymentsManager {
}.consumeItAll();
}
public void requestPurchased(){
try{
PaymentsCache pc = new PaymentsCache(Godot.getInstance());
// Log.d("godot", "requestPurchased for " + activity.getPackageName());
Bundle bundle = mService.getPurchases(3, activity.getPackageName(), "inapp",null);
/*
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
Log.d("godot", String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
}
*/
if (bundle.getInt("RESPONSE_CODE") == 0){
final ArrayList<String> myPurchases = bundle.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
final ArrayList<String> mySignatures = bundle.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
if (myPurchases == null || myPurchases.size() == 0){
// Log.d("godot", "No purchases!");
godotPaymentV3.callbackPurchased("", "", "");
return;
}
// Log.d("godot", "# products are purchased:" + myPurchases.size());
for (int i=0;i<myPurchases.size();i++)
{
try{
String receipt = myPurchases.get(i);
JSONObject inappPurchaseData = new JSONObject(receipt);
String sku = inappPurchaseData.getString("productId");
String token = inappPurchaseData.getString("purchaseToken");
String signature = mySignatures.get(i);
// Log.d("godot", "purchased item:" + token + "\n" + receipt);
pc.setConsumableValue("ticket_signautre", sku, signature);
pc.setConsumableValue("ticket", sku, receipt);
pc.setConsumableFlag("block", sku, true);
pc.setConsumableValue("token", sku, token);
godotPaymentV3.callbackPurchased(receipt, signature, sku);
} catch (JSONException e) {
}
}
}
}catch(Exception e){
Log.d("godot", "Error requesting purchased products:" + e.getClass().getName() + ":" + e.getMessage());
}
}
public void processPurchaseResponse(int resultCode, Intent data) {
new HandlePurchaseTask(activity){
@Override
protected void success(final String sku, final String signature, final String ticket) {
godotPaymentV3.callbackSuccess(ticket, signature);
new ConsumeTask(mService, activity) {
@Override
protected void success(String ticket) {
// godotPaymentV3.callbackSuccess("");
}
@Override
protected void error(String message) {
godotPaymentV3.callbackFail();
}
}.consume(sku);
godotPaymentV3.callbackSuccess(ticket, signature, sku);
if (auto_consume){
new ConsumeTask(mService, activity) {
@Override
protected void success(String ticket) {
// godotPaymentV3.callbackSuccess("");
}
@Override
protected void error(String message) {
godotPaymentV3.callbackFail();
}
}.consume(sku);
}
// godotPaymentV3.callbackSuccess(new PaymentsCache(activity).getConsumableValue("ticket", sku),signature);
// godotPaymentV3.callbackSuccess(ticket);
@ -151,7 +210,7 @@ public class PaymentsManager {
godotPaymentV3.callbackCancel();
}
}.handlePurchaseRequest(resultCode, data);
}.handlePurchaseRequest(resultCode, data);
}
public void validatePurchase(String purchaseToken, final String sku){
@ -165,7 +224,7 @@ public class PaymentsManager {
@Override
protected void success(String ticket) {
godotPaymentV3.callbackSuccess(ticket, null);
godotPaymentV3.callbackSuccess(ticket, null, sku);
}
@ -192,11 +251,31 @@ public class PaymentsManager {
}.validatePurchase(sku);
}
public void setAutoConsume(boolean autoConsume){
auto_consume = autoConsume;
}
public void consume(final String sku){
new ConsumeTask(mService, activity) {
@Override
protected void success(String ticket) {
godotPaymentV3.callbackSuccessProductMassConsumed(ticket, "", sku);
}
@Override
protected void error(String message) {
godotPaymentV3.callbackFail();
}
}.consume(sku);
}
private GodotPaymentV3 godotPaymentV3;
public void setBaseSingleton(GodotPaymentV3 godotPaymentV3) {
this.godotPaymentV3 = godotPaymentV3;
}
}

View File

@ -62,7 +62,11 @@ abstract public class PurchaseTask {
// Log.d("XXX", "Buy intent response code: " + responseCode);
if(responseCode == 1 || responseCode == 3 || responseCode == 4){
canceled();
return ;
return;
}
if(responseCode == 7){
alreadyOwned();
return;
}
@ -92,6 +96,6 @@ abstract public class PurchaseTask {
abstract protected void error(String message);
abstract protected void canceled();
abstract protected void alreadyOwned();
}

View File

@ -19,4 +19,3 @@ if env['bb10_lgles_override'] == "yes":
prog = None
prog = env_bps.Program('#bin/godot', bb10_lib)

View File

@ -195,9 +195,10 @@ void OSBB10::finalize() {
// memdelete(debugger_connection_console);
//}
memdelete(sample_manager);
audio_server->finish();
memdelete(audio_server);
memdelete(sample_manager);
visual_server->finish();
memdelete(visual_server);

Some files were not shown because too many files have changed in this diff Show More