Commit d9f1f3aa authored by miyehn's avatar miyehn Committed by cmu462
Browse files

Add clarifications, rename variables, etc. based on last semester's documentation piazza post (#8)

* wip of adding clarifications

* more clarification changes

* added windows clion build instructions

* files overview & a few more ta advice
parent 8c1a146f
This diff is collapsed.
...@@ -73,8 +73,8 @@ void DrawSVG::init() { ...@@ -73,8 +73,8 @@ void DrawSVG::init() {
// auto adjust // auto adjust
auto_adjust(i); auto_adjust(i);
// set initial canvas_to_norm for imp using ref // set initial svg_2_norm for imp using ref
viewport_imp[i]->set_canvas_to_norm(viewport_ref[i]->get_canvas_to_norm()); viewport_imp[i]->set_svg_2_norm(viewport_ref[i]->get_svg_2_norm());
// generate mipmaps // generate mipmaps
regenerate_mipmap(i); regenerate_mipmap(i);
...@@ -436,12 +436,12 @@ void DrawSVG::redraw() { ...@@ -436,12 +436,12 @@ void DrawSVG::redraw() {
clear(); clear();
// set canvas_to_screen transformation // set svg_2_screen transformation
Matrix3x3 m_imp = norm_to_screen * viewport_imp[current_tab]->get_canvas_to_norm(); Matrix3x3 m_imp = norm_to_screen * viewport_imp[current_tab]->get_svg_2_norm();
Matrix3x3 m_ref = norm_to_screen * viewport_ref[current_tab]->get_canvas_to_norm(); Matrix3x3 m_ref = norm_to_screen * viewport_ref[current_tab]->get_svg_2_norm();
software_renderer_imp->set_canvas_to_screen( m_imp ); software_renderer_imp->set_svg_2_screen( m_imp );
software_renderer_ref->set_canvas_to_screen( m_ref ); software_renderer_ref->set_svg_2_screen( m_ref );
hardware_renderer->set_canvas_to_screen( m_ref ); hardware_renderer->set_svg_2_screen( m_ref );
switch (method) { switch (method) {
......
...@@ -50,7 +50,7 @@ void HardwareRenderer::draw_svg( SVG& svg ) { ...@@ -50,7 +50,7 @@ void HardwareRenderer::draw_svg( SVG& svg ) {
begin2DDrawing(); begin2DDrawing();
// set top level transformation // set top level transformation
transformation = canvas_to_screen; transformation = svg_2_screen;
// draw all elements // draw all elements
for ( size_t i = 0; i < svg.elements.size(); ++i ) { for ( size_t i = 0; i < svg.elements.size(); ++i ) {
......
...@@ -33,8 +33,8 @@ class HardwareRenderer : public SVGRenderer { ...@@ -33,8 +33,8 @@ class HardwareRenderer : public SVGRenderer {
} }
// Set svg to screen transformation // Set svg to screen transformation
inline void set_canvas_to_screen( Matrix3x3 canvas_to_screen ) { inline void set_svg_2_screen( Matrix3x3 svg_2_screen ) {
this->canvas_to_screen = canvas_to_screen; this->svg_2_screen = svg_2_screen;
} }
private: private:
...@@ -96,7 +96,7 @@ class HardwareRenderer : public SVGRenderer { ...@@ -96,7 +96,7 @@ class HardwareRenderer : public SVGRenderer {
size_t context_w; size_t context_h; size_t context_w; size_t context_h;
// SVG coordinates to screen space coordinates // SVG coordinates to screen space coordinates
Matrix3x3 canvas_to_screen; Matrix3x3 svg_2_screen;
}; // class HardwareRenderer }; // class HardwareRenderer
......
...@@ -17,7 +17,7 @@ namespace CMU462 { ...@@ -17,7 +17,7 @@ namespace CMU462 {
void SoftwareRendererImp::draw_svg( SVG& svg ) { void SoftwareRendererImp::draw_svg( SVG& svg ) {
// set top level transformation // set top level transformation
transformation = canvas_to_screen; transformation = svg_2_screen;
// draw all elements // draw all elements
for ( size_t i = 0; i < svg.elements.size(); ++i ) { for ( size_t i = 0; i < svg.elements.size(); ++i ) {
......
...@@ -39,8 +39,8 @@ class SoftwareRenderer : public SVGRenderer { ...@@ -39,8 +39,8 @@ class SoftwareRenderer : public SVGRenderer {
} }
// Set svg to screen transformation // Set svg to screen transformation
inline void set_canvas_to_screen( Matrix3x3 canvas_to_screen ) { inline void set_svg_2_screen( Matrix3x3 svg_2_screen ) {
this->canvas_to_screen = canvas_to_screen; this->svg_2_screen = svg_2_screen;
} }
protected: protected:
...@@ -58,7 +58,7 @@ class SoftwareRenderer : public SVGRenderer { ...@@ -58,7 +58,7 @@ class SoftwareRenderer : public SVGRenderer {
Sampler2D* sampler; Sampler2D* sampler;
// SVG coordinates to screen space coordinates // SVG coordinates to screen space coordinates
Matrix3x3 canvas_to_screen; Matrix3x3 svg_2_screen;
}; // class SoftwareRenderer }; // class SoftwareRenderer
......
...@@ -4,23 +4,23 @@ ...@@ -4,23 +4,23 @@
namespace CMU462 { namespace CMU462 {
void ViewportImp::set_viewbox( float x, float y, float span ) { void ViewportImp::set_viewbox( float centerX, float centerY, float vspan ) {
// Task 5 (part 2): // Task 5 (part 2):
// Set svg to normalized device coordinate transformation. Your input // Set normalized svg to normalized device coordinate transformation. Your input
// arguments are defined as SVG canvans coordinates. // arguments are defined as normalized SVG canvas coordinates.
this->x = x; this->centerX = centerX;
this->y = y; this->centerY = centerY;
this->span = span; this->vspan = vspan;
} }
void ViewportImp::update_viewbox( float dx, float dy, float scale ) { void ViewportImp::update_viewbox( float dx, float dy, float scale ) {
this->x -= dx; this->centerX -= dx;
this->y -= dy; this->centerY -= dy;
this->span *= scale; this->vspan *= scale;
set_viewbox( x, y, span ); set_viewbox( centerX, centerY, vspan );
} }
} // namespace CMU462 } // namespace CMU462
...@@ -11,27 +11,26 @@ class Viewport { ...@@ -11,27 +11,26 @@ class Viewport {
Viewport( ) : svg_2_norm( Matrix3x3::identity() ) { } Viewport( ) : svg_2_norm( Matrix3x3::identity() ) { }
inline Matrix3x3 get_canvas_to_norm() { inline Matrix3x3 get_svg_2_norm() {
return svg_2_norm; return svg_2_norm;
} }
inline void set_canvas_to_norm( Matrix3x3 m ) { inline void set_svg_2_norm( Matrix3x3 m ) {
svg_2_norm = m; svg_2_norm = m;
} }
// set viewbox to look at (x,y) in svg coordinate space. Span defineds // set viewbox to look at (centerX, centerY) in normalized svg coordinate space. vspan defines
// the view radius of the viewbox in number of pixels (the amout of pixels // the vertical view radius of the viewbox (ie. vspan>=0.5 means the entire svg canvas is in view)
// included in the viewbox in both x and y direction). virtual void set_viewbox( float centerX, float centerY, float vspan ) = 0;
virtual void set_viewbox( float x, float y, float span ) = 0;
// Move the viewbox by (dx,dy) in svg coordinate space. Scale the the view // Move the viewbox by (dx,dy) in normalized svg coordinate space. Scale the the view
// range by scale. // range by scale.
virtual void update_viewbox( float dx, float dy, float scale ) = 0; virtual void update_viewbox( float dx, float dy, float scale ) = 0;
protected: protected:
// current viewbox properties // current viewbox properties
float x, y, span; float centerX, centerY, vspan;
// SVG coordinate to normalized display coordinates // SVG coordinate to normalized display coordinates
Matrix3x3 svg_2_norm; Matrix3x3 svg_2_norm;
...@@ -42,7 +41,7 @@ class Viewport { ...@@ -42,7 +41,7 @@ class Viewport {
class ViewportImp : public Viewport { class ViewportImp : public Viewport {
public: public:
virtual void set_viewbox( float x, float y, float size ); virtual void set_viewbox( float centerX, float centerY, float size );
virtual void update_viewbox( float dx, float dy, float scale ); virtual void update_viewbox( float dx, float dy, float scale );
}; // class ViewportImp }; // class ViewportImp
...@@ -51,7 +50,7 @@ class ViewportImp : public Viewport { ...@@ -51,7 +50,7 @@ class ViewportImp : public Viewport {
class ViewportRef : public Viewport { class ViewportRef : public Viewport {
public: public:
virtual void set_viewbox( float x, float y, float size ); virtual void set_viewbox( float centerX, float centerY, float size );
virtual void update_viewbox( float dx, float dy, float scale ); virtual void update_viewbox( float dx, float dy, float scale );
}; // class ViewportRef }; // class ViewportRef
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment