예제 #1
0
파일: main.c 프로젝트: luxkyluke/Hovercraft
int main(int argc, char** argv) {
	//initialisation du contexte glut
	initGlut(argc, argv);

	Menu* menu = (Menu *) malloc(sizeof(Menu));

	Game* game = (Game *) malloc(sizeof(Game));

	//si probleme lors de la création du menu -> exit
	if (!MakeMenu(WINDOW_WIDTH, WINDOW_HEIGHT, menu, debut))
		return EXIT_FAILURE;

	//si porblème lors de la création du game -> exit
	if (!MakeGame(game)) {
		printf("Erreur MakeGame !!");
		return EXIT_FAILURE;
	}

	CallMenuDemarrage(menu, game);

	//liberation du *game
	FreeGame(game);
	free(game);
	game = NULL;

	//libéraiton du *menu
	free(menu);
	menu = NULL;

	return EXIT_SUCCESS;
}
예제 #2
0
파일: MainWindow.cpp 프로젝트: apoddubn/Cpp
MainWindow::MainWindow(string filename)
{

	// Save pointer to current instance. Later on we
	// will create a proper singleton here...
	MainWindow::master = this;

    // Init glut main window
    initGlut();
    initGL();

	for(int i = 0; i < 256; i++)
	{
		m_keyStates[i] = false;
		m_specialkeyStates[i] = false;
	}

	// Create a triangle mesh instance
	m_mesh = TriangleMeshFactory::instance().getMesh(filename);

	// Create a sky box
	string names[6];
	names[0] = "box1.ppm";
	names[1] = "box2.ppm";
	names[2] = "box3.ppm";
	names[3] = "box4.ppm";
	names[4] = "box5.ppm";
	names[5] = "box6.ppm";

	m_skybox = new Skybox(2048, names);

	// Call main loop
    glutMainLoop();
}
예제 #3
0
// main() function
// Initializes the user interface (and any user variables)
// then hands over control to the event handler, which calls 
// display() whenever the GL window needs to be redrawn.
int main(int argc, char** argv)
{
    // Process program arguments
    if(argc != 3) {
        printf("Usage: demo [width] [height]\n");
        printf("Using 800x600 window by default...\n");
        Win[0] = 800;
        Win[1] = 600;
    } else {
        Win[0] = atoi(argv[1]);
        Win[1] = atoi(argv[2]);
    }


    // Initialize glut, glui, and opengl
    glutInit(&argc, argv);
    initGlut(argv[0]);
    initGlui();
    initGl();

    // Invoke the standard GLUT main event loop
    glutMainLoop();

    return 0;         // never reached
}
예제 #4
0
파일: sim.c 프로젝트: abyxcos/MoboRoboSim
int main(int argc, char **argv) {
	initGlut(&argc, argv);
	initServer(&argc, argv);

	glutMainLoop();	// Loop forever
	return 0;
}
예제 #5
0
  /* main function in embree namespace */
  int main(int argc, char** argv) 
  {
    /* create stream for parsing */
    Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv));

    /* parse command line */  
    parseCommandLine(stream, FileName());
    if (filename.str() == "") {
      printf("Error: No input OBJ file specified, use -i option.\n");
      exit(1);
    }

    /* load scene */
    loadOBJ(filename,g_mesh);

    /* initialize ISPC */
    init(g_verbose);

    /* set scene */
    setScene(g_mesh,g_pointLightPosition,g_pointLightIntensity,g_ambientLightIntensity);

    /* initialize GLUT */
    initGlut("tutorial03",g_width,g_height,g_fullscreen,false);
    
    return 0;
  }
예제 #6
0
  /* main function in embree namespace */
  int main(int argc, char** argv) 
  {
    /* create stream for parsing */
    Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv));

    /* parse command line */  
    parseCommandLine(stream, FileName());
    if (g_numThreads) 
      g_rtcore += ",threads=" + std::stringOf(g_numThreads);

    /* initialize task scheduler */
#if !defined(__EXPORT_ALL_SYMBOLS__)
    TaskScheduler::create(g_numThreads);
#endif

    /* load scene */
    loadOBJ(filename,g_obj_scene);

    /* initialize ray tracing core */
    init(g_rtcore.c_str());
    
    /* send model */
    set_scene(&g_obj_scene);

    /* initialize GLUT */
    initGlut(tutorialName,g_width,g_height,g_fullscreen,true);
    
    return 0;
  }
