#Makefile
ARCH := $(shell uname -m)
-CXX = g++ -std=gnu++0x -Wall -Werror -Wshadow -pedantic -g
+# TODO: stb_truetype doesn't compile with some of these warnings.
+CXX = g++ -std=gnu++0x -g
+# -Wall -Werror -Wshadow -pedantic
MAIN = main.o
- OBJ = log.o document.o view.o screen.o vfpu.o stb_truetype.o
-OBJ = log.o real.o document.o view.o screen.o vfpu.o
++OBJ = log.o real.o document.o view.o screen.o vfpu.o stb_truetype.o
LIB_x86_64 = ../contrib/lib/libSDL2-2.0.so.0 -lGL
LIB_i386 = ../contrib/lib32/libSDL2-2.0.so.0 -lGL
#include "common.h"
- namespace IPDF
- {
+ #define REAL_SINGLE 0
+ #define REAL_DOUBLE 1
+
+ #ifndef REAL
+ #error "REAL was not defined!"
+ #endif
- //#define REAL_SINGLE
- #define REAL_DOUBLE
- //#define REAL_HALF
-
+ namespace IPDF
+ {
+ extern const char * g_real_name[];
- #ifdef REAL_SINGLE
+ #if REAL == REAL_SINGLE
typedef float Real;
inline float Float(Real r) {return r;}
- #elif defined REAL_DOUBLE
+ #elif REAL == REAL_DOUBLE
typedef double Real;
inline double Float(Real r) {return r;}
- #endif
+ #else
+ #error "Type of Real unspecified."
+ #endif //REAL
+
}
#endif //_REAL_H
unsigned char * pixels = new unsigned char[w*h*4];
if (pixels == NULL)
Fatal("Failed to allocate %d x %d x 4 = %d pixel array", w, h, w*h*4);
- glReadBuffer(GL_FRONT);
- glPixelStorei(GL_PACK_ALIGNMENT, 1);
+
-
for (int y = 0; y < h; ++y)
{
glReadPixels(0,h-y-1,w, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[y*w*4]);
m_bounds.y = y - top;
m_bounds.w *= scaleAmt;
m_bounds.h *= scaleAmt;
+ Debug("View Bounds => %s", m_bounds.Str().c_str());
}
+Rect View::TransformToViewCoords(const Rect& inp) const
+{
+ Rect out;
+ out.x = (inp.x - m_bounds.x) / m_bounds.w;
+ out.y = (inp.y - m_bounds.y) / m_bounds.h;
+
+ out.w = inp.w / m_bounds.w;
+ out.h = inp.h / m_bounds.h;
+ return out;
+}
+
void View::DrawGrid()
{
// Draw some grid lines at fixed pixel positions
{
public:
View(Document & document, const Rect & bounds = Rect(0,0,1,1), const Colour & colour = Colour(0.f,0.f,0.f,1.f))
- : m_document(document), m_bounds(bounds), m_colour(colour), m_use_gpu_transform(false) {}
- : m_document(document), m_bounds(bounds), m_colour(colour)
++ : m_document(document), m_bounds(bounds), m_colour(colour), m_use_gpu_transform(false)
+ {
+ Debug("View Created - Bounds => {%s}", m_bounds.Str().c_str());
+ }
virtual ~View() {}
void Render();