Ejemplo n.º 1
0
int main(int argc, char* args[])
{
	//this is me being difficult
	initGLUT(const_cast<int&>(argc), args);

	if(!initGL()){
		printf("Unable to initialize GL : main\n");
		return 1;
	}

	if(!initGFXPrograms()){
		printf("Unable to initialize GFX Programs : main\n");
		return 2;
	}

	if(!loadMedia()){
		printf("Unable to load media : main\n");
		return 3;
	}

	//second thread
    moodState.start();
    moodState.addMessageCarrier(msgs);

	glutKeyboardFunc(vfp_handleKeys);
	glutDisplayFunc(vfp_render);
	glutTimerFunc(TIME, vfp_mainLoop, 0);

	glutMainLoop();
    
    return 0;
}
Ejemplo n.º 2
0
int main(int argc, char** argv) {

	for (int i = 0; i < M.GetLayers(); i++)
	{
		M.Show(i);
		printf("\n");
	}

	current_elevator_i = M.getElevatorI();
	current_elevator_j = M.getElevatorJ();

	fvc = read_obj("flashlight.obj", fv, ftv, fn);

	initGLUT(&argc, argv);
	initGLEW();
	initOpenGL();

	
	glutKeyboardFunc(Movement);
	glutWarpPointer(200, 200);
	glutMotionFunc(MouseActiveMotion);
	glutPassiveMotionFunc(MouseMotion);
	glutMouseFunc(MouseButtons);
	glutMainLoop();

	freeVAO();
	freeVBO();
	cleanShaders();
	return 0;
}
Ejemplo n.º 3
0
int create_window(struct window *window) {
    if (window == 0) {
        return 1;
    }
    initGLUT(window);
    return 0;
}
Ejemplo n.º 4
0
bool Engine::init() {
	window = new WindowInfo(std::string("EEL"), 200, 200, 800, 800, true);
	context = new ContextInfo(3, 3, true /*CORE*/);
	framebuffer = new FramebufferInfo(true, true, true, true);

	initGLUT();

	sceneManager = new SceneManager();
	listener = sceneManager;
	shaderManager = new ShaderManager();
	modelManager = new ModelManager();
	textureLoader = new TextureLoader();
	inputManager = new InputManager();
	if(sceneManager && shaderManager && modelManager && textureLoader && inputManager) {
		sceneManager->setModelManager(modelManager);
		sceneManager->setInputManager(inputManager);
		inputManager->setWindowInfo(window);

		//inputManager->toggleMouseCapture();
	} else {
		return false;
	}

	return true;
}
Ejemplo n.º 5
0
int main(int argc, char** argv)
{
    srand(time(0));
    initGLUT(argc, argv);
    initGL();

    glutMainLoop();
    return 0;
}
Ejemplo n.º 6
0
int start_engine(int argc, char** argv)
{
    srand(time(0));
    initGLUT(argc, argv);
    initGL();
    initBOX2D(&world);
    glutMainLoop();
    return 0;
}
Ejemplo n.º 7
0
int main(int argc, char** argv){
	globalEngine = new Engine();
	globalCamera = new Camera();
	
	initGLUT(&argc, argv);
	initGLEW();
	loadModels();
	
	initOpenGL();
	glutMainLoop();
	return 0;
}
Ejemplo n.º 8
0
int main(int argc, char** argv) {
  printInstructions();
  initGLUT(&argc, argv);
  gluOrtho2D(0, W, H, 0);
  glutKeyboardFunc(keyboard);
  glutSpecialFunc(handleSpecialKeypress);
  glutPassiveMotionFunc(mouseMove);
  glutMotionFunc(mouseDrag);
  glutDisplayFunc(display);
  initPixelBuffer();
  glutMainLoop();
  atexit(exitfunc);
  return 0;
}
Ejemplo n.º 9
0
void OpenGLHelper::initOpenGL(int *argc, char** argv, string windowCaption, int windowXPosition, int windowYPosition, int windowWidth, int windowHeight)
{
	initGLUT(argc, argv, windowCaption, windowXPosition, windowYPosition, windowWidth, windowHeight);
	initGLEW();	

	glEnable(GL_LIGHTING);
	glEnable(GL_COLOR_MATERIAL);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_LIGHT0);
	glEnable(GL_NORMALIZE);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);
	GLint textureUnits = 3;
	glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &textureUnits);
