Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0b2cd94
add simple vertex shader
ziyezhou-Jerry Oct 9, 2015
ca7a319
add simple Primitive assembly
ziyezhou-Jerry Oct 9, 2015
0f61eee
add rasterization
ziyezhou-Jerry Oct 10, 2015
4538686
fix some bugs in the pipeline
ziyezhou-Jerry Oct 10, 2015
623e607
add camera class
ziyezhou-Jerry Oct 10, 2015
9cba09e
add mouse call back function
ziyezhou-Jerry Oct 10, 2015
5ca8e37
small fix
ziyezhou-Jerry Oct 11, 2015
a1179c7
add camera interaction
ziyezhou-Jerry Oct 11, 2015
3737bdb
add extra feature
ziyezhou-Jerry Oct 11, 2015
b1f134d
generate blending image
ziyezhou-Jerry Oct 11, 2015
4640442
add cow image
ziyezhou-Jerry Oct 11, 2015
a43f314
add more images
ziyezhou-Jerry Oct 12, 2015
aec6363
edit images
ziyezhou-Jerry Oct 12, 2015
be7c497
edit image
ziyezhou-Jerry Oct 12, 2015
68ef5a4
edit image2
ziyezhou-Jerry Oct 12, 2015
408e50b
add debug image
ziyezhou-Jerry Oct 12, 2015
7c0452d
add represent
ziyezhou-Jerry Oct 12, 2015
6c8109a
add sample image
ziyezhou-Jerry Oct 12, 2015
636881b
add sample combine
ziyezhou-Jerry Oct 12, 2015
681f49b
udpate 1
ziyezhou-Jerry Oct 12, 2015
854d546
fix
ziyezhou-Jerry Oct 12, 2015
d904221
add multiple sample image
ziyezhou-Jerry Oct 12, 2015
2625d11
udpate 2
ziyezhou-Jerry Oct 12, 2015
f3659ad
update image
ziyezhou-Jerry Oct 12, 2015
b02098e
add
ziyezhou-Jerry Oct 12, 2015
adacf69
add comapre
ziyezhou-Jerry Oct 12, 2015
2ce3603
add blending compare
ziyezhou-Jerry Oct 12, 2015
5991c1b
add more results
ziyezhou-Jerry Oct 12, 2015
ba7c49d
add
ziyezhou-Jerry Oct 12, 2015
c8cf71f
udpate 3
ziyezhou-Jerry Oct 12, 2015
22f7a40
add excel
ziyezhou-Jerry Oct 12, 2015
7e63f01
udpate 4
ziyezhou-Jerry Oct 12, 2015
9062785
udpate 5
ziyezhou-Jerry Oct 12, 2015
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
370 changes: 49 additions & 321 deletions README.md

Large diffs are not rendered by default.

Binary file added image/1.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 image/2.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 image/3.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 image/4.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 image/bending_compare.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 image/blending.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 image/color_interpolation.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 image/compare.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 image/cow.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 image/cow_smooth.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 image/debug_image.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 image/excel.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 image/flower.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 image/flower2.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 image/image.docx
Binary file not shown.
Binary file added image/more_results.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 image/multiple_sample.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 image/representive.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 image/sample_combine.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 image/sample_inside.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 image/sample_outside.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 image/suzanne.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 image/suzanne_smooth.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 image/w_anti_aliasing.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 image/w_anti_aliasing_new - Copy.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 image/w_anti_aliasing_new.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 image/wo_anti_aliasing.png
Binary file added image/wo_anti_aliasing_new - Copy.png
Binary file added image/wo_anti_aliasing_new.png
Binary file added image/wo_blending.png
114 changes: 112 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@
//-------------------------------

