Skip to content

Commit

Permalink
[Wasm] Renamed all Emscripten class names to Wasm.
Browse files Browse the repository at this point in the history
Appendix to renaming of filenames.
  • Loading branch information
LukasBanana committed Aug 22, 2024
1 parent 150f71f commit 7ff8367
Show file tree
Hide file tree
Showing 25 changed files with 153 additions and 161 deletions.
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ endif()
set(LLGL_UWP_PLATFORM OFF)
set(LLGL_IOS_PLATFORM OFF)
set(LLGL_ANDROID_PLATFORM OFF)
set(LLGL_HTML5_PLATFORM OFF)
set(LLGL_WASM_PLATFORM OFF)

if(NOT DEFINED LLGL_TARGET_PLATFORM)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
Expand All @@ -35,8 +35,8 @@ if(NOT DEFINED LLGL_TARGET_PLATFORM)
set(LLGL_TARGET_PLATFORM "${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}")
set(LLGL_UWP_PLATFORM ON)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Emscripten")
set(LLGL_TARGET_PLATFORM "HTML5")
set(LLGL_HTML5_PLATFORM ON)
set(LLGL_TARGET_PLATFORM "WebAssembly")
set(LLGL_WASM_PLATFORM ON)
elseif(WIN32)
if(LLGL_BUILD_64BIT)
set(LLGL_TARGET_PLATFORM "Win64")
Expand Down Expand Up @@ -95,7 +95,7 @@ set( BACKEND_INCLUDE_DIR "${PROJECT_INCLUDE_DIR}/LLGL/Backend" )

# === Macros ===

if(LLGL_IOS_PLATFORM OR LLGL_ANDROID_PLATFORM OR LLGL_HTML5_PLATFORM)
if(LLGL_IOS_PLATFORM OR LLGL_ANDROID_PLATFORM OR LLGL_WASM_PLATFORM)
set(LLGL_MOBILE_PLATFORM ON)
else()
set(LLGL_MOBILE_PLATFORM OFF)
Expand Down Expand Up @@ -538,8 +538,8 @@ if(LLGL_ENABLE_DEBUG_LAYER)
endif()

if(EMSCRIPTEN)
find_source_files(FilesPlatform CXX "${PROJECT_SOURCE_DIR}/sources/Platform/Emscripten")
find_source_files(FilesIncludePlatform CXX "${PROJECT_INCLUDE_DIR}/LLGL/Platform/Emscripten")
find_source_files(FilesPlatform CXX "${PROJECT_SOURCE_DIR}/sources/Platform/Wasm")
find_source_files(FilesIncludePlatform CXX "${PROJECT_INCLUDE_DIR}/LLGL/Platform/Wasm")
elseif(WIN32)
if(LLGL_UWP_PLATFORM)
find_source_files(FilesPlatform CXX "${PROJECT_SOURCE_DIR}/sources/Platform/UWP")
Expand Down
4 changes: 2 additions & 2 deletions include/LLGL/Backend/OpenGL/NativeHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
# include <LLGL/Backend/OpenGL/IOS/IOSNativeHandle.h>
#elif defined(LLGL_OS_ANDROID)
# include <LLGL/Backend/OpenGL/Android/AndroidNativeHandle.h>
#elif defined(LLGL_OS_EMSCRIPTEN)
# include <LLGL/Backend/OpenGL/Emscripten/EmscriptenNativeHandle.h>
#elif defined(LLGL_OS_WASM)
# include <LLGL/Backend/OpenGL/Wasm/WasmNativeHandle.h>
#endif


Expand Down
6 changes: 3 additions & 3 deletions include/LLGL/Backend/OpenGL/Wasm/WasmNativeHandle.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* EmscriptenNativeHandle.h (OpenGL)
* WasmNativeHandle.h (OpenGL)
*
* Copyright (c) 2015 Lukas Hermanns. All rights reserved.
* Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt).
*/

#ifndef LLGL_OPENGL_EMSCRIPTEN_NATIVE_HANDLE_H
#define LLGL_OPENGL_EMSCRIPTEN_NATIVE_HANDLE_H
#ifndef LLGL_OPENGL_WASM_NATIVE_HANDLE_H
#define LLGL_OPENGL_WASM_NATIVE_HANDLE_H


