Exemplo n.º 1
0
Arquivo: main.cpp Projeto: wy32/CS130
int main(int argc, char** argv)
{	
	GLInit(&argc, argv);
	glutMainLoop();
	
	return 0;
}
Exemplo n.º 2
0
//ENTRY POINT FOR APPLICATION
//CALL WINDOW CREATION ROUTINE, DEAL WITH MESSAGES, WATCH FOR INTERACTION
int main(int argc, char **argv) {
	Util::log("%s" , "TEST");
	View * v = new View(&argc, argv);
	// Open a window
	v->createWindow("bumpmapping", 640, 480);

	//init variables etc, then GL
	if(!DemoInit())
	{
		Util::log("Demo Initiation failed");
		return 0;
	}
	else
		Util::log("Demo Initiation Successful");

	if(!GLInit())
	{
		Util::log("OpenGL Initiation failed");
		return 0;
	}
	else
		Util::log("OpenGL Initiation Successful");

	v->onKeyboard(&UpdateFrame);
	v->onDraw(&RenderFrame);
	v->start();
	DemoShutdown();
	
	Util::log("Exiting...");
	return 0;								//Exit The Program
}
Exemplo n.º 3
0
void Viewer::CreateWin(char *Name,int Width,int Height)
{
	m_pWinName   = Name;
	m_iWinWidth  = Width;
	m_iWinHeight = Height;

	GLInit();
}
Exemplo n.º 4
0
//Init the renderer
bool CRenderer::Init(int w, int h)
{
	if(!SetDisplaySize(w, h))
		return false;

	GLInit();

	frameTimer.Start();

	return true;
}
Exemplo n.º 5
0
int main(int argc, char **argv)
{
	int window;		// glut windows

	// Initialize GLUT
	glutInit(&argc, argv);

	/* Select type of Display mode:	 Double buffer	 RGBA color	 Depth buffer	 Alpha blending */
	//glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA);
	//glutInitDisplayMode(GLUT_RGB);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

	// demande une fenetre de 640 x 480 à la position 0,0
	glutInitWindowSize(640, 480);
	glutInitWindowPosition(0, 0);

	// Creer une fenetre
	window = glutCreateWindow("CHARA");

	// La fonction d'affichage est GLDraw
	glutDisplayFunc(&GLUpdate);

	// Plein écran
	//glutFullScreen();

	// Quand il n'y a aucun évenement, on affiche quand même la scène
	glutIdleFunc(&GLUpdate);

	// Quand la fenetre change de taille
	glutReshapeFunc(&GLResize);

	// quand une touche est pressee
	glutKeyboardFunc(&keyPressed);

	// quand une touche speciale est pressee
	glutSpecialFunc(&specialKeyPressed);

	// mouse
	glutMouseFunc(processMouse);
	glutMotionFunc(processMouseActiveMotion);
	glutPassiveMotionFunc(processMousePassiveMotion);
	//    glutEntryFunc(processMouseEntry);


	// Notre init:
	GLInit(640, 480);

	// La boucle principale
	glutMainLoop();

	return 0;
}
void UnsharpMask::runGUI(int argc , char *argv[])
{
    // Run in  graphical window if requested
    glutInit(&argc, argv);
    glutInitWindowPosition(100,10);
    glutInitWindowSize(1024,1024);
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
    glutCreateWindow("Unsharp Mask Filter");
    GLInit();
    glutDisplayFunc(displayFunc);
    ::usage();
    glutKeyboardFunc(keyboardFunc);
    glutMainLoop();
}
Exemplo n.º 7
0
int 
main(int argc, char * argv[])
{
    NBody clNBody("OpenCL NBody");
    me = &clNBody;

    if(clNBody.initialize() != SDK_SUCCESS)
        return SDK_FAILURE;
    if(!clNBody.parseCommandLine(argc, argv))
        return SDK_FAILURE;

    if(clNBody.isDumpBinaryEnabled())
    {
        return clNBody.genBinaryImage();
    }
    else
    {
        cl_int retValue = clNBody.setup();
        if(retValue != SDK_SUCCESS)
            return (retValue == SDK_EXPECTED_FAILURE) ? SDK_SUCCESS : SDK_FAILURE;

        if(clNBody.run() != SDK_SUCCESS)
            return SDK_FAILURE;
        if(clNBody.verifyResults() != SDK_SUCCESS)
            return SDK_FAILURE;

        clNBody.printStats();

        if(display)
        {
            // Run in  graphical window if requested 
            glutInit(&argc, argv);
            glutInitWindowPosition(100,10);
            glutInitWindowSize(600,600); 
            glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
            glutCreateWindow("nbody simulation"); 
            GLInit(); 
            glutDisplayFunc(displayfunc); 
            glutReshapeFunc(reShape);
            glutIdleFunc(idle); 
            glutKeyboardFunc(keyboardFunc);
            glutMainLoop();
        }

        if(clNBody.cleanup()!=SDK_SUCCESS)
            return SDK_FAILURE;
    }

    return SDK_SUCCESS;
}
Exemplo n.º 8
0
int main(int argc, char **argv)
{
	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );

	glutInit(&argc, argv);
	glewInit();

	GLInit();
	WorldInit();

	glutMainLoop();

	return 0;
}
Exemplo n.º 9
0
int main(int args, char **argv)
{
    glutInit(&args,argv);											//glut的初始化函数,负责处理命令行参数,在这里我们只需记住它是用glut搭建Opengl显示环境必须要第一个调用的函数
    glutInitWindowPosition(500,100);								//glut的窗口初始化函数,设定了绘图窗口左上角在整个屏幕上的坐标(以像素为单位,下同)
    glutInitWindowSize(500,500);									//glut的窗口初始化函数,设定了绘图窗口的大小
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH);			//将窗口显示模式设定为双缓冲、RGBA颜色模式并且带深度缓存,在完成本次作业后,可以去掉或者修改这三个参数中的任意一个,看看显示结果会有什么不同,为什么会这样呢?
    glutCreateWindow("何超越——太阳系");							//创建一个名为"GLUT Framework(BNU CG Lab1)"的窗口,如果把这一行放在上面三个函数任意一个之前呢?
    GLInit();														//初始化OpenGL的函数
    glutDisplayFunc(GLRender);										//显示回调函数的设定,在这里我们将回调函数设定为之前已经定义的GLRender函数,注意这里对回调函数本身的参数和返回值的要求
    glutReshapeFunc(GLReshape);										//窗口大小调整回调函数的设定,在这里我们将回调函数设定为之前已经定义的GLReshape函数,注意这里对回调函数本身的参数和返回值的要求
    glutKeyboardFunc(GLKeyDown);
    glutKeyboardUpFunc(GLKeyUp);
    glutIdleFunc(GLPostRedisplay);
    glutMainLoop();													//只有调用了这个函数,才会出现绘图窗口
    return 0;
}
Exemplo n.º 10
0
int main(int argc, char *argv[])
{
    glutInit (&argc,argv);

    glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);
    glutInitWindowSize(400,400);
    glutInitWindowPosition(200,200);
    glutCreateWindow("Controler");

    glutReshapeFunc(handle_reshape);
    glutDisplayFunc(handle_draw);
    glutKeyboardFunc(handle_keyboard);
    glutIdleFunc(handle_draw);
    
    GLInit();
    
    glutMainLoop();

    return 0;
}
Exemplo n.º 11
0
//WinMain
int WINAPI WinMain(	HINSTANCE	hInstance,			//Instance
					HINSTANCE	hPrevInstance,		//Previous Instance
					LPSTR		lpCmdLine,			//Command line params
					int			nShowCmd)			//Window show state
{
	//Save hInstance
	WINDOW::Instance()->hInstance=hInstance;

	//Init GL and variables
	if(!GLInit())
	{
		LOG::Instance()->OutputError("OpenGL Initiation Failed");
		return false;
	}
	else
		LOG::Instance()->OutputSuccess("OpenGL Initiation Successful");

	if(!DemoInit())
	{
		LOG::Instance()->OutputError("Demo Initiation Failed");
		return false;
	}
	else
		LOG::Instance()->OutputSuccess("Demo Initiation Successful");

	//Main Loop
	for(;;)
	{
		if(!(WINDOW::Instance()->HandleMessages()))	//quit if HandleMessages returns false
			break;

		UpdateFrame();
	}

	//Shutdown
	DemoShutdown();

	//Exit program
	LOG::Instance()->OutputSuccess("Exiting...");
	return 0;
}
Exemplo n.º 12
0
//ENTRY POINT FOR APPLICATION
//CALL WINDOW CREATION ROUTINE, DEAL WITH MESSAGES, WATCH FOR INTERACTION
int WINAPI WinMain(	HINSTANCE	hInstance,				//instance
					HINSTANCE	hPrevInstance,			//Previous Instance
					LPSTR		lpCmdLine,				//command line parameters
					int			nCmdShow)				//Window show state
{
	//Initiation
	errorLog.Init("Error Log.txt");

	//init variables etc, then GL
	if(!DemoInit())
	{
		errorLog.OutputError("Demo Initiation failed");
		return 0;
	}
	else
		errorLog.OutputSuccess("Demo Initiation Successful");

	if(!GLInit())
	{
		errorLog.OutputError("OpenGL Initiation failed");
		return 0;
	}
	else
		errorLog.OutputSuccess("OpenGL Initiation Successful");

	//Main Loop
	for(;;)
	{
		if(!(window.HandleMessages())) break;//handle windows messages, quit if returns false
		UpdateFrame();
		RenderFrame();
	}

	DemoShutdown();
	
	errorLog.OutputSuccess("Exiting...");
	return (window.msg.wParam);								//Exit The Program
}
Exemplo n.º 13
0
int main(int argc, char **argv) {
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGBA);
	glutInitWindowPosition(0, 0);
	glutInitWindowSize(512, 512);
	glutCreateWindow("lights");

	GLInit();

	// display callback and idle callback
	glutDisplayFunc(myDisplay);
	glutIdleFunc(myDisplay);

	//reshape callback
	glutReshapeFunc(reshape);

	// keyboard callback
	glutKeyboardFunc(keyboard);

	glutMainLoop();

	return 0;
}
Exemplo n.º 14
0
void MyRenderThread::run()
{
    GLFrame->makeCurrent();
    GLInit();

    while (doRendering)
        {
        if (doResize)
            {
            GLResize(w, h);
            doResize = false;
            }
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glLoadIdentity();

        paintGL(); // render actual frame

        FrameCounter++;
        GLFrame->swapBuffers();

        msleep(16); // wait 16ms => about 60 FPS
        }
}
Exemplo n.º 15
0
int main()
{
	
	// SFML window that will host our OpenGL magic
	
    sf::Window window(sf::VideoMode(1920, 1080), "OpenGL", sf::Style::Default, sf::ContextSettings(32));
    window.setVerticalSyncEnabled(true);
	window.setMouseCursorVisible(false);
	sf::View view;
	
	sf::Mouse::setPosition(sf::Vector2i(window.getSize().x / 2, window.getSize().y / 2),  window);
	
	glewInit();
	
	Player	player;
	programInit(shaderMap, modelMap, textureMap, normalMap);
	initPresetSystem(shaderMap, modelMap, textureMap, normalMap, presetMap);
	Editor editor(modelMap, shaderMap, textureMap, normalMap, presetMap);

	GLInit();
	
	// ---------------------- MODELS -------------------------------
	Model		sphereModel, unitSquareModel;
	generateSphere(&sphereModel, 50);						sphereModel.upload();
	myLoadObj("Models/unitSquare.obj", &unitSquareModel);	unitSquareModel.upload();

	loadNoise();

	// Add terrain information to earth
	cv::Mat earthBumpMap = cv::imread("Textures/earthBumpMap.jpg");
	earthBumpMap.convertTo(earthBumpMap, CV_32F);
	int height = earthBumpMap.rows;
	int width = earthBumpMap.cols;
	std::cout << "Dims: " << height << ", " << width << std::endl;
	std::cout << "Dims: " << *earthBumpMap.row(height-1).col(5).ptr<float>() << std::endl;

	// ---------------------- OBJECTS -------------------------------
	// Initiation of all objects in the program
	// ShaderParameters = (ambientCoeff, diffuseCoeff, specularCoeff, specularExponent)
	cv::Vec4f standardShaderParameters(0.2f, 0.5f, 0.8f, 10);

	Object squareNormalMap, squareSpecularityMap;
	GLuint earthNormalMap, earthSpecularityMap, earthTextureDay, earthTextureNight;
	GLuint normalMapShader, specularityMapShader;

	shaderInit(&phongNoTex, "Shaders/phongNoTex.vert", "Shaders/phongNoTex.frag");
	shaderInit(&normalMapShader, "Shaders/normalMap.vert", "Shaders/normalMap.frag");
	shaderInit(&specularityMapShader, "Shaders/specularityMap.vert", "Shaders/specularityMap.frag");
	
	LoadTGATextureSimple("Textures/earthTextureDay.tga", &earthTextureDay);
	LoadTGATextureSimple("Textures/earthTextureNight.tga", &earthTextureNight);
	LoadTGATextureSimple("Textures/earthNormalMap.tga", &earthNormalMap);
	LoadTGATextureSimple("Textures/earthSpecularityMap.tga", &earthSpecularityMap);

	//squareNormalMap.init(&unitSquareModel, phongNoTex, standardShaderParameters, 0, 0, 0, earthNormalMap);
	squareNormalMap.init(&unitSquareModel, normalMapShader, standardShaderParameters, 0, 0, 0, earthNormalMap);
	squareSpecularityMap.init(&unitSquareModel, specularityMapShader, standardShaderParameters, earthTextureDay, earthTextureNight, earthSpecularityMap, earthNormalMap);
	squareNormalMap.set(cv::Vec3f(100,0,0),  cv::Vec3f(50,50,100), cv::Vec3f(0, pi/2, -pi/2), cv::Vec3f(0,0,0), 1);
	squareSpecularityMap.set(cv::Vec3f(100,0,0),  cv::Vec3f(50,50,100), cv::Vec3f(0, pi/2, -pi/2), cv::Vec3f(0,0,0), 1);
	

	// ---------------------- SKYSPHERE -------------------------------
	Object skysphere;
	GLuint skysphereTexture, skyboxShader;
	LoadTGATextureSimple("Textures/spaceBox6.tga", &skysphereTexture);


	shaderInit(&skyboxShader, "Shaders/skybox.vert", "Shaders/skybox.frag");

	skysphere.init(&sphereModel, skyboxShader, standardShaderParameters, skysphereTexture);
	skysphere.set(player.position,  cv::Vec3f(1,1,1), cv::Vec3f(0,0,0), cv::Vec3f(0,0,0), 1);

	


	int item;

	// SFML built-in clock
	sf::Clock clock;
	states[RUNNING] = true;
    states[EDITOR] = true;
	states[STARTUP] = true;
	/*
	bool running = true;
    bool runningEditor = true;
	bool startup = true;
	bool selectObject = false;
	bool cooldown = false;
	*/
	Object* currentObject = NULL;
	Object* playerObject = NULL;
	

	while (states[RUNNING])
    {
		dt = clock.getElapsedTime().asSeconds();
		if(states[EDITOR])
		{
			window.setVisible(false);
			if(states[SELECTOBJECT])
			{
				solsystem.getObjects(&allObjects);
				currentObject = getSelectedObject(&allObjects, &player);
				allObjects.clear();
			}
			editor.edit(solsystem, states, currentObject);
			states[STARTUP] = false;
			sf::Mouse::setPosition(sf::Vector2i(window.getSize().x / 2, window.getSize().y / 2),  window);
			clock.restart();
			window.setActive();

			states[SELECTOBJECT] = false;
			currentObject = NULL;
			
			states[EDITOR] = false;
			window.setVisible(true);
		}

		else
		{
			clock.restart();
			if (playerObject != NULL)
			{
				std::cout << player.position << std::endl;
			
				player.move(playerObject->position);
				//player.position = playerObject->position;

				std::cout << playerObject->position << std::endl;
			}
			
			handleEvents(&window, states, &item, playerObject, &player, dt);
			player.lookAtUpdate(dt);

			// Plocka ut all planeters positioner
			std::list<Object*> allObjects;
			solsystem.getObjects(&allObjects);
			std::vector<cv::Vec3f> positionVector;
			std::vector<cv::Vec3f> radiusVector;
			

			std::list<Object*>::iterator i = allObjects.begin();

			for (i++ ; i != allObjects.end(); ++i)
			{
				positionVector.push_back((*i)->position);
				radiusVector.push_back((*i)->scale);
				//std::cout << "Scale: " << (*i)->scale << std::endl;
			}

			int numberOfPlanets = positionVector.size();

			GLfloat* positions = makeArray(positionVector);
			GLfloat* radius = makeArray(radiusVector);
			

			/////////////////////////////////   SKYBOX   /////////////////////////////////////////
			window.setActive();
			//drawSkybox(&player, &skyboxModel, skyboxShader, skyboxTexture);

			glDisable(GL_DEPTH_TEST);
			//skybox.set(player.position,  cv::Vec3f(5,5,5), cv::Vec3f(0,0,0), cv::Vec3f(0,0,0), 1);
			//skybox.draw(&player);
			skysphere.set(player.position,  cv::Vec3f(5,5,5), cv::Vec3f(0,0,0), cv::Vec3f(0,0,0), 1);
			skysphere.draw(&player, 0, dt);
			glEnable(GL_DEPTH_TEST);

			/////////////////////////////////   ALX   /////////////////////////////////////////

			if (states[NORMALMAP])
			{
				squareNormalMap.draw(&player, dt, numberOfPlanets, positions, radius);
			}
			if (states[SPECULARITYMAP])
			{
				squareSpecularityMap.draw(&player, dt, numberOfPlanets, positions, radius);
			}

			/////////////////////////////////   ALX   /////////////////////////////////////////




		
			if(!states[COOLDOWN] && item == 1)
			{
				Object* newItem = presetMap["Earth"]->clone();
				newItem->set(player.position,  cv::Vec3f(0.25,0.25,0.25), cv::Vec3f(0,0,0), 10*player.getLookAtDirection(), 1);
				solsystem.addItem(newItem);
				std::cout << 10*normalize(player.position - player.lookAtVector) << std::endl;
				states[COOLDOWN] = true;
			}
			item = 0;
			if(states[ENABLEGRAVITY] && playerObject == NULL)
			{
				playerObject = presetMap["Earth"]->clone();
				playerObject->set(player.position,  cv::Vec3f(1.25,1.25,1.25), cv::Vec3f(0,0,0), cv::Vec3f(0,0,0), 1);
				solsystem.addPlayerItem(playerObject);
				states[ENABLEGRAVITY] = false;
			}
			if(states[DISABLEGRAVITY] && playerObject != NULL)
			{
				solsystem.removePlayerItem();
				playerObject = NULL;
				states[DISABLEGRAVITY] = false;
			}

			solsystem.update(physEngine, dt*0.5);
			solsystem.draw(&player, accTime);
			accTime += dt;

			window.display();
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		}

		cv::waitKey(0);
	}
    // release resources...
	glDeleteVertexArrays(1, &sphereModel.VAO);
	//glDeleteVertexArrays(1, &skyboxModel.VAO);
	//glDeleteVertexArrays(1, &unitSquareModel.VAO);
	//glDeleteVertexArrays(1, &groundModel.VAO);
	
	return 0;
}
Exemplo n.º 16
0
Application::Application(int argc, char** argv) 
{
    GLInit(argc, argv);
}
Exemplo n.º 17
0
int main(int argc, char** argv) {


#ifdef DEBUGCONSOLE
if(AllocConsole())
{
    freopen("CONOUT$", "wt", stdout);

    SetConsoleTitle("The Outcast : Debug Console");

    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);

}
#endif




	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "THE OUTCAST 0.4\n");
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "===============\n");


    DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Reading cmd line arguments\n");

    for (int i=1;i<argc;i++) {
        if (!strcmp(argv[i], "sprplayground")) {
        	sprplayground = true;
        }
        #ifndef WIN32
        // linux only arguments:
        if (!strcmp(argv[i], "softwarerenderer")) {
            setenv("LIBGL_ALWAYS_INDIRECT", "1", 1);
        }
        #endif
    }

	DEBUGPRINT(DEBUGPRINT_LEVEL_USEFUL, DEBUGPRINT_NORMAL, "Setting up net\n");
	NetInit();
	DEBUGPRINT(DEBUGPRINT_LEVEL_USEFUL, DEBUGPRINT_NORMAL, "Setting up database\n");
	DBInit();
	DEBUGPRINT(DEBUGPRINT_LEVEL_USEFUL, DEBUGPRINT_NORMAL, "Setting up sound system\n");
	SoundInit(NULL);

	DEBUGPRINT(DEBUGPRINT_LEVEL_USEFUL, DEBUGPRINT_NORMAL, "Setting up windowing system\n");

    win_Init(&argc, argv);
    options.Load();

    win_CreateDisplay();



	DEBUGPRINT(DEBUGPRINT_LEVEL_USEFUL, DEBUGPRINT_NORMAL, "Setting up GL\n");
	GLInit();

	if (!sprplayground) {
	    DEBUGPRINT(DEBUGPRINT_LEVEL_USEFUL, DEBUGPRINT_NORMAL, "Loading skin\n");
	    skin = new Skin;
        skin->Load(options.skin.c_str());
	}


	DEBUGPRINT(DEBUGPRINT_LEVEL_USEFUL, DEBUGPRINT_NORMAL, "Loading mousepointer\n");
	win_SetMousePointer("DEFAULT");

	// game must be inited LAST.
	DEBUGPRINT(DEBUGPRINT_LEVEL_USEFUL, DEBUGPRINT_NORMAL, "Setting up game\n");
	GameInit();



    win_MainLoop();

	return 0;
}
Exemplo n.º 18
0
   ############################################################################################################################ */

