///
///	Create main window and bind to it
///
uint8_t initGUI( void )
{
uint8_t ret=0;
uint32_t w,h;
		// create top window
		guiRootWindow=create_mainWindow();
		
		if(!guiRootWindow) return 0;

#ifdef ENABLE_WINDOW_SIZING_HACK
                do_tmpwin_hack();
#endif

		gtk_register_dialog(guiRootWindow);
					
		// and seek global sub entity
		ret= bindGUI();		
		if(ret) gtk_widget_show(guiRootWindow);
                UI_purge();
		// Set it as always low level
		//gtk_window_set_keep_below(GTK_WINDOW(guiRootWindow), 1);
		renderInit();
		GUI_initCursor(  );
    
                
                UI_getPhysicalScreenSize(guiRootWindow, &w, &h);
                printf("The screen seems to be %u x %u px\n",w,h);
 
                GUI_gtk_grow_off(1);
#ifdef USE_JOG
                physical_jog_shuttle = &(PhysicalJogShuttle::getInstance());
                physical_jog_shuttle->registerCBs (NULL, jogButton, jogDial, jogRing);
#endif 
	return ret;
}
Exemple #2
0
int main() {
	
	if(!glfwInit()) {
		fprintf(stderr, "Failed to initialize GLFWn");
		return -1;
	}

	GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
	glfwMakeContextCurrent(window);

	// glewInit must be called after glfwMakeContextCurrent
	if (glewInit() != GLEW_OK) {
		fprintf(stderr, "Failed to initialize GLEWn");
		return -1;
	}

	glfwSetKeyCallback(window, keyCallback);
	glfwSetWindowSizeCallback(window, sizeChangedCallback);
	glfwSetWindowCloseCallback(window, destoryCallback);
	renderInit(window);

	while (!glfwWindowShouldClose(window))
	{
		render(window);
		glfwSwapBuffers(window);
		glfwPollEvents();
	}
	return 0;
}
Exemple #3
0
int EXPORT_THIS d_init_rest(const char *wtitle, int win_w, int win_h, int fullscreen, const char *icon) {
	int t;

	videoSetIcon(icon);
	renderInit();
	tpw_cursor_show(0);
	d->fps.time_at_last_frame = d->fps.time_at_flip = tpw_ticks();
	d->fps.time = tpw_ticks() / 1000;

	t = videoInit(wtitle, win_w, win_h, fullscreen);
	darnitSetPlatform(0);
//	renderLineTest();

	return t;
}
///
///	Create main window and bind to it
///
uint8_t initGUI( void )
{
uint8_t ret=0;
		// create top window
		guiRootWindow=create_mainWindow();
		
		if(!guiRootWindow) return 0;
		gtk_register_dialog(guiRootWindow);
					
		// and seek global sub entity
		ret= bindGUI();		
		if(ret) gtk_widget_show(guiRootWindow);
		// Set it as always low level
		//gtk_window_set_keep_below(GTK_WINDOW(guiRootWindow), 1);
		renderInit();
		GUI_initCursor(  );
		
	return ret;
}
Exemple #5
0
Fichier : main.c Projet : kpj/mmb
int main(int argc, char *argv[]) {
	printf("MMB version %s, \"%s\"\n\n", VERSION, CODENAME);

	render = renderInit(argc, argv);
	camera = &(render->camera);

	generatorInit();

	world = worldInit(generatorGetBlock);

	worldrenderInit(world, camera);
	ray = worldrenderGetRay(world, camera);
	glutDisplayFunc(&onDisplay);
	glutReshapeFunc(&onReshape);

	renderHookMouse(&onMouse, NULL);
	renderRun();
	return EXIT_SUCCESS;
}
Exemple #6
0
int main() {
	printf ("Initializing SDL 2.0...\n");
	SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
	//initialize defaults, video and audio
	if ((SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)) == -1) {
		printf("ERROR: Could not initialize SDL: %s. \n", SDL_GetError());
		exit(-1);
	}
	printf("SDL successfully initialized.\nCreating window...");
	SDL_Window *window;
	window = SDL_CreateWindow("SDL Window", 50, 50, 1920, 1080, SDL_WINDOW_OPENGL);
	context = SDL_GL_CreateContext(window);
	glewInit();
	printf ("Window created.\nChecking OGL Context:\n");
	printf ("Vendor: %s\nRenderer: %s\nVersion: %s\nShading Language Version: %s\nExtensions: %s\n", glGetString(GL_VENDOR), glGetString(GL_RENDERER), glGetString(GL_SHADING_LANGUAGE_VERSION), glGetString(GL_EXTENSIONS));
	SDL_GL_MakeCurrent(window, context);
	renderInit();
	while (true) {
		SDL_Event ev;
		while (SDL_PollEvent(&ev)) {
			switch (ev.type) {
			case SDL_QUIT:
				return 0;
				break;
			default:
				ProcEvent(ev);
			}
		}
		//GL rendering
		render();
		SDL_GL_SwapWindow(window);
	}
	renderFin();
	printf("Quitting SDL.\n");
	SDL_Quit();
	printf("Quitting....");
	exit(0);
	return 0;
}
Exemple #7
0
int main() {

	if (!glfwInit()) {
		fprintf(stderr, "Failed to initialize GLFWn");
		return -1;
	}

	GLFWwindow* window = glfwCreateWindow(800, 600, "My Title", NULL, NULL);
	glfwMakeContextCurrent(window);

	// glewInit must be called after glfwMakeContextCurrent
	if (glewInit() != GLEW_OK) {
		fprintf(stderr, "Failed to initialize GLEWn");
		return -1;
	}

	glfwSetKeyCallback(window, keyCallback);
	glfwSetWindowSizeCallback(window, sizeChangedCallback);
	glfwSetWindowCloseCallback(window, destoryCallback);
	renderInit(window);

	double lasttime = glfwGetTime();

	while (!glfwWindowShouldClose(window))
	{
		double nowtime = glfwGetTime();
		render(window, (nowtime - lasttime)/100);
		lasttime = nowtime;

		updateFps();

		glfwSwapBuffers(window);
		glfwPollEvents();
	}
	return 0;
}
Exemple #8
0
int main(int argc, char **argv)
{
//	SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
//	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);

	/* initialize OpenGL */
	initGraphics(800,600,0);
	initGL( );
	initInput();
	renderInit();
	imguiRenderGLInit("DroidSans.ttf");
	curl_global_init(CURL_GLOBAL_ALL); 

	FW::FileWatcher* watcher = new FW::FileWatcher();
	/*FW::WatchID watchid = */watcher->addWatch( "./", new RecompileListener() );

	recompile();
	/* resize the initial window */
//	resizeWindow( xres, yres );

	/* These are to calculate our fps */
	static GLint T0     = 0;
	static GLint Frames = 0;



	/* wait for events */
	bool done = false;
	SDL_Event event;
	while ( !done )
	{
		/* handle the events in the queue */

		while ( SDL_PollEvent( &event ) )
		{
			switch( event.type )
			{
			//case SDL_ACTIVEEVENT:
				/* Something's happend with our focus
				* If we lost focus or we are iconified, we
				* shouldn't draw the screen
				*/
				//if ( event.active.gain == 0 )
				//	isActive = FALSE;
				//   else
				//		isActive = TRUE;
			//	break;			    
#if 0
			case SDL_VIDEORESIZE:
				/* handle resize event */
				surface = SDL_SetVideoMode( event.resize.w,
					event.resize.h,
					16, videoFlags );
				if ( !surface )
				{
					fprintf( stderr, "Could not get a surface after resize: %s\n", SDL_GetError( ) );
					Quit( 1 );
				}
				resizeWindow( event.resize.w, event.resize.h );
				break;
#endif
			case SDL_KEYDOWN:
				/* handle key presses */
				handleKeyPress( &event.key.keysym );
				break;
			case SDL_KEYUP:
                    if(event.key.keysym.sym<=255){
                        keystat[event.key.keysym.sym] = 0;
                    }
                    break;
			case SDL_MOUSEMOTION:
				mousexr = event.motion.xrel;
				mouseyr = event.motion.yrel;
				mousex = event.motion.x;
				mousey = event.motion.y;
				break;
			case SDL_MOUSEBUTTONDOWN:
				mousestat[event.button.button] = 1;
				break;
			case SDL_MOUSEBUTTONUP:
				mousestat[event.button.button] = 0;
				break;
			case SDL_QUIT:
				/* handle quit requests */
				done = TRUE;
				break;
			default:
				break;
			}
		}

		/* draw the scene */
		//if ( isActive )
		{
			watcher->update();
            
            //glClearColor(1, 0, 0, 1);
            //glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
            
			if(update)
			{
				update();
			}
            /*
            glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            float projection[16] = { 2.f/800, 0.f, 0.f,  0.f,
                0.f, 2.f/600,  0.f,  0.f,
                0.f,  0.f, -2.f, 0.f,
                -1.f, -1.f,  -1.f,  1.f };
            glLoadMatrixf(projection);
            glMatrixMode(GL_MODELVIEW);
            glLoadIdentity();*/
            glEnable(GL_BLEND);
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
            glDisable(GL_DEPTH_TEST);
			imguiRenderGLDraw(800, 600);
            
/*
            glBegin(GL_TRIANGLES);
            glColor3f(1, 1, 0);
            glVertex2d(1, 1);
            glVertex2d(1, 0);
            glVertex2d(0, 1);
            glEnd();
*/
			/* Draw it to the screen */
			swapBuffers();
			
			/* Gather our frames per second */
			Frames++;
			{
				GLint t = SDL_GetTicks();
				if (t - T0 < 16) {
//					SDL_Delay(16 - (t-T0));

//					GLfloat seconds = (t - T0) / 1000.f;
//					GLfloat fps = Frames / seconds;
//					Frames = 0;
				}

				T0 = t;
			}

		}
	}

	imguiRenderGLDestroy();
	renderFini();

	/* clean ourselves up and exit */
	Quit( 0 );

	/* Should never get here */
	return( 0 );
}