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() {
// auto adjust
auto_adjust(i);
// set initial canvas_to_norm for imp using ref
viewport_imp[i]->set_canvas_to_norm(viewport_ref[i]->get_canvas_to_norm());
// set initial svg_2_norm for imp using ref
viewport_imp[i]->set_svg_2_norm(viewport_ref[i]->get_svg_2_norm());
// generate mipmaps
regenerate_mipmap(i);
......@@ -436,12 +436,12 @@ void DrawSVG::redraw() {
clear();
// set canvas_to_screen transformation
Matrix3x3 m_imp = norm_to_screen * viewport_imp[current_tab]->get_canvas_to_norm();
Matrix3x3 m_ref = norm_to_screen * viewport_ref[current_tab]->get_canvas_to_norm();
software_renderer_imp->set_canvas_to_screen( m_imp );
software_renderer_ref->set_canvas_to_screen( m_ref );
hardware_renderer->set_canvas_to_screen( m_ref );
// set svg_2_screen transformation
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_svg_2_norm();
software_renderer_imp->set_svg_2_screen( m_imp );
software_renderer_ref->set_svg_2_screen( m_ref );
hardware_renderer->set_svg_2_screen( m_ref );
switch (method) {
......
......@@ -50,7 +50,7 @@ void HardwareRenderer::draw_svg( SVG& svg ) {
begin2DDrawing();
// set top level transformation
transformation = canvas_to_screen;
transformation = svg_2_screen;
// draw all elements
for ( size_t i = 0; i < svg.elements.size(); ++i ) {
......
......@@ -33,8 +33,8 @@ class HardwareRenderer : public SVGRenderer {
}
// Set svg to screen transformation
inline void set_canvas_to_screen( Matrix3x3 canvas_to_screen ) {
this->canvas_to_screen = canvas_to_screen;
inline void set_svg_2_screen( Matrix3x3 svg_2_screen ) {
this->svg_2_screen = svg_2_screen;
}
private:
......@@ -96,7 +96,7 @@ class HardwareRenderer : public SVGRenderer {
size_t context_w; size_t context_h;
// SVG coordinates to screen space coordinates
Matrix3x3 canvas_to_screen;
Matrix3x3 svg_2_screen;
}; // class HardwareRenderer
......
......@@ -17,7 +17,7 @@ namespace CMU462 {
void SoftwareRendererImp::draw_svg( SVG& svg ) {
// set top level transformation
transformation = canvas_to_screen;
transformation = svg_2_screen;
// draw all elements
for ( size_t i = 0; i < svg.elements.size(); ++i ) {
......
......@@ -39,8 +39,8 @@ class SoftwareRenderer : public SVGRenderer {
}
// Set svg to screen transformation
inline void set_canvas_to_screen( Matrix3x3 canvas_to_screen ) {
this->canvas_to_screen = canvas_to_screen;
inline void set_svg_2_screen( Matrix3x3 svg_2_screen ) {
this->svg_2_screen = svg_2_screen;
}
protected:
......@@ -58,7 +58,7 @@ class SoftwareRenderer : public SVGRenderer {
Sampler2D* sampler;
// SVG coordinates to screen space coordinates
Matrix3x3 canvas_to_screen;
Matrix3x3 svg_2_screen;
}; // class SoftwareRenderer
......
......@@ -4,23 +4,23 @@
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):
// Set svg to normalized device coordinate transformation. Your input
// arguments are defined as SVG canvans coordinates.
this->x = x;
this->y = y;
this->span = span;
// Set normalized svg to normalized device coordinate transformation. Your input
// arguments are defined as normalized SVG canvas coordinates.
this->centerX = centerX;
this->centerY = centerY;
this->vspan = vspan;
}
void ViewportImp::update_viewbox( float dx, float dy, float scale ) {
this->x -= dx;
this->y -= dy;
this->span *= scale;
set_viewbox( x, y, span );
this->centerX -= dx;
this->centerY -= dy;
this->vspan *= scale;
set_viewbox( centerX, centerY, vspan );
}
} // namespace CMU462
\ No newline at end of file
} // namespace CMU462
......@@ -11,27 +11,26 @@ class Viewport {
Viewport( ) : svg_2_norm( Matrix3x3::identity() ) { }
inline Matrix3x3 get_canvas_to_norm() {
inline Matrix3x3 get_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;
}
// set viewbox to look at (x,y) in svg coordinate space. Span defineds
// the view radius of the viewbox in number of pixels (the amout of pixels
// included in the viewbox in both x and y direction).
virtual void set_viewbox( float x, float y, float span ) = 0;
// set viewbox to look at (centerX, centerY) in normalized svg coordinate space. vspan defines
// the vertical view radius of the viewbox (ie. vspan>=0.5 means the entire svg canvas is in view)
virtual void set_viewbox( float centerX, float centerY, float vspan ) = 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.
virtual void update_viewbox( float dx, float dy, float scale ) = 0;
protected:
// current viewbox properties
float x, y, span;
float centerX, centerY, vspan;
// SVG coordinate to normalized display coordinates
Matrix3x3 svg_2_norm;
......@@ -42,7 +41,7 @@ class Viewport {
class ViewportImp : public Viewport {
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 );
}; // class ViewportImp
......@@ -51,7 +50,7 @@ class ViewportImp : public Viewport {
class ViewportRef : public Viewport {
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 );
}; // class ViewportRef
......@@ -59,4 +58,4 @@ class ViewportRef : public Viewport {
} // namespace CMU462
#endif // CMU462_VIEWPORT_H
\ No newline at end of file
#endif // CMU462_VIEWPORT_H
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