You can move around a document with Click+Drag!
[ipdf/code.git] / src / view.cpp
1 #include "view.h"
2
3 #include "SDL_opengl.h"
4
5 using namespace IPDF;
6 using namespace std;
7
8 void View::Translate(Real x, Real y)
9 {
10         m_bounds.x += x;
11         m_bounds.y += y;
12 }
13
14 void View::Render()
15 {
16         static bool debug_output_done = false;
17         if (!debug_output_done)
18         {
19                 m_document.DebugDumpObjects();
20                 debug_output_done = true;
21         }
22
23         glClearColor(1.f,1.f,1.f,1.f);
24         glClear(GL_COLOR_BUFFER_BIT);
25
26         glMatrixMode(GL_PROJECTION);
27         glLoadIdentity();
28         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);
29         glMatrixMode(GL_MODELVIEW);
30         glLoadIdentity();
31
32         glColor4f(0.f,0.f,0.f,1.f);
33         glBegin(GL_QUADS);
34         for (unsigned id = 0; id < m_document.ObjectCount(); ++id)
35         {
36                 if (m_document.m_objects.types[id] == RECT_FILLED)
37                         continue;
38                 Rect obj_bounds = m_document.m_objects.bounds[id];
39                 glVertex2f(Float(obj_bounds.x), Float(obj_bounds.y));
40                 glVertex2f(Float(obj_bounds.x) + Float(obj_bounds.w), Float(obj_bounds.y));
41                 glVertex2f(Float(obj_bounds.x) + Float(obj_bounds.w), Float(obj_bounds.y) + Float(obj_bounds.h));
42                 glVertex2f(Float(obj_bounds.x), Float(obj_bounds.y) + Float(obj_bounds.h));
43         }
44         glEnd();
45
46         for (unsigned id = 0; id < m_document.ObjectCount(); ++id)
47         {
48                 if (m_document.m_objects.types[id] == RECT_OUTLINE)
49                         continue;
50                 Rect obj_bounds = m_document.m_objects.bounds[id];
51                 glBegin(GL_LINE_LOOP);
52                 glVertex2f(Float(obj_bounds.x), Float(obj_bounds.y));
53                 glVertex2f(Float(obj_bounds.x) + Float(obj_bounds.w), Float(obj_bounds.y));
54                 glVertex2f(Float(obj_bounds.x) + Float(obj_bounds.w), Float(obj_bounds.y) + Float(obj_bounds.h));
55                 glVertex2f(Float(obj_bounds.x), Float(obj_bounds.y) + Float(obj_bounds.h));
56                 glEnd();
57         }
58
59 }

UCC git Repository :: git.ucc.asn.au