Пример #1
0
void bbSetFont( gxFont *f ){
	debugFont( f );
	gx_canvas->setFont( curr_font=f );
}
Пример #2
0
void bbFreeFont( gxFont *f ){
	debugFont( f );
	if( f==curr_font ) bbSetFont( gx_graphics->getDefaultFont() );
	gx_graphics->freeFont( f );
}
Пример #3
0
int Saloon::start() {
	if(_window != nullptr) {

		// Create an OpenGL context associated with the window.
		SDL_GLContext glContext = SDL_GL_CreateContext(_window);

		// Init and check for GL Errors.
		glInit(_displayWidth, _displayHeight);

		GLenum error = glGetError();
		if( error != GL_NO_ERROR )
		{
			logSDLError(std::cout, "GL INIT");
			return 1;
		}

		LTimer fpsTimer;
		fpsTimer.start();
		Uint32 frames = 0, FPS = 0;

		//Our event structure
		SDL_Event e;
		bool quit = false;

		int curTime, prevTime = SDL_GetTicks();

		BMFont debugFont("Fonts/system16.fnt");

		onCreate();


		while (!quit){

			while (SDL_PollEvent(&e)){
				if (e.type == SDL_QUIT)
					quit = true;
				//Use number input to select which clip should be drawn
				if (e.type == SDL_KEYDOWN){
					switch (e.key.keysym.sym){
						case SDLK_ESCAPE:
							quit = true;
							break;
						case SDLK_TAB:
							if(_debugEnabled) {
								setVSyncEnabled(false);
							}
							break;
						default:
							break;
					}
				}
				else if(e.type == SDL_KEYUP) {
					switch (e.key.keysym.sym){
						case SDLK_TAB:
							if(_debugEnabled) {
								setVSyncEnabled(true);
							}
							break;
						default:
							break;
					}
				}
			}

			if(_debugEnabled) {
				debugStart();

				curTime = SDL_GetTicks();

				deltaTime = (curTime - prevTime) / 1000.0f;

				prevTime = curTime;

				if(fpsTimer.getTicks() >= 1000) {
					FPS = frames;
					frames = 0;
					fpsTimer.reset();
				}

				frames++;

				debugWatch("FPS", FPS);
			}

			onUpdate();

			glClear(GL_COLOR_BUFFER_BIT);

			//Reset modelview matrix
			glMatrixMode( GL_MODELVIEW );
			glLoadIdentity();

			glPushMatrix();

			glTranslatef(_halfDisplayWidth, _halfDisplayHeight, 0.0f);

			glPushMatrix();
			// Camera transformations
			glScalef(_camZoom, _camZoom, 1.0f);
			glRotatef(_camAng, 0, 0, 1);
			glTranslatef(-_camX, _camY, 0);

			onRender();

			glPopMatrix();

			glPopMatrix();

			glColor4(_debugColor);
			debugDraw(debugFont);

			SDL_GL_SwapWindow(_window);

		}

		onDestroy();

		glDestroy();

		// Once finished with OpenGL functions, the SDL_GLContext can be deleted.
		SDL_GL_DeleteContext(glContext);
		SDL_DestroyWindow(_window);

		TTF_Quit();
		IMG_Quit();
		SDL_Quit();
		return 0;
	}
	else {
		logSDLError(std::cout, "Saloon::start");
		return 1;
	}

}