You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
GODOT IS OPEN SOURCE
This commit is contained in:
12
main/SCsub
Normal file
12
main/SCsub
Normal file
@@ -0,0 +1,12 @@
|
||||
Import('env')
|
||||
|
||||
env.main_sources=[]
|
||||
env.add_source_files(env.main_sources,"*.cpp")
|
||||
|
||||
Export('env')
|
||||
|
||||
lib = env.Library("main",env.main_sources)
|
||||
|
||||
env.Prepend(LIBS=[lib])
|
||||
|
||||
|
||||
1409
main/main.cpp
Normal file
1409
main/main.cpp
Normal file
File diff suppressed because it is too large
Load Diff
60
main/main.h
Normal file
60
main/main.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*************************************************************************/
|
||||
/* main.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
/**
|
||||
@author Juan Linietsky <reduzio@gmail.com>
|
||||
*/
|
||||
|
||||
#include "error_list.h"
|
||||
#include "typedefs.h"
|
||||
|
||||
|
||||
class Main {
|
||||
|
||||
static void print_help(const char* p_binary);
|
||||
|
||||
static uint64_t last_ticks;
|
||||
static float time_accum;
|
||||
static uint32_t frames;
|
||||
static uint32_t frame;
|
||||
static bool force_redraw_requested;
|
||||
|
||||
public:
|
||||
|
||||
static Error setup(const char *execpath,int argc, char *argv[],bool p_second_phase=true);
|
||||
static Error setup2();
|
||||
static bool start();
|
||||
static bool iteration();
|
||||
static void cleanup();
|
||||
static void force_redraw();
|
||||
};
|
||||
|
||||
#endif
|
||||
158
main/performance.cpp
Normal file
158
main/performance.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
/*************************************************************************/
|
||||
/* performance.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "performance.h"
|
||||
#include "os/os.h"
|
||||
#include "servers/visual_server.h"
|
||||
#include "message_queue.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
Performance *Performance::singleton=NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
void Performance::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("get_monitor","monitor"),&Performance::get_monitor);
|
||||
|
||||
BIND_CONSTANT( TIME_FPS );
|
||||
BIND_CONSTANT( TIME_PROCESS );
|
||||
BIND_CONSTANT( TIME_FIXED_PROCESS );
|
||||
BIND_CONSTANT( MEMORY_STATIC );
|
||||
BIND_CONSTANT( MEMORY_DYNAMIC );
|
||||
BIND_CONSTANT( MEMORY_STATIC_MAX );
|
||||
BIND_CONSTANT( MEMORY_DYNAMIC_MAX );
|
||||
BIND_CONSTANT( MEMORY_MESSAGE_BUFFER_MAX );
|
||||
BIND_CONSTANT( OBJECT_COUNT );
|
||||
BIND_CONSTANT( OBJECT_RESOURCE_COUNT );
|
||||
BIND_CONSTANT( OBJECT_NODE_COUNT );
|
||||
BIND_CONSTANT( RENDER_OBJECTS_IN_FRAME );
|
||||
BIND_CONSTANT( RENDER_VERTICES_IN_FRAME );
|
||||
BIND_CONSTANT( RENDER_MATERIAL_CHANGES_IN_FRAME );
|
||||
BIND_CONSTANT( RENDER_SHADER_CHANGES_IN_FRAME );
|
||||
BIND_CONSTANT( RENDER_SURFACE_CHANGES_IN_FRAME );
|
||||
BIND_CONSTANT( RENDER_DRAW_CALLS_IN_FRAME );
|
||||
BIND_CONSTANT( RENDER_USAGE_VIDEO_MEM_TOTAL );
|
||||
BIND_CONSTANT( RENDER_VIDEO_MEM_USED );
|
||||
BIND_CONSTANT( RENDER_TEXTURE_MEM_USED );
|
||||
BIND_CONSTANT( RENDER_VERTEX_MEM_USED );
|
||||
BIND_CONSTANT( MONITOR_MAX );
|
||||
|
||||
}
|
||||
|
||||
String Performance::get_monitor_name(Monitor p_monitor) const {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_monitor,MONITOR_MAX,String());
|
||||
static const char* names[MONITOR_MAX]={
|
||||
|
||||
"time/fps",
|
||||
"time/process",
|
||||
"time/fixed_process",
|
||||
"memory/static",
|
||||
"memory/dynamic",
|
||||
"memory/static_max",
|
||||
"memory/dynamic_max",
|
||||
"memory/msg_buf_max",
|
||||
"object/objects",
|
||||
"object/resources",
|
||||
"object/nodes",
|
||||
"raster/objects_drawn",
|
||||
"raster/vertices_drawn",
|
||||
"raster/mat_changes",
|
||||
"raster/shader_changes",
|
||||
"raster/surface_changes",
|
||||
"raster/draw_calls",
|
||||
"video/video_mem",
|
||||
"video/texure_mem",
|
||||
"video/vertex_mem",
|
||||
"render/mem_max"
|
||||
};
|
||||
|
||||
return names[p_monitor];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
float Performance::get_monitor(Monitor p_monitor) const {
|
||||
|
||||
switch(p_monitor) {
|
||||
case TIME_FPS: return OS::get_singleton()->get_frames_per_second();
|
||||
case TIME_PROCESS: return _process_time;
|
||||
case TIME_FIXED_PROCESS: return _fixed_process_time;
|
||||
case MEMORY_STATIC: return Memory::get_static_mem_usage();
|
||||
case MEMORY_DYNAMIC: return Memory::get_dynamic_mem_usage();
|
||||
case MEMORY_STATIC_MAX: return Memory::get_static_mem_max_usage();
|
||||
case MEMORY_DYNAMIC_MAX: return Memory::get_dynamic_mem_available();
|
||||
case MEMORY_MESSAGE_BUFFER_MAX: return MessageQueue::get_singleton()->get_max_buffer_usage();
|
||||
case OBJECT_COUNT: return ObjectDB::get_object_count();
|
||||
case OBJECT_RESOURCE_COUNT: return ResourceCache::get_cached_resource_count();
|
||||
case OBJECT_NODE_COUNT: {
|
||||
|
||||
MainLoop *ml = OS::get_singleton()->get_main_loop();
|
||||
if (!ml)
|
||||
return 0;
|
||||
SceneMainLoop *sml = ml->cast_to<SceneMainLoop>();
|
||||
if (!sml)
|
||||
return 0;
|
||||
return sml->get_node_count();
|
||||
|
||||
};
|
||||
case RENDER_OBJECTS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_OBJECTS_IN_FRAME);
|
||||
case RENDER_VERTICES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_VERTICES_IN_FRAME);
|
||||
case RENDER_MATERIAL_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME);;
|
||||
case RENDER_SHADER_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME);;
|
||||
case RENDER_SURFACE_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME);;
|
||||
case RENDER_DRAW_CALLS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_DRAW_CALLS_IN_FRAME);
|
||||
case RENDER_VIDEO_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_VIDEO_MEM_USED);
|
||||
case RENDER_TEXTURE_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED);
|
||||
case RENDER_VERTEX_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_VERTEX_MEM_USED);
|
||||
case RENDER_USAGE_VIDEO_MEM_TOTAL: return VS::get_singleton()->get_render_info(VS::INFO_USAGE_VIDEO_MEM_TOTAL);
|
||||
default: {}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Performance::set_process_time(float p_pt) {
|
||||
|
||||
_process_time=p_pt;
|
||||
}
|
||||
|
||||
void Performance::set_fixed_process_time(float p_pt) {
|
||||
|
||||
_fixed_process_time=p_pt;
|
||||
}
|
||||
|
||||
|
||||
Performance::Performance() {
|
||||
|
||||
_process_time=0;
|
||||
_fixed_process_time=0;
|
||||
singleton=this;
|
||||
}
|
||||
92
main/performance.h
Normal file
92
main/performance.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*************************************************************************/
|
||||
/* performance.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifndef PERFORMANCE_H
|
||||
#define PERFORMANCE_H
|
||||
|
||||
#include "object.h"
|
||||
|
||||
#define PERF_WARN_OFFLINE_FUNCTION
|
||||
#define PERF_WARN_PROCESS_SYNC
|
||||
|
||||
|
||||
class Performance : public Object {
|
||||
|
||||
OBJ_TYPE(Performance,Object);
|
||||
|
||||
static Performance *singleton;
|
||||
static void _bind_methods();
|
||||
|
||||
float _process_time;
|
||||
float _fixed_process_time;
|
||||
public:
|
||||
|
||||
enum Monitor {
|
||||
|
||||
TIME_FPS,
|
||||
TIME_PROCESS,
|
||||
TIME_FIXED_PROCESS,
|
||||
MEMORY_STATIC,
|
||||
MEMORY_DYNAMIC,
|
||||
MEMORY_STATIC_MAX,
|
||||
MEMORY_DYNAMIC_MAX,
|
||||
MEMORY_MESSAGE_BUFFER_MAX,
|
||||
OBJECT_COUNT,
|
||||
OBJECT_RESOURCE_COUNT,
|
||||
OBJECT_NODE_COUNT,
|
||||
RENDER_OBJECTS_IN_FRAME,
|
||||
RENDER_VERTICES_IN_FRAME,
|
||||
RENDER_MATERIAL_CHANGES_IN_FRAME,
|
||||
RENDER_SHADER_CHANGES_IN_FRAME,
|
||||
RENDER_SURFACE_CHANGES_IN_FRAME,
|
||||
RENDER_DRAW_CALLS_IN_FRAME,
|
||||
RENDER_VIDEO_MEM_USED,
|
||||
RENDER_TEXTURE_MEM_USED,
|
||||
RENDER_VERTEX_MEM_USED,
|
||||
RENDER_USAGE_VIDEO_MEM_TOTAL,
|
||||
//physics
|
||||
MONITOR_MAX
|
||||
};
|
||||
|
||||
|
||||
float get_monitor(Monitor p_monitor) const;
|
||||
String get_monitor_name(Monitor p_monitor) const;
|
||||
|
||||
void set_process_time(float p_pt);
|
||||
void set_fixed_process_time(float p_pt);
|
||||
|
||||
static Performance *get_singleton() { return singleton; }
|
||||
|
||||
Performance();
|
||||
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST( Performance::Monitor );
|
||||
|
||||
|
||||
#endif // PERFORMANCE_H
|
||||
41
main/splash.h
Normal file
41
main/splash.h
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user