Changeset 62
- Timestamp:
- 11/05/11 11:03:51 (7 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
README (modified) (1 diff)
-
configure.ac (modified) (2 diffs)
-
src/pdfcube.cc (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/README
r29 r62 45 45 libpoppler-dev libpoppler-glib-dev) 46 46 * GtkGlExt (Debian/Ubuntu package: libgtkglext1-dev) 47 * OpenGL (freeglut3-dev)48 47 * Boost C++ Program Option Library 49 48 -
trunk/configure.ac
r61 r62 20 20 AC_PROG_CC 21 21 AC_PROG_CXX 22 dnl AM_PROG_LIBTOOL23 22 AM_SANITY_CHECK 24 23 … … 45 44 AC_SUBST(poppler_glib_LIBS) 46 45 46 PKG_CHECK_MODULES(cairo, cairo >= 0.25) 47 AC_SUBST(cairo_CFLAGS) 48 AC_SUBST(cairo_LIBS) 49 47 50 AC_CHECK_HEADERS(GL/gl.h) 48 51 AC_CHECK_HEADERS(GL/glu.h) 49 52 AC_CHECK_HEADERS(GL/glx.h) 50 AC_CHECK_HEADERS(GL/glut.h)51 53 52 54 AX_BOOST_BASE([1.33.1]) -
trunk/src/pdfcube.cc
r60 r62 3 3 // PDFCube source file - pdfcube.cc 4 4 // 5 // Copyright (C) 2006-20 085 // Copyright (C) 2006-2011 6 6 // Mirko Maischberger <mirko.maischberger@gmail.com> 7 7 // Karol Sokolowski <sokoow@gmail.com> … … 44 44 #include <GL/glx.h> 45 45 46 // PDF to GdkPixbuf (pkg-config poppler-glib)46 // PDF to cairo_surface_t using Cairo (pkg-config poppler-glib cairo) 47 47 #include <poppler.h> 48 #include <cairo.h> 48 49 49 50 #include <boost/program_options.hpp> … … 124 125 frame(0), 125 126 lookposx(0.0), lookposy(0.0), lookposz(3.48), 126 atx(0.0), aty(0.0), atz(0.0), persp(44.0), angle(0.0), pixmap(0) { 127 atx(0.0), aty(0.0), atz(0.0), persp(44.0), angle(0.0), 128 context(0), pixmap(0) { 127 129 texmap[0] = 0; 128 130 texmap[1] = 1; 129 131 texmap[2] = 2; 130 132 cube_faces=0; 133 PopplerPage *page; 134 double w,h; 135 page = poppler_document_get_page(d, 1); 136 poppler_page_get_size(page, &w, &h); 137 tex_width = 1024; 138 tex_height = 768; 131 139 pixmap = 132 gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, tex_width, 133 tex_height); 140 cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 141 tex_width, 142 tex_height); 143 context = cairo_create(pixmap); 144 cairo_scale(context, tex_width/w, (double)tex_height/h); 145 134 146 steps = new GLfloat[N_FRAMES]; 135 147 xsteps = new double[N_FRAMES]; … … 230 242 glEnable(GL_TEXTURE_RECTANGLE_ARB); 231 243 232 GLfloat mat_ambient[] = { 0.0, 0.0, 0.0, 1.00 };233 GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.00 };244 GLfloat mat_ambient[] = { 0.0, 0.0, 0.0, 0.00 }; 245 GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 0.00 }; 234 246 GLfloat mat_shininess[] = { 3.0 }; 235 247 … … 325 337 void 326 338 redraw(GtkWidget * widget) { 327 328 339 double yoffset = 0.1; 329 340 if (animating) { … … 726 737 0, 0, 0, 127 727 738 }; 728 glDrawPixels(1, 1, GL_ RGBA, GL_UNSIGNED_BYTE, rcube);739 glDrawPixels(1, 1, GL_BGRA, GL_UNSIGNED_BYTE, rcube); 729 740 730 741 active_animation = ANIM_NONE; … … 937 948 texmap[1] = texmap[0]; 938 949 texmap[0] = tmp; 939 render_page( pixmap, next_page(), tex_width, tex_height);950 render_page(next_page()); 940 951 } else { 941 952 current_page = prev_page(); … … 944 955 texmap[1] = texmap[2]; 945 956 texmap[2] = tmp; 946 render_page(p ixmap, prev_page(), tex_width, tex_height);957 render_page(prev_page()); 947 958 } 948 959 … … 955 966 tex_height, 956 967 0, 957 GL_ RGBA,958 GL_UNSIGNED_BYTE, gdk_pixbuf_get_pixels(pixmap));968 GL_BGRA, 969 GL_UNSIGNED_BYTE, cairo_image_surface_get_data(pixmap)); 959 970 960 971 gdk_window_invalidate_rect(widget->window, &widget->allocation, … … 968 979 assert(current_page >= 0); 969 980 assert(current_page < total_pages); 970 render_page( pixmap, current_page, tex_width, tex_height);981 render_page(current_page); 971 982 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textures[texmap[0]]); 972 983 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, … … 976 987 tex_height, 977 988 0, 978 GL_ RGBA,979 GL_UNSIGNED_BYTE, gdk_pixbuf_get_pixels(pixmap));980 981 render_page(p ixmap, prev_page(), tex_width, tex_height);989 GL_BGRA, 990 GL_UNSIGNED_BYTE, cairo_image_surface_get_data(pixmap)); 991 992 render_page(prev_page()); 982 993 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textures[texmap[1]]); 983 994 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, … … 987 998 tex_height, 988 999 0, 989 GL_ RGBA,990 GL_UNSIGNED_BYTE, gdk_pixbuf_get_pixels(pixmap));991 992 render_page( pixmap, next_page(), tex_width, tex_height);1000 GL_BGRA, 1001 GL_UNSIGNED_BYTE, cairo_image_surface_get_data(pixmap)); 1002 1003 render_page(next_page()); 993 1004 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textures[texmap[2]]); 994 1005 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, … … 998 1009 tex_height, 999 1010 0, 1000 GL_ RGBA,1001 GL_UNSIGNED_BYTE, gdk_pixbuf_get_pixels(pixmap));1011 GL_BGRA, 1012 GL_UNSIGNED_BYTE, cairo_image_surface_get_data(pixmap)); 1002 1013 1003 1014 gdk_window_invalidate_rect(widget->window, &widget->allocation, … … 1015 1026 double atx, aty, atz; 1016 1027 double persp, angle; 1017 GdkPixbuf *pixmap; 1028 cairo_surface_t *pixmap; 1029 cairo_t *context; 1018 1030 int texmap[3]; 1019 1031 … … 1025 1037 // ratio is fixed, should instead depend on the 1026 1038 // aspect ratio of the pdf page) 1027 static const gint tex_width =(gint) (3 * 1024 / 2);1028 static const gint tex_height =(gint) (3 * 768 / 2);1039 gint tex_width; //(gint) (3 * 1024 / 2); 1040 gint tex_height; //(gint) (3 * 768 / 2); 1029 1041 1030 1042 // renders the poppler page on a pixmap 1031 1043 void 1032 render_page( GdkPixbuf * pm, int i, gint iWidth, gint iHeight) {1044 render_page(int i) { 1033 1045 PopplerPage *page; 1034 1046 page = poppler_document_get_page(doc, i); 1035 double w, h; 1036 poppler_page_get_size(page, &w, &h); 1037 poppler_page_render_to_pixbuf(page, 0, 0, iWidth, iHeight, 1038 ((double)iWidth)/w, 0, pm); 1047 //double w,h; 1048 //poppler_page_get_size(page, &w, &h); 1049 cairo_save(context); 1050 unsigned char* data = cairo_image_surface_get_data(pixmap); 1051 std::fill(data, data+4*tex_width*tex_height, 0); 1052 cairo_surface_mark_dirty(pixmap); 1053 poppler_page_render(page, context); 1054 cairo_restore(context); 1039 1055 } 1040 1056

