It now is all the working.
[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                 m_document.DebugDumpObjects();
14                 debug_output_done = true;
15         }
16
17         glClearColor(1.f,1.f,1.f,1.f);
18         glClear(GL_COLOR_BUFFER_BIT);
19
20         glMatrixMode(GL_PROJECTION);
21         glLoadIdentity();
22         glOrtho(m_bounds.x, m_bounds.x+m_bounds.w, m_bounds.y + m_bounds.h, m_bounds.y, -1.f, 1.f);
23         glMatrixMode(GL_MODELVIEW);
24         glLoadIdentity();
25
26         glColor4f(0.f,0.f,0.f,1.f);
27         glBegin(GL_QUADS);
28         for (unsigned id = 0; id < m_document.ObjectCount(); ++id)
29         {
30                 if (m_document.m_objects.types[id] == RECT_FILLED)
31                         continue;
32                 Rect obj_bounds = m_document.m_objects.bounds[id];
33                 glVertex2f(obj_bounds.x, obj_bounds.y);
34                 glVertex2f(obj_bounds.x + obj_bounds.w, obj_bounds.y);
35                 glVertex2f(obj_bounds.x + obj_bounds.w, obj_bounds.y + obj_bounds.h);
36                 glVertex2f(obj_bounds.x, obj_bounds.y + obj_bounds.h);
37         }
38         glEnd();
39
40         for (unsigned id = 0; id < m_document.ObjectCount(); ++id)
41         {
42                 if (m_document.m_objects.types[id] == RECT_OUTLINE)
43                         continue;
44                 Rect obj_bounds = m_document.m_objects.bounds[id];
45                 glBegin(GL_LINE_LOOP);
46                 glVertex2f(obj_bounds.x, obj_bounds.y);
47                 glVertex2f(obj_bounds.x + obj_bounds.w, obj_bounds.y);
48                 glVertex2f(obj_bounds.x + obj_bounds.w, obj_bounds.y + obj_bounds.h);
49                 glVertex2f(obj_bounds.x, obj_bounds.y + obj_bounds.h);
50                 glEnd();
51         }
52
53 }

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