当前位置: 首页>>代码示例>>C++>>正文


C++ MyWindow::run方法代码示例

本文整理汇总了C++中MyWindow::run方法的典型用法代码示例。如果您正苦于以下问题:C++ MyWindow::run方法的具体用法?C++ MyWindow::run怎么用?C++ MyWindow::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MyWindow的用法示例。


在下文中一共展示了MyWindow::run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

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;
}
开发者ID:hariganesan,项目名称:zombie-roll,代码行数:39,代码来源:zombie.cpp

示例2: main

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;
}
开发者ID:andrei-b-git,项目名称:WS-Ubisoft,代码行数:36,代码来源:main.cpp


注:本文中的MyWindow::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。