Skip to content

Commit fa28c1b

Browse files
author
Peter Whidden
committed
it works
1 parent 174f5c0 commit fa28c1b

File tree

11 files changed

+128
-0
lines changed

11 files changed

+128
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "external/glm"]
2+
path = external/glm
3+
url = https://github.com/g-truc/glm

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.0)
2+
3+
project(SP-OfflineRender)
4+
5+
if(MSVC)
6+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 -O3")
7+
else()
8+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -std=c++11 -O3")
9+
endif()
10+
11+
include_directories(external/glm/)
12+
13+
add_executable(render src/generated/full.cpp)

build/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

external/glm

Submodule glm added at ea678fa

output/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.ppm

render.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cat src/head.cpp $1 src/tail.cpp > src/generated/full.cpp
2+
cd build
3+
cmake ..
4+
make
5+
./render
6+
cd ..

src/config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define img_width 5000
2+
#define img_height 5000
3+
#define frame_count 1
4+
#define antialias 1

src/generated/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.cpp

src/head.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#define GLM_FORCE_SWIZZLE
2+
#include <glm/glm.hpp>
3+
#include "../config.h"
4+
#include "../output.cpp"
5+
6+
#define time frameTime
7+
8+
using glm::vec2;
9+
using glm::vec3;
10+
using glm::vec4;
11+
using glm::mat2;
12+
using glm::mat3;
13+
using glm::clamp;
14+
using glm::min;
15+
using glm::max;
16+
using glm::length;
17+
using glm::round;
18+
using glm::sin;
19+
using glm::cos;
20+
using glm::atan;
21+
using glm::sign;
22+
using glm::mod;
23+
using glm::mix;
24+
using glm::fract;
25+
using glm::normalize;
26+
27+
vec3 worldPos = vec3(0.0f,0.0f,0.0f);
28+
vec3 cameraPosition = vec3(0.0f, 0.0f, -1.0f);
29+

src/output.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <string>
2+
#include <fstream>
3+
#include <iostream>
4+
#include <sstream>
5+
#include <iomanip>
6+
7+
std::string pad_number(int n)
8+
{
9+
std::ostringstream ss;
10+
ss << std::setw( 7 ) << std::setfill( '0' ) << n;
11+
return ss.str();
12+
}
13+
14+
void save_image(uint8_t *pixels, int x, int y, std::string name, int count) {
15+
std::ofstream file(name+pad_number(count+1)+".ppm", std::ofstream::binary);
16+
if (file.is_open()) {
17+
file << "P6\n" << x << " " << y << "\n" << "255\n";
18+
file.write((char *)pixels, x*y*3);
19+
file.close();
20+
} else {
21+
std::cout << "Could not open file :(\n";
22+
}
23+
}

0 commit comments

Comments
 (0)