소스 검색

Restored black bars and custom images instead of black bars, closes #1571

Juan Linietsky 8 년 전
부모
커밋
539fbad919

+ 67 - 0
drivers/gles3/rasterizer_canvas_gles3.cpp

@@ -941,6 +941,8 @@ void RasterizerGLES2::_canvas_item_setup_shader_params(ShaderMaterial *material,
 
 
 void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) {
 void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) {
 
 
+	glDisable(GL_BLEND);
+
 	state.canvas_texscreen_used = true;
 	state.canvas_texscreen_used = true;
 	//blur diffuse into effect mipmaps using separatable convolution
 	//blur diffuse into effect mipmaps using separatable convolution
 	//storage->shaders.copy.set_conditional(CopyShaderGLES3::GAUSSIAN_HORIZONTAL,true);
 	//storage->shaders.copy.set_conditional(CopyShaderGLES3::GAUSSIAN_HORIZONTAL,true);
@@ -1003,12 +1005,16 @@ void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) {
 
 
 	glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); //back to front
 	glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); //back to front
 	glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height);
 	glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height);
+
 	state.canvas_shader.bind(); //back to canvas
 	state.canvas_shader.bind(); //back to canvas
+	_bind_canvas_texture(state.current_tex, state.current_normal);
 
 
 	if (state.using_texture_rect) {
 	if (state.using_texture_rect) {
 		state.using_texture_rect = false;
 		state.using_texture_rect = false;
 		_set_texture_rect_mode(state.using_texture_rect, state.using_ninepatch);
 		_set_texture_rect_mode(state.using_texture_rect, state.using_ninepatch);
 	}
 	}
+
+	glEnable(GL_BLEND);
 }
 }
 
 
 void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light) {
 void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light) {
@@ -1595,6 +1601,67 @@ void RasterizerCanvasGLES3::draw_generic_textured_rect(const Rect2 &p_rect, cons
 	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 }
 }
 
 