int main(int argc, char **argv) {
if (argc != 2) {

/*glm::mat4 m_model = glm::translate(glm::mat4(1.0),glm::vec3(1.0,0.0,0.0));

glm::vec3 a (0.0);

a = glm::vec3(m_model*glm::vec4(a,1.0));*/




if (argc != 2) {
cout << "Usage: [obj file]" << endl;
return 0;
}
Expand All @@ -23,6 +33,7 @@ int main(int argc, char **argv) {
{
objLoader loader(argv[1], mesh);
mesh->buildBufPoss();
//mesh->setFirstTriColor();
}

frame = 0;
Expand Down Expand Up @@ -78,7 +89,7 @@ void runCuda() {
dptr = NULL;

cudaGLMapBufferObject((void **)&dptr, pbo);
rasterize(dptr);
rasterize(dptr,g_camera);
cudaGLUnmapBufferObject(pbo);

frame++;
Expand All @@ -92,6 +103,7 @@ void runCuda() {

bool init(obj *mesh) {
glfwSetErrorCallback(errorCallback);


if (!glfwInit()) {
return false;
Expand All @@ -106,6 +118,9 @@ bool init(obj *mesh) {
}
glfwMakeContextCurrent(window);
glfwSetKeyCallback(window, keyCallback);
glfwSetMouseButtonCallback(window,mouseCallback);
glfwSetCursorPosCallback(window,cursorPosCallback);
glfwSetScrollCallback(window,scrollCallback);

// Set up GL context
glewExperimental = GL_TRUE;
Expand All @@ -119,6 +134,10 @@ bool init(obj *mesh) {
initCuda();
initPBO();

//init the camera
g_camera = new Camera();
g_camera->Reset(width, height);

float cbo[] = {
0.0, 1.0, 0.0,
0.0, 0.0, 1.0,
Expand Down Expand Up @@ -273,4 +292,95 @@ void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
glfwSetWindowShouldClose(window, GL_TRUE);
}
else if (key == GLFW_KEY_UP && action == GLFW_PRESS) {

g_camera->KeyChangeScale(true);
}
else if (key == GLFW_KEY_DOWN && action == GLFW_PRESS) {

g_camera->KeyChangeScale(false);

}
else if(key == GLFW_KEY_W && action == GLFW_PRESS)
{
g_camera->KeyChangeTranslate(2,true);
}
else if(key == GLFW_KEY_S && action == GLFW_PRESS)
{
g_camera->KeyChangeTranslate(2,false);
}
else if(key == GLFW_KEY_A && action == GLFW_PRESS)
{
g_camera->KeyChangeTranslate(1,true);
}
else if(key == GLFW_KEY_D && action == GLFW_PRESS)
{
g_camera->KeyChangeTranslate(1,false);
}
else if(key == GLFW_KEY_X && action == GLFW_PRESS)
{
g_camera->KeyChangeTranslate(3,false);
}
else if(key == GLFW_KEY_Z && action == GLFW_PRESS)
{
g_camera->KeyChangeTranslate(3,true);
}


}

void mouseCallback(GLFWwindow *window, int button, int action, int mods)
{
if(button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS)
{
glfwGetCursorPos(window,&g_mouse_old_x,&g_mouse_old_y);
}
else if(button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS)
{
glfwGetCursorPos(window,&g_mouse_old_x,&g_mouse_old_y);
}
else if(button == GLFW_MOUSE_BUTTON_MIDDLE && action == GLFW_PRESS)
{
glfwGetCursorPos(window,&g_mouse_old_x,&g_mouse_old_y);
}
}

void scrollCallback(GLFWwindow* window, double xoffset, double yoffset)
{
g_camera->MouseChangeDistance(1.0f,xoffset ,yoffset );
}

void cursorPosCallback(GLFWwindow *window, double xpos, double ypos)
{
if(glfwGetMouseButton(window,GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS)
{
double dx, dy;
dx = (double)(xpos - g_mouse_old_x);
dy = (double)(ypos - g_mouse_old_y);
g_camera->MouseChangeHeadPitch(0.2f, dx, dy);

g_mouse_old_x = xpos;
g_mouse_old_y = ypos;

}
else if(glfwGetMouseButton(window,GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS)
{
double dx, dy;
dx = (double)(xpos - g_mouse_old_x);
dy = (double)(ypos - g_mouse_old_y);
g_camera->MouseChangeLookat(0.01f, dx, dy);

g_mouse_old_x = xpos;
g_mouse_old_y = ypos;
}
else if(glfwGetMouseButton(window,GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS)
{
double dx, dy;
dx = (double)(xpos - g_mouse_old_x);
dy = (double)(ypos - g_mouse_old_y);
g_camera->MouseChangeDistance(0.05f, dx, dy);

g_mouse_old_x = xpos;
g_mouse_old_y = ypos;
}
}
19 changes: 19 additions & 0 deletions src/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
#include <cuda_gl_interop.h>
#include <cuda_runtime.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <util/glslUtility.hpp>
#include <util/utilityCore.hpp>
#include <util/objloader.hpp>
#include "rasterize.h"
#include <util/camera.h>

using namespace std;

Expand Down Expand Up @@ -93,3 +95,20 @@ void deleteTexture(GLuint *tex);
void mainLoop();
void errorCallback(int error, const char *description);
void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods);
void mouseCallback(GLFWwindow *window, int button, int action, int mods);
void scrollCallback(GLFWwindow* window, double xoffset, double yoffset);
void cursorPosCallback(GLFWwindow *window, double xpos, double ypos);


//------------------------------
//-------Mouse Sate---------
//------------------------------

double g_mouse_old_x;
double g_mouse_old_y;


//------------------------------
//-------Camera ---------
//------------------------------
Camera* g_camera;
Loading