SDL/WASM Port

This commit is contained in:
TheBrokenRail
2023-08-05 01:58:24 -04:00
committed by iProgramInCpp
parent 0b16b2843a
commit 0fbe90752d
37 changed files with 1704 additions and 40 deletions

254
source/CMakeLists.txt Normal file
View File

@@ -0,0 +1,254 @@
cmake_minimum_required(VERSION 3.16.0)
project(reminecraftpe-core)
# Build
add_library(reminecraftpe-core STATIC
NinecraftApp.cpp
client/renderer/LevelRenderer.cpp
client/renderer/Culler.cpp
client/renderer/entity/HumanoidMobRenderer.cpp
client/renderer/entity/TntRenderer.cpp
client/renderer/entity/MobRenderer.cpp
client/renderer/entity/FallingTileRenderer.cpp
client/renderer/entity/EntityRenderer.cpp
client/renderer/entity/ItemRenderer.cpp
client/renderer/entity/TripodCameraRenderer.cpp
client/renderer/entity/ItemSpriteRenderer.cpp
client/renderer/entity/EntityRenderDispatcher.cpp
client/renderer/RenderList.cpp
client/renderer/Chunk.cpp
client/renderer/RenderChunk.cpp
client/renderer/Frustum.cpp
client/renderer/ItemInHandRenderer.cpp
client/renderer/DynamicTexture.cpp
client/renderer/GameRenderer.cpp
client/renderer/Textures.cpp
client/renderer/FrustumCuller.cpp
client/renderer/LightUpdate.cpp
client/renderer/Font.cpp
client/renderer/WaterSideTexture.cpp
client/renderer/Tesselator.cpp
client/renderer/TileRenderer.cpp
client/renderer/LightLayer.cpp
client/renderer/WaterTexture.cpp
client/network/Packets/UpdateBlockPacket.cpp
client/network/Packets/RequestChunkPacket.cpp
client/network/Packets/PlayerEquipmentPacket.cpp
client/network/Packets/ChunkDataPacket.cpp
client/network/Packets/PlaceBlockPacket.cpp
client/network/Packets/LoginPacket.cpp
client/network/Packets/StartGamePacket.cpp
client/network/Packets/RemoveEntityPacket.cpp
client/network/Packets/AddPlayerPacket.cpp
client/network/Packets/RemoveBlockPacket.cpp
client/network/Packets/MovePlayerPacket.cpp
client/network/Packets/MessagePacket.cpp
client/network/ServerSideNetworkHandler.cpp
client/network/RakNetInstance.cpp
client/network/ClientSideNetworkHandler.cpp
client/network/MinecraftPackets.cpp
client/network/NetEventCallback.cpp
client/sound/SoundData.cpp
client/sound/SoundSystem.cpp
client/sound/SoundRepository.cpp
client/sound/SoundEngine.cpp
client/gui/Screen.cpp
client/gui/screens/OptionsScreen.cpp
client/gui/screens/StartMenuScreen.cpp
client/gui/screens/CreateWorldScreen.cpp
client/gui/screens/SelectWorldScreen.cpp
client/gui/screens/SavingWorldScreen.cpp
client/gui/screens/InvalidLicenseScreen.cpp
client/gui/screens/ConfirmScreen.cpp
client/gui/screens/DeleteWorldScreen.cpp
client/gui/screens/ChatScreen.cpp
client/gui/screens/RenameMPLevelScreen.cpp
client/gui/screens/ProgressScreen.cpp
client/gui/screens/JoinGameScreen.cpp
client/gui/screens/IngameBlockSelectionScreen.cpp
client/gui/screens/PauseScreen.cpp
client/gui/components/ScrolledSelectionList.cpp
client/gui/components/AvailableGamesList.cpp
client/gui/components/RolledSelectionList.cpp
client/gui/components/Button.cpp
client/gui/components/TextInputBox.cpp
client/gui/components/SmallButton.cpp
client/gui/components/WorldSelectionList.cpp
client/gui/Gui.cpp
client/gui/GuiComponent.cpp
client/model/PolygonQuad.cpp
client/model/Model.cpp
client/model/HumanoidModel.cpp
client/model/Cube.cpp
client/common/Random.cpp
client/common/HitResult.cpp
client/common/Utils.cpp
client/common/PerlinNoise.cpp
client/common/ImprovedNoise.cpp
client/common/Matrix.cpp
client/common/Mth.cpp
client/common/Options.cpp
client/common/Timer.cpp
client/common/Synth.cpp
client/common/CThread.cpp
client/common/Util.cpp
client/common/Vec3.cpp
client/common/AABB.cpp
client/player/input/ControllerTurnInput.cpp
client/player/input/Controller.cpp
client/player/input/Mouse.cpp
client/player/input/Keyboard.cpp
client/player/input/MouseTurnInput.cpp
client/player/input/KeyboardInput.cpp
client/player/input/ITurnInput.cpp
Minecraft.cpp
world/gamemode/SurvivalMode.cpp
world/gamemode/GameMode.cpp
world/gamemode/CreativeMode.cpp
world/entity/Mob.cpp
world/entity/LocalPlayer.cpp
world/entity/Player.cpp
world/entity/PrimedTnt.cpp
world/entity/Entity.cpp
world/entity/FallingTile.cpp
world/entity/TripodCamera.cpp
world/entity/ItemEntity.cpp
world/level/Dimension.cpp
world/level/Material.cpp
world/level/LevelListener.cpp
world/level/TickNextTickData.cpp
world/level/Explosion.cpp
world/level/storage/LevelStorageSource.cpp
world/level/storage/MemoryLevelStorageSource.cpp
world/level/storage/LevelData.cpp
world/level/storage/ExternalFileLevelStorage.cpp
world/level/storage/RegionFile.cpp
world/level/storage/LevelStorage.cpp
world/level/storage/MemoryLevelStorage.cpp
world/level/storage/ChunkStorage.cpp
world/level/storage/LevelSource.cpp
world/level/storage/MemoryChunkStorage.cpp
world/level/storage/ExternalFileLevelStorageSource.cpp
world/level/levelgen/feature/BirchFeature.cpp
world/level/levelgen/feature/LargeFeature.cpp
world/level/levelgen/feature/Feature.cpp
world/level/levelgen/feature/LargeCaveFeature.cpp
world/level/levelgen/feature/SpringFeature.cpp
world/level/levelgen/feature/TreeFeature.cpp
world/level/levelgen/feature/PineFeature.cpp
world/level/levelgen/feature/ReedsFeature.cpp
world/level/levelgen/feature/OreFeature.cpp
world/level/levelgen/feature/ClayFeature.cpp
world/level/levelgen/feature/FlowerFeature.cpp
world/level/levelgen/feature/SpruceFeature.cpp
world/level/levelgen/biome/Biome.cpp
world/level/levelgen/biome/BiomeSource.cpp
world/level/levelgen/chunk/RandomLevelSource.cpp
world/level/levelgen/chunk/LevelChunk.cpp
world/level/levelgen/chunk/ChunkCache.cpp
world/level/levelgen/chunk/ChunkSource.cpp
world/level/levelgen/chunk/PerformanceTestChunkSource.cpp
world/level/levelgen/chunk/TestChunkSource.cpp
world/level/Level.cpp
world/level/Region.cpp
world/item/TilePlanterItem.cpp
world/item/CameraItem.cpp
world/item/TileItem.cpp
world/item/Inventory.cpp
world/item/DoorItem.cpp
world/item/ItemInstance.cpp
world/item/Item.cpp
world/particle/RedDustParticle.cpp
world/particle/TerrainParticle.cpp
world/particle/BubbleParticle.cpp
world/particle/ExplodeParticle.cpp
world/particle/ParticleEngine.cpp
world/particle/FlameParticle.cpp
world/particle/SmokeParticle.cpp
world/particle/Particle.cpp
world/particle/LavaParticle.cpp
world/tile/InvisibleTile.cpp
world/tile/Sapling.cpp
world/tile/TreeTile.cpp
world/tile/GrassTile.cpp
world/tile/HalfTransparentTile.cpp
world/tile/ClothTile.cpp
world/tile/TorchTile.cpp
world/tile/MetalTile.cpp
world/tile/SpongeTile.cpp
world/tile/GlassTile.cpp
world/tile/SandTile.cpp
world/tile/Tile.cpp
world/tile/ClayTile.cpp
world/tile/StoneTile.cpp
world/tile/LadderTile.cpp
world/tile/IceTile.cpp
world/tile/TopSnowTile.cpp
world/tile/ReedTile.cpp
world/tile/Bush.cpp
world/tile/RedStoneOreTile.cpp
world/tile/DirtTile.cpp
world/tile/LiquidTileStatic.cpp
world/tile/BookshelfTile.cpp
world/tile/TntTile.cpp
world/tile/OreTile.cpp
world/tile/StairTile.cpp
world/tile/SandStoneTile.cpp
world/tile/FireTile.cpp
world/tile/StoneSlabTile.cpp
world/tile/LiquidTile.cpp
world/tile/GravelTile.cpp
world/tile/LiquidTileDynamic.cpp
world/tile/TransparentTile.cpp
world/tile/LeafTile.cpp
world/tile/ObsidianTile.cpp
world/tile/FarmTile.cpp
world/tile/DoorTile.cpp
App.cpp
AppPlatform.cpp
)
target_include_directories(reminecraftpe-core PUBLIC . ..)
# RakNet
add_subdirectory(../thirdparty/raknet raknet)
target_link_libraries(reminecraftpe-core PUBLIC raknet)
# SDL
add_library(SDL INTERFACE)
if(EMSCRIPTEN)
set(SDL_FLAG -sUSE_SDL=2)
target_compile_options(SDL INTERFACE "${SDL_FLAG}")
target_link_options(SDL INTERFACE "${SDL_FLAG}")
else()
find_package(SDL2 REQUIRED)
target_link_libraries(SDL INTERFACE SDL2::SDL2)
endif()
target_link_libraries(reminecraftpe-core PUBLIC SDL)
# OpenGL
if(NOT EMSCRIPTEN)
option(USE_GLES1_COMPATIBILITY_LAYER "Whether To Enable The GLESv1_CM Compatibility Layer" TRUE)
else()
set(USE_GLES1_COMPATIBILITY_LAYER TRUE)
endif()
if(USE_GLES1_COMPATIBILITY_LAYER)
set(GLES_COMPATIBILITY_LAYER_USE_SDL TRUE CACHE BOOL "" FORCE)
set(GLES_COMPATIBILITY_LAYER_DEPENDENCY SDL CACHE STRING "" FORCE)
add_subdirectory(../thirdparty/gles-compatibility-layer gles-compatibility-layer)
target_link_libraries(reminecraftpe-core PUBLIC gles-compatibility-layer)
target_compile_definitions(reminecraftpe-core PUBLIC USE_GLES1_COMPATIBILITY_LAYER)
if(EMSCRIPTEN)
target_link_options(reminecraftpe-core PUBLIC -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2)
endif()
else()
find_package(OpenGL REQUIRED)
target_link_libraries(reminecraftpe-core PUBLIC OpenGL::OpenGL OpenGL::GLU)
endif()
# OpenAL
if(EMSCRIPTEN)
target_link_libraries(reminecraftpe-core PUBLIC openal)
else()
find_library(OPENAL_LIBRARY NAMES openal REQUIRED)
target_link_libraries(reminecraftpe-core PUBLIC "${OPENAL_LIBRARY}")
endif()