int main (int argc, char **argv)
{

/* **************************************************************************************************************************** */

 	/* Pointeurs vers l'application */
	glutInit(&argc, argv);         

  	/*  Activation des buffers :   
     	Double buffer 
     	RGBA color
     	Depth buffer */               
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); 

  	/* Création de la fenêtre */
	glutInitWindowSize(1024, 768);

	/* Positionnement de la fenêtre */
	glutInitWindowPosition(100, 100);

	/* Ouverture de la fenêtre */  
	glutCreateWindow("TD_Animation_3D");

	/* Spécification de la fontion de dessin */
	glutDisplayFunc(display);

  	/* Spécification de la fontion de redimensionnement */
	glutReshapeFunc(reshape);

  	/* Spécification des fontions de gestion du clavier */
	glutKeyboardFunc(keyboardDown);
	glutKeyboardUpFunc(keyboardUp);
	glutSpecialFunc(keyboardSpecDown);
	glutSpecialUpFunc(keyboardSpecUp);

 	/* Spécification des fontions de gestion de la souris */
	glutMouseFunc(mouse);
	glutMotionFunc(motion);

 	/* Spécification de la fonction de mise-à-jour */
	glutIdleFunc(timeTick);

/* **************************************************************************************************************************** */

	/* Affichage des fonctions clavier */
	HelpMessage();