#include <emscripten/html5.h>
Expand Down
4 changes: 2 additions & 2 deletions include/LLGL/Platform/NativeHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
# include <LLGL/Platform/MacOS/MacOSNativeHandle.h>
#elif defined(LLGL_OS_LINUX)
# include <LLGL/Platform/Linux/LinuxNativeHandle.h>
#elif defined(LLGL_OS_EMSCRIPTEN)
# include <LLGL/Platform/Emscripten/EmscriptenNativeHandle.h>
#elif defined(LLGL_OS_WASM)
# include <LLGL/Platform/Wasm/WasmNativeHandle.h>
#elif defined(LLGL_OS_IOS)
# include <LLGL/Platform/IOS/IOSNativeHandle.h>
#elif defined(LLGL_OS_ANDROID)
Expand Down
2 changes: 1 addition & 1 deletion include/LLGL/Platform/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ see https://sourceforge.net/p/predef/wiki/OperatingSystems/
#elif defined __ANDROID__ || defined ANDROID
# define LLGL_OS_ANDROID
#elif defined EMSCRIPTEN
# define LLGL_OS_EMSCRIPTEN
# define LLGL_OS_WASM
#elif defined __linux__
# define LLGL_OS_LINUX
#endif
Expand Down
10 changes: 6 additions & 4 deletions include/LLGL/Platform/Wasm/WasmNativeHandle.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/*
* LinuxNativeHandle.h
* WasmNativeHandle.h
*
* Copyright (c) 2015 Lukas Hermanns. All rights reserved.
* Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt).
*/

#ifndef LLGL_EMSCRIPTEN_NATIVE_HANDLE_H
#define LLGL_EMSCRIPTEN_NATIVE_HANDLE_H
#ifndef LLGL_WASM_NATIVE_HANDLE_H
#define LLGL_WASM_NATIVE_HANDLE_H


#include <emscripten/val.h>


namespace LLGL
{

Expand All @@ -18,7 +20,7 @@ namespace LLGL
struct NativeHandle
{
//! CSS selector of canvas object.
std::string canvas;
std::string canvas;
};


Expand Down
4 changes: 2 additions & 2 deletions sources/Platform/Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
# include "MacOS/MacOSDebug.h"
# elif defined(LLGL_OS_LINUX)
# include "Linux/LinuxDebug.h"
# elif defined(LLGL_OS_EMSCRIPTEN)
# include "Emscripten/EmscriptenDebug.h"
# elif defined(LLGL_OS_WASM)
# include "Wasm/WasmDebug.h"
# elif defined(LLGL_OS_IOS)
# include "IOS/IOSDebug.h"
# elif defined(LLGL_OS_ANDROID)
Expand Down
79 changes: 40 additions & 39 deletions sources/Platform/Wasm/WasmCanvas.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* EmscriptenCanvas.cpp
* WasmCanvas.cpp
*
* Copyright (c) 2015 Lukas Hermanns. All rights reserved.
* Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt).
*/

#include "EmscriptenCanvas.h"
#include "MapKey.h"
#include "WasmCanvas.h"
#include "WasmKeyCodes.h"
#include <LLGL/Platform/NativeHandle.h>
#include <LLGL/Display.h>
#include "../../Core/CoreUtils.h"
Expand Down Expand Up @@ -47,20 +47,20 @@ static Offset2D GetScreenCenteredPosition(const Extent2D& size)

std::unique_ptr<Canvas> Canvas::Create(const CanvasDescriptor& desc)
{
return MakeUnique<EmscriptenCanvas>(desc);
return MakeUnique<WasmCanvas>(desc);
}


/*
* EmscriptenCanvas class
* WasmCanvas class
*/

EmscriptenCanvas::EmscriptenCanvas(const CanvasDescriptor& desc)
WasmCanvas::WasmCanvas(const CanvasDescriptor& desc)
{
CreateEmscriptenCanvas(desc);
}

