Browse Source

Merge pull request #94 from sreich/master

opengl -- don't hardcode the height of the screen to 768 for scissoring
Lloyd Weehuizen 12 years ago
parent
commit
cc0312f0ec

+ 2 - 0
Samples/basic/customlog/src/main.cpp

@@ -61,6 +61,8 @@ int main(int ROCKET_UNUSED(argc), char** ROCKET_UNUSED(argv))
 	// Rocket initialisation.
 	// Rocket initialisation.
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
+    opengl_renderer.SetViewport(1024,768);
+
 
 
 	// Initialise our system interface to write the log messages to file.
 	// Initialise our system interface to write the log messages to file.
 	SystemInterface system_interface;
 	SystemInterface system_interface;

+ 1 - 0
Samples/basic/drag/src/main.cpp

@@ -61,6 +61,7 @@ int main(int ROCKET_UNUSED(argc), char** ROCKET_UNUSED(argv))
 	// Rocket initialisation.
 	// Rocket initialisation.
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
+    opengl_renderer.SetViewport(1024,768);
 
 
 	ShellSystemInterface system_interface;
 	ShellSystemInterface system_interface;
 	Rocket::Core::SetSystemInterface(&system_interface);
 	Rocket::Core::SetSystemInterface(&system_interface);

+ 1 - 0
Samples/basic/loaddocument/src/main.cpp

@@ -60,6 +60,7 @@ int main(int ROCKET_UNUSED(argc), char** ROCKET_UNUSED(argv))
 	// Rocket initialisation.
 	// Rocket initialisation.
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
+    opengl_renderer.SetViewport(1024,768);
 
 
 	ShellSystemInterface system_interface;
 	ShellSystemInterface system_interface;
 	Rocket::Core::SetSystemInterface(&system_interface);
 	Rocket::Core::SetSystemInterface(&system_interface);

+ 2 - 0
Samples/basic/treeview/src/main.cpp

@@ -62,6 +62,8 @@ int main(int ROCKET_UNUSED(argc), char** ROCKET_UNUSED(argv))
 
 
 	// Rocket initialisation.
 	// Rocket initialisation.
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	ShellRenderInterfaceOpenGL opengl_renderer;
+    opengl_renderer.SetViewport(1024,768);
+
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
 
 
 	ShellSystemInterface system_interface;
 	ShellSystemInterface system_interface;

+ 2 - 0
Samples/invaders/src/main.cpp

@@ -71,6 +71,8 @@ int main(int, char**)
 	// Rocket initialisation.
 	// Rocket initialisation.
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
+    opengl_renderer.SetViewport(1024,768);
+
 	ShellSystemInterface system_interface;
 	ShellSystemInterface system_interface;
 	Rocket::Core::SetSystemInterface(&system_interface);
 	Rocket::Core::SetSystemInterface(&system_interface);
 
 

+ 6 - 0
Samples/shell/include/ShellRenderInterfaceOpenGL.h

@@ -41,6 +41,12 @@ class ShellRenderInterfaceOpenGL : public Rocket::Core::RenderInterface
 public:
 public:
 	ShellRenderInterfaceOpenGL();
 	ShellRenderInterfaceOpenGL();
 
 
+    /**
+     * @p width width of viewport
+     * @p height height of viewport
+     */
+    void SetViewport(int width, int height);
+
 	/// Called by Rocket when it wants to render geometry that it does not wish to optimise.
 	/// Called by Rocket when it wants to render geometry that it does not wish to optimise.
 	virtual void RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation);
 	virtual void RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation);
 
 

+ 8 - 1
Samples/shell/src/ShellRenderInterfaceOpenGL.cpp

@@ -34,6 +34,13 @@ ShellRenderInterfaceOpenGL::ShellRenderInterfaceOpenGL()
 {
 {
 }
 }
 
 
