Пример #1
0
void LaunchMarket(const char *url) {
#ifdef _WIN32
	ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
#elif __linux__
	std::string command = std::string("xdg-open ") + url;
	int err = system(command.c_str());
	if (err) {
		ILOG("Would have gone to %s but xdg-utils seems not to be installed", url)
	}
#elif __APPLE__
	std::string command = std::string("open ") + url;
	system(command.c_str());
#else
	ILOG("Would have gone to %s but LaunchMarket is not implemented on this platform", url);
#endif
}
Пример #2
0
extern "C" void Java_com_henrikrydgard_libnative_NativeRenderer_displayRender(JNIEnv *env, jobject obj) {
	// Too spammy
	// ILOG("NativeApp.displayRender()");
	if (renderer_inited) {
		// TODO: Look into if these locks are a perf loss
		{
			lock_guard guard(input_state.lock);
			pad_buttons_down |= pad_buttons_async_set;
			pad_buttons_down &= ~pad_buttons_async_clear;
			input_state.pad_buttons = pad_buttons_down;
			UpdateInputState(&input_state);
		}

		{
			lock_guard guard(input_state.lock);
			input_state.pad_lstick_x = left_joystick_x_async;
			input_state.pad_lstick_y = left_joystick_y_async;
			NativeUpdate(input_state);
		}

		{
			lock_guard guard(input_state.lock);
			EndInputState(&input_state);
		}

		NativeRender();
		time_update();
	} else {
		ELOG("BAD: Ended up in nativeRender even though app has quit.%s", "");
		// Shouldn't really get here. Let's draw magenta.
		glstate.depthWrite.set(GL_TRUE);
		glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
		glClearColor(1.0, 0.0, 1.0f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
	}
	
	if (!frameCommand.empty()) {
		ILOG("frameCommand %s %s", frameCommand.c_str(), frameCommandParam.c_str());

		jstring cmd = env->NewStringUTF(frameCommand.c_str());
		jstring param = env->NewStringUTF(frameCommandParam.c_str());
		env->CallVoidMethod(obj, postCommand, cmd, param);
		
		frameCommand = "";
		frameCommandParam = "";
	}
}
Пример #3
0
void TestGetMatrix(int matrix, MatrixSize sz) {
	ILOG("Testing matrix %s", GetMatrixNotation(matrix, sz));
	u8 fullMatrix[16];

	u8 cols[4];
	u8 rows[4];

	GetMatrixColumns(matrix, sz, cols);
	GetMatrixRows(matrix, sz, rows);

	GetMatrixRegs(fullMatrix, sz, matrix);

	int n = GetMatrixSide(sz);
	VectorSize vsz = GetVectorSize(sz);
	for (int i = 0; i < n; i++) {
		// int colName = GetColumnName(matrix, sz, i, 0);
		// int rowName = GetRowName(matrix, sz, i, 0);
		int colName = cols[i];
		int rowName = rows[i];
		ILOG("Column %i: %s", i, GetVectorNotation(colName, vsz));
		ILOG("Row %i: %s", i, GetVectorNotation(rowName, vsz));

		u8 colRegs[4];
		u8 rowRegs[4];
		GetVectorRegs(colRegs, vsz, colName);
		GetVectorRegs(rowRegs, vsz, rowName);

		// Check that the individual regs are the expected ones.
		std::stringstream a, b, c, d;
		for (int j = 0; j < n; j++) {
			a.clear();
			b.clear();
			a << (int)fullMatrix[i * 4 + j] << " ";
			b << (int)colRegs[j] << " ";

			c.clear();
			d.clear();

			c << (int)fullMatrix[j * 4 + i] << " ";
			d << (int)rowRegs[j] << " ";
		}
		ILOG("Col: %s vs %s", a.str().c_str(), b.str().c_str());
		if (a.str() != b.str())
			ILOG("WRONG!");
		ILOG("Row: %s vs %s", c.str().c_str(), d.str().c_str());
		if (c.str() != d.str())
			ILOG("WRONG!");
	}
}
Пример #4
0
bool RequestHeader::GetParamValue(const char *param_name, std::string *value) const {
  if (!params)
    return false;
  std::string p(params);
  std::vector<std::string> v;
	SplitString(p, '&', v);
  for (size_t i = 0; i < v.size(); i++) {
    std::vector<std::string> parts;
		SplitString(v[i], '=', parts);
    ILOG("Param: %s Value: %s", parts[0].c_str(), parts[1].c_str());
    if (parts[0] == param_name) {
      *value = parts[1];
      return true;
    }
  }
  return false;
}
Пример #5
0
void NativeInit(int argc, const char *argv[], const char *savegame_directory, const char *external_directory, const char *installID)
{
    host = new NativeHost;

    logger = new AndroidLogger();

	LogManager::Init();
	LogManager *logman = LogManager::GetInstance();
	ILOG("Logman: %p", logman);

    LogTypes::LOG_LEVELS logLevel = LogTypes::LINFO;
	for(int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
	{
		LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i;
        logman->SetLogLevel(type, logLevel);
    }
}
Пример #6
0
void GLSLProgram::GLRestore() {
	// Quoth http://developer.android.com/reference/android/opengl/GLSurfaceView.Renderer.html;
	// "Note that when the EGL context is lost, all OpenGL resources associated with that context will be automatically deleted. 
	// You do not need to call the corresponding "glDelete" methods such as glDeleteTextures to manually delete these lost resources."
	// Hence, we comment out:
	// glDeleteShader(this->vsh_);
	// glDeleteShader(this->fsh_);
	// glDeleteProgram(this->program_);
	this->program_ = 0;
	this->vsh_ = 0;
	this->fsh_ = 0;
	ILOG("Restoring GLSL program %s/%s",
		strlen(this->vshader_filename) > 0 ? this->vshader_filename : "(mem)",
		strlen(this->fshader_filename) > 0 ? this->fshader_filename : "(mem)");
	glsl_recompile(this);
	// Note that any shader uniforms are still lost, hopefully the client sets them every frame at a minimum...
}
Пример #7
0
void VulkanRenderManager::ThreadFunc() {
	setCurrentThreadName("RenderMan");
	int threadFrame = threadInitFrame_;
	bool nextFrame = false;
	bool firstFrame = true;
	while (true) {
		{
			if (nextFrame) {
				threadFrame++;
				if (threadFrame >= vulkan_->GetInflightFrames())
					threadFrame = 0;
			}
			FrameData &frameData = frameData_[threadFrame];
			std::unique_lock<std::mutex> lock(frameData.pull_mutex);
			while (!frameData.readyForRun && run_) {
				VLOG("PULL: Waiting for frame[%d].readyForRun", threadFrame);
				frameData.pull_condVar.wait(lock);
			}
			if (!frameData.readyForRun && !run_) {
				// This means we're out of frames to render and run_ is false, so bail.
				break;
			}
			VLOG("PULL: frame[%d].readyForRun = false", threadFrame);
			frameData.readyForRun = false;
			// Previously we had a quick exit here that avoided calling Run() if run_ was suddenly false,
			// but that created a race condition where frames could end up not finished properly on resize etc.

			// Only increment next time if we're done.
			nextFrame = frameData.type == VKRRunType::END;
			assert(frameData.type == VKRRunType::END || frameData.type == VKRRunType::SYNC);
		}
		VLOG("PULL: Running frame %d", threadFrame);
		if (firstFrame) {
			ILOG("Running first frame (%d)", threadFrame);
			firstFrame = false;
		}
		Run(threadFrame);
		VLOG("PULL: Finished frame %d", threadFrame);
	}

	// Wait for the device to be done with everything, before tearing stuff down.
	vkDeviceWaitIdle(vulkan_->GetDevice());

	VLOG("PULL: Quitting");
}
Пример #8
0
VulkanRenderManager::~VulkanRenderManager() {
	ILOG("VulkanRenderManager destructor");
	StopThread();
	vulkan_->WaitUntilQueueIdle();

	VkDevice device = vulkan_->GetDevice();
	vkDestroySemaphore(device, acquireSemaphore_, nullptr);
	vkDestroySemaphore(device, renderingCompleteSemaphore_, nullptr);
	for (int i = 0; i < vulkan_->GetInflightFrames(); i++) {
		VkCommandBuffer cmdBuf[2]{ frameData_[i].mainCmd, frameData_[i].initCmd };
		vkFreeCommandBuffers(device, frameData_[i].cmdPoolInit, 1, &frameData_[i].initCmd);
		vkFreeCommandBuffers(device, frameData_[i].cmdPoolMain, 1, &frameData_[i].mainCmd);
		vkDestroyCommandPool(device, frameData_[i].cmdPoolInit, nullptr);
		vkDestroyCommandPool(device, frameData_[i].cmdPoolMain, nullptr);
		vkDestroyFence(device, frameData_[i].fence, nullptr);
	}
	queueRunner_.DestroyDeviceObjects();
}
Пример #9
0
uint8_t *VFSReadFile(const char *filename, size_t *size) {
	int fn_len = strlen(filename);
	for (int i = 0; i < num_entries; i++) {
		int prefix_len = strlen(entries[i].prefix);
		if (prefix_len >= fn_len) continue;
		if (0 == memcmp(filename, entries[i].prefix, prefix_len)) {
			ILOG("Prefix match: %s (%s) -> %s", entries[i].prefix, filename, filename + prefix_len);
			uint8_t *data = entries[i].reader->ReadAsset(filename + prefix_len, size);
			if (data)
				return data;
			else
				continue;
			// Else try the other registered file systems.
		}
	}
	ELOG("Missing filesystem for %s", filename);
	return 0;
}
Пример #10
0
extern "C" void Java_org_ppsspp_ppsspp_NativeApp_shutdown(JNIEnv *, jclass) {
	if (renderer_inited && useCPUThread && graphicsContext) {
		// Only used in Java EGL path.
		EmuThreadStop("shutdown");
		ILOG("BeginAndroidShutdown");
		graphicsContext->BeginAndroidShutdown();
		// Skipping GL calls, the old context is gone.
		while (graphicsContext->ThreadFrame()) {
			ILOG("graphicsContext->ThreadFrame executed to clear buffers");
		}
		ILOG("Joining emuthread");
		EmuThreadJoin();
		ILOG("Joined emuthread");

		graphicsContext->ThreadEnd();
		graphicsContext->ShutdownFromRenderThread();
		ILOG("Graphics context now shut down from NativeApp_shutdown");
	}

	ILOG("NativeApp.shutdown() -- begin");
	if (renderer_inited) {
		ILOG("Shutting down renderer");
		// This will be from the wrong thread? :/
		graphicsContext->Shutdown();
		delete graphicsContext;
		graphicsContext = nullptr;
		renderer_inited = false;
	} else {
		ILOG("Not shutting down renderer - not initialized");
	}

	NativeShutdown();
	VFSShutdown();
	while (frameCommands.size())
		frameCommands.pop();
	ILOG("NativeApp.shutdown() -- end");
}
Пример #11
0
  void IState::deInit(void)
  {
    ILOG() << "IState::deInit(" << mStateID << ")" << std::endl;

    if(true == mInit)
    {
      mCleanup = true;
      mInit = false;

      mElapsedTime += mElapsedClock.getElapsedTime().asSeconds();

      if(true == mPaused)
      {

        mPausedTime += mPausedClock.getElapsedTime().asSeconds();

      }
    }
  }
Пример #12
0
void EmuScreen::pspKey(int pspKeyCode, int flags) {
	if (pspKeyCode >= VIRTKEY_FIRST) {
		int vk = pspKeyCode - VIRTKEY_FIRST;
		if (flags & KEY_DOWN) {
			virtKeys[vk] = true;
			onVKeyDown(pspKeyCode);
		}
		if (flags & KEY_UP) {
			virtKeys[vk] = false;
			onVKeyUp(pspKeyCode);
		}
	} else {
		ILOG("pspKey %i %i", pspKeyCode, flags);
		if (flags & KEY_DOWN)
			__CtrlButtonDown(pspKeyCode);
		if (flags & KEY_UP)
			__CtrlButtonUp(pspKeyCode);
	}
}
Пример #13
0
bool Server::Listen6(int port, bool ipv6_only) {
	listener_ = socket(AF_INET6, SOCK_STREAM, 0);
	if (listener_ < 0)
		return false;

	struct sockaddr_in6 server_addr;
	memset(&server_addr, 0, sizeof(server_addr));
	server_addr.sin6_family = AF_INET6;
	server_addr.sin6_addr = in6addr_any;
	server_addr.sin6_port = htons(port);

	int opt = 1;
	// Enable re-binding to avoid the pain when restarting the server quickly.
	setsockopt(listener_, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt));

	// Enable listening on IPv6 and IPv4?
	opt = ipv6_only ? 1 : 0;
	setsockopt(listener_, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&opt, sizeof(opt));

	if (bind(listener_, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
		closesocket(listener_);
		ELOG("Failed to bind to port %i. Bailing.", port);
		return false;
	}

	fd_util::SetNonBlocking(listener_, true);

	// 1024 is the max number of queued requests.
	if (listen(listener_, 1024) < 0) {
		closesocket(listener_);
		return false;
	}

	socklen_t len = sizeof(server_addr);
	if (getsockname(listener_, (struct sockaddr *)&server_addr, &len) == 0) {
		port = ntohs(server_addr.sin6_port);
	}

	ILOG("HTTP server started on port %i", port);
	port_ = port;

	return true;
}
Пример #14
0
  PrototypeManager::~PrototypeManager()
  {
    ILOG() << "PrototypeManager::dtor()" << std::endl;

    // Make sure we delete all registered Prototype classes
    std::map<const typePrototypeID, Prototype*>::iterator anPrototypeIter;

    // Start at the beginning of the list of ISystem classes
    anPrototypeIter = mPrototypes.begin();
    while(anPrototypeIter != mPrototypes.end())
    {
      Prototype* anPrototype = anPrototypeIter->second;

      // Remove the Prototype from our list
      mPrototypes.erase(anPrototypeIter++);

      // Now delete the Prototype
      delete anPrototype;
    }
  }
Пример #15
0
void closeProxyConnection(struct proxyConnection *cp) {
	if(!(cp->error || cp->done) && !(cp->secure_eof && cp->plain_eof))
		return;
	
	DLOG("Closing connection");
	int secure_fd=cp->secure->fd;
	int status=0;
	if(cp->secure_up && !cp->error) {
		sslWriteClosureAlert(cp->secure);
	}
	status=close(cp->secure->fd);	
	socketShutdown(cp->secure->fd);
	sslFreeConnection(&cp->secure);
	
	status=close(cp->plain);
	socketShutdown(cp->plain);
	
	memset(cp,0,sizeof(struct proxyConnection));
	ILOG("Connection closed");
}
Пример #16
0
	void IState::init(void)
	{
		ILOG() << "IState::DoInit(" << mStateID << ")" << std::endl;

		// If Cleanup hasn't been called yet, call it now!
		if(true == mCleanup)
		{
			handleCleanup();
		}

		// Initialize if necessary
		if(false == mInit)
		{
			mInit = true;
			mPaused = false;
			mElapsedTime = 0.0f;
			mElapsedClock.restart();
			mPausedTime = 0.0f;
			mPausedClock.restart();
		}
	}
Пример #17
0
extern "C" void Java_org_ppsspp_ppsspp_NativeApp_audioInit(JNIEnv *, jclass) {
	sampleRate = optimalSampleRate;
	if (NativeQueryConfig("force44khz") != "0" || optimalSampleRate == 0) {
		sampleRate = 44100;
	}
	if (optimalFramesPerBuffer > 0) {
		framesPerBuffer = optimalFramesPerBuffer;
	} else {
		framesPerBuffer = 512;
	}

	// Some devices have totally bonkers buffer sizes like 8192. They will have terrible latency anyway, so to avoid having to
	// create extra smart buffering code, we'll just let their regular mixer deal with it, missing the fast path (as if they had one...)
	if (framesPerBuffer > 512) {
		framesPerBuffer = 512;
		sampleRate = 44100;
	}

	ILOG("NativeApp.audioInit() -- Using OpenSL audio! frames/buffer: %i   optimal sr: %i   actual sr: %i", optimalFramesPerBuffer, optimalSampleRate, sampleRate);
	AndroidAudio_Init(&NativeMix, library_path, framesPerBuffer, sampleRate);
}
Пример #18
0
void NativeShutdown() {
	screenManager->shutdown();
	delete screenManager;
	screenManager = 0;

	g_gameInfoCache.Shutdown();

	delete host;
	host = 0;
	g_Config.Save();
#ifndef _WIN32
	LogManager::Shutdown();
#endif
	// This means that the activity has been completely destroyed. PPSSPP does not
	// boot up correctly with "dirty" global variables currently, so we hack around that
	// by simply exiting.
#ifdef ANDROID
	ILOG("NativeShutdown called");
	exit(0);
#endif
}
Пример #19
0
/**
 * Check if the new version of the app is available
 * @param silent If this is set to false, no error messages will be displayed to the user
 */
void MiniLaunchBar::CheckForNewVersion(bool silent) {

  ILOG(_T("Looking for an update..."));
  UpdaterVersionInfo versionInfo;
  bool success = Updater::CheckVersion(CHECK_VERSION_URL, versionInfo);
  
  if (!success) {
    ELOG(_T("Could not get update information"));
    if (!silent) MessageBoxes::ShowError(_("Could not get update information"));
    return;
  }

  wxString thisVersion = VersionInfo::GetVersionString();

  ILOG(wxString::Format(_T("This version: %s"), thisVersion));
  ILOG(wxString::Format(_T("Current version: %s"), versionInfo.Version));
  ILOG(wxString::Format(_T("Page URL: %s"), versionInfo.PageURL));
  ILOG(wxString::Format(_T("Download URL: %s"), versionInfo.DownloadURL));
  ILOG(wxString::Format(_T("Release notes: %s"), versionInfo.ReleaseNotes));

  if (Updater::CompareVersions(thisVersion, versionInfo.Version) >= 0) {
    ILOG(_T("=> No new version"));
    if (!silent) MessageBoxes::ShowInformation(_("You have the latest version."));
    return;
  } else {
    ILOG(_T("=> A new version is available"));
  }

  wxString message;
  message = wxString::Format(_("A new version of Appetizer is available!\n\nYour version: %s\nNew version: %s\nRelease notes: %s\nDo you wish to download it now?"), thisVersion, versionInfo.Version, versionInfo.ReleaseNotes);
      
  int result = MessageBoxes::ShowConfirmation(message, 2|8, wxEmptyString, false, _("New version of Appetizer"));

  if (result == wxID_YES) {
    bool wasLaunched = ::wxLaunchDefaultBrowser(versionInfo.PageURL, wxBROWSER_NEW_WINDOW);
    if (!wasLaunched) MessageBoxes::ShowError(_("Error launching web browser"));
  }
}
Пример #20
0
stlink_t* stlink_v1_open_inner(const int verbose) {
    ugly_init(verbose);
    stlink_t *sl = stlink_open(verbose);
    if (sl == NULL) {
        fputs("Error: could not open stlink device\n", stderr);
        return NULL;
    }

    stlink_version(sl);
    if ((sl->version.st_vid != USB_ST_VID) || (sl->version.stlink_pid != USB_STLINK_PID)) {
        ugly_log(UERROR, LOG_TAG, 
            "WTF? successfully opened, but unable to read version details. BROKEN!\n");
        return NULL;
    }

    DLOG("Reading current mode...\n");
    switch (stlink_current_mode(sl)) {
    case STLINK_DEV_MASS_MODE:
            return sl;
    case STLINK_DEV_DEBUG_MODE:
        // TODO go to mass?
        return sl;
    default:
        ILOG("Current mode unusable, trying to get back to a useful state...\n");
        break;
    }

    DLOG("Attempting to exit DFU mode\n");
    _stlink_sg_exit_dfu_mode(sl);
    
    // re-query device info (and retest)
    stlink_version(sl);
    if ((sl->version.st_vid != USB_ST_VID) || (sl->version.stlink_pid != USB_STLINK_PID)) {
        ugly_log(UERROR, LOG_TAG, 
            "WTF? successfully opened, but unable to read version details. BROKEN!\n");
        return NULL;
    }

    return sl;
}
Пример #21
0
VkResult VulkanContext::CreateDevice() {
	if (!init_error_.empty() || physical_device_ < 0) {
		ELOG("Vulkan init failed: %s", init_error_.c_str());
		return VK_ERROR_INITIALIZATION_FAILED;
	}

	VkDeviceQueueCreateInfo queue_info = { VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO };
	float queue_priorities[1] = { 1.0f };
	queue_info.queueCount = 1;
	queue_info.pQueuePriorities = queue_priorities;
	bool found = false;
	for (int i = 0; i < (int)queue_count; i++) {
		if (queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
			queue_info.queueFamilyIndex = i;
			found = true;
			break;
		}
	}
	assert(found);

	deviceExtensionsLookup_.DEDICATED_ALLOCATION = EnableDeviceExtension(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME);

	VkDeviceCreateInfo device_info { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO };
	device_info.queueCreateInfoCount = 1;
	device_info.pQueueCreateInfos = &queue_info;
	device_info.enabledLayerCount = (uint32_t)device_layer_names_.size();
	device_info.ppEnabledLayerNames = device_info.enabledLayerCount ? device_layer_names_.data() : nullptr;
	device_info.enabledExtensionCount = (uint32_t)device_extensions_enabled_.size();
	device_info.ppEnabledExtensionNames = device_info.enabledExtensionCount ? device_extensions_enabled_.data() : nullptr;
	device_info.pEnabledFeatures = &featuresEnabled_;
	VkResult res = vkCreateDevice(physical_devices_[physical_device_], &device_info, nullptr, &device_);
	if (res != VK_SUCCESS) {
		init_error_ = "Unable to create Vulkan device";
		ELOG("Unable to create Vulkan device");
	} else {
		VulkanLoadDeviceFunctions(device_);
	}
	ILOG("Device created.\n");
	return res;
}
Пример #22
0
  void StateManager::addActiveState(IState* theState)
  {
    // Check that they didn't provide a bad pointer
    assert(NULL != theState && "StateManager::addActiveState() received a bad pointer");

    // Log the adding of each state
    ILOG() << "StateManager::addActiveState(" << theState->getID() << ")" << std::endl;

    // Is there a state currently running? then Pause it
    if(!mStack.empty())
    {
      // Pause the currently running state since we are changing the
      // currently active state to the one provided
      mStack.back()->pause();
    }

    // Add the active state
    mStack.push_back(theState);

    // Initialize the new active state
    mStack.back()->doInit();
  }
Пример #23
0
void ProcessGPUFeatures() {
	gl_extensions.bugs = 0;

	ILOG("Checking for GL driver bugs... vendor=%i model='%s'", (int)gl_extensions.gpuVendor, gl_extensions.model);
	// Should be table driven instead, this is a quick hack for Galaxy Y
	if (System_GetProperty(SYSPROP_NAME) == "samsung:GT-S5360") {
		gl_extensions.bugs |= BUG_FBO_UNUSABLE;
	}

	if (gl_extensions.gpuVendor == GPU_VENDOR_POWERVR) {
		if (!strcmp(gl_extensions.model, "PowerVR SGX 543") ||
			  !strcmp(gl_extensions.model, "PowerVR SGX 540") ||
			  !strcmp(gl_extensions.model, "PowerVR SGX 530") ||
				!strcmp(gl_extensions.model, "PowerVR SGX 520") ) {
			WLOG("GL DRIVER BUG: PVR with bad and terrible precision");
			gl_extensions.bugs |= BUG_PVR_SHADER_PRECISION_TERRIBLE | BUG_PVR_SHADER_PRECISION_BAD;
		} else {
			WLOG("GL DRIVER BUG: PVR with bad precision");
			gl_extensions.bugs |= BUG_PVR_SHADER_PRECISION_BAD;
		}
		gl_extensions.bugs |= BUG_PVR_GENMIPMAP_HEIGHT_GREATER;
	}
}
Пример #24
0
CEntity::CEntity(){
		
		ILOG() << "IEntity::ctor()" << std::endl;
    
		pos.x=0;pos.y=0;
		speed.x=0;speed.y=0;
		accel.x=0;accel.y=0;

    moveLeft  = false;
    moveRight = false;
    canJump = false;

    type = ENTITY_TYPE_GENERIC;

    dead = false;
    flags = ENTITY_FLAG_GRAVITY;
    
		maxSpeed.x = 500;
    maxSpeed.y = 500;

    CurrentFrameCol = 0;
    CurrentFrameRow = 0;
}
Пример #25
0
bool AndroidEGLGraphicsContext::Init(ANativeWindow *wnd, int backbufferWidth, int backbufferHeight, int backbufferFormat, int androidVersion) {
	wnd_ = wnd;
	gl = HostGL_CreateGLInterface();
	if (!gl) {
		ELOG("ERROR: Failed to create GL interface");
		return false;
	}
	ILOG("EGL interface created. Desired backbuffer size: %dx%d", backbufferWidth, backbufferHeight);

	// Apparently we still have to set this through Java through setFixedSize on the bufferHolder for it to take effect...
	gl->SetBackBufferDimensions(backbufferWidth, backbufferHeight);
	gl->SetMode(MODE_DETECT_ES);

	bool use565 = false;

	// This workaround seems only be needed on some really old devices.
	if (androidVersion < ANDROID_VERSION_ICS) {
		switch (backbufferFormat) {
		case 4:	// PixelFormat.RGB_565
			use565 = true;
			break;
		default:
			break;
		}
	}

	if (!gl->Create(wnd, false, use565)) {
		ELOG("EGL creation failed! (use565=%d)", (int)use565);
		// TODO: What do we do now?
		delete gl;
		return false;
	}
	gl->MakeCurrent();
	CheckGLExtensions();
	draw_ = Draw::T3DCreateGLContext();
	return true;
}
Пример #26
0
void WidgetRdpView::slotTimerResizeHappendFired()
{
  
  if (inErrorMode_)
    return;

  if (!connectionEstablished_)
  {
    // We have to increase the count of attempts to try to establish a new connection
    retryCount_++;

    if (retryCount_ > 5)
    {
      IERR("WidgetRdpView: aborting because of the detection of an rdp reconnection loop, user has to reopen this VmMask");

      // replace the RDP-Widget with an Label showing an error
      loGrid_->removeWidget(freeRDPwidget_);
      delete (freeRDPwidget_);
      freeRDPwidget_ = 0;
      lblErrorMessage_->setText("connection to VM-Mask lost, please close this tab and try again");
      loGrid_->addWidget(lblErrorMessage_, 0, 0, 1, 1, Qt::AlignHCenter);
      inErrorMode_ = true;
    }
    else
    {
      ILOG("WidgetRdpView: timer is ready - connectViaRdp()");
      resizeVmDesktopAndConnectViaRdp();
    }
  }
  else
  {
    if (!onDisconnecting_)
    {
      disconnectRdpConnection(); // in the disconnect event we will fire the timer timerResizeHappend_
    }
  }
}
Пример #27
0
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_backbufferResize(JNIEnv *, jclass, jint bufw, jint bufh, jint format) {
	ILOG("NativeApp.backbufferResize(%d x %d)", bufw, bufh);

	bool new_size = pixel_xres != bufw || pixel_yres != bufh;
	int old_w = pixel_xres;
	int old_h = pixel_yres;
	// pixel_*res is the backbuffer resolution.
	pixel_xres = bufw;
	pixel_yres = bufh;
	backbuffer_format = format;

	g_dpi = display_dpi_x;
	g_dpi_scale_x = 240.0f / g_dpi;
	g_dpi_scale_y = 240.0f / g_dpi;
	g_dpi_scale_real_x = g_dpi_scale_x;
	g_dpi_scale_real_y = g_dpi_scale_y;

	dp_xres = display_xres * g_dpi_scale_x;
	dp_yres = display_yres * g_dpi_scale_y;

	// Touch scaling is from display pixels to dp pixels.
	dp_xscale = (float)dp_xres / (float)display_xres;
	dp_yscale = (float)dp_yres / (float)display_yres;

	pixel_in_dps_x = (float)pixel_xres / dp_xres;
	pixel_in_dps_y = (float)pixel_yres / dp_yres;

	ILOG("g_dpi=%f g_dpi_scale_x=%f g_dpi_scale_y=%f", g_dpi, g_dpi_scale_x, g_dpi_scale_y);
	ILOG("dp_xscale=%f dp_yscale=%f", dp_xscale, dp_yscale);
	ILOG("dp_xres=%d dp_yres=%d", dp_xres, dp_yres);
	ILOG("pixel_xres=%d pixel_yres=%d", pixel_xres, pixel_yres);

	if (new_size) {
		ILOG("Size change detected (previously %d,%d) - calling NativeResized()", old_w, old_h);
		NativeResized();
	} else {
		ILOG("Size didn't change.");
	}
}
Пример #28
0
int azPrint(lua_State *L) {
  int argc = lua_gettop(L);

  wxString output;

  for (int n = 1; n <= argc; ++n) {
    if (lua_isboolean(L, n)) {
      output += lua_toboolean(L, n) ? _T("true") : _T("false");
      continue;
    }

    const char* c = lua_tostring(L, n);
    if (!c) {
      output += _T("<null>");
      continue;
    }

    output += wxString::FromUTF8(c);
  }

  ILOG(_T("%s %s"), _T("[Lua Script]"), output);

  return 0;
}
Пример #29
0
// JavaEGL
extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * env, jobject obj) {
	// We should be running on the render thread here.
	std::string errorMessage;
	if (renderer_inited) {
		// Would be really nice if we could get something on the GL thread immediately when shutting down.
		ILOG("NativeApp.displayInit() restoring");
		if (useCPUThread) {
			EmuThreadStop("displayInit");
			graphicsContext->BeginAndroidShutdown();
			ILOG("BeginAndroidShutdown. Looping until emu thread done...");
			// Skipping GL calls here because the old context is lost.
			while (graphicsContext->ThreadFrame()) {
				continue;
			}
			ILOG("Joining emu thread");
			EmuThreadJoin();
		} else {
			NativeShutdownGraphics();
		}
		graphicsContext->ThreadEnd();
		graphicsContext->ShutdownFromRenderThread();

		ILOG("Shut down both threads. Now let's bring it up again!");

		graphicsContext->InitFromRenderThread(nullptr, 0, 0, 0, 0);
		if (useCPUThread) {
			EmuThreadStart();
		} else {
			NativeInitGraphics(graphicsContext);
		}
		graphicsContext->ThreadStart();
		ILOG("Restored.");
	} else {
		ILOG("NativeApp.displayInit() first time");
		graphicsContext->InitFromRenderThread(nullptr, 0, 0, 0, 0);
		graphicsContext->ThreadStart();
		renderer_inited = true;
	}
	NativeMessageReceived("recreateviews", "");
}
Пример #30
0
static void EmuThreadFunc() {
	JNIEnv *env;
	gJvm->AttachCurrentThread(&env, nullptr);

	setCurrentThreadName("Emu");
	ILOG("Entering emu thread");

	// Wait for render loop to get started.
	if (!graphicsContext || !graphicsContext->Initialized()) {
		ILOG("Runloop: Waiting for displayInit...");
		while (!graphicsContext || !graphicsContext->Initialized()) {
			sleep_ms(20);
		}
	} else {
		ILOG("Runloop: Graphics context available! %p", graphicsContext);
	}
	NativeInitGraphics(graphicsContext);

	ILOG("Graphics initialized. Entering loop.");

	// There's no real requirement that NativeInit happen on this thread.
	// We just call the update/render loop here.
	emuThreadState = (int)EmuThreadState::RUNNING;
	while (emuThreadState != (int)EmuThreadState::QUIT_REQUESTED) {
		UpdateRunLoopAndroid(env);
	}
	ILOG("QUIT_REQUESTED found, left loop. Setting state to STOPPED.");
	emuThreadState = (int)EmuThreadState::STOPPED;

	NativeShutdownGraphics();

	// Also ask the main thread to stop, so it doesn't hang waiting for a new frame.
	graphicsContext->StopThread();

	gJvm->DetachCurrentThread();
	ILOG("Leaving emu thread");
}