예제 #7
0
파일: main.cpp 프로젝트: jhpy1024/Mazel
int main(int argc, char** argv)
{
    initGlut(argc, argv);
    initGlew();

    game.init();

    glutMainLoop();
}
예제 #8
0
// The ubiquituous main function.
int main ( int argc, char** argv )   // Create Main Function For Bringing It All Together
{
	// get the the filename from the commandline.
	if (argc!=2)
	{
	}


	//initialize glut specific items
	initGlut(argc, argv);

	//initialize openGL specific items
	initGL ();

	// tells glut to use a particular display function to redraw
	glutDisplayFunc(display);

	// allow the user to quit using the right mouse button menu
	// Set menu function callback
	g_iMenuId = glutCreateMenu(menufunc);

	// Set identifier for menu
	glutSetMenu(g_iMenuId);

	// Add quit option to menu
	glutAddMenuEntry("Quit",0);
	glutAddMenuEntry("Take a Snapshot",1);

	// Attach menu to right button clicks
	glutAttachMenu(GLUT_RIGHT_BUTTON);

	// Set idle function.  You can change this to call code for your animation,
	// or place your animation code in doIdle
	glutIdleFunc(doIdle);

	// callback for keyboard input
	glutKeyboardFunc(keyboard);

	// callback for mouse drags
	glutMotionFunc(mousedrag);

	// callback for idle mouse movement
	glutPassiveMotionFunc(mouseidle);

	// callback for mouse button changes
	glutMouseFunc(mousebutton);

	//initialize global variables
	sky.init();

	c.init("track");

	glutMainLoop        ();          // Initialize The Main Loop

	return 0;
}
예제 #9
0
MainWindow::MainWindow()
{
   m_sizeX = 762;
   m_sizeY = 576;
   m_cam = NULL;
   m_mesh = NULL;
   m_oldX = m_oldY = 0;
   initGlut();
   initCallbacks();
}
예제 #10
0
파일: main.cpp 프로젝트: AlphaO/Starfox
int main(int argc, char** argv)
{
	srand((unsigned int)time(0)); //Seed the random number generator
	initGlut(argc, argv);
	initCallbacks();
	glewInit();
	init();
	glutMainLoop();
	return 0;
}
예제 #11
0
/******************************************************************************
 Main function.
******************************************************************************/
int main(int argc, char* argv[])
{
    HDErrorInfo error;

    printf("Starting application\n");
    
    atexit(exitHandler);

    // Initialize the device.  This needs to be called before any other
    // actions on the device are performed.
    ghHD = hdInitDevice(HD_DEFAULT_DEVICE);
    if (HD_DEVICE_ERROR(error = hdGetError()))
    {
        hduPrintError(stderr, &error, "Failed to initialize haptic device");
        fprintf(stderr, "\nPress any key to quit.\n");
        getchar();
        exit(-1);
    }

    printf("Found device %s\n",hdGetString(HD_DEVICE_MODEL_TYPE));
    
    hdEnable(HD_FORCE_OUTPUT);
    hdEnable(HD_MAX_FORCE_CLAMPING);

    hdStartScheduler();
    if (HD_DEVICE_ERROR(error = hdGetError()))
    {
        hduPrintError(stderr, &error, "Failed to start scheduler");
        fprintf(stderr, "\nPress any key to quit.\n");
        getchar();
        exit(-1);
    }
    
    initGlut(argc, argv);

    // Get the workspace dimensions.
    HDdouble maxWorkspace[6];
    hdGetDoublev(HD_MAX_WORKSPACE_DIMENSIONS, maxWorkspace);

    // Low/left/back point of device workspace.
    hduVector3Dd LLB(maxWorkspace[0], maxWorkspace[1], maxWorkspace[2]);
    // Top/right/front point of device workspace.
    hduVector3Dd TRF(maxWorkspace[3], maxWorkspace[4], maxWorkspace[5]);
    initGraphics(LLB, TRF);

    // Application loop.
    CoulombForceField();

    printf("Done\n");
    return 0;
}
예제 #12
0
	void runEventLoop()
	{
		initGlut();

		glutThreadId = boost::this_thread::get_id();

		mainLoopRunning = true;
		while (mainLoopRunning) {
#ifdef TARGET_OSX
			glutCheckLoop();
#elif TARGET_LINUX
			glutMainLoopEvent();
#endif
		}
	}