bool EmscriptenCanvas::GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize)
bool WasmCanvas::GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize)
{
if (nativeHandle != nullptr && nativeHandleSize == sizeof(NativeHandle))
{
Expand All @@ -71,7 +71,7 @@ bool EmscriptenCanvas::GetNativeHandle(void* nativeHandle, std::size_t nativeHan
return false;
}

Extent2D EmscriptenCanvas::GetContentSize() const
Extent2D WasmCanvas::GetContentSize() const
{
int width = 0, height = 0;
emscripten_get_canvas_element_size("#canvas", &width, &height);
Expand All @@ -82,13 +82,14 @@ Extent2D EmscriptenCanvas::GetContentSize() const
};
}

void EmscriptenCanvas::SetTitle(const UTF8String& title)
void WasmCanvas::SetTitle(const UTF8String& title)
{
//todo
}

UTF8String EmscriptenCanvas::GetTitle() const
UTF8String WasmCanvas::GetTitle() const
{
char* title = nullptr;
char* title = nullptr; //todo
return title;
}

Expand Down Expand Up @@ -152,16 +153,16 @@ static int interpret_charcode_for_keyevent(int eventType, const EmscriptenKeyboa
return e->keyCode;
}

const char* EmscriptenCanvas::OnBeforeUnloadCallback(int eventType, const void* reserved, void* userData)
const char* WasmCanvas::OnBeforeUnloadCallback(int eventType, const void* reserved, void* userData)
{
EmscriptenCanvas* canvas = reinterpret_cast<EmscriptenCanvas*>(userData);
WasmCanvas* canvas = reinterpret_cast<WasmCanvas*>(userData);
canvas->PostDestroy();
return nullptr;
}

int EmscriptenCanvas::OnCanvasResizeCallback(int eventType, const EmscriptenUiEvent* event, void *userData)
int WasmCanvas::OnCanvasResizeCallback(int eventType, const EmscriptenUiEvent* event, void *userData)
{
EmscriptenCanvas* canvas = reinterpret_cast<EmscriptenCanvas*>(userData);
WasmCanvas* canvas = reinterpret_cast<WasmCanvas*>(userData);
const Extent2D clientAreaSize
{
static_cast<std::uint32_t>(event->documentBodyClientWidth),
Expand All @@ -171,9 +172,9 @@ int EmscriptenCanvas::OnCanvasResizeCallback(int eventType, const EmscriptenUiEv
return 0;
}

EM_BOOL EmscriptenCanvas::OnKeyCallback(int eventType, const EmscriptenKeyboardEvent *e, void *userData)
EM_BOOL WasmCanvas::OnKeyCallback(int eventType, const EmscriptenKeyboardEvent *e, void *userData)
{
EmscriptenCanvas* canvas = reinterpret_cast<EmscriptenCanvas*>(userData);
WasmCanvas* canvas = reinterpret_cast<WasmCanvas*>(userData);

int dom_pk_code = emscripten_compute_dom_pk_code(e->code);

Expand All @@ -188,7 +189,7 @@ EM_BOOL EmscriptenCanvas::OnKeyCallback(int eventType, const EmscriptenKeyboardE

printf("%s, key: \"%s\", code: \"%s\" = %s (%d)\n", emscripten_event_type_to_string(eventType), e->key, e->code, emscripten_dom_pk_code_to_string(dom_pk_code), dom_pk_code);

auto key = MapKey(e->code);
auto key = MapEmscriptenKeyCode(e->code);

if (eventType == 2)
canvas->PostKeyDown(key);
Expand All @@ -198,7 +199,7 @@ EM_BOOL EmscriptenCanvas::OnKeyCallback(int eventType, const EmscriptenKeyboardE
return true;
}

EM_BOOL EmscriptenCanvas::OnMouseCallback(int eventType, const EmscriptenMouseEvent *e, void *userData)
EM_BOOL WasmCanvas::OnMouseCallback(int eventType, const EmscriptenMouseEvent *e, void *userData)
{
/*
printf("%s, screen: (%ld,%ld), client: (%ld,%ld),%s%s%s%s button: %hu, buttons: %hu, movement: (%ld,%ld), canvas: (%ld,%ld), target: (%ld, %ld)\n",
Expand Down Expand Up @@ -229,7 +230,7 @@ EM_BOOL EmscriptenCanvas::OnMouseCallback(int eventType, const EmscriptenMouseEv
return EMSCRIPTEN_RESULT_SUCCESS;
}

EM_BOOL EmscriptenCanvas::OnWheelCallback(int eventType, const EmscriptenWheelEvent *e, void *userData)
EM_BOOL WasmCanvas::OnWheelCallback(int eventType, const EmscriptenWheelEvent *e, void *userData)
{
/*
printf("%s, screen: (%ld,%ld), client: (%ld,%ld),%s%s%s%s button: %hu, buttons: %hu, canvas: (%ld,%ld), target: (%ld, %ld), delta:(%g,%g,%g), deltaMode:%lu\n",
Expand All @@ -247,7 +248,7 @@ EM_BOOL EmscriptenCanvas::OnWheelCallback(int eventType, const EmscriptenWheelEv
return EMSCRIPTEN_RESULT_SUCCESS;
}

void EmscriptenCanvas::CreateEmscriptenCanvas(const CanvasDescriptor& desc)
void WasmCanvas::CreateEmscriptenCanvas(const CanvasDescriptor& desc)
{
/* Find canvas handle*/
emscripten::val config = emscripten::val::module_property("config");
Expand Down Expand Up @@ -275,21 +276,21 @@ void EmscriptenCanvas::CreateEmscriptenCanvas(const CanvasDescriptor& desc)

/* Set callbacks */
EMSCRIPTEN_RESULT ret;
ret = emscripten_set_beforeunload_callback(this, EmscriptenCanvas::OnBeforeUnloadCallback);
ret = emscripten_set_resize_callback(canvas_selector.c_str(), this, true, EmscriptenCanvas::OnCanvasResizeCallback);

ret = emscripten_set_keydown_callback(canvas_selector.c_str(), this, true, EmscriptenCanvas::OnKeyCallback);
ret = emscripten_set_keyup_callback(canvas_selector.c_str(), this, true, EmscriptenCanvas::OnKeyCallback);

ret = emscripten_set_click_callback(canvas_selector.c_str(), this, true, EmscriptenCanvas::OnMouseCallback);
ret = emscripten_set_mousedown_callback(canvas_selector.c_str(), this, true, EmscriptenCanvas::OnMouseCallback);
ret = emscripten_set_mouseup_callback(canvas_selector.c_str(), this, true, EmscriptenCanvas::OnMouseCallback);
ret = emscripten_set_dblclick_callback(canvas_selector.c_str(), this, true, EmscriptenCanvas::OnMouseCallback);
ret = emscripten_set_mousemove_callback(canvas_selector.c_str(), this, true, EmscriptenCanvas::OnMouseCallback);
ret = emscripten_set_wheel_callback(canvas_selector.c_str(), this, true, EmscriptenCanvas::OnWheelCallback);
ret = emscripten_set_beforeunload_callback(this, WasmCanvas::OnBeforeUnloadCallback);
ret = emscripten_set_resize_callback(canvas_selector.c_str(), this, true, WasmCanvas::OnCanvasResizeCallback);

ret = emscripten_set_keydown_callback(canvas_selector.c_str(), this, true, WasmCanvas::OnKeyCallback);
ret = emscripten_set_keyup_callback(canvas_selector.c_str(), this, true, WasmCanvas::OnKeyCallback);

ret = emscripten_set_click_callback(canvas_selector.c_str(), this, true, WasmCanvas::OnMouseCallback);
ret = emscripten_set_mousedown_callback(canvas_selector.c_str(), this, true, WasmCanvas::OnMouseCallback);
ret = emscripten_set_mouseup_callback(canvas_selector.c_str(), this, true, WasmCanvas::OnMouseCallback);
ret = emscripten_set_dblclick_callback(canvas_selector.c_str(), this, true, WasmCanvas::OnMouseCallback);
ret = emscripten_set_mousemove_callback(canvas_selector.c_str(), this, true, WasmCanvas::OnMouseCallback);
ret = emscripten_set_wheel_callback(canvas_selector.c_str(), this, true, WasmCanvas::OnWheelCallback);
}

void EmscriptenCanvas::ProcessKeyEvent(/*event, bool down*/)
void WasmCanvas::ProcessKeyEvent(/*event, bool down*/)
{
/*auto key = MapKey(event);
if (down)
Expand All @@ -298,7 +299,7 @@ void EmscriptenCanvas::ProcessKeyEvent(/*event, bool down*/)
PostKeyUp(key);*/
}

void EmscriptenCanvas::ProcessMouseKeyEvent(/*event, bool down*/)
void WasmCanvas::ProcessMouseKeyEvent(/*event, bool down*/)
{
/*switch (event.button)
{
Expand All @@ -320,7 +321,7 @@ void EmscriptenCanvas::ProcessMouseKeyEvent(/*event, bool down*/)
}*/
}

/*void EmscriptenCanvas::ProcessExposeEvent()
/*void WasmCanvas::ProcessExposeEvent()
{
const Extent2D size
{
Expand All @@ -330,22 +331,22 @@ void EmscriptenCanvas::ProcessMouseKeyEvent(/*event, bool down*/)
PostResize(size);
}*/