View File

@@ -1,7 +1,7 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
@@ -48,7 +48,7 @@ Minecraft::Minecraft() : m_gui(this)
#else
m_pTurnInput = new ControllerTurnInput;
#endif
m_pRakNetInstance = new RakNetInstance;
m_pSoundEngine = new SoundEngine;
@@ -59,7 +59,7 @@ int Minecraft::getLicenseId()
{
if (m_licenseID < 0)
m_licenseID = m_pPlatform->checkLicense();
return m_licenseID;
}
@@ -80,7 +80,7 @@ void Minecraft::grabMouse()
{
if (m_bGrabbedMouse)
return;
m_bGrabbedMouse = true;
field_D20 = 0.0f;
field_D24 = 0.0f;
@@ -91,6 +91,12 @@ void Minecraft::grabMouse()
void Minecraft::setScreen(Screen* pScreen)
{
#ifndef ORIGINAL_CODE
if (pScreen == nullptr && !isLevelGenerated()) {
return;
}
#endif
if (m_bUsingScreen)
{
m_bHasQueuedScreen = true;
@@ -396,7 +402,7 @@ void Minecraft::tickInput()
{
m_gui.handleKeyPressed(keyCode);
int index = keyCode - '1';
int index = keyCode - AKEYCODE_1;
if (index <= 8 && index >= 0)
{
m_pLocalPlayer->m_pInventory->selectSlot(index);
@@ -441,7 +447,7 @@ void Minecraft::tickInput()
}
}
// @TODO: fix gotos
// @TODO: fix gotos
bool v12 = false;
if (m_options.field_19)
@@ -484,7 +490,7 @@ void Minecraft::tickMouse()
{
if (!m_bGrabbedMouse)
return;
platform()->recenterMouse();
}
@@ -506,7 +512,7 @@ void Minecraft::tick()
field_DA4--;
tickInput();
m_gui.tick();
// if the level has been prepared, delete the prep thread
@@ -547,8 +553,12 @@ void Minecraft::tick()
#ifndef ORIGINAL_CODE
if (m_pMobPersp)
{
#ifdef USE_SDL
m_pSoundEngine->m_soundSystem.update(m_pMobPersp->m_pos.x, m_pMobPersp->m_pos.y, m_pMobPersp->m_pos.z, m_pMobPersp->m_yaw);
#else
m_pSoundEngine->m_soundSystem.setListenerPos(m_pMobPersp->m_pos.x, m_pMobPersp->m_pos.y, m_pMobPersp->m_pos.z);
m_pSoundEngine->m_soundSystem.setListenerAngle(m_pMobPersp->m_yaw, m_pMobPersp->m_pitch);
#endif
}
#endif
@@ -653,7 +663,7 @@ void Minecraft::prepareLevel(const std::string& unused)
float startTime = getTimeS();
Level* pLevel = m_pLevel;
if (!pLevel->field_B0C)
{
pLevel->setUpdateLights(0);
@@ -769,7 +779,7 @@ void Minecraft::generateLevel(const std::string& unused, Level* pLevel)
if (m_pLevelRenderer)
m_pLevelRenderer->setLevel(pLevel);
if (m_pParticleEngine)
m_pParticleEngine->setLevel(pLevel);
@@ -925,30 +935,38 @@ void Minecraft::leaveGame(bool bCopyMap)
void Minecraft::hostMultiplayer()
{
#ifndef __EMSCRIPTEN__
m_pRakNetInstance->host(m_pUser->field_0, C_DEFAULT_PORT, C_MAX_CONNECTIONS);
m_pNetEventCallback = new ServerSideNetworkHandler(this, m_pRakNetInstance);
#endif
}
void Minecraft::joinMultiplayer(const PingedCompatibleServer& serverInfo)
{
#ifndef __EMSCRIPTEN__
if (field_18 && m_pNetEventCallback)
{
field_18 = false;
m_pRakNetInstance->connect(serverInfo.m_address.ToString(), serverInfo.m_address.GetPort());
}
#endif
}
void Minecraft::cancelLocateMultiplayer()
{
#ifndef __EMSCRIPTEN__
field_18 = false;
m_pRakNetInstance->stopPingForHosts();
delete m_pNetEventCallback;
m_pNetEventCallback = nullptr;
#endif
}
void Minecraft::locateMultiplayer()
{
#ifndef __EMSCRIPTEN__
field_18 = true;
m_pRakNetInstance->pingForHosts(C_DEFAULT_PORT);
m_pNetEventCallback = new ClientSideNetworkHandler(this, m_pRakNetInstance);
#endif
}

View File

@@ -1,7 +1,7 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/

View File

@@ -33,6 +33,8 @@
int g_TimeSecondsOnInit = 0;
#ifndef USE_SDL
DIR* opendir(const char* name)
{
size_t len = strlen(name);
@@ -97,6 +99,13 @@ void closedir(DIR* dir)
free(dir);
}
#else
#include <sys/types.h>
#include <dirent.h>
#endif
bool createFolderIfNotExists(const char* pDir)
{
if (!XPL_ACCESS(pDir, 0))

View File

@@ -1,7 +1,7 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
@@ -21,6 +21,6 @@ public:
void fillGradient(int left, int top, int right, int bottom, int colorUp, int colorDown);
public:
float field_4;
float field_4 = 0;
};

View File

@@ -1,7 +1,7 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
@@ -30,7 +30,7 @@ void Screen::init(Minecraft* pMinecraft, int a3, int a4)
void Screen::init()
{
}
void Screen::buttonClicked(Button* pButton)
@@ -65,7 +65,7 @@ bool Screen::isInGameScreen()
void Screen::keyPressed(int key)
{
if (key == '\x1B')//escape
if (key == AKEYCODE_MENU)//escape
{
m_pMinecraft->setScreen(nullptr);
}

View File

@@ -128,6 +128,11 @@ void TextInputBox::keyPressed(Minecraft* minecraft, int key)
case AKEYCODE_ARROW_RIGHT:
chr = '\003';
break;
#ifdef USE_SDL
case AKEYCODE_DEL:
chr = '\b';
break;
#endif
}
#endif

View File

@@ -1,7 +1,7 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
@@ -93,7 +93,7 @@ void StartMenuScreen::init()
m_buyButton.m_yPos = yPos;
m_startButton.m_xPos = (m_width - m_startButton.m_width) / 2;
int x1 = m_width - m_joinButton.m_width;
m_joinButton.m_xPos = x1 / 2;

View File

@@ -8,6 +8,8 @@
#include "Controller.hpp"
#include <cmath>
bool Controller::isTouchedValues[2];
float Controller::stickValuesX[2];
float Controller::stickValuesY[2];

View File

@@ -9,6 +9,8 @@
#include "ControllerTurnInput.hpp"
#include "Controller.hpp"
#include <cmath>
ITurnInput::Delta ControllerTurnInput::getTurnDelta()
{
bool isTouched = Controller::isTouched(m_stickNo);

View File

@@ -1,19 +1,28 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
#include "Keyboard.hpp"
#include "GameMods.hpp"
std::vector<Keyboard::Input> Keyboard::_inputs;
int Keyboard::_index = -1;
int Keyboard::_states[256];
int Keyboard::_states[KEYBOARD_STATES_SIZE];
void Keyboard::feed(int down, int key)
{
#ifndef ORIGINAL_CODE
// Prevent Crashes
if (key >= KEYBOARD_STATES_SIZE || key < 0) {
return;
}
#endif
Input i;
i.field_0 = down;
i.field_4 = uint8_t(key);

View File

@@ -1,7 +1,7 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
@@ -9,6 +9,9 @@
#pragma once
#include <vector>
#include <cstdint>
#define KEYBOARD_STATES_SIZE 256
class Keyboard
{
@@ -21,7 +24,7 @@ public:
};
static std::vector<Input> _inputs;
static int _states[256];
static int _states[KEYBOARD_STATES_SIZE];
static int _index;
// likely inlined

View File

@@ -1,7 +1,7 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
@@ -328,7 +328,7 @@ void GameRenderer::setupFog(int i)
float GameRenderer::getFov(float f)
{
Mob* pMob = m_pMinecraft->m_pMobPersp;
float x1 = 70.0f;
if (pMob->isUnderLiquid(Material::water))

View File

@@ -1,7 +1,7 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
@@ -459,14 +459,14 @@ void LevelRenderer::render(Mob* pMob, int a, float b)
if (!a)
field_54 = field_58 = field_5C = field_60 = field_64 = 0;
float mobX1 = pMob->m_pos.x;
float mobX2 = pMob->field_98.x + (pMob->m_pos.x - pMob->field_98.x) * b;
float mobY1 = pMob->m_pos.y;
float mobY2 = pMob->field_98.y + (pMob->m_pos.y - pMob->field_98.y) * b;
float mobZ1 = pMob->m_pos.z;
float mobZ2 = pMob->field_98.z + (pMob->m_pos.z - pMob->field_98.z) * b;
float dX = pMob->m_pos.x - field_4, dY = pMob->m_pos.y - field_8, dZ = pMob->m_pos.z - field_C;
if (dX * dX + dY * dY + dZ * dZ > 16.0f)
@@ -567,7 +567,8 @@ void LevelRenderer::render(Mob* pMob, int a, float b)
y3++;
y2++;
pChunk->field_4E++;
//pChunk->field_4E++;
pChunk->field_4E = true;
if (y3 == x3)
goto label_37;
}
@@ -576,7 +577,7 @@ void LevelRenderer::render(Mob* pMob, int a, float b)
label_26:
y3++;
y2++;
if (y3 == x3)
goto label_37;
@@ -663,7 +664,7 @@ void LevelRenderer::tick()
void LevelRenderer::updateDirtyChunks(Mob* pMob, bool b)
{
// @TODO This updates 16 chunks per frame. Not good.
int updated = 0;
for (int i = 0; i < 16 && i < int(field_88.size()); i++)
{
@@ -1021,7 +1022,7 @@ void LevelRenderer::takePicture(TripodCamera* pCamera, Entity* pOwner)
#ifdef ENH_CAMERA_NO_PARTICLES
g_bDisableParticles = false;
#endif
t_keepPic = -1;
static char str[256];
@@ -1100,7 +1101,7 @@ void LevelRenderer::renderSky(float f)
{
if (m_pMinecraft->m_pLevel->m_pDimension->field_C)
return;
glDisable(GL_TEXTURE_2D);
Vec3 skyColor = m_pLevel->getSkyColor(m_pMinecraft->m_pMobPersp, f);

View File

@@ -9,6 +9,8 @@
#include "RenderList.hpp"
#include "Tesselator.hpp"
#include <cstddef>
constexpr int C_MAX_RENDERS = 3072;
RenderList::RenderList()

View File

@@ -1,7 +1,7 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
@@ -9,6 +9,8 @@
#include "compat/GL.hpp"
#include "Tesselator.hpp"
#include <cstddef>
int dword_2514A4 = 0;
Tesselator Tesselator::instance;

View File

@@ -1,7 +1,7 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
@@ -69,7 +69,7 @@ int Textures::assignTexture(const std::string& name, Texture& texture)
if (texture.field_C)
internalFormat = GL_RGBA;
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, texture.m_width, texture.m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture.m_pixels);
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, texture.m_width, texture.m_height, 0, internalFormat, GL_UNSIGNED_BYTE, texture.m_pixels);
m_textures[name] = textureID;

View File

@@ -63,8 +63,13 @@ void SoundEngine::play(const std::string& name)
SoundDesc sd;
if (m_repository.get(name, sd))
if (m_repository.get(name, sd)) {
#ifdef USE_SDL
m_soundSystem.play(sd, 0, 0, 0, 1, 1, true);
#else
m_soundSystem.playAt(sd, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f);
#endif
}
}
void SoundEngine::play(const std::string& name, float a, float b, float c, float d, float e)
@@ -74,6 +79,11 @@ void SoundEngine::play(const std::string& name, float a, float b, float c, float
SoundDesc sd;
if (m_repository.get(name, sd))
if (m_repository.get(name, sd)) {
#ifdef USE_SDL
m_soundSystem.play(sd, a, b, c, d, e, false);
#else
m_soundSystem.playAt(sd, a, b, c, d, e);
#endif
}
}