예제 #13
0
int main(int argc, char * argv[])
{
	if (!initGlut(argc, argv))
	{
		return -1;
	}
	if (!kinect.init())
	{
		return -2;
	}

	initOpenGL();
	execute();
	return 0;
}
예제 #14
0
MainWindow::MainWindow(string filename)
{

	// Save pointer to current instance. Later on we
	// will create a proper singleton here...
	MainWindow::master = this;

    // Init glut main window
    initGlut();
    initGL();

	for(int i = 0; i < 256; i++)
	{
		m_keyStates[i] = false;
		m_specialkeyStates[i] = false;
	}


   /* // Timestamp this point */
   /* Timestamp t; */
   Logger::instance() << "Start loading mesh.";

	// Create a triangle mesh instance
	m_mesh = TriangleMeshFactory::instance().getMesh(filename);

	// Create a sky box. We assume that a model was loaded beforehand
	// to ensure that the base path in texture factory was set correctly.
	// If not set it manually before creating the sky box!!
	string names[6];
	names[0] = "box1.ppm";
	names[1] = "box2.jpg";
	names[2] = "box3.ppm";
	names[3] = "box4.jpg";
	names[4] = "box5.ppm";
	names[5] = "box6.jpg";

   Logger::instance() << "Start rendering.";

   m_skybox = new Skybox(2048, names);

   Logger::instance() << "Finished rendering.";

   /* // print elapsed time */
   /* std::cout << t << std::endl; */

   // Call main loop
   glutMainLoop();
}
예제 #15
0
void OpenGL::InitOpenGLContext(int argc, char** argv)
{
    printf ("Initializing OpenGL Contex ... \n");
    printf ("	First Initialize OpenGL Context, So We Can Properly Set the GL for CUDA. \n");
    printf ("	This is Necessary in order to Achieve Optimal Performance with OpenGL/CUDA Interop. \n");


    // GLUT Initialization
    initGlut(argc, argv);



    // Register OpenGL CallBack Functions
    OpenGLRegisterOpenGLCallBacks();

}
예제 #16
0
int main(int argc, char ** argv)
{
	//init OpenGL context
	initGlut(argc, argv);
	initGlew();

	OnInit();
	glutCloseFunc(OnShutDown);
	glutDisplayFunc(OnRender);
	glutReshapeFunc(OnResize);
	glutMouseFunc(OnMouseDown);
	glutMotionFunc(OnMouseMove);
	glutKeyboardFunc(OnKeyDown);
	glutIdleFunc(OnIdle);
	glutMainLoop();
	return 0;
}
예제 #17
0
MainWindow::MainWindow()
{
	// Save pointer to current instance. Later on we
	// will create a proper singleton here...
	MainWindow::master = this;
	for(int i = 0; i < 256; i++)
	{
		m_keyStates[i] = false;
		m_specialkeyStates[i] = false;
	}

	// Create a triangle mesh instance
	m_mesh = new TriangleMesh(arrow_faces, arrow_vertices, 248, 396);
    
    m_cam = Camera(0, 20, 100);

	// Init glut main window
	initGlut();
}
예제 #18
0
GlutWindow::GlutWindow(unsigned int const width, unsigned int const height,
        char const * title) {
    this->width = width;
    this->height = height;

    initGlut();
    /*
     * Set up a basic window.  This is not very generic, but
     * exactly what is needed to render a raster image transferred via
     * OpenCL.
     */
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
    glutInitWindowSize(width, height);
    glutInitWindowPosition(glutGet(GLUT_SCREEN_WIDTH) / 2 - width / 2, glutGet(
            GLUT_SCREEN_HEIGHT) / 2 - height / 2);
    glutWindowID = glutCreateWindow(title);
    glutWindows[glutWindowID] = this;

    glutDisplayFunc(glutWindowDisplay);
    glutReshapeFunc(glutWindowReshape);
    glutKeyboardFunc(glutKeypress);
    glutSpecialFunc(glutSpecialKeypress);
    glutMouseFunc(glutMouse);
}
예제 #19
0
void Tutorial::Run()
{
#ifdef __TUT_VERSION

#if __TUT_VERSION >= 17
  if (_tutorialID >= 17) {
    char windowName[255];
    sprintf(&windowName[0], "Tutorial %d", _tutorialID);
    if (!GLUTBackendCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, false, windowName)) {
      return;
    }
#if __TUT_VERSION == 17
    _tutorial = new Tutorial17();
#elif __TUT_VERSION == 18
    _tutorial = new Tutorial18();
#elif __TUT_VERSION == 19
    _tutorial = new Tutorial19();
#elif __TUT_VERSION == 20
    _tutorial = new Tutorial20();
#elif __TUT_VERSION == 21
    _tutorial = new Tutorial21();
#elif __TUT_VERSION == 22
    _tutorial = new Tutorial22();
#elif __TUT_VERSION == 23
    _tutorial = new Tutorial23();
#endif

    if (!_tutorial->Init(pVSFileName, pFSFileName)) {
      return;
    }

    char* version = (char*)glGetString(GL_VERSION);
    fprintf(stdout, "Version: '%s'\n", version);
    _tutorial->Run();
    delete _tutorial;
    return;
  }
