Browse Source

create ShellRenderInterfaceOpenGL::SetViewport, instead of hardcoding

the height of the screen for scissoring. anything that would overflow
y with scrollbars would result in being cut off by a the difference between
768 and the viewports current resolution. even the debugger was broken.

change all examples to use this now as well.
Shaun Reich 13 years ago
parent
commit
14c5eaac0b

+ 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);