Ejemplo n.º 10
0
int main(int argc, char** argv) {
  cudaMalloc(&d_vol, NX*NY*NZ*sizeof(float)); // 3D volume data
  volumeKernelLauncher(d_vol, volumeSize, id, params);
  printInstructions();
  initGLUT(&argc, argv);
  createMenu();
  gluOrtho2D(0, W, H, 0);
  glutKeyboardFunc(keyboard);
  glutSpecialFunc(handleSpecialKeypress);
  glutDisplayFunc(display);
  initPixelBuffer();
  glutMainLoop();
  atexit(exitfunc);
  return 0;
}
Ejemplo n.º 11
0
int main(int argc, char **argv) {
    if (argc != 2) {
        fprintf(stderr,"Usage: MazeViewer <file>\n");
        fprintf(stderr,"argc: %d\n", argc);
        getchar();
        return -1;
    }

    setDefaults();

    initGLUT(argc, argv);

    sceneCleanup();

    return 1;
}
Ejemplo n.º 12
0
int main(const int argc, const char* argv[])
{
	printf("<< %s >>\n", TITLE);

	//GLU initialize
	{
		initGLUT(argc, argv);
		createGLUTWindow();
	}

	//GLEW initialize
	{
		const GLenum result = initGLEW();
		if (result != GLEW_OK){ abort_program(); return EXIT_FAILURE; }
	}
	{
		printGLEWInfo();
		const bool result = checkGLEWFunctions();
		if (!result){ abort_program(); return EXIT_FAILURE; }
	}

	//Shader initialize
	const GLuint vertex_shader_handle = createAndLoadVertexShaderAll();
	if (!vertex_shader_handle){ abort_program(); return EXIT_FAILURE; }
	const GLuint fragment_shader_handle = createAndLoadFragmentShaderAll();
	if (!fragment_shader_handle){ abort_program(); return EXIT_FAILURE; }
	const GLuint program_handle = createAndLinkShaderProgram(vertex_shader_handle, fragment_shader_handle);
	g_program_handle = program_handle;

	printActiveAttribInfo(program_handle);
	printActiveUniformInfo(program_handle);
	
	//GLM test
	testGLM();

	//Main loop
	setupGLUTFunctions();
	mainloopGLUT();

	return EXIT_SUCCESS;
}
Ejemplo n.º 13
0
int main(int argc, char** argv) 
{
	initApplication( argc, argv );

	//initGL( argc, argv );

	initGLUT( argc, argv );

	GLenum err = glewInit();

	if (err || !glewIsSupported("GL_VERSION_2_0 GL_ARB_pixel_buffer_object")) 
	{
        fprintf(stderr, "Required OpenGL extensions missing.");
        exit(-1);

	} else {

		initCUDA( argc, argv );

		initObservationSpace();

		// init the pbo
		dispResp->createPBO(); // Create pixel buffer object

		// init result device memory
		//createResMem();

		atexit(cleanUpAtExit);

		//
		printHelpMenu();

		// start glut main loop
		glutMainLoop();

	}
	return 0;
}
Ejemplo n.º 14
0
void Labyrinth::init(int* argc, char** argv, int w, int h) {
    m_w_width  = 800;
    m_w_height = 800;
    
    m_key_u_press = false;
    m_key_d_press = false;
    m_key_l_press = false;
    m_key_r_press = false;
    m_key_u_val   = 119;    // w
    m_key_l_val   = 97;     // a
    m_key_d_val   = 115;    // s
    m_key_r_val   = 100;    // d

    m_maze_offset_x = m_w_width/2;
    m_maze_offset_y = m_w_height/2;
    m_max_maze_size = 10;
    m_light_radius  = 50;

    m_film_grain = false;
    m_film_grain_val = 400;
    m_show_data  = false;
    m_splash_screen = true;

    m_frame_count = 0;
    m_frame_time  = 0;
    m_fps         = 0;

    if(!m_screen)
        m_screen = new Screen(w,h);
    if(!m_maze)
        m_maze   = new Maze();
    if(!m_player)
        m_player = new Player(m_maze->nodeAt(0,0));
    
    initGLUT(argc,argv);
    registerCallbacks();
}
Ejemplo n.º 15
0
Archivo: main.cpp Proyecto: hgl888/glfw
int main(int argc, char **argv)
{
    initSharedMem();

    // register exit callback
    atexit(exitCB);

    // init GLUT and GL
    initGLUT(argc, argv);
    initGL();

    // get OpenGL info
    glInfo glInfo;
    glInfo.getInfo();
    glInfo.printSelf();

#ifdef _WIN32
    // check PBO is supported by your video card
    if(glInfo.isExtensionSupported("GL_ARB_pixel_buffer_object"))
    {
        // get pointers to GL functions
        glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");
        glBindBufferARB = (PFNGLBINDBUFFERARBPROC)wglGetProcAddress("glBindBufferARB");
        glBufferDataARB = (PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB");
        glBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC)wglGetProcAddress("glBufferSubDataARB");
        glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)wglGetProcAddress("glDeleteBuffersARB");
        glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)wglGetProcAddress("glGetBufferParameterivARB");
        glMapBufferARB = (PFNGLMAPBUFFERARBPROC)wglGetProcAddress("glMapBufferARB");
        glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)wglGetProcAddress("glUnmapBufferARB");

        // check once again PBO extension
        if(glGenBuffersARB && glBindBufferARB && glBufferDataARB && glBufferSubDataARB &&
           glMapBufferARB && glUnmapBufferARB && glDeleteBuffersARB && glGetBufferParameterivARB)
        {
            pboSupported = pboUsed = true;
            std::cout << "Video card supports GL_ARB_pixel_buffer_object." << std::endl;
        }
        else
        {
            pboSupported = pboUsed = false;
            std::cout << "Video card does NOT support GL_ARB_pixel_buffer_object." << std::endl;
        }
    }

    // check EXT_swap_control is supported
    if(glInfo.isExtensionSupported("WGL_EXT_swap_control"))
    {
        // get pointers to WGL functions
        wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
        wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress("wglGetSwapIntervalEXT");
        if(wglSwapIntervalEXT && wglGetSwapIntervalEXT)
        {
            // disable v-sync
            wglSwapIntervalEXT(0);
            std::cout << "Video card supports WGL_EXT_swap_control." << std::endl;
        }
    }

