3 #include "SDL_opengl.h"
8 void View::Translate(Real x, Real y)
14 Debug("View Bounds => %s", m_bounds.Str().c_str());
17 void View::ScaleAroundPoint(Real x, Real y, Real scaleAmt)
19 // x and y are coordinates in the window
20 // Convert to local coords.
26 //Debug("Mouse wheel event %f %f %f\n", Float(x), Float(y), Float(scaleAmt));
28 Real top = y - m_bounds.y;
29 Real left = x - m_bounds.x;
34 m_bounds.x = x - left;
36 m_bounds.w *= scaleAmt;
37 m_bounds.h *= scaleAmt;
38 Debug("View Bounds => %s", m_bounds.Str().c_str());
43 // Draw some grid lines at fixed pixel positions
44 glMatrixMode(GL_PROJECTION);
46 glOrtho(0.0, 1.0, 1.0, 0.0, -1.f, 1.f);
47 glMatrixMode(GL_MODELVIEW);
50 glColor4f(0.9,0.9,0.9,0.1);
51 const float num_lines = 50.0;
52 for (float i = 0; i < num_lines; ++i)
55 glVertex2f(i*(1.0/num_lines), 0.0);
56 glVertex2f(i*(1.0/num_lines), 1.0);
59 glVertex2f(0.0,i*(1.0/num_lines));
60 glVertex2f(1.0,i*(1.0/num_lines));
68 static bool debug_output_done = false;
69 if (!debug_output_done)
71 m_document.DebugDumpObjects();
72 debug_output_done = true;
76 //DrawGrid(); // Draw the gridlines
78 glMatrixMode(GL_PROJECTION);
80 glOrtho(Float(m_bounds.x), Float(m_bounds.x)+Float(m_bounds.w), Float(m_bounds.y) + Float(m_bounds.h), Float(m_bounds.y), -1.f, 1.f);
81 glMatrixMode(GL_MODELVIEW);
84 if (m_colour.a < 1.0f)
87 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
89 glColor4f(m_colour.r, m_colour.g, m_colour.b, m_colour.a);
91 for (unsigned id = 0; id < m_document.ObjectCount(); ++id)
93 if (m_document.m_objects.types[id] != RECT_FILLED)
95 Rect obj_bounds = m_document.m_objects.bounds[id];
96 glVertex2f(Float(obj_bounds.x), Float(obj_bounds.y));
97 glVertex2f(Float(obj_bounds.x) + Float(obj_bounds.w), Float(obj_bounds.y));
98 glVertex2f(Float(obj_bounds.x) + Float(obj_bounds.w), Float(obj_bounds.y) + Float(obj_bounds.h));
99 glVertex2f(Float(obj_bounds.x), Float(obj_bounds.y) + Float(obj_bounds.h));
104 for (unsigned id = 0; id < m_document.ObjectCount(); ++id)
106 if (m_document.m_objects.types[id] != RECT_OUTLINE)
108 Rect obj_bounds = m_document.m_objects.bounds[id];
109 glBegin(GL_LINE_LOOP);
110 glVertex2f(Float(obj_bounds.x), Float(obj_bounds.y));
111 glVertex2f(Float(obj_bounds.x) + Float(obj_bounds.w), Float(obj_bounds.y));
112 glVertex2f(Float(obj_bounds.x) + Float(obj_bounds.w), Float(obj_bounds.y) + Float(obj_bounds.h));
113 glVertex2f(Float(obj_bounds.x), Float(obj_bounds.y) + Float(obj_bounds.h));
117 if (m_colour.a < 1.0f)