+void RasterizerCanvasGLES3::draw_window_margins(int *black_margin, RID *black_image) {
+
+	Vector2 window_size = OS::get_singleton()->get_window_size();
+	int window_h = window_size.height;
+	int window_w = window_size.width;
+
+	glBindFramebuffer(GL_FRAMEBUFFER, storage->system_fbo);
+	glViewport(0, 0, window_size.width, window_size.height);
+	canvas_begin();
+
+	if (black_image[MARGIN_LEFT].is_valid()) {
+		_bind_canvas_texture(black_image[MARGIN_LEFT], RID());
+		Size2 sz(storage->texture_get_width(black_image[MARGIN_LEFT]), storage->texture_get_height(black_image[MARGIN_LEFT]));
+		draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h), Rect2(0, 0, sz.x, sz.y));
+	} else if (black_margin[MARGIN_LEFT]) {
+		glActiveTexture(GL_TEXTURE0);
+		glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
+
+		draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h), Rect2(0, 0, 1, 1));
+	}
+
+	if (black_image[MARGIN_RIGHT].is_valid()) {
+		_bind_canvas_texture(black_image[MARGIN_RIGHT], RID());
+		Size2 sz(storage->texture_get_width(black_image[MARGIN_RIGHT]), storage->texture_get_height(black_image[MARGIN_RIGHT]));
+		draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h), Rect2(0, 0, sz.x, sz.y));
+	} else if (black_margin[MARGIN_RIGHT]) {
+		glActiveTexture(GL_TEXTURE0);
+		glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
+
+		draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h), Rect2(0, 0, 1, 1));
+	}
+
+	if (black_image[MARGIN_TOP].is_valid()) {
+		_bind_canvas_texture(black_image[MARGIN_TOP], RID());
+
+		Size2 sz(storage->texture_get_width(black_image[MARGIN_TOP]), storage->texture_get_height(black_image[MARGIN_TOP]));
+		draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]), Rect2(0, 0, sz.x, sz.y));
+
+	} else if (black_margin[MARGIN_TOP]) {
+		glActiveTexture(GL_TEXTURE0);
+		glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
+
+		draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]), Rect2(0, 0, 1, 1));
+	}
+
+	if (black_image[MARGIN_BOTTOM].is_valid()) {
+
+		_bind_canvas_texture(black_image[MARGIN_BOTTOM], RID());
+
+		Size2 sz(storage->texture_get_width(black_image[MARGIN_BOTTOM]), storage->texture_get_height(black_image[MARGIN_BOTTOM]));
+		draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, sz.x, sz.y));
+
+	} else if (black_margin[MARGIN_BOTTOM]) {
+
+		glActiveTexture(GL_TEXTURE0);
+		glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
+
+		draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, 1, 1));
+	}
+}
+
 void RasterizerCanvasGLES3::initialize() {
 void RasterizerCanvasGLES3::initialize() {
 
 
 	{
 	{

+ 2 - 0
drivers/gles3/rasterizer_canvas_gles3.h

@@ -138,6 +138,8 @@ public:
 	void initialize();
 	void initialize();
 	void finalize();
 	void finalize();
 
 
+	virtual void draw_window_margins(int *black_margin, RID *black_image);
+
 	RasterizerCanvasGLES3();
 	RasterizerCanvasGLES3();
 };
 };
 
 

+ 8 - 3
main/input_default.cpp

@@ -453,7 +453,8 @@ void InputDefault::set_mouse_position(const Point2 &p_posf) {
 	mouse_speed_track.update(p_posf - mouse_pos);
 	mouse_speed_track.update(p_posf - mouse_pos);
 	mouse_pos = p_posf;
 	mouse_pos = p_posf;
 	if (custom_cursor.is_valid()) {
 	if (custom_cursor.is_valid()) {
-		VisualServer::get_singleton()->cursor_set_pos(get_mouse_position());
+		//removed, please insist that we implement hardware cursors
+		//		VisualServer::get_singleton()->cursor_set_pos(get_mouse_position());
 	}
 	}
 }
 }
 
 
@@ -538,6 +539,7 @@ bool InputDefault::is_emulating_touchscreen() const {
 }
 }
 
 
 void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, const Vector2 &p_hotspot) {
 void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, const Vector2 &p_hotspot) {
+	/* no longer supported, leaving this for reference to anyone who might want to implement hardware cursors
 	if (custom_cursor == p_cursor)
 	if (custom_cursor == p_cursor)
 		return;
 		return;
 
 
@@ -545,7 +547,8 @@ void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, const Vector2 &p
 
 
 	if (p_cursor.is_null()) {
 	if (p_cursor.is_null()) {
 		set_mouse_mode(MOUSE_MODE_VISIBLE);
 		set_mouse_mode(MOUSE_MODE_VISIBLE);
-		VisualServer::get_singleton()->cursor_set_visible(false);
+		//removed, please insist us to implement hardare cursors
+		//VisualServer::get_singleton()->cursor_set_visible(false);
 	} else {
 	} else {
 		Ref<AtlasTexture> atex = custom_cursor;
 		Ref<AtlasTexture> atex = custom_cursor;
 		Rect2 region = atex.is_valid() ? atex->get_region() : Rect2();
 		Rect2 region = atex.is_valid() ? atex->get_region() : Rect2();
@@ -554,10 +557,11 @@ void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, const Vector2 &p
 		VisualServer::get_singleton()->cursor_set_texture(custom_cursor->get_rid(), p_hotspot, 0, region);
 		VisualServer::get_singleton()->cursor_set_texture(custom_cursor->get_rid(), p_hotspot, 0, region);
 		VisualServer::get_singleton()->cursor_set_pos(get_mouse_position());
 		VisualServer::get_singleton()->cursor_set_pos(get_mouse_position());
 	}
 	}
+	*/
 }
 }
 
 
 void InputDefault::set_mouse_in_window(bool p_in_window) {
 void InputDefault::set_mouse_in_window(bool p_in_window) {
-
+	/* no longer supported, leaving this for reference to anyone who might want to implement hardware cursors
 	if (custom_cursor.is_valid()) {
 	if (custom_cursor.is_valid()) {
 
 
 		if (p_in_window) {
 		if (p_in_window) {
@@ -568,6 +572,7 @@ void InputDefault::set_mouse_in_window(bool p_in_window) {
 			VisualServer::get_singleton()->cursor_set_visible(false);
 			VisualServer::get_singleton()->cursor_set_visible(false);
 		}
 		}
 	}
 	}
+	*/
 }
 }
 
 
 // from github.com/gabomdq/SDL_GameControllerDB
 // from github.com/gabomdq/SDL_GameControllerDB

+ 2 - 0
servers/visual/rasterizer.h

@@ -1014,6 +1014,8 @@ public:
 
 
 	virtual void reset_canvas() = 0;
 	virtual void reset_canvas() = 0;
 
 
+	virtual void draw_window_margins(int *p_margins, RID *p_margin_textures) = 0;
+
 	virtual ~RasterizerCanvas() {}
 	virtual ~RasterizerCanvas() {}
 };
 };
 
 

+ 21 - 10
servers/visual/visual_server_raster.cpp

@@ -41,23 +41,29 @@
 
 
 int VisualServerRaster::changes = 0;
 int VisualServerRaster::changes = 0;
 
 
-/* CURSOR */
-void VisualServerRaster::cursor_set_rotation(float p_rotation, int p_cursor) {
-}
-void VisualServerRaster::cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor, const Rect2 &p_region) {
-}
-void VisualServerRaster::cursor_set_visible(bool p_visible, int p_cursor) {
-}
-void VisualServerRaster::cursor_set_pos(const Point2 &p_pos, int p_cursor) {
-}
-
 /* BLACK BARS */
 /* BLACK BARS */
 
 
 void VisualServerRaster::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) {
 void VisualServerRaster::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) {
+
+	black_margin[MARGIN_LEFT] = p_left;
+	black_margin[MARGIN_TOP] = p_top;
+	black_margin[MARGIN_RIGHT] = p_right;
+	black_margin[MARGIN_BOTTOM] = p_bottom;
 }
 }
