Restored (And auto-generated) splash image

This commit is contained in:
Juan Linietsky 2017-04-09 20:02:04 -03:00
parent d596946a45
commit 7ba71fb243
9 changed files with 112 additions and 1425 deletions

View File

@ -271,6 +271,62 @@ void RasterizerGLES3::clear_render_target(const Color &p_color) {
storage->frame.clear_request_color = p_color;
}
void RasterizerGLES3::set_boot_image(const Image &p_image, const Color &p_color, bool p_scale) {
if (p_image.empty())
return;
begin_frame();
int window_w = OS::get_singleton()->get_video_mode(0).width;
int window_h = OS::get_singleton()->get_video_mode(0).height;
glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
glViewport(0, 0, window_w, window_h);
glDisable(GL_BLEND);
glDepthMask(GL_FALSE);
glClearColor(p_color.r, p_color.g, p_color.b, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
canvas->canvas_begin();
RID texture = storage->texture_create();
storage->texture_allocate(texture, p_image.get_width(), p_image.get_height(), p_image.get_format(), VS::TEXTURE_FLAG_FILTER);
storage->texture_set_data(texture, p_image);
Rect2 imgrect(0, 0, p_image.get_width(), p_image.get_height());
Rect2 screenrect;
if (p_scale) {
if (window_w > window_h) {
//scale horizontally
screenrect.size.y = window_h;
screenrect.size.x = imgrect.size.x * window_h / imgrect.size.y;
screenrect.pos.x = (window_w - screenrect.size.x) / 2;
} else {
//scale vertically
screenrect.size.x = window_w;
screenrect.size.y = imgrect.size.y * window_w / imgrect.size.x;
screenrect.pos.y = (window_h - screenrect.size.y) / 2;
}
} else {
screenrect = imgrect;
screenrect.pos += ((Size2(window_w, window_h) - screenrect.size) / 2.0).floor();
}
RasterizerStorageGLES3::Texture *t = storage->texture_owner.get(texture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, t->tex_id);
canvas->draw_generic_textured_rect(screenrect, Rect2(0, 0, 1, 1));
glBindTexture(GL_TEXTURE_2D, 0);
canvas->canvas_end();
storage->free(texture); // free since it's only one frame that stays there
OS::get_singleton()->swap_buffers();
}
void RasterizerGLES3::blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect, int p_screen) {
ERR_FAIL_COND(storage->frame.current_rt);

View File

@ -48,6 +48,8 @@ public:
virtual RasterizerCanvas *get_canvas();
virtual RasterizerScene *get_scene();
virtual void set_boot_image(const Image &p_image, const Color &p_color, bool p_scale);
virtual void initialize();
virtual void begin_frame();
virtual void set_current_render_target(RID p_render_target);

View File

@ -2,11 +2,57 @@
Import('env')
def make_splash(target, source, env):
src = source[0].srcnode().abspath
dst = target[0].srcnode().abspath
f = open(src, "rb")
g = open(dst, "wb")
buf = f.read()
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef BOOT_SPLASH_H\n")
g.write("#define BOOT_SPLASH_H\n")
g.write("static const Color boot_splash_bg_color = Color(1,1,1,1);\n");
g.write("static const unsigned char boot_splash_png[] = {\n")
for i in range(len(buf)):
g.write(str(ord(buf[i])) + ",\n")
g.write("};\n")
g.write("#endif")
def make_app_icon(target, source, env):
src = source[0].srcnode().abspath
dst = target[0].srcnode().abspath
f = open(src, "rb")
g = open(dst, "wb")
buf = f.read()
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef APP_ICON_H\n")
g.write("#define APP_ICON_H\n")
g.write("static const unsigned char app_icon_png[] = {\n")
for i in range(len(buf)):
g.write(str(ord(buf[i])) + ",\n")
g.write("};\n")
g.write("#endif")
env.main_sources = []
env.add_source_files(env.main_sources, "*.cpp")
Export('env')
env.Depends("#main/splash.h", "#main/splash.png")
env.Command("#main/splash.h", "#main/splash.png", make_splash)
env.Depends("#main/app_icon.h", "#main/app_icon.png")
env.Command("#main/app_icon.h", "#main/app_icon.png", make_app_icon)
SConscript('tests/SCsub')
lib = env.Library("main", env.main_sources)

BIN
main/app_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "main.h"
#include "app_icon.h"
#include "core/register_core_types.h"
#include "drivers/register_driver_types.h"
#include "global_config.h"
@ -885,6 +886,9 @@ Error Main::setup2() {
} else if (init_fullscreen) {
OS::get_singleton()->set_window_fullscreen(true);
}
register_server_types();
MAIN_PRINT("Main: Load Remaps");
Color clear = GLOBAL_DEF("rendering/viewport/default_clear_color", Color(0.3, 0.3, 0.3));
@ -953,7 +957,6 @@ Error Main::setup2() {
MAIN_PRINT("Main: Load Scene Types");
register_scene_types();
register_server_types();
GLOBAL_DEF("display/mouse_cursor/custom_image", String());
GLOBAL_DEF("display/mouse_cursor/custom_image_hotspot", Vector2());

File diff suppressed because it is too large Load Diff

BIN
main/splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

View File

@ -931,6 +931,8 @@ public:
virtual RasterizerCanvas *get_canvas() = 0;
virtual RasterizerScene *get_scene() = 0;
virtual void set_boot_image(const Image &p_image, const Color &p_color, bool p_scale) = 0;
virtual void initialize() = 0;
virtual void begin_frame() = 0;
virtual void set_current_render_target(RID p_render_target) = 0;

View File

@ -122,6 +122,8 @@ int VisualServerRaster::get_render_info(RenderInfo p_info) {
/* TESTING */
void VisualServerRaster::set_boot_image(const Image &p_image, const Color &p_color, bool p_scale) {
VSG::rasterizer->set_boot_image(p_image, p_color, p_scale);
}
void VisualServerRaster::set_default_clear_color(const Color &p_color) {
}