#else // for linux, do not need to get function pointers, it is up-to-date
    if(glInfo.isExtensionSupported("GL_ARB_pixel_buffer_object"))
    {
        pboSupported = pboUsed = true;
        std::cout << "Video card supports GL_ARB_pixel_buffer_object." << std::endl;
    }
    else
    {
        pboSupported = pboUsed = false;
        std::cout << "Video card does NOT support GL_ARB_pixel_buffer_object." << std::endl;
    }
#endif

    if(pboSupported)
    {
        // create 2 pixel buffer objects, you need to delete them when program exits.
        // glBufferDataARB with NULL pointer reserves only memory space.
        glGenBuffersARB(PBO_COUNT, pboIds);
        glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[0]);
        glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, DATA_SIZE, 0, GL_STREAM_READ_ARB);
        glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[1]);
        glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, DATA_SIZE, 0, GL_STREAM_READ_ARB);

        glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
    }

    // start timer, the elapsed time will be used for updateVertices()
    timer.start();

    // the last GLUT call (LOOP)
    // window will be shown and display callback is triggered by events
    // NOTE: this call never return main().
    glutMainLoop(); /* Start GLUT event-processing loop */

    return 0;
}
Ejemplo n.º 16
0
Archivo: main.cpp Proyecto: hgl888/glfw
int main(int argc, char **argv)
{
    // init global vars
    initSharedMem();

    // register exit callback
    atexit(exitCB);

    // init GLUT and GL
    initGLUT(argc, argv);
    initGL();

    // create a texture object
    glGenTextures(1, &textureId);
    glBindTexture(GL_TEXTURE_2D, textureId);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); // automatic mipmap generation included in OpenGL v1.4
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
    glBindTexture(GL_TEXTURE_2D, 0);

    // get OpenGL info
    glInfo glInfo;
    glInfo.getInfo();
    //glInfo.printSelf();

