Exemplo n.º 1
0
void * PthreadMain (void * param)
{
	Logger::Info("[Thread::ThreadFunction] param = %p", param);

	Thread * t = (Thread*)param;

    ThreadContext *context = NULL;
    CorePlatformAndroid *core = (CorePlatformAndroid *)Core::Instance();

	if(t->needCopyContext)
    {
        context = core->CreateThreadContext();
        core->BindThreadContext(context);
    }

	t->state = Thread::STATE_RUNNING;
	t->msg(t);

    if(t->needCopyContext)
	{
        core->UnbindThreadContext(context);
        core->ReleaseThreadContext(context);
        context = NULL;
	}

	t->state = Thread::STATE_ENDED;
	t->Release();

	pthread_exit(0);
}
Exemplo n.º 2
0
void * PthreadMain (void * param)
{
	Logger::Info("[PthreadMain] param = %p", param);

	Thread * t = (Thread*)param;

	if(t->needCopyContext)
    {
    	EGLConfig localConfig;
    	bool ret = GetConfig(Thread::currentDisplay, localConfig);
		Logger::Info("[PthreadMain] GetConfig returned = %d", ret);

    	if(ret)
    	{
        	EGLint contextAttrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
        	t->localContext = eglCreateContext(t->currentDisplay, localConfig, t->currentContext, contextAttrs);
//        	t->localContext = eglCreateContext(t->currentDisplay, localConfig, EGL_NO_CONTEXT, contextAttrs);
    	}

    	if(t->localContext == EGL_NO_CONTEXT)
    	{
    		Logger::Error("[PthreadMain] Can't create local context");
    	}

    	GLint surfAttribs[] =
    	{
    			EGL_HEIGHT, 768,
    			EGL_WIDTH, 1024,
    			EGL_NONE
    	};

        
    	EGLSurface readSurface = eglCreatePbufferSurface(t->currentDisplay, localConfig, surfAttribs);
//    	EGLSurface drawSurface = eglCreatePbufferSurface(t->currentDisplay, localConfig, surfAttribs);

        //TODO: set context
//		bool ret2 = eglMakeCurrent(t->currentDisplay, t->currentDrawSurface, t->currentReadSurface, t->localContext);
		bool ret2 = eglMakeCurrent(t->currentDisplay, readSurface, readSurface, t->localContext);
		Logger::Info("[PthreadMain] set eglMakeCurrent returned = %d", ret2);
    }

	t->state = Thread::STATE_RUNNING;
	t->msg(t);

    if(t->needCopyContext)
	{
        //TODO: Restore context
		bool ret = eglMakeCurrent(t->currentDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
		Logger::Info("[PthreadMain] restore eglMakeCurrent returned = %d", ret);
	}

	t->state = Thread::STATE_ENDED;
	t->Release();

	pthread_exit(0);
}
Exemplo n.º 3
0
void * PthreadMain (void * param)
{
	Thread * t = (Thread*)param;
	t->SetThreadId(Thread::GetCurrentThreadId());
	
	t->state = Thread::STATE_RUNNING;
	t->msg(t);

	t->state = Thread::STATE_ENDED;
	t->Release();

	pthread_exit(0);
}
Exemplo n.º 4
0
DWORD WINAPI ThreadFunc(void* param)
{	
	Thread * t = (Thread*)param;
	t->SetThreadId(Thread::GetCurrentThreadId());

	t->state = Thread::STATE_RUNNING;
	t->msg(t);

	t->state = Thread::STATE_ENDED;
	t->Release();
	
	return 0;
}
Exemplo n.º 5
0
DWORD WINAPI ThreadFunc(void* param)
{	
	Thread * t = (Thread*)param;
	if(t->needCopyContext)
	{
#if defined(__DAVAENGINE_OPENGL__)
		int32 res = wglMakeCurrent(Thread::currentDC, Thread::secondaryContext);
		if(!res)
		{
			DWORD error = GetLastError();
			Logger::Error("ThreadFunc::wglMakeCurrent error %d", error);
		}
#elif defined(__DAVAENGINE_DIRECTX9__)

	



#endif // #if defined(__DAVAENGINE_OPENGL__)

	}

	t->state = Thread::STATE_RUNNING;
	t->msg(t);

	if(t->needCopyContext)
	{
#if defined(__DAVAENGINE_OPENGL__)
		int32 res = wglMakeCurrent(Thread::currentDC, NULL);
		if(!res)
		{
			DWORD error = GetLastError();
			Logger::Error("ThreadFunc::wglMakeCurrent NULL, error %d", error);
		}
#elif defined(__DAVAENGINE_DIRECTX9__)





#endif // #if defined(__DAVAENGINE_OPENGL__)
	}

	t->state = Thread::STATE_ENDED;
	t->Release();
	
	return 0;
}
Exemplo n.º 6
0
void FileDownloader::AsynchDownload()
{
    Thread * downloadThread = Thread::Create( Message( this, &FileDownloader::DownloadFile ) );
    downloadThread->Start();
    downloadThread->Release();
}