void init(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(width, height); glutCreateWindow("565 NBody sim"); // Init GLEW glewInit(); GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ std::cout << "glewInit failed, aborting." << std::endl; exit (1); } if (argc > 1) { if (!strcmp (argv [1], "true")) customSimulation = true; if (argc > 2) if (!strcmp (argv [2], "prefetch")) prefetchEnabled = true; } initVAO(); initTextures(); }
PlaneMesh::PlaneMesh(): shader(initShader()), vao(initVAO(shader, vertex_attrib_idx, uniform)), mode(GL_TRIANGLES), first_idx(0), count(6) { }
int main(){ //Change this line to use your name! yourName = "Karl Li"; // Needed in OSX to force use of OpenGL3.2 glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); init(); initCuda(); CUT_CHECK_ERROR_GL(); initVAO(); initTextures(); GLuint passthroughProgram; passthroughProgram = initShader("shaders/passthroughVS.glsl", "shaders/passthroughFS.glsl"); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); // send into GLFW main loop while(1){ display(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS || !glfwGetWindowParam( GLFW_OPENED )){ exit(0); } } glfwTerminate(); return 0; }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(width, height); glutCreateWindow("Image Processing"); glewInit(); GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ std::cout << "glewInit failed, aborting." << std::endl; exit (1); } std::cout << "Status: Using GLEW " << glewGetString(GLEW_VERSION) << std::endl; std::cout << "OpenGL version " << glGetString(GL_VERSION) << " supported" << std::endl; initVAO(); initTextures(); passthroughProgram = initShader("passthroughVS.glsl", "passthroughFS.glsl"); boxBlurProgram = initShader("passthroughVS.glsl", "boxBlurFS.glsl"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); glutMainLoop(); return 0; }
void init(){ if (glfwInit() != GL_TRUE){ shut_down(1); } // 16 bit color, no depth, alpha or stencil buffers, windowed if (glfwOpenWindow(width, height, 5, 6, 5, 0, 0, 0, GLFW_WINDOW) != GL_TRUE){ shut_down(1); } // Set window title to "Student Name: GPU Name" string deviceName; cudaDeviceProp deviceProp; int gpudevice = 0; int device_count = 0; int device; cudaGetDeviceCount( &device_count); if (gpudevice > device_count) { printf("Error: GPU device number is greater than the number of devices! Perhaps a CUDA-capable GPU is not installed?\n"); exit(1); } cudaError_t cudareturn; cudaGetDeviceProperties(&deviceProp, gpudevice); deviceName = deviceProp.name; deviceName = yourName + ": " + deviceProp.name; major = deviceProp.major; minor = deviceProp.minor; glfwSetWindowTitle(deviceName.c_str()); // Set up vertex array object, texture stuff initVAO(); initTextures(); }
void Reloadable::reload() { initBuffers(); initPipeline(); initVBO(); initVAO(); initUniformsCache(); }
void FXAA::init(int width, int height) { m_technique->setUniformAttribute("screenWidth", static_cast<GLfloat>(width)); m_technique->setUniformAttribute("screenHeight", static_cast<GLfloat>(height)); m_sampler = m_renderer->getTextureManager()->getSamplerPreset(TextureManager::NearestClamp); initFBO(width, height); initVAO(); }
/** * Initialization of CUDA and GLFW. */ bool init(int argc, char **argv) { // Set window title to "Student Name: [SM 2.0] GPU Name" std::string deviceName; cudaDeviceProp deviceProp; int gpuDevice = 0; int device_count = 0; cudaGetDeviceCount(&device_count); if (gpuDevice > device_count) { std::cout << "Error: GPU device number is greater than the number of devices!" << "Perhaps a CUDA-capable GPU is not installed?" << std::endl; return false; } cudaGetDeviceProperties(&deviceProp, gpuDevice); m_major = deviceProp.major; m_minor = deviceProp.minor; std::ostringstream ss; ss << m_yourName << ": [SM " << m_major << "." << m_minor << "] " << deviceProp.name; deviceName = ss.str(); // Window setup stuff glfwSetErrorCallback(errorCallback); if (!glfwInit()) { return false; } m_width = 800; m_height = 800; m_window = glfwCreateWindow(m_width, m_height, deviceName.c_str(), NULL, NULL); if (!m_window) { glfwTerminate(); return false; } glfwMakeContextCurrent(m_window); glfwSetKeyCallback(m_window, keyCallback); glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { return false; } // init all of the things initVAO(); initTextures(); initCUDA(); initPBO(&m_pbo); GLuint passthroughProgram; passthroughProgram = initShader(); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); return true; }
CubMapStudyR::CubMapStudyR() { skyboxShader = new ShaderHandle("cubmapstudy2"); cubeShader = new ShaderHandle("cubmapcube2"); camera = new Camera(); glEnable(GL_DEPTH_TEST); initTextrueID(); initVAO(); GLFWwindow* window = RenderDelegate::getInstance()->getWindowHandle(); glfwSetKeyCallback(window, &Camera::key_callback); glfwSetCursorPosCallback(window, &Camera::mouse_callback); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); glfwSetScrollCallback(window, &Camera::scroll_callback); }
void init(){ if (glfwInit() != GL_TRUE){ shut_down(1); } // 16 bit color, no depth, alpha or stencil buffers, windowed if (glfwOpenWindow(width, height, 5, 6, 5, 0, 0, 0, GLFW_WINDOW) != GL_TRUE){ shut_down(1); } // Set up vertex array object, texture stuff initVAO(); initTextures(); }
Mesh::Mesh( Engine* engine, const Material& material, core::Texture2D* diffuseMap, core::Texture2D* normalMap, core::Texture2D* specularMap, core::Program* program, core::Program* programShadow, core::Program* programShadowColor, core::Program* programOcclusion, core::Program* programAmbientOcclusionGeometry, core::Program* programAmbientOcclusionColor, LightSystem* lights, core::VertexBufferBasic* vbo, core::IndexBuffer* ibo, #ifdef FILLWAVE_MODEL_LOADER_ASSIMP Animator* animator, #endif /* FILLWAVE_MODEL_LOADER_ASSIMP */ GLenum renderMode, core::VertexArray* vao) : IReloadable(engine, vao), mMaterial(material), mDiffuseMap(diffuseMap), mNormalMap(normalMap), mSpecularMap(specularMap), mProgram(program), mProgramShadow(programShadow), mProgramShadowColor(programShadowColor), mProgramOQ(programOcclusion), mProgramAOGeometry(programAmbientOcclusionGeometry), mProgramAOColor(programAmbientOcclusionColor), mRenderMode(renderMode), mIBO(ibo), mVBO(vbo), mLights(lights) #ifdef FILLWAVE_MODEL_LOADER_ASSIMP , mAnimator(animator) #endif /* FILLWAVE_MODEL_LOADER_ASSIMP */ #ifdef FILLWAVE_GLES_3_0 #else , mConditionalRendering(GL_QUERY_WAIT) #endif { initPipeline(); initVBO(); initVAO(); initUniformsCache(); }
bool init(obj *mesh) { glfwSetErrorCallback(errorCallback); if (!glfwInit()) { return false; } width = 350; height = 350; window = glfwCreateWindow(width, height, "CIS 565 Pathtracer", NULL, NULL); if (!window) { glfwTerminate(); return false; } glfwMakeContextCurrent(window); glfwSetKeyCallback(window, keyCallback); // Set up GL context glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { return false; } // Initialize other stuff initVAO(); initTextures(); initCuda(); initPBO(); float cbo[] = { 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0 }; rasterizeSetBuffers(mesh->getBufIdxsize(), mesh->getBufIdx(), mesh->getBufPossize() / 3, mesh->getBufPos(), mesh->getBufNor(), mesh->getBufCol()); GLuint passthroughProgram; passthroughProgram = initShader(); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); return true; }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(width, height); glutCreateWindow("Image Processing"); glewInit(); GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ std::cout << "glewInit failed, aborting." << std::endl; exit (1); } std::cout << "Status: Using GLEW " << glewGetString(GLEW_VERSION) << std::endl; std::cout << "OpenGL version " << glGetString(GL_VERSION) << " supported" << std::endl; initVAO(); initTextures(); passthroughProgram = initShader("passthroughVS.glsl", "passthroughFS.glsl"); boxBlurProgram = initShader("passthroughVS.glsl", "boxBlurFS.glsl"); negativeProgram = initShader("passthroughVS.glsl", "negativeFS.glsl"); gaussianBlurProgram = initShader("passthroughVS.glsl", "gaussianBlurFS.glsl"); grayscaleProgram = initShader("passthroughVS.glsl", "grayscaleFS.glsl"); edgeDetectionProgram = initShader("passthroughVS.glsl", "edgeDetectionFS.glsl"); toonShadingProgram = initShader("passthroughVS.glsl", "toonShadingFS.glsl"); vintageProgram = initShader("passthroughVS.glsl", "vintageFS.glsl"); brightnessProgram = initShader("passthroughVS.glsl", "brightnessFS.glsl"); unsharpMaskProgram = initShader("passthroughVS.glsl", "unsharpMaskFS.glsl"); sharpenProgram = initShader("passthroughVS.glsl", "sharpenFS.glsl"); nightVisionProgram = initShader("passthroughVS.glsl", "nightVisionFS.glsl"); weirdProgram = initShader("weirdVS.glsl", "passthroughFS.glsl"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); glutMainLoop(); return 0; }
void init(int argc, char* argv[]){ glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(width, height); glutCreateWindow("CIS565 Rasterizer"); // Init GLEW glewInit(); GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ std::cout << "glewInit failed, aborting." << std::endl; exit (1); } initVAO(); initTextures(); }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(width, height); glutCreateWindow("Image Processing"); glewInit(); GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ std::cout << "glewInit failed, aborting." << std::endl; exit (1); } std::cout << "Status: Using GLEW " << glewGetString(GLEW_VERSION) << std::endl; std::cout << "OpenGL version " << glGetString(GL_VERSION) << " supported" << std::endl; initVAO(); initTextures(); passthroughProgram = initShader("passthroughVS.glsl", "passthroughFS.glsl"); boxBlurProgram = initShader("passthroughVS.glsl", "boxBlurFS.glsl"); //=========================================================================== imageNegativeProgram = initShader("passthroughVS.glsl", "hy_imageNegative.glsl"); gaussianBlurProgram = initShader("passthroughVS.glsl", "hy_gaussianBlur.glsl"); grayScaleFSProgram = initShader("passthroughVS.glsl", "hy_grayScale.glsl"); edgeDetectionProgram = initShader("passthroughVS.glsl", "hy_edgeDetection.glsl"); toonShadingProgram = initShader("passthroughVS.glsl", "hy_toonShading.glsl"); pixelateProgram = initShader("passthroughVS.glsl", "hy_pixelate.glsl"); brightnessProgram = initShader("passthroughVS.glsl", "hy_brightness.glsl"); nightVisionProgram = initShader("passthroughVS.glsl", "hy_nightVision.glsl"); constractProgram = initShader("passthroughVS.glsl", "hy_contrast.glsl"); //=========================================================================== glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); glutMainLoop(); return 0; }
void init(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(width, height); glutCreateWindow("565 NBody sim"); timeSinceLastFrame = glutGet(GLUT_ELAPSED_TIME); // Init GLEW glewInit(); GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ std::cout << "glewInit failed, aborting." << std::endl; exit (1); } initVAO(); }
bool init(int argc, char* argv[]) { glfwSetErrorCallback(errorCallback); if (!glfwInit()) { return false; } width = 800; height = 800; window = glfwCreateWindow(width, height, "CIS 565 Rasterizer", NULL, NULL); if (!window){ glfwTerminate(); return false; } glfwMakeContextCurrent(window); glfwSetKeyCallback(window, keyCallback); glfwSetMouseButtonCallback(window,MouseClickCallback); glfwSetCursorEnterCallback(window,CursorEnterCallback); glfwSetCursorPosCallback(window,CursorCallback); // Set up GL context glewExperimental = GL_TRUE; if(glewInit()!=GLEW_OK){ return false; } // Initialize other stuff initVAO(); initTextures(); initCuda(); initPBO(); GLuint passthroughProgram; passthroughProgram = initShader(); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); return true; }
int main(int argc, char* argv[]){ //Change this line to use your name! yourName = "Aparajith Sairam"; init(argc, argv); initVAO(); initTextures(); initCuda(); GLuint passthroughProgram; passthroughProgram = initShader("shaders/passthroughVS.glsl", "shaders/passthroughFS.glsl"); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }
/** * Initialization of CUDA and GLFW. */ bool init(int argc, char **argv) { // Set window title to "Student Name: [SM 2.0] GPU Name" cudaDeviceProp deviceProp; int gpuDevice = 0; int device_count = 0; cudaGetDeviceCount(&device_count); if (gpuDevice > device_count) { std::cout << "Error: GPU device number is greater than the number of devices!" << " Perhaps a CUDA-capable GPU is not installed?" << std::endl; return false; } cudaGetDeviceProperties(&deviceProp, gpuDevice); int major = deviceProp.major; int minor = deviceProp.minor; std::ostringstream ss; ss << projectName << " [SM " << major << "." << minor << " " << deviceProp.name << "]"; deviceName = ss.str(); // Window setup stuff glfwSetErrorCallback(errorCallback); if (!glfwInit()) { std::cout << "Error: Could not initialize GLFW!" << " Perhaps OpenGL 3.3 isn't available?" << std::endl; return false; } int width = 1280; int height = 720; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); window = glfwCreateWindow(width, height, deviceName.c_str(), NULL, NULL); if (!window) { glfwTerminate(); return false; } glfwMakeContextCurrent(window); glfwSetKeyCallback(window, keyCallback); glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { return false; } // Initialize drawing state initVAO(); // Default to device ID 0. If you have more than one GPU and want to test a non-default one, // change the device ID. cudaGLSetGLDevice(0); cudaGLRegisterBufferObject(planetVBO); // Initialize N-body simulation Nbody::initSimulation(N_FOR_VIS); projection = glm::perspective(fovy, float(width) / float(height), zNear, zFar); glm::mat4 view = glm::lookAt(cameraPosition, glm::vec3(0), glm::vec3(0, 0, 1)); projection = projection * view; initShaders(program); glEnable(GL_DEPTH_TEST); return true; }
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 #ifdef __APPLE__ // Needed in OSX to force use of OpenGL3.2 glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); init(); #else init(argc, argv); #endif // Initialize camera position cam = glm::translate( cam, glm::vec3( 0.0, 0.0, 2.0f ) ); initCuda(); initVAO(); initTextures(); GLuint passthroughProgram; passthroughProgram = initShader("shaders/passthroughVS.glsl", "shaders/passthroughFS.glsl"); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); #ifdef __APPLE__ // send into GLFW main loop while(1){ display(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS || !glfwGetWindowParam( GLFW_OPENED )){ kernelCleanup(); cudaDeviceReset(); exit(0); } } glfwTerminate(); #else glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMouseFunc(mouse); glutMotionFunc(mouse_motion); glutMainLoop(); #endif kernelCleanup(); return 0; }
int main(int argc, char** argv){ #ifdef __APPLE__ // Needed in OSX to force use of OpenGL3.2 glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); #endif // Set up pathtracer stuff bool loadedScene = false; finishedRender = false; targetFrame = 0; singleFrameMode = false; // Load scene file 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(), "scene")==0){ renderScene = new scene(data); loadedScene = true; }else if(strcmp(header.c_str(), "frame")==0){ targetFrame = atoi(data.c_str()); singleFrameMode = true; } else if(strcmp(header.c_str(), "mblur")==0){ mblur = atoi(data.c_str()); } else if(strcmp(header.c_str(), "dof")==0){ dof = atoi(data.c_str()); } else if(strcmp(header.c_str(), "textureMode")==0){ textureMode = atoi(data.c_str()); } } if(!loadedScene){ cout << "Error: scene file needed!" << endl; return 0; } // Set up camera stuff from loaded pathtracer settings iterations = 0; renderCam = &renderScene->renderCam; width = renderCam->resolution[0]; height = renderCam->resolution[1]; if(targetFrame>=renderCam->frames){ cout << "Warning: Specified target frame is out of range, defaulting to frame 0." << endl; targetFrame = 0; } // Launch CUDA/GL #ifdef __APPLE__ init(); #else init(argc, argv); #endif initCuda(); initVAO(); initTextures(); GLuint passthroughProgram; passthroughProgram = initShader("shaders/passthroughVS.glsl", "shaders/passthroughFS.glsl"); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); #ifdef __APPLE__ // send into GLFW main loop while(1){ display(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS || !glfwGetWindowParam( GLFW_OPENED )){ exit(0); } } glfwTerminate(); #else glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMouseFunc(mouse); glutMainLoop(); #endif 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; } // Initialization of camera parameters cam.position = glm::vec3(0.0f, 1.0f, 1.0f); cam.up = glm::vec3(0.0f, 1.0f, 0.0f); cam.view = glm::normalize(-cam.position); cam.right = glm::normalize(glm::cross(cam.view, cam.up)); cam.fovy = 45.0f; // Initialize transformation model = new glm::mat4(utilityCore::buildTransformationMatrix(glm::vec3(0.0f, -0.2f, 0.0f), glm::vec3(0.0f), glm::vec3(0.7f))); view = new glm::mat4(glm::lookAt(cam.position, glm::vec3(0.0f), cam.up)); projection = new glm::mat4(glm::perspective(cam.fovy, (float)width / height, zNear, zFar)); transformModel2Projection = new cudaMat4(utilityCore::glmMat4ToCudaMat4(*projection * *view * *model)); // Initialize viewport in the model space viewPort = glm::normalize(utilityCore::multiplyMat(utilityCore::glmMat4ToCudaMat4(*projection * *view), glm::vec4(cam.view, 1.0f))); frame = 0; seconds = time (NULL); fpstracker = 0; // Launch CUDA/GL #ifdef __APPLE__ // Needed in OSX to force use of OpenGL3.2 glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); init(); #else init(argc, argv); #endif initCuda(); initVAO(); initTextures(); GLuint passthroughProgram; passthroughProgram = initShader("shaders/passthroughVS.glsl", "shaders/passthroughFS.glsl"); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); #ifdef __APPLE__ // send into GLFW main loop while(1){ display(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS || !glfwGetWindowParam( GLFW_OPENED )){ kernelCleanup(); cudaDeviceReset(); exit(0); } } glfwTerminate(); #else glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutSpecialFunc(specialFunction); glutMouseFunc(mouseClick); glutMotionFunc(mouseMotion); glutMainLoop(); #endif kernelCleanup(); delete model; delete view; delete projection; delete transformModel2Projection; return 0; }
int main(int argc, char** argv){ #ifdef __APPLE__ // Needed in OSX to force use of OpenGL3.2 glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); #endif // Set up pathtracer stuff bool loadedScene = false; finishedRender = false; targetFrame = 0; singleFrameMode = false; // Load scene file 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(), "scene")==0){ renderScene = new scene(data); loadedScene = true; }else if(strcmp(header.c_str(), "frame")==0){ targetFrame = atoi(data.c_str()); singleFrameMode = true; } } if(!loadedScene){ cout << "Error: scene file needed!" << endl; return 0; } // Set up camera stuff from loaded pathtracer settings iterations = 0; renderCam = &renderScene->renderCam; parameterSet = &renderScene->parameterSet; width = renderCam->resolution[0]; height = renderCam->resolution[1]; textures=new m_BMP[renderScene->bmps.size()]; int i,j,k; for(i=0;i<renderScene->bmps.size();i++) { //int w=renderScene->bmps[i]->Width; //int h=renderScene->bmps[i]->Height; BMP now; now.ReadFromFile(renderScene->bmps[i].c_str()); int h=now.TellHeight();int w=now.TellWidth(); textures[i].resolution=glm::vec2(w,h); textures[i].colors=new glm::vec3[w*h]; for(j=0;j<w;j++)for(k=0;k<h;k++) { RGBApixel current=now.GetPixel(j,k); textures[i].colors[j*h+k]=glm::vec3(current.Red,current.Green,current.Blue)*(1.0f/255.0f); } } if(targetFrame>=renderCam->frames){ cout << "Warning: Specified target frame is out of range, defaulting to frame 0." << endl; targetFrame = 0; } // Launch CUDA/GL #ifdef __APPLE__ init(); #else init(argc, argv); #endif initCuda(); initVAO(); initTextures(); GLuint passthroughProgram; passthroughProgram = initShader("shaders/passthroughVS.glsl", "shaders/passthroughFS.glsl"); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); starttime=clock(); #ifdef __APPLE__ // send into GLFW main loop while(1){ display(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS || !glfwGetWindowParam( GLFW_OPENED )){ exit(0); } } glfwTerminate(); #else glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMainLoop(); #endif 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); //laoding file for obj data = "../../objs/plane.obj"; mesh = new obj(); objLoader* loader = new objLoader(data, mesh); mesh->buildVBOs(); meshVector.push_back(mesh); data = "../../objs/bunny.obj"; mesh = new obj(); loader = new objLoader(data, mesh); mesh->buildVBOs(); meshVector.push_back(mesh); delete loader; loadedScene = true; //} //} stencilBuffer = new int[width*height]; #if STENCIL == 1 isStencil = true; #else isStencil = false; #endif firstObj = 0; secondObj = FIRST; if(!loadedScene){ cout << "Usage: mesh=[obj file]" << endl; return 0; } frame = 0; seconds = time (NULL); fpstracker = 0; // Launch CUDA/GL #ifdef __APPLE__ // Needed in OSX to force use of OpenGL3.2 glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); init(); #else init(argc, argv); #endif initCuda(); initVAO(); initTextures(); GLuint passthroughProgram; passthroughProgram = initShader("shaders/passthroughVS.glsl", "shaders/passthroughFS.glsl"); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); #ifdef __APPLE__ // send into GLFW main loop while(1){ display(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS || !glfwGetWindowParam( GLFW_OPENED )){ kernelCleanup(); cudaDeviceReset(); exit(0); } } glfwTerminate(); #else glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMainLoop(); #endif kernelCleanup(); return 0; }