#endif

#endif



  initGlut();
  initGlew();

  glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

  if (_tutorialID == 16) {
    glFrontFace(GL_CW);
    glCullFace(GL_BACK);
    glEnable(GL_CULL_FACE);
  }

  char* version = (char*)glGetString(GL_VERSION);
  fprintf(stdout, "Version: '%s'\n", version);

  ///
  /// Create vertex buffer: glGenBuffers, glBindBuffer, glBufferData.
  ///
  createVertexBuffer();

  ///
  /// Create the index buffer: glGenBuffers, glBindBuffer, glBufferData.
  ///
  createIndexBuffer();

  ///
  /// Read shaders from file, compile, verify and add to shader program.
  ///
  compileShaders();

  if (_tutorialID == 16) {
    glUniform1i(_gSampler, 0);

    _pTexture = new Texture(GL_TEXTURE_2D, "/home/lparkin/Projects/S3/OpenGlDirsProject/LearnOpenGL-nonQt/Project/Content/test.png");

    if (!_pTexture->Load()) {
      exit(1);
    }
  }

  ///
  /// Setup the perspective projection information.
  ///
  _gPersProjInfo.FOV = 60.0f;
  _gPersProjInfo.Height = WINDOW_HEIGHT_1_14;
  _gPersProjInfo.Width = WINDOW_WIDTH_1_14;
  _gPersProjInfo.zNear = 1.0f;
  _gPersProjInfo.zFar = 100.0f;

  ///
  /// Start the rendering loop.
  ///
  glutMainLoop();
}
예제 #20
0
int main( int argc, char** argv )
{
    bool setQuit = false;
    int capWidth = gw;
    int capHeight = gh;

    state.use_IPP = false;
	state.bqatest = false;
	unsigned int devN = 0;
	if( shrGetCmdLineArgumentu(argc, (const char **)argv, "device", &devN ) ) {
		printf("Using device %d\n", devN);
	}
	if( shrCheckCmdLineFlag( argc,  (const char **)argv, "qatest") ) {
		printf("QA test mode.\n");
		capture = NULL;
		state.bqatest = true;
	} else {

		printf("Attempting to initialize camera\n");
		if( argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0])))
			capture = cvCaptureFromCAM( argc == 2 ? argv[1][0] - '0' : 0 );
		else if( argc == 2 )
			capture = cvCaptureFromAVI( argv[1] );
	}

	if( !capture )
	{
		fprintf(stderr,"Could not initialize capturing...\n");
		fprintf(stderr,"Attempting to use PGM files..\n");
	} else { 
		printf("Camera Initialized\n");
		printf("Setting Size\n");
#ifdef _MSC_VER
		Sleep(5000);
#else
		sleep(5); // pause 5 seconds before setting size on Mac , otherwise unstable
#endif
		cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, gw);
		cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, gh);

	}

    initGlut(argc,argv, gw, gh);
	initGLData(gw, gh, NULL);
	// Initialize openCL
	// loads the CL functions from the .cl files
	// also loads reference images../data/minicooper/frame10.pgm
	
    clCtx = initOCLFlow(vbo,devN);
	if( !capture ) {
		if( images[0].w != gw || images[0].h != gh || images[1].w != gw || images[1].h != gh ) {
			fprintf(stderr, "Bad image sizes supplied. Please use %d x %d images\n", gw, gh );
		}

		// load the file into the texture (actually initOCLFLow loaded them into GPU but discarded them
		// so this is justa quick way to load them into the texture as well)
		unsigned int w, h;
		unsigned char *image_ub = NULL;
		shrLoadPGMub( "data/minicooper/frame10.pgm", (unsigned char **)&image_ub, &w, &h );
		glBindTexture(GL_TEXTURE_RECTANGLE_NV, tex);
		glTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, gw, gh, GL_LUMINANCE, GL_UNSIGNED_BYTE, image_ub );
	}
    glutMainLoop();

    return 0;
}
bool GlutApp::init()
{
    initGlut(m_argc, m_argv);
    return true;
}
// initalise display 
void
initDisplay(int argc, char *argv[])
{
    initGlut(argc, argv);
    initGL();
}
예제 #23
0
RTresult sutilInitGlut(int* argc, char** argv)
{
  return initGlut(argc, argv);
}
예제 #24
0
	Segregation(int window_width_,
		int window_height_,
		int width_,
		int height_,
		int num_teams_,
		double rate_population,
		double rate_friend_)
		: window_width(window_width_),
		window_height(window_height_),
		width(width_),
		height(height_),
		num_teams(num_teams_),
		rate_friend(rate_friend_),
		agent_vertex_vbo(0),
		agent_color_vbo(0),
		max_num_teams(5),
		empty(-1),
		mouse_button(0),
		translate_x(0),
		translate_y(0),
		scale_size(1),
		pause(false),
		single(false),
		fpsLimit(1),
		fpsCount(0),
		vsync(1),
		ticks(0)
	{
		if (num_teams > max_num_teams) {
			std::cerr << "Error: Invalid Number of Teams\n";
			std::exit(0);
		}

		if (!initGlut()) {
			std::exit(0);
		}

		patch = (float)window_width / width;
		halfPatch = patch / 2;

		/* Calculating population */
		one_team_population = width * height * rate_population / num_teams;
		population = one_team_population * num_teams;

		/* Initializing Parameters */
		pos = std::vector< Point<int> >(population, Point<int>());
		group = std::vector<int>(population, 0);
		space = std::vector<int>(width * height, -1);// empty: -1

		int agent_id = 0;
		while (agent_id < population) {
			int x = mcl::Random::random(width);
			int y = mcl::Random::random(height);
			if (space[getOneDimIdx(x, y)] == empty) {
				pos[agent_id].x = x, pos[agent_id].y = y;
				space[getOneDimIdx(x, y)] = group[agent_id] = agent_id % num_teams;
				agent_id++;
			}
		}

		/* Setting Positions on Screen */
		fp[0].x = halfPatch;      fp[0].y = -1 * halfPatch;
		fp[1].x = -1 * halfPatch; fp[1].y = -1 * halfPatch;
		fp[2].x = -1 * halfPatch; fp[2].y = halfPatch;
		fp[3].x = halfPatch;      fp[3].y = halfPatch;

		/* Setting Color */
		color_set = std::vector<mcl::Color::ColorElement>(max_num_teams);
		color_set[0].value = mcl::Color::Red;
		color_set[1].value = mcl::Color::Green;
		color_set[2].value = mcl::Color::Yellow;
		color_set[3].value = mcl::Color::Blue;
		color_set[4].value = mcl::Color::Orange;

		createVertexBuffer();
		createColorBuffer();
	}
