Don't sigfpe as much
authorSam Moore <[email protected]>
Sun, 5 Oct 2014 06:32:12 +0000 (14:32 +0800)
committerSam Moore <[email protected]>
Sun, 5 Oct 2014 06:32:12 +0000 (14:32 +0800)
.gitignore
src/Makefile
src/debugscript.cpp
src/main.cpp
src/path.h
src/real.h
src/screen.cpp
src/shaderprogram.cpp
src/view.cpp
src/view.h

index 025bbce..7903839 100644 (file)
@@ -20,3 +20,4 @@ tools/*
 !src/tests/*.cpp
 !src/tests/*.h
 src/*.dll
+*.exe
index c64bebd..04e52fe 100644 (file)
@@ -19,7 +19,7 @@ QT_LIB :=  -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread
 LIB_x86_64 = ../contrib/lib/libSDL2-2.0.so.0 -lGL -lgmp
 LIB_i386 = ../contrib/lib32/libSDL2-2.0.so.0 -lGL -lgmp
 LIB_i686 = $(LIB_i386)
-LIB_win32 = -mwindows -lmingw32 -L../contrib/win32/lib/ -lSDL2main -lSDL2 -lgmp -static-libgcc -static-libstdc++
+LIB_win32 = -mwindows -lmingw32 -L../contrib/win32/lib/ -lSDL2main -lSDL2 -lgmp -static-libgcc -lopengl32 -static-libstdc++
 
 MAINRPATH_x86_64 = -Wl,-rpath,'$$ORIGIN/../contrib/lib'
 MAINRPATH_i386 = -Wl,-rpath,'$$ORIGIN/../contrib/lib32'
@@ -28,6 +28,7 @@ MAINRPATH_win32 = -Wl,-rpath,'$$ORIGIN/../contrib/win32/lib'
 TESTRPATH_x86_64 = -Wl,-rpath,'$$ORIGIN/../../contrib/lib'
 TESTRPATH_i386 = -Wl,-rpath,'$$ORIGIN/../../contrib/lib32'
 TESTRPATH_i686 = $(TESTRPATH_i386)
+TESTRPATH_win32 = -Wl,-rpath,'$$ORIGIN/../../contrib/win32/lib'
 OBJPATHS = $(OBJ:%=../obj/%)
 DEPS := $(OBJPATHS:%.o=%.d)
 CFLAGS_x86_64 := -I../contrib/include/SDL2 -I`pwd`
index 9fd95a6..d7ccad3 100644 (file)
@@ -242,12 +242,12 @@ void DebugScript::PrintPerformance(View * view, Screen * scr)
        // object_count  clock  delta_clock  x  Log10(x)  y  Log10(y)  w  Log10(w)  Size(w)
        #ifdef QUADTREE_DISABLED
        printf("%d\t%llu\t%llu\t%s\t%f\t%s\t%f\t%s\t%f\t%u\n",
-               now.object_count, (uint64_t)now.clock,
-               (uint64_t)(now.clock - m_perf_last.clock),
+               now.object_count, (long long unsigned)now.clock,
+               (long long unsigned)(now.clock - m_perf_last.clock),
                Str(now.view_bounds.x).c_str(), Log10(Abs(now.view_bounds.x)),
                Str(now.view_bounds.y).c_str(), Log10(Abs(now.view_bounds.y)),
                Str(now.view_bounds.w).c_str(), Log10(now.view_bounds.w),
-               Size(now.view_bounds.w));
+               (unsigned)Size(now.view_bounds.w));
        #endif
        m_perf_last = now;
 }
index 051f7ce..67e2076 100644 (file)
@@ -21,6 +21,7 @@ void sigfpe_handler(int sig)
 
 int main(int argc, char ** argv)
 {      
+       //Debug("Main!");
        signal(SIGFPE, sigfpe_handler);
        #if REALTYPE == REAL_IRRAM
          iRRAM_initialize(argc,argv);
index fffbeba..06aff7a 100644 (file)
@@ -16,7 +16,7 @@
 namespace IPDF
 {
        #ifdef TRANSFORM_BEZIERS_TO_PATH
-               typedef ParanoidNumber PReal;
+               typedef Gmprat PReal;
        #else
                typedef Real PReal;
        #endif
index 42bc5c0..e72709b 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "common.h"
 #include <cmath>
+#include <cfloat>
 
 
 #define REAL_SINGLE 0
@@ -139,6 +140,13 @@ namespace IPDF
        inline double Log10(double a) {return log(a)/log(10.0);}
        inline size_t Size(double a) {return sizeof(a);}
        inline size_t Size(float a) {return sizeof(a);}
+       
+       // Don't cause an exception
+       inline float ClampFloat(double d)
+       {
+               float f = (fabs(d) < FLT_MAX) ? ((fabs(d) > FLT_MIN) ? (float)d : FLT_MIN) : FLT_MAX;
+               return copysign(f, d);
+       }
 
        inline int64_t Int64(double a)
        {
index 0df64a2..5c11fe1 100644 (file)
@@ -8,6 +8,8 @@
 #include "bufferbuilder.h"
 #include "shaderprogram.h"
 
+
+
 #define BASICTEX_VERT "shaders/basictex_vert.glsl"
 #define BASICTEX_FRAG "shaders/basictex_frag.glsl"
 
@@ -70,9 +72,9 @@ Screen::Screen(bool visible)
        m_frame_begin_time = SDL_GetPerformanceCounter();
        m_last_frame_time = 0;
        m_last_frame_gpu_timer = 0;
+
        glGenQueries(1, &m_frame_gpu_timer);
        glBeginQuery(GL_TIME_ELAPSED, m_frame_gpu_timer);
-
        #ifndef __MINGW32__
        glDebugMessageCallback(opengl_debug_callback, 0);
        #endif
index 68a4767..c72ad48 100644 (file)
@@ -104,7 +104,7 @@ char * ShaderProgram::GetShaderSource(const char * src_file) const
 bool ShaderProgram::AttachShader(const char * src_file, GLenum type)
 {
        GLuint shader_obj = glCreateShader(type);
-       glObjectLabel(GL_SHADER, shader_obj, -1, src_file);
+       //glObjectLabel(GL_SHADER, shader_obj, -1, src_file);
        char * src = GetShaderSource(src_file);
        if (src == NULL)
        {
index 5acd860..1d99f2c 100644 (file)
@@ -542,10 +542,10 @@ void View::UpdateObjBoundsVBO(unsigned first_obj, unsigned last_obj)
                        obj_bounds = TransformToViewCoords(m_document.m_objects.bounds[id]);
                }
                GPUObjBounds gpu_bounds = {
-                       (float)Float(obj_bounds.x),
-                       (float)Float(obj_bounds.y),
-                       (float)Float(obj_bounds.x + obj_bounds.w),
-                       (float)Float(obj_bounds.y + obj_bounds.h)
+                       Float(obj_bounds.x),
+                       Float(obj_bounds.y),
+                       Float(obj_bounds.x + obj_bounds.w),
+                       Float(obj_bounds.y + obj_bounds.h)
                };
 
                obj_bounds_builder.Add(gpu_bounds);
@@ -572,19 +572,19 @@ void View::UpdateObjBoundsVBO(unsigned first_obj, unsigned last_obj)
                        if (!m_use_gpu_transform)
                                obj_bounds = TransformToViewCoords(obj_bounds);
                        GPUObjBounds gpu_bounds = {
-                               Float(obj_bounds.x),
-                               Float(obj_bounds.y),
-                               Float(obj_bounds.x + obj_bounds.w),
-                               Float(obj_bounds.y + obj_bounds.h)
+                               ClampFloat(obj_bounds.x),
+                               ClampFloat(obj_bounds.y),
+                               ClampFloat(obj_bounds.x + obj_bounds.w),
+                               ClampFloat(obj_bounds.y + obj_bounds.h)
                        };
                        obj_bounds_builder.Add(gpu_bounds);
                        //Debug("Path %d %s -> %s via %s", id, m_document.m_objects.bounds[id].Str().c_str(), obj_bounds.Str().c_str(), pbounds.Str().c_str()); 
                }
                GPUObjBounds p_gpu_bounds = {
-                               Float(pbounds.x),
-                               Float(pbounds.y),
-                               Float(pbounds.x + pbounds.w),
-                               Float(pbounds.y + pbounds.h)
+                               ClampFloat(pbounds.x),
+                               ClampFloat(pbounds.y),
+                               ClampFloat(pbounds.x + pbounds.w),
+                               ClampFloat(pbounds.y + pbounds.h)
                };              
                obj_bounds_builder.Add(p_gpu_bounds);
        }
index 0359565..4bcff89 100644 (file)
@@ -20,7 +20,7 @@
 namespace IPDF
 {
        #ifdef TRANSFORM_BEZIERS_TO_PATH
-               typedef ParanoidNumber VReal;
+               typedef Gmprat VReal;
        #else
                typedef Real VReal;
        #endif

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