#ifdef _WIN32
    // check if FBO is supported by your video card
    if(glInfo.isExtensionSupported("GL_ARB_framebuffer_object"))
    {
        // get pointers to GL functions
        glGenFramebuffers                     = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers");
        glDeleteFramebuffers                  = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers");
        glBindFramebuffer                     = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer");
        glCheckFramebufferStatus              = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)wglGetProcAddress("glCheckFramebufferStatus");
        glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)wglGetProcAddress("glGetFramebufferAttachmentParameteriv");
        glGenerateMipmap                      = (PFNGLGENERATEMIPMAPPROC)wglGetProcAddress("glGenerateMipmap");
        glFramebufferTexture1D                = (PFNGLFRAMEBUFFERTEXTURE1DPROC)wglGetProcAddress("glFramebufferTexture1D");
        glFramebufferTexture2D                = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D");
        glFramebufferTexture3D                = (PFNGLFRAMEBUFFERTEXTURE3DPROC)wglGetProcAddress("glFramebufferTexture3D");
        glFramebufferTextureLayer             = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)wglGetProcAddress("glFramebufferTextureLayer");
        glFramebufferRenderbuffer             = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer");
        glIsFramebuffer                       = (PFNGLISFRAMEBUFFERPROC)wglGetProcAddress("glIsFramebuffer");
        glBlitFramebuffer                     = (PFNGLBLITFRAMEBUFFERPROC)wglGetProcAddress("glBlitFramebuffer");
        glGenRenderbuffers                    = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers");
        glDeleteRenderbuffers                 = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress("glDeleteRenderbuffers");
        glBindRenderbuffer                    = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer");
        glRenderbufferStorage                 = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage");
        glRenderbufferStorageMultisample      = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)wglGetProcAddress("glRenderbufferStorageMultisample");
        glGetRenderbufferParameteriv          = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)wglGetProcAddress("glGetRenderbufferParameteriv");
        glIsRenderbuffer                      = (PFNGLISRENDERBUFFERPROC)wglGetProcAddress("glIsRenderbuffer");

        // check once again FBO extension
        if(glGenFramebuffers && glDeleteFramebuffers && glBindFramebuffer && glCheckFramebufferStatus &&
           glGetFramebufferAttachmentParameteriv && glGenerateMipmap && glFramebufferTexture1D && glFramebufferTexture2D && glFramebufferTexture3D &&
           glFramebufferTextureLayer && glFramebufferRenderbuffer && glIsFramebuffer && glBlitFramebuffer &&
           glGenRenderbuffers && glDeleteRenderbuffers && glBindRenderbuffer && glRenderbufferStorage &&
           glRenderbufferStorageMultisample && glGetRenderbufferParameteriv && glIsRenderbuffer)
        {
            fboSupported = fboUsed = true;
            std::cout << "Video card supports GL_ARB_framebuffer_object." << std::endl;
        }
        else
        {
            fboSupported = fboUsed = false;
            std::cout << "Video card does NOT support GL_ARB_framebuffer_object." << std::endl;
        }
    }

    // check EXT_swap_control is supported
    if(glInfo.isExtensionSupported("WGL_EXT_swap_control"))
    {
        // get pointers to WGL functions
        wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
        wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress("wglGetSwapIntervalEXT");
        if(wglSwapIntervalEXT && wglGetSwapIntervalEXT)
        {
            // disable v-sync
            wglSwapIntervalEXT(0);
            std::cout << "Video card supports WGL_EXT_swap_control." << std::endl;
        }
    }