예제 #25
0
HapticApp::HapticApp(int width, int height) {
	initGlut(width, height);
	initHL();
	_happ = this;
	_running = false;
}
예제 #26
0
///
//	main() for GLinterop example
//
int main(int argc, char** argv)
{
	cl_device_id device = 0;

	imWidth = 256;
	imHeight = 256;
	vbolen = imHeight;

	initGlut(argc, argv, imWidth, imHeight);
	vbo = initVBO(vbolen);
	initTexture(imWidth, imHeight);

	// Create an OpenCL context on first available platform
	context = CreateContext();
	if (context == NULL)
	{
		std::cerr << "Failed to create OpenCL context." << std::endl;
		return 1;
	}

	// Create a command-queue on the first device available
	// on the created context
	commandQueue = CreateCommandQueue(context, &device);
	if (commandQueue == NULL)
	{
		Cleanup();
		return 1;
	}

	// Create OpenCL program from GLinterop.cl kernel source
	program = CreateProgram(context, device, "kernel/GLinterop.cl");
	if (program == NULL)
	{
		Cleanup();
		return 1;
	}

	// Create OpenCL kernel
	kernel = clCreateKernel(program, "init_vbo_kernel", NULL);
	if (kernel == NULL)
	{
		std::cerr << "Failed to create kernel" << std::endl;
		Cleanup();
		return 1;
	}

	tex_kernel = clCreateKernel(program, "init_texture_kernel", NULL);
	if (tex_kernel == NULL)
	{
		std::cerr << "Failed to create kernel" << std::endl;
		Cleanup();
		return 1;
	}

	// Create memory objects that will be used as arguments to
	// kernel
	if (!CreateMemObjects(context, tex, vbo, &cl_vbo_mem, &cl_tex_mem))
	{
		Cleanup();
		return 1;
	}

	// Perform some queries to get information about the OpenGL objects
	performQueries();

	glutMainLoop();

	std::cout << std::endl;
	std::cout << "Executed program succesfully." << std::endl;
	Cleanup();

	return 0;
}