Beispiel #1
0
	bool LuaEngine::RunScript(const String& filePath)
	{
		/*sol::state_view lua(_L);

		std::string path = filePath.ToStdString();
		sol::protected_function_result lr = lua.script_file(path);
		if (!lr.valid())
		{
			sol::error err = lr;
			std::string what = err.what();
			String error = (String)"************SCRIPT ERROR*************" + "\n" + what.c_str();
			THLog(error);
			ExceptionManager::GetInstance()->PushException(Ptr<Exception>::New(error));
			return false;
		}
		return true;*/

		if (luaL_dofile(_L, filePath.ToStdString().c_str()))
		{
			String error = (String)"************SCRIPT ERROR*************" + "\n" + lua_tostring(_L, -1);
			lua_pop(_L, 1);
			THLog(error);
			ExceptionManager::GetInstance()->PushException(Ptr<Exception>::New(error));
			return false;
		}

		return true;
	}
Beispiel #2
0
bool STGResources::LoadTexTures()
{
	auto manager = AssetManager::GetInstance();

	THLog("加载STG纹理。。。");

	STGRES_LOAD_TEXTURE(texPlayerCenter, "res/player/center.png");
	STGRES_LOAD_TEXTURE(texEnemy01, "res/enemy/enemy01.png");
	STGRES_LOAD_TEXTURE(texBullet01, "res/bullet/bullet1.png");
	STGRES_LOAD_TEXTURE(texBullet02, "res/bullet/bullet2.png");
	STGRES_LOAD_TEXTURE(texBullet03, "res/bullet/bullet3.png");
	STGRES_LOAD_TEXTURE(texBullet04, "res/bullet/bullet4.png");
	STGRES_LOAD_TEXTURE(texReimu, "res/player/reimu.png");
	STGRES_LOAD_TEXTURE(texEffBase, "res/effect/eff_base.png");
	STGRES_LOAD_TEXTURE(texPointLight, "res/effect/point_light.png");
	STGRES_LOAD_TEXTURE(texFourAngleStar, "res/effect/four_angle_star.png");

	THLog("加载STG纹理成功。");

	return true;
}
Beispiel #3
0
void SetOrtho(const THVector2& minp,const THVector2& maxp)
{
	gameMinBound=minp;
	gameMaxBound=maxp;

	gameScale=(maxp-minp) / windowSize;

	THOrthoMatrix33(THProjectMatrix,minp,maxp);
	glUniform3fv(THDefaultProgram.projectMatrixHandler,2,THProjectMatrix);

	const GLfloat fv[]=MAKE_VERTEX(minp.x,minp.y,maxp.x,maxp.y);
	memcpy(THGameFullVertices,fv,sizeof(GLfloat)*8);

	THLog("Set Ortho : %.1f , %.1f / %.1f , %.1f",minp.x,minp.y,maxp.x,maxp.y);
}
Beispiel #4
0
void STGResources::UnloadTextures()
{
	auto manager = AssetManager::GetInstance();

	THLog("释放STG纹理。");

	texPlayerCenter = nullptr;
	texEnemy01 = nullptr;
	texBullet01 = nullptr;
	texBullet02 = nullptr;
	texBullet03 = nullptr;
	texBullet04 = nullptr;
	texReimu = nullptr;
	texEffBase = nullptr;
	texPointLight = nullptr;
	texFourAngleStar = nullptr;
}
Beispiel #5
0
	bool LuaEngine::RunCode(const std::string& code, const std::string& codeName)
	{
		int error;
		if (error = luaL_loadbuffer(_L, code.c_str(), code.size(), codeName.c_str())
			|| lua_pcall(_L, 0, 0, 0))
		{
			// get error file and line number
			lua_Debug ar;
			lua_getstack(_L, 1, &ar);
			lua_getinfo(_L, "nSl", &ar);

			String error = (String)"[SCRIPT ERROR] In file " + ar.source + ":\n" + lua_tostring(_L, -1);
			lua_pop(_L, 1);
			THLog(error);
			ExceptionManager::GetInstance()->PushException(Ptr<Exception>::New(error));
			return false;
		}

		return true;
	}
Beispiel #6
0
void THEGLInit(THApplicaation* state)
{
    eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);

    EGLint eglMajor,eglMinor;
    eglInitialize(eglDisplay, &eglMajor,&eglMinor);
	THLog("EGL Initialization : %d.%d",eglMajor,eglMinor);

	const EGLint attribs[] = {
            EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
			EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
            EGL_BLUE_SIZE, 8,
            EGL_GREEN_SIZE, 8,
            EGL_RED_SIZE, 8,
#if USE_DEPTH_BUFFER==1
			EGL_DEPTH_SIZE,8,
#endif
            EGL_NONE
    };
	EGLint numConfigs;
    EGLConfig config;
    eglChooseConfig(eglDisplay, attribs, &config, 1, &numConfigs);

#if THPLATFORM==THPLATFORM_ANDROID
	EGLint format;
    eglGetConfigAttrib(eglDisplay, config, EGL_NATIVE_VISUAL_ID, &format);
	
    ANativeWindow_setBuffersGeometry(state->window, 0, 0, format);

    eglSurface = eglCreateWindowSurface(eglDisplay, config, (EGLNativeWindowType)(state->window), NULL);
#elif THPLATFORM==THPLATFORM_WINDOWS

	eglSurface = eglCreateWindowSurface(eglDisplay, config, *state, NULL);
	
	if(eglSurface == EGL_NO_SURFACE)
	{
		eglGetError(); // Clear error
		eglSurface = eglCreateWindowSurface(eglDisplay, config, NULL, NULL);
	}
#endif


	const EGLint attrib_list[] = {
		EGL_CONTEXT_CLIENT_VERSION, 2,
        EGL_NONE
    };
    eglContext = eglCreateContext(eglDisplay, config, NULL, attrib_list);
#if THPLATFORM==THPLATFORM_WINDOWS
	eglBindAPI(EGL_OPENGL_ES_API);
#endif

	if (eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) == EGL_FALSE) {
		THError("Unable to eglMakeCurrent");
		assert(0);
		return;
    }

	EGLint sw,sh;
    eglQuerySurface(eglDisplay, eglSurface, EGL_WIDTH, &sw);
    eglQuerySurface(eglDisplay, eglSurface, EGL_HEIGHT, &sh);
	windowWidthi=sw;
	windowHeighti=sh;
	windowSize.Set((float)sw,(float)sh);
	gameScale.Set(0.0f,0.0f);
}