#else // for linux, do not need to get function pointers, it is up-to-date
    if(glInfo.isExtensionSupported("GL_ARB_framebuffer_object"))
    {
        fboSupported = fboUsed = true;
        std::cout << "Video card supports GL_ARB_framebuffer_object." << std::endl;
    }
    else
    {
        fboSupported = fboUsed = false;
        std::cout << "Video card does NOT support GL_ARB_framebuffer_object." << std::endl;
    }
#endif

    if(fboSupported)
    {
        // create a MSAA framebuffer object
        // NOTE: All attachment images must have the same # of samples.
        // Ohterwise, the framebuffer status will not be completed.
        glGenFramebuffers(1, &fboMsaaId);
        glBindFramebuffer(GL_FRAMEBUFFER, fboMsaaId);

        // create a MSAA renderbuffer object to store color info
        glGenRenderbuffers(1, &rboColorId);
        glBindRenderbuffer(GL_RENDERBUFFER, rboColorId);
        glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaaCount, GL_RGB8, TEXTURE_WIDTH, TEXTURE_HEIGHT);
        glBindRenderbuffer(GL_RENDERBUFFER, 0);

        // create a MSAA renderbuffer object to store depth info
        // NOTE: A depth renderable image should be attached the FBO for depth test.
        // If we don't attach a depth renderable image to the FBO, then
        // the rendering output will be corrupted because of missing depth test.
        // If you also need stencil test for your rendering, then you must
        // attach additional image to the stencil attachement point, too.
        glGenRenderbuffers(1, &rboDepthId);
        glBindRenderbuffer(GL_RENDERBUFFER, rboDepthId);
        glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaaCount, GL_DEPTH_COMPONENT, TEXTURE_WIDTH, TEXTURE_HEIGHT);
        glBindRenderbuffer(GL_RENDERBUFFER, 0);

        // attach msaa RBOs to FBO attachment points
        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rboColorId);
        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboDepthId);


        // create a normal (no MSAA) FBO to hold a render-to-texture
        glGenFramebuffers(1, &fboId);
        glBindFramebuffer(GL_FRAMEBUFFER, fboId);

        glGenRenderbuffers(1, &rboId);
        glBindRenderbuffer(GL_RENDERBUFFER, rboId);
        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, TEXTURE_WIDTH, TEXTURE_HEIGHT);
        glBindRenderbuffer(GL_RENDERBUFFER, 0);

        // attach a texture to FBO color attachement point
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureId, 0);

        // attach a rbo to FBO depth attachement point
        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboId);

        //@@ disable color buffer if you don't attach any color buffer image,
        //@@ for example, rendering the depth buffer only to a texture.
        //@@ Otherwise, glCheckFramebufferStatus will not be complete.
        //glDrawBuffer(GL_NONE);
        //glReadBuffer(GL_NONE);

        // check FBO status
        printFramebufferInfo(fboMsaaId);
        bool status = checkFramebufferStatus(fboMsaaId);
        if(!status)
            fboUsed = false;

        glBindFramebuffer(GL_FRAMEBUFFER, 0);
    }

    // start timer, the elapsed time will be used for rotating the teapot
    timer.start();

    // the last GLUT call (LOOP)
    // window will be shown and display callback is triggered by events
    // NOTE: this call never return main().
    glutMainLoop(); /* Start GLUT event-processing loop */

    return 0;
}