void InitFonts()
{
	ftex = loadTGA(arialtga, false);

	f16 = new Font(ftex, 256, 256, 16, arialinfo);
	f24 = new Font(ftex, 256, 256, 24, arialinfo);
	f32 = new Font(ftex, 256, 256, 32, arialinfo);

	morpheus.InitMPQ(morpheusttf, 40);
	arialn13.InitMPQ(arialnttf, 13);
	
	arial12.Init(arialttf, 12);
	arial14.Init(arialttf, 14);
	arial16.Init(arialttf, 16);
}
Beispiel #2
0
/* general OpenGL initialization function */
int initGL( )
{

    /* Enable smooth shading */
    glShadeModel( GL_SMOOTH );

    /* Set the background black */
    glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );

    /* Depth buffer setup */
    glClearDepth( 1.0f );

    /* Enables Depth Testing */
    glEnable( GL_DEPTH_TEST );

    /* The Type Of Depth Test To Do */
    glDepthFunc( GL_LEQUAL );

    /* Really Nice Perspective Calculations */
    glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );

    our_font.init("simfang.ttf", 16);

    return( TRUE );
}
Beispiel #3
0
//=================================================================
//	int InitGL(GLvoid)	
//	setup for OpenGL 
//==================================================================
int InitGL(GLvoid)										
{
	float df = 100.0f;
	

	glClearDepth(1.0f);									// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);								// The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations

	glClearColor(0,0,0,0);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glShadeModel(GL_SMOOTH);
	glEnable(GL_CULL_FACE);
	glEnable(GL_DEPTH_TEST);

	glMaterialfv(GL_FRONT,GL_SPECULAR,spec);
	glMaterialfv(GL_FRONT,GL_SHININESS,&df);

	glEnable(GL_LIGHTING);
	glLightfv(GL_LIGHT0,GL_POSITION,posl);
	glLightfv(GL_LIGHT0,GL_AMBIENT,amb2);
	glEnable(GL_LIGHT0);

	glLightModelfv(GL_LIGHT_MODEL_AMBIENT,amb);
	glEnable(GL_COLOR_MATERIAL);
	glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);

	glEnable(GL_TEXTURE_2D);
	LoadGLTextures();
	
	//Construct billboarded explosion primitive as display list
	//4 quads at right angles to each other
	glNewList(dlist=glGenLists(1), GL_COMPILE);
	glBegin(GL_QUADS);
	glRotatef(-45,0,1,0);
	glNormal3f(0,0,1);
	glTexCoord2f(0.0f, 0.0f); glVertex3f(-50,-40,0);
	glTexCoord2f(0.0f, 1.0f); glVertex3f(50,-40,0);
	glTexCoord2f(1.0f, 1.0f); glVertex3f(50,40,0);
	glTexCoord2f(1.0f, 0.0f); glVertex3f(-50,40,0);
	glNormal3f(0,0,-1);
	glTexCoord2f(0.0f, 0.0f); glVertex3f(-50,40,0);
	glTexCoord2f(0.0f, 1.0f); glVertex3f(50,40,0);
	glTexCoord2f(1.0f, 1.0f); glVertex3f(50,-40,0);
	glTexCoord2f(1.0f, 0.0f); glVertex3f(-50,-40,0);

	glNormal3f(1,0,0);
	glTexCoord2f(0.0f, 0.0f); glVertex3f(0,-40,50);
	glTexCoord2f(0.0f, 1.0f); glVertex3f(0,-40,-50);
	glTexCoord2f(1.0f, 1.0f); glVertex3f(0,40,-50);
	glTexCoord2f(1.0f, 0.0f); glVertex3f(0,40,50);
	glNormal3f(-1,0,0);
	glTexCoord2f(0.0f, 0.0f); glVertex3f(0,40,50);
	glTexCoord2f(0.0f, 1.0f); glVertex3f(0,40,-50);
	glTexCoord2f(1.0f, 1.0f); glVertex3f(0,-40,-50);
	glTexCoord2f(1.0f, 0.0f); glVertex3f(0,-40,50);
	
	glEnd();
	glEndList();
    
	font.init("knight.TTF", 20);
	font1.init("test.TTF", 13);
	
	return TRUE;										
}
Beispiel #4
0
//note to self- C++ argv[] starts with the name of the file (moshball.exe 10 is 2 arguments)
int main(int argc, char* argv[]){

	//Starting up DevIL
	ilInit();
	iluInit();
	ilutInit();
	ilutRenderer(ILUT_OPENGL); 

	int seed = 0;
	//Dealing with command line arguments

	//2 actual arguments- number of balls , random number seed
	//more than 2 arguments is treated the same as 2 arguments
	if(argc >= 3){
		seed = atoi(argv[2]);
		numTargets = atoi(argv[1]);
	}

	//1 actual argument- number of balls
	else if(argc == 2){
		numTargets = atoi(argv[1]);
		seed = 0;
	}

	//nothing provided- default seed of 0, 10 balls(set in global)
	else{
		seed = 0;
	}

	//TODO- check input for doubles, other strange errors (if I have time)


	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
	//TODO- any other display modes?? Probably.

	glutInitWindowPosition(0, 0);
	glutInitWindowSize(320, 200);
	glutCreateWindow("Moshball");

	glutDisplayFunc(DisplayFunc);
	glutReshapeFunc(ReshapeFunc);
	glutKeyboardFunc(KeyboardFunc);
	glutPassiveMotionFunc(mouseMotion);
	glutCloseFunc(CloseFunc);

	InitShaders();

	if (glewInit() != GLEW_OK)
			throw std::string("GLEW failed to initialize.");

	//Should allow closeFunc to run after exit, cleaning memory
	glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);

	glutTimerFunc(period, TimerFunc, 0);

	glutFullScreen();

	//TODO- can we even use multisampling without glext.h included??
	glEnable(GL_MULTISAMPLE);
	glEnable(GL_NORMALIZE);


	our_font.init("C:\\windows\\fonts\\micross.ttf", 72);

	skybox_id[0] = ilutGLLoadImage("interstellar_large.jpg");
	if(skybox_id[0] == 0)
		throw std::string("Skybox1 texture not found.");

	skybox_id[1] = ilutGLLoadImage("skybox_texture.jpg");

	if(skybox_id[1] == 0)
		throw std::string("Skybox2 texture not found.");

	skybox_id[2] = ilutGLLoadImage("skybox3.png");

	if(skybox_id[1] == 0)
		throw std::string("Skybox3 texture not found.");

	assert(skybox_id != 0);
	//TODO- implement error checking for loading the texture
	//(the above throw statement doesn't work yet, and the assert won't work outside debug mode)

	//Set up the targets and arena (****after GL is initialized****)
	createTargets(seed);
	ourArena = new Arena();
	ourArena->setUpScreens();


	glutMainLoop();

	//TODO
	//After main loop: Clean memory
	//any display lists (not after GLUT is done, it won't understand)
	//all heap allocated things
	//all of the shader stuff in video memory **IMPORTANT**
	string user;

	cout << "Game has ended at time " << localTime << endl;
	if(targetsHit == numTargets){
		cout << "You've Won!" << endl;
	}
	else cout << "Game terminated early" << endl;
	cout << "Hit enter to exit:" << endl;
	//doesn't really care if you've also typed something, just consumes the line.
	getline(cin, user);


	return 0;
}
Beispiel #5
0
int main(int argc, char * argv[])
{
	srand(unsigned int(time(NULL)));

	// glutInit must be the first thing to use OpenGL
	glutInit(&argc, argv);

	// Initializes the Develeoper's Imaging Library. This is the library that will be used to load images in different formats
	// for use as textures. This library is old - others are better in some ways but unusable in others.
	ilInit();

	// Add a line here for every shader defined. This will take care of loading and unloading.
	shaders.push_back(ShaderInitializer(&phong_shader, "per-fragment-phong.vs.glsl", "per-fragment-phong.fs.glsl", "phong shader failed to initialize"));
	shaders.push_back(ShaderInitializer(&constant_shader, "constant.vs.glsl", "constant.fs.glsl", "phong shader failed to initialize"));

	// Adds objects to the world. These instances are for the massive mashup of shapes.
	Instance::DefineInstances(instances, NUMBER_OF_OBJECTS);

	glutInitWindowSize(512, 512);
	glutInitWindowPosition(-1, -1);
	glutInitDisplayMode(DISPLAY_MODE);

	// By setting this action, control is returned to our program when glutLeaveMainLoop is called. Without this, the program exits.
	glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE , GLUT_ACTION_CONTINUE_EXECUTION);

	// By setting this option, all windows created in the program share the same OpenGL context. This means all buffers and shaders and such need be instantiated only once.
	glutSetOption(GLUT_RENDERING_CONTEXT , GLUT_USE_CURRENT_CONTEXT);

	// This is the grid constellation initialization. The preferred argument is n^2.
	gc.Initialize(525);

	// This vector is used to initialize all the window objects. 
	//windows.push_back(Window("Basic Shape Viewer" , nullptr , nullptr , nullptr , nullptr , ivec2(512 , 512) , 50.0f , 1.0f , 100.0f));
	windows.push_back(Window("Cylinder" , DisplayCylinder , nullptr , nullptr , nullptr , ivec2(512 , 512) , 50.0f , 1.0f , 100.0f));
	windows.push_back(Window("Plane" , DisplayPlane , nullptr , nullptr , nullptr , ivec2(512 , 512) , 50.0f , 1.0f , 100.0f));
	windows.push_back(Window("Disc" , DisplayDisc , nullptr , nullptr , nullptr , ivec2(512 , 512) , 50.0f , 1.0f , 100.0f));
	windows.push_back(Window("Cube", DisplayCube, nullptr, nullptr, nullptr, ivec2(512, 512), 50.0f, 1.0f, 100.0f));
	windows.push_back(Window("Grid" , DisplayGrid , nullptr , nullptr , nullptr , ivec2(512 , 512) , 50.0f , 1.0f , 400.0f));
	Window::InitializeWindows(windows , DisplayFunc , KeyboardFunc , CloseFunc, ReshapeFunc , IdleFunc);

	// This must be called AFTER an OpenGL context has been built.
	if (glewInit() != GLEW_OK)
	{
		cerr << "GLEW failed to initialize." << endl;
		cerr << "Hit enter to exit:";
		cin.get();
		return 0;
	}

	// This must be called AFTER initializing GLEW - else non of the 
	// new GL features will be found.
	if (!ShaderInitializer::Initialize(&shaders))
	{
		cerr << "Hit enter to exit:";
		cin.get();
		return 0;
	}

	our_font.init("c:\\windows\\fonts\\Candarai.ttf" , 128);
	
	// Add any textures needed here. This will someday be replaced with a function
	// doing the same thing but taking its list of textures from a URI.
	if (!InitializeTextures())
	{
		cerr << "Hit enter to exit:";
		cin.get();
		return 0;
	}

#ifdef FULL_SCREEN
	glutFullScreen();
#endif
	
	glutMainLoop();

	ShaderInitializer::TakeDown(&shaders);
	ILContainer::TakeDown(textures);
	return 0;
}