+
 void VisualServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) {
 void VisualServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) {
+
+	black_image[MARGIN_LEFT] = p_left;
+	black_image[MARGIN_TOP] = p_top;
+	black_image[MARGIN_RIGHT] = p_right;
+	black_image[MARGIN_BOTTOM] = p_bottom;
 }
 }
 
 
+void VisualServerRaster::_draw_margins() {
+
+	VSG::canvas_render->draw_window_margins(black_margin, black_image);
+};
+
 /* FREE */
 /* FREE */
 
 
 void VisualServerRaster::free(RID p_rid) {
 void VisualServerRaster::free(RID p_rid) {
@@ -121,6 +127,8 @@ void VisualServerRaster::draw() {
 
 
 		frame_drawn_callbacks.pop_front();
 		frame_drawn_callbacks.pop_front();
 	}
 	}
+
+	_draw_margins();
 }
 }
 void VisualServerRaster::sync() {
 void VisualServerRaster::sync() {
 }
 }
@@ -189,6 +197,9 @@ VisualServerRaster::VisualServerRaster() {
 	VSG::storage = VSG::rasterizer->get_storage();
 	VSG::storage = VSG::rasterizer->get_storage();
 	VSG::canvas_render = VSG::rasterizer->get_canvas();
 	VSG::canvas_render = VSG::rasterizer->get_canvas();
 	VSG::scene_render = VSG::rasterizer->get_scene();
 	VSG::scene_render = VSG::rasterizer->get_scene();
+
+	for (int i = 0; i < 4; i++)
+		black_margin[i] = 0;
 }
 }
 
 
 VisualServerRaster::~VisualServerRaster() {
 VisualServerRaster::~VisualServerRaster() {

+ 5 - 6
servers/visual/visual_server_raster.h

@@ -61,6 +61,9 @@ class VisualServerRaster : public VisualServer {
 	bool draw_extra_frame;
 	bool draw_extra_frame;
 	RID test_cube;
 	RID test_cube;
 
 
+	int black_margin[4];
+	RID black_image[4];
+
 	struct FrameDrawnCallbacks {
 	struct FrameDrawnCallbacks {
 
 
 		ObjectID object;
 		ObjectID object;
@@ -584,6 +587,8 @@ class VisualServerRaster : public VisualServer {
 
 
 #endif
 #endif
 
 
+	void _draw_margins();
+
 public:
 public:
 	_FORCE_INLINE_ static void redraw_request() { changes++; }
 	_FORCE_INLINE_ static void redraw_request() { changes++; }
 
 
@@ -1110,12 +1115,6 @@ public:
 
 
 	BIND2(canvas_occluder_polygon_set_cull_mode, RID, CanvasOccluderPolygonCullMode)
 	BIND2(canvas_occluder_polygon_set_cull_mode, RID, CanvasOccluderPolygonCullMode)
 
 
-	/* CURSOR */
-	virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0); // radians
-	virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset = Point2(0, 0), int p_cursor = 0, const Rect2 &p_region = Rect2());
-	virtual void cursor_set_visible(bool p_visible, int p_cursor = 0);
-	virtual void cursor_set_pos(const Point2 &p_pos, int p_cursor = 0);
-
 	/* BLACK BARS */
 	/* BLACK BARS */
 
 
 	virtual void black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom);
 	virtual void black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom);

+ 0 - 6
servers/visual/visual_server_wrap_mt.h

@@ -538,12 +538,6 @@ public:
 
 
 	FUNC2(canvas_occluder_polygon_set_cull_mode, RID, CanvasOccluderPolygonCullMode)
 	FUNC2(canvas_occluder_polygon_set_cull_mode, RID, CanvasOccluderPolygonCullMode)
 
 
-	/* CURSOR */
-	FUNC2(cursor_set_rotation, float, int) // radians
-	FUNC4(cursor_set_texture, RID, const Point2 &, int, const Rect2 &)
-	FUNC2(cursor_set_visible, bool, int)
-	FUNC2(cursor_set_pos, const Point2 &, int)
-
 	/* BLACK BARS */
 	/* BLACK BARS */
 
 
 	FUNC4(black_bars_set_margins, int, int, int, int)
 	FUNC4(black_bars_set_margins, int, int, int, int)

+ 0 - 6
servers/visual_server.h

@@ -875,12 +875,6 @@ public:
 	};
 	};
 	virtual void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, CanvasOccluderPolygonCullMode p_mode) = 0;
 	virtual void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, CanvasOccluderPolygonCullMode p_mode) = 0;
 
 
-	/* CURSOR */
-	virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0) = 0; // radians
-	virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset = Point2(0, 0), int p_cursor = 0, const Rect2 &p_region = Rect2()) = 0;
-	virtual void cursor_set_visible(bool p_visible, int p_cursor = 0) = 0;
-	virtual void cursor_set_pos(const Point2 &p_pos, int p_cursor = 0) = 0;
-
 	/* BLACK BARS */
 	/* BLACK BARS */
 
 
 	virtual void black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) = 0;
 	virtual void black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) = 0;