Пример #1
0
	void SquareLogicGame::InitGame(void)
	{
		InitClasses();
		m_sqLogic = new SquareLogic();
		m_sqLogic->LoadAnswerSquare();
/*		m_sqLogic->InitSquareCounter();

		m_sqLogicView = new SquareLogicView();
		m_sqLogicView->Refresh();*/

		StartGame();
	}
Пример #2
0
void CLuaMain::InitVM()
{
    assert(!m_luaVM);

    // Create a new VM
    m_luaVM = lua_open();
    lua_pushlightuserdata(m_luaVM, m_luaVM);
    lua_setfield(m_luaVM, LUA_REGISTRYINDEX, "lua.mainstate");
    m_pLuaManager->OnLuaMainOpenVM(this, m_luaVM);

    // Set the instruction count hook
    lua_sethook(m_luaVM, InstructionCountHook, LUA_MASKCOUNT, HOOK_INSTRUCTION_COUNT);

    // Load LUA libraries
    luaL_openlibs(m_luaVM);
    /*
    luaopen_base(m_luaVM);
    luaopen_math(m_luaVM);
    luaopen_string(m_luaVM);
    luaopen_table(m_luaVM);
    luaopen_debug(m_luaVM);
    luaopen_utf8(m_luaVM);
    luaopen_os(m_luaVM);
    */

    // Initialize security restrictions. Very important to prevent lua trojans and viruses!
    //InitSecurity();

    // Registering C functions
    CLuaCFunctions::RegisterFunctionsWithVM(m_luaVM);

    // Create class metatables
    InitClasses(m_luaVM);

    // Oli: Don't forget to add new ones to CLuaManager::LoadCFunctions. Thanks!

    // create global vars
    lua_pushelement(m_luaVM, g_pGame->GetMapManager()->GetRootElement());
    lua_setglobal(m_luaVM, "root");

    lua_pushresource(m_luaVM, m_pResource);
    lua_setglobal(m_luaVM, "resource");

    lua_pushelement(m_luaVM, m_pResource->GetResourceRootElement());
    lua_setglobal(m_luaVM, "resourceRoot");

    // Load pre-loaded lua scripts
    LoadScript(EmbeddedLuaCode::exports);
    LoadScript(EmbeddedLuaCode::coroutine_debug);
    LoadScript(EmbeddedLuaCode::inspect);
}
Пример #3
0
int main(int argc, char** argv)
{
	GLenum type;

	glutInit(&argc, argv);

	type = GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH;
	glutInitDisplayMode(type); 

	glutInitWindowSize(800 ,600);
	glutCreateWindow("ABGR extension");

	supportVBO = false;
	
	/************* Game things ***************/
	ReSizeGLScene(WIDTH, HEIGHT);
	glewInit();
	
	/************* GL things ***************/
	if (!InitGL()) {
		fprintf( stderr, "Init GL failed. End.\n");
		exit(0);
	}
	InitClasses();
	// load textures
	s_Texture->LoadAllTextures();

	//************* Game preinit ***************/

	s_World->LoadWorld();

	m_Player->eyepos = float3(20, 20, 20);
	m_Player->theta = PI/2;
	m_Player->phi = PI/4;

	glutKeyboardFunc(Key);
	glutDisplayFunc(DrawGLScene);
	glutIdleFunc(glutPostRedisplay);
	glutPassiveMotionFunc(Motion);
	glutMainLoop();


	DeInitClasses();
	return 0;
}
Пример #4
0
void CLuaMain::InitVM ( void )
{
    assert( !m_luaVM );

    // Create a new VM
    m_luaVM = lua_open ();
    m_pLuaManager->OnLuaMainOpenVM( this, m_luaVM );

    // Set the instruction count hook
    lua_sethook ( m_luaVM, InstructionCountHook, LUA_MASKCOUNT, HOOK_INSTRUCTION_COUNT );

    // Load LUA libraries
    luaopen_base ( m_luaVM );
    luaopen_math ( m_luaVM );
    luaopen_string ( m_luaVM );
    luaopen_table ( m_luaVM );
    luaopen_debug ( m_luaVM );
    luaopen_utf8 ( m_luaVM );

    // Initialize security restrictions. Very important to prevent lua trojans and viruses!
    InitSecurity ();

    // Registering C functions
    CLuaCFunctions::RegisterFunctionsWithVM ( m_luaVM );

    // Create class metatables
    InitClasses ( m_luaVM );

    // Oli: Don't forget to add new ones to CLuaManager::LoadCFunctions. Thanks!

    // create global vars
    lua_pushelement ( m_luaVM, g_pGame->GetMapManager()->GetRootElement() );
    lua_setglobal ( m_luaVM, "root" );

    lua_pushresource ( m_luaVM, m_pResource );
    lua_setglobal ( m_luaVM, "resource" );

    lua_pushelement ( m_luaVM, m_pResource->GetResourceRootElement () );
    lua_setglobal ( m_luaVM, "resourceRoot" );

    // Load pre-loaded lua code
    LoadScript ( szPreloadedScript );
}
Пример #5
0
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
{
	MSG		msg;
	BOOL	done = FALSE;

	::hInst = hInst;

	if (!CreateGLWindow())
		return 0;

	ShowWindow(hWnd, SW_SHOW);
	ReSizeGLScene(WIDTH, HEIGHT);

	glewInit();
	
	/************* GL things ***************/
	if (!InitGL()) {
		MessageBox(0, "Fail to init GL", "ERROR", MB_OK);
		return FALSE;
	}
	
	/************* Game things ***************/
	InitClasses();

	LARGE_INTEGER _FREQ;
	QueryPerformanceFrequency(&_FREQ);
	tickFreq = (double)_FREQ.QuadPart;
	
	MersenneRandomInit((int)ReadTSC());

	// load textures
	s_Texture->LoadAllTextures();

	//************* Game preinit ***************/

	s_World->LoadWorld();

	m_Player->eyepos = float3(20, 20, 80);
	m_Player->theta = PI/2;
	m_Player->phi = PI/4;
	
	//************* Event loop ***************/

	ShowCursor(false);

	while (!done) {
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
			if (msg.message == WM_QUIT)
				done = TRUE;
			else {
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		else {
			if (active && !DrawGLScene()) {
				done = TRUE;
			}
			else {
				SwapBuffers(hDC);
			}
		}
	}
	
	ShowCursor(true);

	DeInitClasses();

	wglMakeCurrent(0, 0);
	wglDeleteContext(hRC);
	ReleaseDC(hWnd, hDC);
	DestroyWindow(hWnd);
	UnregisterClass("OpenGL", hInst);

	KillFont();

	return 0;
}