Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed project 4. #16

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
296 changes: 113 additions & 183 deletions README.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions objs/tri.obj
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Geometric vertices.
v 0 0 0
v 0.1 0 0
v 0 0.1 0

# Vertex normals.
vn 0 0 1

# Face with vertex normals.
f 1//1 2//1 3//1
Binary file added renders/cow_diffuse_colored.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cow_diffuse_no_aa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cow_diffuse_no_aa_zoomed.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cow_diffuse_no_aa_zoomed_02.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cow_diffuse_outlined.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cow_diffuse_with_aa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cow_diffuse_with_aa_zoomed.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cow_diffuse_with_aa_zoomed_02.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cow_flat_colored.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cow_flat_no_aa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cow_flat_outlined.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cow_flat_with_aa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/rasterizer_bar_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/rasterizer_bar_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/rasterizer_pie_chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/tri_colored.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/tri_colored_smaller.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/tri_gray.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/tri_gray_no_aa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/tri_gray_smaller.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/video_demo.mp4
Binary file not shown.
44 changes: 44 additions & 0 deletions src/SimpleTimer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "SimpleTimer.h"


SimpleTimer::SimpleTimer()
{
}


SimpleTimer::~SimpleTimer()
{
}


void SimpleTimer::start()
{
start_time = GetTimeMs64();
}


float SimpleTimer::stop()
{
__int64 end_time = GetTimeMs64();
return ( float )( end_time - start_time );
}


__int64 SimpleTimer::GetTimeMs64()
{
/* Windows */
FILETIME ft;
LARGE_INTEGER li;

/* Get the amount of 100 nano seconds intervals elapsed since January 1, 1601 (UTC) and copy it
* to a LARGE_INTEGER structure. */
GetSystemTimeAsFileTime(&ft);
li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;

__int64 ret = li.QuadPart;
ret -= 116444736000000000LL; /* Convert from file time to UNIX epoch time. */
ret /= 10000; /* From 100 nano seconds (10^-7) to 1 millisecond (10^-3) intervals */

return ret;
}
23 changes: 23 additions & 0 deletions src/SimpleTimer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#ifndef _SIMPLE_TIMER
#define _SIMPLE_TIMER

#include <Windows.h>

class SimpleTimer
{
public:
SimpleTimer( void );
~SimpleTimer( void );

void start( void );
float stop( void );

private:
__int64 GetTimeMs64( void );

__int64 start_time;
};

#endif
87 changes: 53 additions & 34 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,48 @@
//-------------MAIN--------------
//-------------------------------

int main(int argc, char** argv){

bool loadedScene = false;
for(int i=1; i<argc; i++){
string header; string data;
istringstream liness(argv[i]);
getline(liness, header, '='); getline(liness, data, '=');
if(strcmp(header.c_str(), "mesh")==0){
//renderScene = new scene(data);
mesh = new obj();
objLoader* loader = new objLoader(data, mesh);
mesh->buildVBOs();
delete loader;
loadedScene = true;
}
}

if(!loadedScene){
cout << "Usage: mesh=[obj file]" << endl;
return 0;
}

frame = 0;
seconds = time (NULL);
fpstracker = 0;

// Launch CUDA/GL
if (init(argc, argv)) {
// GLFW main loop
mainLoop();
}

return 0;
int main( int argc, char **argv )
{
bool loadedScene = false;
for(int i=1; i<argc; i++){
string header; string data;
istringstream liness(argv[i]);
getline(liness, header, '='); getline(liness, data, '=');
if(strcmp(header.c_str(), "mesh")==0){
//renderScene = new scene(data);
mesh = new obj();
objLoader* loader = new objLoader(data, mesh);
mesh->buildVBOs();
delete loader;
loadedScene = true;
}
}

if(!loadedScene){
cout << "Usage: mesh=[obj file]" << endl;
return 0;
}

frame = 0;
seconds = time (NULL);
fpstracker = 0;

// Hardcoded camera definition.
camera.position = glm::vec3( 0.0f, 0.0f, 4.0f );
camera.target = glm::vec3( 0.0f, 0.0f, 0.0f );
camera.up = glm::vec3( 0.0f, -1.0f, 0.0f );
camera.fov_y = 25.0f;
camera.resolution = glm::vec2( width, height );
camera.near_clip = 0.01f;
camera.far_clip = 1000.0f;

// Launch CUDA/GL
if (init(argc, argv)) {
// GLFW main loop
mainLoop();
}

return 0;
}

void mainLoop() {
Expand Down Expand Up @@ -87,14 +96,24 @@ void runCuda(){
float newcbo[] = {0.0, 1.0, 0.0,
0.0, 0.0, 1.0,
1.0, 0.0, 0.0};

cbo = newcbo;
cbosize = 9;

ibo = mesh->getIBO();
ibosize = mesh->getIBOsize();

nbo = mesh->getNBO();
nbosize = mesh->getNBOsize();

cudaGLMapBufferObject((void**)&dptr, pbo);
cudaRasterizeCore(dptr, glm::vec2(width, height), frame, vbo, vbosize, cbo, cbosize, ibo, ibosize);
cudaRasterizeCore( dptr,
frame,
vbo, vbosize,
cbo, cbosize,
ibo, ibosize,
nbo, nbosize,
camera );
cudaGLUnmapBufferObject(pbo);

vbo = NULL;
Expand Down
18 changes: 14 additions & 4 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,22 @@
#include <string>
#include <time.h>


#include "rasterizeKernels.h"
#include "utilities.h"
#include "sceneStructs.h"

using namespace std;

//-------------------------------
//----------CAMERA STUFF---------
//-------------------------------

simpleCamera camera;

//-------------------------------
//------------GL STUFF-----------
//-------------------------------

int frame;
int fpstracker;
double seconds;
Expand All @@ -43,13 +50,16 @@ GLFWwindow *window;

obj* mesh;

float* vbo;
float *vbo;
int vbosize;
float* cbo;
float *cbo;
int cbosize;
int* ibo;
int *ibo;
int ibosize;

float *nbo;
int nbosize;

//-------------------------------
//----------CUDA STUFF-----------
//-------------------------------
Expand Down
Loading