예제 #1
0
int main(int argc, char **argv) {
	// initialize sdl and ttf
	if (SDL_Init(SDL_INIT_EVERYTHING) == -1)
		return EXIT_FAILURE;

	if (TTF_Init() == -1)
		return EXIT_FAILURE;

	if (Mix_OpenAudio(AUDIO_RATE, AUDIO_S16, 
										AUDIO_CHANNELS, AUDIO_BUFFERS) == -1) {
		return EXIT_FAILURE;
	}

	// deprecated openGL fns
	//SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	//SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	//SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	//SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
	//SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
	//SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
	//SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	//glClearColor(0, 0, FIELD_COLOR, 1); // RGBA
	//glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);// viewable part of the window
	//glShadeModel(GL_SMOOTH); // add a gradient
	//glMatrixMode(GL_PROJECTION); // 2D drawing
	//glLoadIdentity(); // save state
	//glDisable(GL_DEPTH_TEST); // disable 3D drawing

	// open and close window
	MyWindow *w = new MyWindow();
	w->run();
	delete w;

	Mix_CloseAudio();
	TTF_Quit();
	SDL_Quit();

	return EXIT_SUCCESS;
}
예제 #2
0
int main() {

	printf("-------------------------------------\n");
	printf("\tLEFT: TASTA A\n");
	printf("\tRIGHT: TASTA D\n");
	printf("\tUP: TASTA W\n");
	printf("\tDOWN: TASTA S\n");
	printf("\tSHOOT: TASTA SPACE\n");
	printf("\tSHOOT ROCKET: TASTA ENTER\n");
	printf("-------------------------------------\n");

	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

	srand((unsigned int)time(NULL));

	if (!glfwInit ()) {
		fprintf (stderr, "ERROR: could not start GLFW3\n");
		return 1;
	}
	glfwSetErrorCallback(glfw_error_callback);

	MyWindow *win = new MyWindow("Space Invaders", WWIDTH, WHEIGHT);
	assert(win);
	/*
	glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
	glDebugMessageCallback(openglDebugCallback, NULL);
	glEnable(GL_DEBUG_OUTPUT);
	*/
	win->run();

	delete win;

	glfwTerminate();

	return 0;
}