mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-23 20:09:46 +03:00
macOS Support & AppPlatform Cleanup (#57)
* macOS Support & Cleanup * Fix malformed comments in build-wasm.bat * Emscripten Fixes * * Add shebang to the grabsounds.py script Since it was changed from rw- to rwx, I'll add the shebang so that it actually runs properly. * * Re-add the patch_data and readme files. * * Remove sound data. * Fix some more things. * Think it's ready to pull now... --------- Co-authored-by: BrentDaMage <BrentDaMage@users.noreply.github.com> Co-authored-by: iProgramInCpp <iprogramincpp@gmail.com>
This commit is contained in:
33
platforms/emscripten/AppPlatform_emscripten.cpp
Normal file
33
platforms/emscripten/AppPlatform_emscripten.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "AppPlatform_emscripten.hpp"
|
||||
|
||||
#include <emscripten.h>
|
||||
|
||||
#include "client/common/Utils.hpp"
|
||||
|
||||
AppPlatform_emscripten::AppPlatform_emscripten(std::string storageDir, SDL_Window *window)
|
||||
: AppPlatform_sdlbase(storageDir, window)
|
||||
{
|
||||
}
|
||||
|
||||
Texture AppPlatform_emscripten::loadTexture(const std::string& path, bool b)
|
||||
{
|
||||
Texture out;
|
||||
out.field_C = 1;
|
||||
out.field_D = 0;
|
||||
|
||||
std::string realPath = getAssetPath(path);
|
||||
|
||||
char *data = emscripten_get_preloaded_image_data(("/" + realPath).c_str(), &out.m_width, &out.m_height);
|
||||
if (data != NULL)
|
||||
{
|
||||
size_t data_size = out.m_width * out.m_height * 4;
|
||||
out.m_pixels = (uint32_t *) new unsigned char[data_size];
|
||||
memcpy(out.m_pixels, data, data_size);
|
||||
free(data);
|
||||
return out;
|
||||
}
|
||||
|
||||
// I don't think this logic makes any sense
|
||||
LogMsg("Couldn't find file: %s", realPath.c_str());
|
||||
return out;
|
||||
}
|
||||
13
platforms/emscripten/AppPlatform_emscripten.hpp
Normal file
13
platforms/emscripten/AppPlatform_emscripten.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../sdl/AppPlatform_sdl.hpp"
|
||||
|
||||
class AppPlatform_emscripten : public AppPlatform_sdlbase
|
||||
{
|
||||
public:
|
||||
AppPlatform_emscripten(std::string storageDir, SDL_Window *window);
|
||||
|
||||
Texture loadTexture(const std::string& path, bool b = false) override;
|
||||
};
|
||||
54
platforms/emscripten/wasm_shell.html
Normal file
54
platforms/emscripten/wasm_shell.html
Normal file
@@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>ReMinecraftPE</title>
|
||||
<style>
|
||||
html, body {
|
||||
background-color: black;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
border: 0px none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
|
||||
<script type="text/javascript" src="coi-serviceworker.min.js"></script>
|
||||
<script type='text/javascript'>
|
||||
var Module = {
|
||||
print: function (text) {
|
||||
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
|
||||
console.log(text);
|
||||
},
|
||||
printErr: function (text) {
|
||||
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
|
||||
console.error(text);
|
||||
},
|
||||
canvas: (function () {
|
||||
var canvas = document.getElementById('canvas');
|
||||
|
||||
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
|
||||
// application robust, you may want to override this behavior before shipping!
|
||||
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
|
||||
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
|
||||
|
||||
// Handle Resize
|
||||
function setCanvasSize() {
|
||||
Module.ccall('resize_from_js', null, ['number', 'number'], [window.innerWidth, window.innerHeight]);
|
||||
}
|
||||
window.addEventListener("resize", setCanvasSize);
|
||||
|
||||
return canvas;
|
||||
})(),
|
||||
arguments: [String(window.innerWidth), String(window.innerHeight)]
|
||||
};
|
||||
</script>
|
||||
<script async type="text/javascript" src="reminecraftpe.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user