+void ShellRenderInterfaceOpenGL::SetViewport(int width, int height)
+{
+    m_width = width;
+    m_height = height;
+}
+
+
 // Called by Rocket when it wants to render geometry that it does not wish to optimise.
 // Called by Rocket when it wants to render geometry that it does not wish to optimise.
 void ShellRenderInterfaceOpenGL::RenderGeometry(Rocket::Core::Vertex* vertices, int ROCKET_UNUSED(num_vertices), int* indices, int num_indices, const Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation)
 void ShellRenderInterfaceOpenGL::RenderGeometry(Rocket::Core::Vertex* vertices, int ROCKET_UNUSED(num_vertices), int* indices, int num_indices, const Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation)
 {
 {
@@ -90,7 +97,7 @@ void ShellRenderInterfaceOpenGL::EnableScissorRegion(bool enable)
 // Called by Rocket when it wants to change the scissor region.		
 // Called by Rocket when it wants to change the scissor region.		
 void ShellRenderInterfaceOpenGL::SetScissorRegion(int x, int y, int width, int height)
 void ShellRenderInterfaceOpenGL::SetScissorRegion(int x, int y, int width, int height)
 {
 {
-	glScissor(x, 768 - (y + height), width, height);
+	glScissor(x, m_height - (y + height), width, height);
 }
 }
 
 
 // Set to byte packing, or the compiler will expand our struct, which means it won't read correctly from file
 // Set to byte packing, or the compiler will expand our struct, which means it won't read correctly from file

+ 1 - 0
Samples/tutorial/datagrid/src/main.cpp

@@ -47,6 +47,7 @@ int main(int ROCKET_UNUSED(argc), char** ROCKET_UNUSED(argv))
 	// Rocket initialisation.
 	// Rocket initialisation.
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
+    opengl_renderer.SetViewport(1024,768);
 
 
 	ShellSystemInterface system_interface;
 	ShellSystemInterface system_interface;
 	Rocket::Core::SetSystemInterface(&system_interface);
 	Rocket::Core::SetSystemInterface(&system_interface);

+ 1 - 0
Samples/tutorial/datagrid_tree/src/main.cpp

@@ -48,6 +48,7 @@ int main(int ROCKET_UNUSED(argc), char** ROCKET_UNUSED(argv))
 	// Rocket initialisation.
 	// Rocket initialisation.
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
+    opengl_renderer.SetViewport(1024, 768);
 
 
 	ShellSystemInterface system_interface;
 	ShellSystemInterface system_interface;
 	Rocket::Core::SetSystemInterface(&system_interface);
 	Rocket::Core::SetSystemInterface(&system_interface);

+ 1 - 0
Samples/tutorial/template/src/main.cpp

@@ -44,6 +44,7 @@ int main(int ROCKET_UNUSED(argc), char** ROCKET_UNUSED(argv))
 	// Rocket initialisation.
 	// Rocket initialisation.
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
+    opengl_renderer.SetViewport(1024, 768);
 
 
 	ShellSystemInterface system_interface;
 	ShellSystemInterface system_interface;
 	Rocket::Core::SetSystemInterface(&system_interface);
 	Rocket::Core::SetSystemInterface(&system_interface);

+ 1 - 0
Samples/tutorial/tutorial_drag/src/main.cpp

@@ -45,6 +45,7 @@ int main(int ROCKET_UNUSED(argc), char** ROCKET_UNUSED(argv))
 	// Rocket initialisation.
 	// Rocket initialisation.
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	ShellRenderInterfaceOpenGL opengl_renderer;
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
 	Rocket::Core::SetRenderInterface(&opengl_renderer);
+    opengl_renderer.SetViewport(1024, 768);
 
 
 	ShellSystemInterface system_interface;
 	ShellSystemInterface system_interface;
 	Rocket::Core::SetSystemInterface(&system_interface);
 	Rocket::Core::SetSystemInterface(&system_interface);

+ 11 - 9
Source/Debugger/Plugin.cpp

@@ -14,7 +14,7 @@
  *
  *
  * The above copyright notice and this permission notice shall be included in
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  * all copies or substantial portions of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -174,15 +174,17 @@ void Plugin::Render()
 			{
 			{
 				Core::Element* element = element_stack.top();
 				Core::Element* element = element_stack.top();
 				element_stack.pop();
 				element_stack.pop();
-
-				for (int j = 0; j < element->GetNumBoxes(); ++j)
+				if (element->IsVisible())
 				{
 				{
-					const Core::Box& box = element->GetBox(j);
-					Geometry::RenderOutline(element->GetAbsoluteOffset(Core::Box::BORDER) + box.GetPosition(Core::Box::BORDER), box.GetSize(Core::Box::BORDER), Core::Colourb(255, 0, 0, 128), 1);
+					for (int j = 0; j < element->GetNumBoxes(); ++j)
+					{
+						const Core::Box& box = element->GetBox(j);
+						Geometry::RenderOutline(element->GetAbsoluteOffset(Core::Box::BORDER) + box.GetPosition(Core::Box::BORDER), box.GetSize(Core::Box::BORDER), Core::Colourb(255, 0, 0, 128), 1);
+					}
+
+					for (int j = 0; j < element->GetNumChildren(); ++j)
+						element_stack.push(element->GetChild(j));
 				}
 				}
-
-				for (int j = 0; j < element->GetNumChildren(); ++j)
-					element_stack.push(element->GetChild(j));
 			}
 			}
 		}
 		}
 	}
 	}
@@ -371,7 +373,7 @@ bool Plugin::LoadLogElement()
 
 
 	// Make the system interface; this will trap the log messages for us.
 	// Make the system interface; this will trap the log messages for us.
 	log_hook = new SystemInterface(log_element);
 	log_hook = new SystemInterface(log_element);
-	
+
 	return true;
 	return true;
 }
 }