From: David Gow Date: Mon, 21 Apr 2014 04:35:36 +0000 (+0800) Subject: Merge branch 'master' of git.ucc.asn.au:ipdf/code X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=commitdiff_plain;h=aaa65d90ac812f924cbbc39bef7a5f8b6cad2da3 Merge branch 'master' of git.ucc.asn.au:ipdf/code Conflicts: src/Makefile src/main.h src/real.h src/screen.cpp src/view.h This was one hell of a merge. I have more code coming, but it breaks other things, so it'll take a little while. --- aaa65d90ac812f924cbbc39bef7a5f8b6cad2da3 diff --cc bin/ipdf index cf8ff78,86a7077..10e25fe Binary files differ diff --cc src/Makefile index f3c287c,ef5bff1..90adae9 --- a/src/Makefile +++ b/src/Makefile @@@ -1,10 -1,8 +1,10 @@@ #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 diff --cc src/real.h index 2a4877c,f65bb98..e6e69bc --- a/src/real.h +++ b/src/real.h @@@ -3,20 -3,28 +3,27 @@@ #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 diff --cc src/screen.cpp index 2764ef7,7d43e41..07d3f94 --- a/src/screen.cpp +++ b/src/screen.cpp @@@ -140,8 -140,8 +142,7 @@@ void Screen::ScreenShot(const char * fi 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]); diff --cc src/view.cpp index 0354ee9,d8a875b..26e9507 --- a/src/view.cpp +++ b/src/view.cpp @@@ -33,19 -35,9 +35,20 @@@ void View::ScaleAroundPoint(Real x, Rea 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 diff --cc src/view.h index b099c18,bbd575e..c6c230d --- a/src/view.h +++ b/src/view.h @@@ -10,7 -10,10 +10,10 @@@ namespace IPD { 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();