void EmscriptenCanvas::ProcessClientMessage(/*XClientMessageEvent& event*/)
void WasmCanvas::ProcessClientMessage(/*XClientMessageEvent& event*/)
{
/*Atom atom = static_cast<Atom>(event.data.l[0]);
if (atom == closeWndAtom_)
PostQuit();*/
}

void EmscriptenCanvas::ProcessMotionEvent(/*XMotionEvent& event*/)
void WasmCanvas::ProcessMotionEvent(/*XMotionEvent& event*/)
{
/*const Offset2D mousePos { event.x, event.y };
PostLocalMotion(mousePos);
PostGlobalMotion({ mousePos.x - prevMousePos_.x, mousePos.y - prevMousePos_.y });
prevMousePos_ = mousePos;*/
}

void EmscriptenCanvas::PostMouseKeyEvent(Key key, bool down)
void WasmCanvas::PostMouseKeyEvent(Key key, bool down)
{
if (down)
PostKeyDown(key);
Expand Down
10 changes: 5 additions & 5 deletions sources/Platform/Wasm/WasmCanvas.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* EmscriptenCanvas.h
* WasmCanvas.h
*
* Copyright (c) 2015 Lukas Hermanns. All rights reserved.
* Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt).
*/

#ifndef LLGL_EMSCRIPTEN_CANVAS_H
#define LLGL_EMSCRIPTEN_CANVAS_H
#ifndef LLGL_WASM_CANVAS_H
#define LLGL_WASM_CANVAS_H


#include <LLGL/Canvas.h>
Expand All @@ -21,12 +21,12 @@ namespace LLGL
{


class EmscriptenCanvas : public Canvas
class WasmCanvas : public Canvas
{

public:

EmscriptenCanvas(const CanvasDescriptor& desc);
WasmCanvas(const CanvasDescriptor& desc);

bool GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize) override;

Expand Down
2 changes: 1 addition & 1 deletion sources/Platform/Wasm/WasmDebug.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* LinuxDebug.cpp
* WasmDebug.cpp
*
* Copyright (c) 2015 Lukas Hermanns. All rights reserved.
* Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt).
Expand Down
6 changes: 3 additions & 3 deletions sources/Platform/Wasm/WasmDebug.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* LinuxDebug.h
* WasmDebug.h
*
* Copyright (c) 2015 Lukas Hermanns. All rights reserved.
* Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt).
*/

#ifndef LLGL_EMSCRIPTEN_DEBUG_H
#define LLGL_EMSCRIPTEN_DEBUG_H
#ifndef LLGL_WASM_DEBUG_H
#define LLGL_WASM_DEBUG_H


#include <signal.h>
Expand Down
Loading

0 comments on commit 7ff8367

Please sign in to comment.