40262ac92e24f05964cb7b7656963f649c1e8a37
[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::Render()
9 {
10         static bool debug_output_done = false;
11         if (!debug_output_done)
12         {
13                 Debug("Bounds are %s", m_bounds.Str().c_str());
14                 Debug("Objects are:");
15                 for (unsigned id = 0; id < m_document.ObjectCount(); ++id)
16                 {
17                         Debug("%u\t%s", id, m_document.m_objects.bounds[id].Str().c_str());
18                 }
19                 debug_output_done = true;
20         }
21
22         glClearColor(1.f,1.f,1.f,1.f);
23         glClear(GL_COLOR_BUFFER_BIT);
24
25         glMatrixMode(GL_PROJECTION);
26         glLoadIdentity();
27         glOrtho(m_bounds.x, m_bounds.x+m_bounds.w, m_bounds.y + m_bounds.h, m_bounds.y, -1.f, 1.f);
28         glMatrixMode(GL_MODELVIEW);
29         glLoadIdentity();
30
31         glColor4f(0.f,0.f,0.f,1.f);
32         glBegin(GL_QUADS);
33         for (unsigned id = 0; id < m_document.ObjectCount(); ++id)
34         {
35                 Rect obj_bounds = m_document.m_objects.bounds[id];
36                 glVertex2f(obj_bounds.x, obj_bounds.y);
37                 glVertex2f(obj_bounds.x + obj_bounds.w, obj_bounds.y);
38                 glVertex2f(obj_bounds.x + obj_bounds.w, obj_bounds.y + obj_bounds.h);
39                 glVertex2f(obj_bounds.x, obj_bounds.y + obj_bounds.h);
40         }
41         glEnd();
42
43 }

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