コード例 #1
0
ファイル: gl_font.cpp プロジェクト: RkShaRkz/Quake2
CFont* FindFont(const char* name)
{
	// check for loaded font
	for (int i = 0; i < fontCount; i++)
		if (!stricmp(fontArray[i].Name, name))
			return &fontArray[i];
	// load a new font
	assert(fontCount < MAX_FONTS);
	CFont *font = &fontArray[fontCount];
	if (font->Load(name))
	{
		fontCount++;
		return font;
	}

	return gl_consoleFont;		// fallback
}
コード例 #2
0
ファイル: main.cpp プロジェクト: dankar/zombies
int main(int argc, char* argv[])
{
	bool show_console = 0;
	bool done = 0;
	int tickCounter = 0;
	int gServer = 0;
	CSocketServer server;
	CSocketClient client;
	CFont font;

	if(argc != 2)
	{
		printf("usage: mecha server|hostname\n");
		return 1;
	}

	gameInit();

	CLog::Get().Init();

	initEngine();

	font.Load("font_big.png");

	if(strcmp(argv[1], "server") == 0)
	{
		gServer = 1;
	}

	clientInit();

	if(gServer)
	{
		if(!server.Listen(4444))
		{
			CLog::Get().Write(APP_LOG, LOG_ERROR, "Listen failed");
			done = 1;
		}
		if(!client.Connect("localhost", 4444))
		{
			CLog::Get().Write(APP_LOG, LOG_ERROR, "Connection failed");
			done = 1;
		}
	}
	else
	{
		if(!client.Connect(argv[1], 4444))
		{
			CLog::Get().Write(APP_LOG, LOG_ERROR, "Connection failed");
			done = 1;
		}
	}

	while(!done)
	{
		timerUpdate();

		tickCounter += timerGetDiff();

		if(show_console)
		{
			if(inpKeyPressed(GLFW_KEY_PAGEUP)) CConsole::ScrollUp();
			if(inpKeyPressed(GLFW_KEY_PAGEDOWN)) CConsole::ScrollDown();
		}
		if(inpKeyPressed(GLFW_KEY_F1))	show_console = !show_console;
		if(inpKeyPressed(GLFW_KEY_ESC)) break;

		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT| GL_STENCIL_BUFFER_BIT);
		glLoadIdentity();

		videoSetPerspective();


		glColor3f(1.0f, 1.0f, 1.0f);

		if(gServer)
			server.Tick();

		client.Tick();

//		if(client.IsConnected())
//			clientTick();

		gfxBlendNormal();

		if(client.IsConnected())
			clientRender(client.GetPreviousSnap(), client.GetCurrentSnap(), client.GetInterpolation());

		gfxSetColor(0.5f, 0.5f, 0.5f, 1.0f);
		videoSetOrtho(800, 600);
		font.Draw(10, 10, "FPS: %f", timerGetFPS());
		font.Draw(10, 25, "Ping: %d", client.m_Ping);
		font.Draw(10, 40, "Snapshot size: %d b", client.GetSnapSize());
		font.Draw(10, 55, "Num objects: %d", client.GetSnapNumObjects());
		videoSetPerspective();

		CConsole::Draw(show_console || !client.IsConnected());

		inpUpdate();

		glfwSwapBuffers();
#ifdef WIN32
		Sleep(1);
#else
		sched_yield();
#endif
	}

	client.Disconnect();
	server.Disconnect();

	closeEngine();

	return true;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: fincs/b0rkshell
int hwMainFunc(void* userData)
{
	CGrf* bootSplash = new CGrf();
	if (!bootSplash)
		return ERR_NOMEM;

	if (!bootSplash->Load(GUI_ASSET_DIR "/bootsplash.grf"))
	{
		delete bootSplash;
		return ERR_NOLOAD;
	}

	setBrightness(3, -16);

	videoSetMode(MODE_3_2D);
	int bg = bgInit(2, BgType_Text8bpp, BgSize_T_256x256, 0, 1);

	dmaCopy(bootSplash->gfxData, bgGetGfxPtr(bg), MemChunk_GetSize(bootSplash->gfxData));
	dmaCopy(bootSplash->mapData, bgGetMapPtr(bg), MemChunk_GetSize(bootSplash->mapData));
	dmaCopy(bootSplash->palData, BG_PALETTE,      MemChunk_GetSize(bootSplash->palData));
	delete bootSplash;

	LoadApps();
	if (!g_appCount) return ERR_NOAPPS;
	LoadFileTypes();

	if (!(background.Load(GUI_ASSET_DIR "/background.grf") &&
		dummy.Load(GUI_ASSET_DIR "/dummy.grf") &&
		selection.Load(GUI_ASSET_DIR "/selection.grf") &&
		topscr.Load(GUI_ASSET_DIR "/topscr.grf") &&
		defappicon.Load(GUI_ASSET_DIR "/dummyapp.grf") &&
		fiGenericFile.Load(GUI_ASSET_DIR "/genericfile.grf") &&
		fiConflictFile.Load(GUI_ASSET_DIR "/conflictfile.grf") &&
		font.Load("tahoma", 10)))
		return ERR_NOLOAD;

	for (int q = 0; q < 92; q ++)
	{
		if (q < 16)
			setBrightness(3, q-16);
		if (q >= (92-16-1))
			setBrightness(3, q-(92-16-1));
		if (keysDown()) break;
		swiWaitForVBlank();
		scanKeys();
	}

	setBrightness(3, 0);
	swiWaitForVBlank();
	DSVideoReset();
	videoInit();
	EnableGuiMon();

	for (;;)
	{
		swiWaitForVBlank();
		scanKeys();
		oamUpdate(&oamMain);
		oamUpdate(&oamSub);
		bgUpdate();

		if (g_curApp)
			RunAppVBlank();
		else if (!MainVBlank())
			break;
		RunBgProcess();
	}

	DisableGuiMon();
	return 0;
}