/* **************************************************************************************************************************** */

	/* Intitialisation des paramètres de l'affichage et de la fenêtre */
	GLInit();

	/* Intitialisation des paramètres du squelette */ 
	SkeletInit();

	/* Intitialisation de la scène cinématique */
	IKInit();

/* **************************************************************************************************************************** */

  	/* Lancement de la boucle OpenGL */  
	glutMainLoop();

/* **************************************************************************************************************************** */

	return 0;
Exemplo n.º 19
0
void *Sys_Video_Open(const char *mode, unsigned int width, unsigned int height, int fullscreen, unsigned char *palette)
{
	struct display *d;
	struct modeinfo modeinfo;
	char monitorname[128];
	char *p;
	int r;
	int i;

	d = AllocVec(sizeof(*d), MEMF_CLEAR);
	if (d)
	{
		if (IntuitionBase->LibNode.lib_Version > 50 || (IntuitionBase->LibNode.lib_Version == 50 && IntuitionBase->LibNode.lib_Revision >= 74))
		{
			d->gammaenabled = 1;
		}

		TinyGLBase = OpenLibrary("tinygl.library", 0);
		if (TinyGLBase)
		{
			if (fullscreen)
			{
				if (*mode && modeline_to_modeinfo(mode, &modeinfo))
				{
					snprintf(monitorname, sizeof(monitorname), "%s.monitor", modeinfo.monitorname);
					d->screen = OpenScreenTags(0,
						SA_Width, modeinfo.width,
						SA_Height, modeinfo.height,
						SA_Depth, modeinfo.depth,
						SA_MonitorName, monitorname,
						SA_Quiet, TRUE,
						SA_GammaControl, TRUE,
						SA_3DSupport, TRUE,
						TAG_DONE);
				}
				else
				{
					d->screen = OpenScreenTags(0,
						SA_Quiet, TRUE,
						SA_GammaControl, TRUE,
						SA_3DSupport, TRUE,
						TAG_DONE);
				}

				if (d->screen)
				{
					width = d->screen->Width;
					height = d->screen->Height;

					strlcpy(monitorname, "Dunno", sizeof(monitorname));

					if (IntuitionBase->LibNode.lib_Version > 50 || (IntuitionBase->LibNode.lib_Version == 50 && IntuitionBase->LibNode.lib_Revision >= 53))
					{
						GetAttr(SA_MonitorName, d->screen, &p);
						if (p)
						{
							strlcpy(monitorname, p, sizeof(monitorname));
							p = strstr(monitorname, ".monitor");
							if (p)
								*p = 0;
						}
					}

					snprintf(d->used_mode, sizeof(d->used_mode), "%s,%d,%d,%d", monitorname, width, height, GetBitMapAttr(d->screen->RastPort.BitMap, BMA_DEPTH));

					if (d->gammaenabled)
					{
						d->gammatable = AllocVec(256*3, MEMF_ANY);
						if (d->gammatable == 0)
						{
							CloseScreen(d->screen);
							d->screen = 0;
						}
					}
				}
				else
					fullscreen = 0;
			}

			if (d->screen || !fullscreen)
			{
				d->window = OpenWindowTags(0,
					WA_InnerWidth, width,
					WA_InnerHeight, height,
					WA_Title, "Fodquake",
					WA_DragBar, d->screen?FALSE:TRUE,
					WA_DepthGadget, d->screen?FALSE:TRUE,
					WA_Borderless, d->screen?TRUE:FALSE,
					WA_RMBTrap, TRUE,
					d->screen?WA_PubScreen:TAG_IGNORE, (ULONG)d->screen,
					WA_Activate, TRUE,
					TAG_DONE);

				if (d->window)
				{
					__tglContext = GLInit();
					if (__tglContext)
					{
						if (d->screen && !(TinyGLBase->lib_Version == 0 && TinyGLBase->lib_Revision < 4))
						{
							r = glAInitializeContextScreen(d->screen);
						}
						else
						{
							r = glAInitializeContextWindowed(d->window);
						}

						if (r)
						{
							d->pointermem = AllocVec(256, MEMF_ANY|MEMF_CLEAR);
							if (d->pointermem)
							{
								SetPointer(d->window, d->pointermem, 16, 16, 0, 0);

								d->width = width;
								d->height = height;
								d->fullscreen = fullscreen;

								d->inputdata = Sys_Input_Init(d->screen, d->window);
								if (d->inputdata)
								{
									return d;
								}

								FreeVec(d->pointermem);
							}

							if (d->screen && !(TinyGLBase->lib_Version == 0 && TinyGLBase->lib_Revision < 4))
								glADestroyContextScreen();
							else
								glADestroyContextWindowed();
						}

						GLClose(__tglContext);
					}

					CloseWindow(d->window);
				}

				if (d->screen)
					CloseScreen(d->screen);
			}

			CloseLibrary(TinyGLBase);
		}

		FreeVec(d);
	}

	return 0;
}
int 
main(int argc, char * argv[])
{
    FluidSimulation2D clFluidSim("OpenCL FluidSimulation2D");
    me = &clFluidSim;

    // create color scale
    bluewhite.AddPoint(0.0, 0, 0, 0);
    bluewhite.AddPoint(0.2, 0, 0, 1);
    bluewhite.AddPoint(0.4, 0, 1, 1);
    bluewhite.AddPoint(0.8, 0, 1, 0);
    bluewhite.AddPoint(1.6, 1, 1, 0);
    bluewhite.AddPoint(3.2, 1, 0, 0);

    // Initialize
    if(clFluidSim.initialize() != SDK_SUCCESS)
        return SDK_FAILURE;

    if(clFluidSim.parseCommandLine(argc, argv) != SDK_SUCCESS)
        return SDK_FAILURE;

    if(clFluidSim.isDumpBinaryEnabled())
    {
        return clFluidSim.genBinaryImage();
    }
    else
    {
        // Setup
        int status = clFluidSim.setup();
        if(status != SDK_SUCCESS)
        {
            if(status == SDK_EXPECTED_FAILURE)
                return SDK_SUCCESS;
            else
                return SDK_FAILURE;
        }

        // Run
        if(clFluidSim.run() != SDK_SUCCESS)
            return SDK_FAILURE;

        // VerifyResults
        if(clFluidSim.verifyResults() != SDK_SUCCESS)
            return SDK_FAILURE;

        clFluidSim.printStats();

        if(display)
        {
            // Run in  graphical window if requested 
            glutInit(&argc, argv);
            glutInitWindowPosition(100,10);
            glutInitWindowSize(400,400); 
            glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
            glutCreateWindow("LBM simulation"); 
            GLInit(); 
            glutDisplayFunc(render);
            glutIdleFunc(update);
            glutMouseFunc(mouse);
            glutMotionFunc(motion);
            glutReshapeFunc(reshape);
            glutKeyboardFunc(keyboard);

            std::cout << "Use Left-Mouse button to move the fluid\n";
            std::cout << "Use Right-Mouse button to draw boundary\n";
            std::cout << "Press r to reset the simulation\n";

            glutMainLoop();
        }

        // Cleanup
        if(clFluidSim.cleanup()!=SDK_SUCCESS)
            return SDK_FAILURE;
    }

    return SDK_SUCCESS;
}