tAdded missing o-ppm.cpp - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
(HTM) git clone git://src.adamsgaard.dk/sphere
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 6ff7614d0fd5bbd0306f7ed63a1ea1bfd0a9b3a0
(DIR) parent cd41737e0b69a87e1dbca387031c53793b51ab56
(HTM) Author: Anders Damsgaard <adc@geo.au.dk>
Date: Mon, 20 Aug 2012 16:39:26 +0200
Added missing o-ppm.cpp
Diffstat:
A output/about.txt | 1 +
A raytracer/doc/np-performance.txt | 6 ++++++
A raytracer/o-ppm.cpp | 30 ++++++++++++++++++++++++++++++
3 files changed, 37 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/output/about.txt b/output/about.txt
t@@ -0,0 +1 @@
+This folder will contain output binary files.
(DIR) diff --git a/raytracer/doc/np-performance.txt b/raytracer/doc/np-performance.txt
t@@ -0,0 +1,6 @@
+np gpu-kernels mem-transfer cpu-kernels
+8 1.22259 3.26922 164.079
+64 5.39379 3.39149 483.582
+512 38.5132 3.67328 3074.94
+5832 432.172 3.3923 33845.2
+50653 3737.38 3.70508 294995
(DIR) diff --git a/raytracer/o-ppm.cpp b/raytracer/o-ppm.cpp
t@@ -0,0 +1,30 @@
+// o-ppm.cpp
+// Write images in the PPM format
+
+#include <iostream>
+#include <cstdio>
+#include "header.h"
+
+
+// Write image structure to PPM file
+int image_to_ppm(rgb* rgb_img, const char* filename, const unsigned int width, const unsigned int height)
+{
+ FILE *fout = fopen(filename, "wb");
+ if (fout == NULL) {
+ std::cout << "File error in img_write() while trying to writing " << filename;
+ return 1;
+ }
+
+ fprintf(fout, "P6 %d %d 255\n", width, height);
+
+ // Write pixel array to ppm image file
+ for (unsigned int i=0; i<height*width; ++i) {
+ putc(rgb_img[i].r, fout);
+ putc(rgb_img[i].g, fout);
+ putc(rgb_img[i].b, fout);
+ }
+
+ fclose(fout);
+ return 0;
+}
+