mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-20 06:53:30 +00:00
Compare commits
6 Commits
0.6.1-alph
...
0.6.1-alph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
416253ebc7 | ||
|
|
0370944cf6 | ||
|
|
6c22f3bc25 | ||
|
|
d0f6a9b805 | ||
|
|
d0995643a5 | ||
|
|
f82021117c |
@@ -5,7 +5,10 @@ include(cmake/CPM.cmake)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||||
|
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
||||||
|
endif()
|
||||||
|
|
||||||
CPMAddPackage("gh:madler/zlib@1.3.2")
|
CPMAddPackage("gh:madler/zlib@1.3.2")
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ First of all I made it build with CMake (w/o VS2012). Also I fixed some compile
|
|||||||
- [x] Add platform GLFW
|
- [x] Add platform GLFW
|
||||||
- [x] Compile for Linux
|
- [x] Compile for Linux
|
||||||
- [ ] Compile for android aarch64
|
- [ ] Compile for android aarch64
|
||||||
|
- [ ] Rewrite platform logic
|
||||||
|
- [x] Fix sound
|
||||||
|
- [ ] Do a server connection gui
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
## CMake
|
## CMake
|
||||||
|
|||||||
@@ -665,7 +665,12 @@ void Minecraft::tickInput() {
|
|||||||
|
|
||||||
if (e.action == MouseAction::ACTION_WHEEL) {
|
if (e.action == MouseAction::ACTION_WHEEL) {
|
||||||
Inventory* v = player->inventory;
|
Inventory* v = player->inventory;
|
||||||
int numSlots = gui.getNumSlots() - 1;
|
|
||||||
|
int numSlots = gui.getNumSlots();
|
||||||
|
#ifndef PLATFORM_DESKTOP
|
||||||
|
numSlots--;
|
||||||
|
#endif
|
||||||
|
|
||||||
int slot = (v->selected - e.dy + numSlots) % numSlots;
|
int slot = (v->selected - e.dy + numSlots) % numSlots;
|
||||||
v->selectSlot(slot);
|
v->selectSlot(slot);
|
||||||
}
|
}
|
||||||
@@ -692,12 +697,12 @@ void Minecraft::tickInput() {
|
|||||||
if (isPressed) {
|
if (isPressed) {
|
||||||
gui.handleKeyPressed(key);
|
gui.handleKeyPressed(key);
|
||||||
|
|
||||||
#if defined(WIN32) || defined(RPI)//|| defined(_DEBUG) || defined(DEBUG)
|
#if defined(WIN32) || defined(RPI) || defined (PLATFORM_DESKTOP)//|| defined(_DEBUG) || defined(DEBUG)
|
||||||
if (key >= '0' && key <= '9') {
|
if (key >= '0' && key <= '9') {
|
||||||
int digit = key - '0';
|
int digit = key - '0';
|
||||||
int slot = digit - 1;
|
int slot = digit - 1;
|
||||||
|
|
||||||
if (slot >= 0 && slot < gui.getNumSlots()-1)
|
if (slot >= 0 && slot < gui.getNumSlots())
|
||||||
player->inventory->selectSlot(slot);
|
player->inventory->selectSlot(slot);
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
@@ -723,14 +728,8 @@ void Minecraft::tickInput() {
|
|||||||
if (!screen && key == Keyboard::KEY_O || key == 250) {
|
if (!screen && key == Keyboard::KEY_O || key == 250) {
|
||||||
releaseMouse();
|
releaseMouse();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if defined(WIN32)
|
|
||||||
if (key == Keyboard::KEY_F) {
|
|
||||||
options.isFlying = !options.isFlying;
|
|
||||||
player->noPhysics = options.isFlying;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key == Keyboard::KEY_T) {
|
if (key == Keyboard::KEY_F5) {
|
||||||
options.thirdPersonView = !options.thirdPersonView;
|
options.thirdPersonView = !options.thirdPersonView;
|
||||||
/*
|
/*
|
||||||
ImprovedNoise noise;
|
ImprovedNoise noise;
|
||||||
@@ -739,6 +738,25 @@ void Minecraft::tickInput() {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Change distance
|
||||||
|
if (key == Keyboard::KEY_F)
|
||||||
|
options.viewDistance = (options.viewDistance + 1) % 4;
|
||||||
|
#endif
|
||||||
|
#if defined(WIN32)
|
||||||
|
if (key == Keyboard::KEY_F) {
|
||||||
|
options.isFlying = !options.isFlying;
|
||||||
|
player->noPhysics = options.isFlying;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (key == Keyboard::KEY_T) {
|
||||||
|
// options.thirdPersonView = !options.thirdPersonView;
|
||||||
|
// /*
|
||||||
|
// ImprovedNoise noise;
|
||||||
|
// for (int i = 0; i < 16; ++i)
|
||||||
|
// printf("%d\t%f\n", i, noise.grad2(i, 3, 8));
|
||||||
|
// */
|
||||||
|
// }
|
||||||
|
|
||||||
if (key == Keyboard::KEY_O) {
|
if (key == Keyboard::KEY_O) {
|
||||||
useAmbientOcclusion = !useAmbientOcclusion;
|
useAmbientOcclusion = !useAmbientOcclusion;
|
||||||
options.ambientOcclusion = useAmbientOcclusion;
|
options.ambientOcclusion = useAmbientOcclusion;
|
||||||
@@ -873,11 +891,20 @@ void Minecraft::tickInput() {
|
|||||||
|
|
||||||
prevMouseDownLeft = Mouse::isButtonDown(MouseAction::ACTION_LEFT);
|
prevMouseDownLeft = Mouse::isButtonDown(MouseAction::ACTION_LEFT);
|
||||||
|
|
||||||
|
static int buildHoldTicks = 0;
|
||||||
|
|
||||||
// Build and use/interact is on same button
|
// Build and use/interact is on same button
|
||||||
|
// USPESHNO spizheno
|
||||||
if (Mouse::isButtonDown(MouseAction::ACTION_RIGHT)) {
|
if (Mouse::isButtonDown(MouseAction::ACTION_RIGHT)) {
|
||||||
|
if (buildHoldTicks >= 5) buildHoldTicks = 0;
|
||||||
|
|
||||||
|
if (++buildHoldTicks == 1) {
|
||||||
BuildActionIntention bai(BuildActionIntention::BAI_BUILD | BuildActionIntention::BAI_INTERACT);
|
BuildActionIntention bai(BuildActionIntention::BAI_BUILD | BuildActionIntention::BAI_INTERACT);
|
||||||
handleBuildAction(&bai);
|
handleBuildAction(&bai);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
buildHoldTicks = 0;
|
||||||
|
}
|
||||||
|
|
||||||
lastTickTime = getTimeMs();
|
lastTickTime = getTimeMs();
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ void Options::initDefaultValues() {
|
|||||||
keyBuild = KeyMapping("key.inventory", Keyboard::KEY_E);
|
keyBuild = KeyMapping("key.inventory", Keyboard::KEY_E);
|
||||||
keySneak = KeyMapping("key.sneak", Keyboard::KEY_LSHIFT);
|
keySneak = KeyMapping("key.sneak", Keyboard::KEY_LSHIFT);
|
||||||
#ifndef RPI
|
#ifndef RPI
|
||||||
keyCraft = KeyMapping("key.crafting", Keyboard::KEY_Q);
|
// keyCraft = KeyMapping("key.crafting", Keyboard::KEY_Q);
|
||||||
keyDrop = KeyMapping("key.drop", Keyboard::KEY_Q);
|
keyDrop = KeyMapping("key.drop", Keyboard::KEY_Q);
|
||||||
keyChat = KeyMapping("key.chat", Keyboard::KEY_T);
|
keyChat = KeyMapping("key.chat", Keyboard::KEY_T);
|
||||||
keyFog = KeyMapping("key.fog", Keyboard::KEY_F);
|
keyFog = KeyMapping("key.fog", Keyboard::KEY_F);
|
||||||
@@ -115,10 +115,11 @@ void Options::initDefaultValues() {
|
|||||||
keyMenuCancel.key = 4;
|
keyMenuCancel.key = 4;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PLATFORM_DESKTOP) || defined(RPI)
|
||||||
|
sensitivity *= 0.4f;
|
||||||
|
#endif
|
||||||
#if defined(RPI)
|
#if defined(RPI)
|
||||||
username = "StevePi";
|
username = "StevePi";
|
||||||
sensitivity *= 0.4f;
|
|
||||||
useMouseForDigging = true;
|
useMouseForDigging = true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Gui.h"
|
#include "Gui.h"
|
||||||
#include "Font.h"
|
#include "Font.h"
|
||||||
|
#include "client/Options.h"
|
||||||
#include "screens/IngameBlockSelectionScreen.h"
|
#include "screens/IngameBlockSelectionScreen.h"
|
||||||
#include "../Minecraft.h"
|
#include "../Minecraft.h"
|
||||||
#include "../player/LocalPlayer.h"
|
#include "../player/LocalPlayer.h"
|
||||||
@@ -106,12 +107,6 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
|||||||
|
|
||||||
renderToolBar(a, ySlot, screenWidth);
|
renderToolBar(a, ySlot, screenWidth);
|
||||||
|
|
||||||
|
|
||||||
//font->drawShadow(APP_NAME, 2, 2, 0xffffffff);
|
|
||||||
//font->drawShadow("This is a demo, not the finished product", 2, 10 + 2, 0xffffffff);
|
|
||||||
#ifdef APPLE_DEMO_PROMOTION
|
|
||||||
font->drawShadow("Demo version", 2, 0 + 2, 0xffffffff);
|
|
||||||
#endif /*APPLE_DEMO_PROMOTION*/
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
unsigned int max = 10;
|
unsigned int max = 10;
|
||||||
bool isChatting = false;
|
bool isChatting = false;
|
||||||
@@ -123,9 +118,6 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
|||||||
renderDebugInfo();
|
renderDebugInfo();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// glPopMatrix2();
|
|
||||||
//
|
|
||||||
// glEnable(GL_ALPHA_TEST);
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glEnable2(GL_ALPHA_TEST);
|
glEnable2(GL_ALPHA_TEST);
|
||||||
}
|
}
|
||||||
@@ -188,11 +180,13 @@ void Gui::handleClick(int button, int x, int y) {
|
|||||||
int slot = getSlotIdAt(x, y);
|
int slot = getSlotIdAt(x, y);
|
||||||
if (slot != -1)
|
if (slot != -1)
|
||||||
{
|
{
|
||||||
|
#ifndef PLATFORM_DESKTOP
|
||||||
if (slot == (getNumSlots()-1))
|
if (slot == (getNumSlots()-1))
|
||||||
{
|
{
|
||||||
minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
minecraft->player->inventory->selectSlot(slot);
|
minecraft->player->inventory->selectSlot(slot);
|
||||||
itemNameOverlayTime = 0;
|
itemNameOverlayTime = 0;
|
||||||
@@ -220,6 +214,10 @@ void Gui::handleKeyPressed(int key)
|
|||||||
{
|
{
|
||||||
minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
||||||
}
|
}
|
||||||
|
else if (key == minecraft->options.keyDrop.key)
|
||||||
|
{
|
||||||
|
minecraft->player->inventory->dropSlot(minecraft->player->inventory->selected, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::tick() {
|
void Gui::tick() {
|
||||||
@@ -395,6 +393,7 @@ void Gui::onConfigChanged( const Config& c ) {
|
|||||||
//LOGI("x,y: %f, %f\n", xx, yy);
|
//LOGI("x,y: %f, %f\n", xx, yy);
|
||||||
}
|
}
|
||||||
rcFeedbackInner = t.end(true, rcFeedbackInner.vboId);
|
rcFeedbackInner = t.end(true, rcFeedbackInner.vboId);
|
||||||
|
|
||||||
if (c.minecraft->useTouchscreen()) {
|
if (c.minecraft->useTouchscreen()) {
|
||||||
// I'll bump this up to 6.
|
// I'll bump this up to 6.
|
||||||
int num = 6; // without "..." dots
|
int num = 6; // without "..." dots
|
||||||
@@ -452,9 +451,16 @@ void Gui::tickItemDrop()
|
|||||||
// Handle item drop
|
// Handle item drop
|
||||||
static bool isCurrentlyActive = false;
|
static bool isCurrentlyActive = false;
|
||||||
isCurrentlyActive = false;
|
isCurrentlyActive = false;
|
||||||
|
|
||||||
|
int slots = getNumSlots();
|
||||||
|
|
||||||
|
#ifndef PLATFORM_DESKTOP
|
||||||
|
slots--;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (Mouse::isButtonDown(MouseAction::ACTION_LEFT)) {
|
if (Mouse::isButtonDown(MouseAction::ACTION_LEFT)) {
|
||||||
int slot = getSlotIdAt(Mouse::getX(), Mouse::getY());
|
int slot = getSlotIdAt(Mouse::getX(), Mouse::getY());
|
||||||
if (slot >= 0 && slot < getNumSlots()-1) {
|
if (slot >= 0 && slot < slots) {
|
||||||
if (slot != _currentDropSlot) {
|
if (slot != _currentDropSlot) {
|
||||||
_currentDropTicks = 0;
|
_currentDropTicks = 0;
|
||||||
_currentDropSlot = slot;
|
_currentDropSlot = slot;
|
||||||
@@ -756,20 +762,24 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
|||||||
t.beginOverride();
|
t.beginOverride();
|
||||||
|
|
||||||
float x = baseItemX;
|
float x = baseItemX;
|
||||||
for (int i = 0; i < getNumSlots()-1; i++) {
|
|
||||||
|
int slots = getNumSlots();
|
||||||
|
|
||||||
|
// TODO: if using touchscreen
|
||||||
|
|
||||||
|
#ifndef PLATFORM_DESKTOP
|
||||||
|
slots--;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int i = 0; i < slots; i++) {
|
||||||
renderSlot(i, (int)x, ySlot, a);
|
renderSlot(i, (int)x, ySlot, a);
|
||||||
x += 20;
|
x += 20;
|
||||||
}
|
}
|
||||||
_inventoryNeedsUpdate = false;
|
_inventoryNeedsUpdate = false;
|
||||||
//_inventoryRc = t.end(_inventoryRc.vboId);
|
|
||||||
|
|
||||||
//drawArrayVTC(_inventoryRc.vboId, _inventoryRc.vertexCount);
|
#ifndef PLATFORM_DESKTOP
|
||||||
|
|
||||||
//renderSlotWatch.stop();
|
|
||||||
//renderSlotWatch.printEvery(100, "Render slots:");
|
|
||||||
|
|
||||||
//int x = screenWidth / 2 + getNumSlots() * 10 + (getNumSlots()-1) * 20 + 2;
|
|
||||||
blit(screenWidth / 2 + 10 * getNumSlots() - 20 + 4, ySlot + 6, 242, 252, 14, 4, 14, 4);
|
blit(screenWidth / 2 + 10 * getNumSlots() - 20 + 4, ySlot + 6, 242, 252, 14, 4, 14, 4);
|
||||||
|
#endif
|
||||||
|
|
||||||
minecraft->textures->loadAndBindTexture("gui/gui_blocks.png");
|
minecraft->textures->loadAndBindTexture("gui/gui_blocks.png");
|
||||||
t.endOverrideAndDraw();
|
t.endOverrideAndDraw();
|
||||||
@@ -779,7 +789,7 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
|||||||
glDisable2(GL_TEXTURE_2D);
|
glDisable2(GL_TEXTURE_2D);
|
||||||
t.beginOverride();
|
t.beginOverride();
|
||||||
x = baseItemX;
|
x = baseItemX;
|
||||||
for (int i = 0; i < getNumSlots()-1; i++) {
|
for (int i = 0; i < slots; i++) {
|
||||||
ItemRenderer::renderGuiItemDecorations(minecraft->player->inventory->getItem(i), x, (float)ySlot);
|
ItemRenderer::renderGuiItemDecorations(minecraft->player->inventory->getItem(i), x, (float)ySlot);
|
||||||
x += 20;
|
x += 20;
|
||||||
}
|
}
|
||||||
@@ -799,7 +809,7 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
|||||||
t.beginOverride();
|
t.beginOverride();
|
||||||
if (minecraft->gameMode->isSurvivalType()) {
|
if (minecraft->gameMode->isSurvivalType()) {
|
||||||
x = baseItemX;
|
x = baseItemX;
|
||||||
for (int i = 0; i < getNumSlots()-1; i++) {
|
for (int i = 0; i < slots; i++) {
|
||||||
ItemInstance* item = minecraft->player->inventory->getItem(i);
|
ItemInstance* item = minecraft->player->inventory->getItem(i);
|
||||||
if (item && item->count >= 0)
|
if (item && item->count >= 0)
|
||||||
renderSlotText(item, k*x, k*ySlot + 1, true, true);
|
renderSlotText(item, k*x, k*ySlot + 1, true, true);
|
||||||
|
|||||||
@@ -425,13 +425,23 @@ void SelectWorldScreen::render( int xm, int ym, float a )
|
|||||||
//Performance::watches.get("sws-worlds").start();
|
//Performance::watches.get("sws-worlds").start();
|
||||||
|
|
||||||
worldsList->setComponentSelected(bWorldView.selected);
|
worldsList->setComponentSelected(bWorldView.selected);
|
||||||
|
// #ifdef PLATFORM_DESKTOP
|
||||||
|
|
||||||
|
// We should add scrolling with mouse wheel but currently i dont know how to implement it
|
||||||
if (_mouseHasBeenUp)
|
if (_mouseHasBeenUp)
|
||||||
worldsList->render(xm, ym, a);
|
worldsList->render(xm, ym, a);
|
||||||
else {
|
else {
|
||||||
worldsList->render(0, 0, a);
|
worldsList->render(0, 0, a);
|
||||||
_mouseHasBeenUp = !Mouse::getButtonState(MouseAction::ACTION_LEFT);
|
_mouseHasBeenUp = !Mouse::getButtonState(MouseAction::ACTION_LEFT);
|
||||||
}
|
}
|
||||||
|
// #else
|
||||||
|
// if (_mouseHasBeenUp)
|
||||||
|
// worldsList->render(xm, ym, a);
|
||||||
|
// else {
|
||||||
|
// worldsList->render(0, 0, a);
|
||||||
|
// _mouseHasBeenUp = !Mouse::getButtonState(MouseAction::ACTION_LEFT);
|
||||||
|
// }
|
||||||
|
// #endif
|
||||||
|
|
||||||
//Performance::watches.get("sws-worlds").stop();
|
//Performance::watches.get("sws-worlds").stop();
|
||||||
//Performance::watches.get("sws-screen").start();
|
//Performance::watches.get("sws-screen").start();
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "../../../../world/level/Level.h"
|
#include "../../../../world/level/Level.h"
|
||||||
#include "../../../../world/item/DyePowderItem.h"
|
#include "../../../../world/item/DyePowderItem.h"
|
||||||
#include "../../../../world/item/crafting/Recipe.h"
|
#include "../../../../world/item/crafting/Recipe.h"
|
||||||
|
#include "platform/input/Keyboard.h"
|
||||||
|
|
||||||
static NinePatchLayer* guiPaneFrame = NULL;
|
static NinePatchLayer* guiPaneFrame = NULL;
|
||||||
|
|
||||||
@@ -420,7 +421,7 @@ void PaneCraftingScreen::clearCategoryItems()
|
|||||||
|
|
||||||
void PaneCraftingScreen::keyPressed( int eventKey )
|
void PaneCraftingScreen::keyPressed( int eventKey )
|
||||||
{
|
{
|
||||||
if (eventKey == Keyboard::KEY_ESCAPE) {
|
if (eventKey == Keyboard::KEY_ESCAPE || eventKey == Keyboard::KEY_E) {
|
||||||
minecraft->setScreen(NULL);
|
minecraft->setScreen(NULL);
|
||||||
//minecraft->grabMouse();
|
//minecraft->grabMouse();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ public:
|
|||||||
|
|
||||||
void destroy() const {
|
void destroy() const {
|
||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
delete buffer;
|
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,14 +230,11 @@ void SoundEngine::playUI(const std::string& name, float volume, float pitch) {}
|
|||||||
void SoundEngine::play(const std::string& name, float x, float y, float z, float volume, float pitch) {
|
void SoundEngine::play(const std::string& name, float x, float y, float z, float volume, float pitch) {
|
||||||
if ((volume *= options->sound) <= 0) return;
|
if ((volume *= options->sound) <= 0) return;
|
||||||
|
|
||||||
volume = Mth::clamp( volume * _getVolumeMult(x, y, z), 0.0f, 1.0f);
|
volume = Mth::clamp(volume, 0.0f, 1.0f);
|
||||||
if (/*!loaded || */options->sound == 0 || volume <= 0) return;
|
|
||||||
|
|
||||||
SoundDesc sound;
|
SoundDesc sound;
|
||||||
if (sounds.get(name, sound)) {
|
if (sounds.get(name, sound)) {
|
||||||
float dist = SOUND_DISTANCE;
|
soundSystem.playAt(sound, x-_x, y-_y, z-_z, volume, pitch);
|
||||||
if (volume > 1) dist *= volume;
|
|
||||||
soundSystem.playAt(sound, x, y, z, volume, pitch);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SoundEngine::playUI(const std::string& name, float volume, float pitch) {
|
void SoundEngine::playUI(const std::string& name, float volume, float pitch) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#if defined(ANDROID) && !defined(PRE_ANDROID23)
|
#if defined(ANDROID) && !defined(PRE_ANDROID23)
|
||||||
#include "../../platform/audio/SoundSystemSL.h"
|
#include "../../platform/audio/SoundSystemSL.h"
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__) || defined (PLATFORM_DESKTOP)
|
||||||
#include "../../platform/audio/SoundSystemAL.h"
|
#include "../../platform/audio/SoundSystemAL.h"
|
||||||
#else
|
#else
|
||||||
#include "../../platform/audio/SoundSystem.h"
|
#include "../../platform/audio/SoundSystem.h"
|
||||||
@@ -23,7 +23,7 @@ class SoundEngine
|
|||||||
|
|
||||||
#if defined(ANDROID) && !defined(PRE_ANDROID23) && !defined(RPI)
|
#if defined(ANDROID) && !defined(PRE_ANDROID23) && !defined(RPI)
|
||||||
SoundSystemSL soundSystem;
|
SoundSystemSL soundSystem;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__) || defined (PLATFORM_DESKTOP)
|
||||||
SoundSystemAL soundSystem;
|
SoundSystemAL soundSystem;
|
||||||
#else
|
#else
|
||||||
SoundSystem soundSystem;
|
SoundSystem soundSystem;
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
#ifndef MAIN_GLFW_H__
|
#ifndef MAIN_GLFW_H__
|
||||||
#define MAIN_GLFW_H__
|
#define MAIN_GLFW_H__
|
||||||
|
|
||||||
|
#include "App.h"
|
||||||
#include "GLFW/glfw3.h"
|
#include "GLFW/glfw3.h"
|
||||||
#include "client/renderer/gles.h"
|
#include "client/renderer/gles.h"
|
||||||
#include "SharedConstants.h"
|
#include "SharedConstants.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include "platform/input/Keyboard.h"
|
||||||
#include "platform/input/Mouse.h"
|
#include "platform/input/Mouse.h"
|
||||||
#include "platform/input/Multitouch.h"
|
#include "platform/input/Multitouch.h"
|
||||||
#include "util/Mth.h"
|
#include "util/Mth.h"
|
||||||
@@ -22,6 +24,7 @@ int transformKey(int glfwkey) {
|
|||||||
case GLFW_KEY_ESCAPE: return Keyboard::KEY_ESCAPE;
|
case GLFW_KEY_ESCAPE: return Keyboard::KEY_ESCAPE;
|
||||||
case GLFW_KEY_BACKSPACE: return Keyboard::KEY_BACKSPACE;
|
case GLFW_KEY_BACKSPACE: return Keyboard::KEY_BACKSPACE;
|
||||||
case GLFW_KEY_LEFT_SHIFT: return Keyboard::KEY_LSHIFT;
|
case GLFW_KEY_LEFT_SHIFT: return Keyboard::KEY_LSHIFT;
|
||||||
|
case GLFW_KEY_ENTER: return Keyboard::KEY_RETURN;
|
||||||
default: return glfwkey;
|
default: return glfwkey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,8 +108,8 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
|
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||||
|
|
||||||
GLFWwindow* window = glfwCreateWindow(appContext.platform->getScreenWidth(), appContext.platform->getScreenHeight(), "main", NULL, NULL);
|
GLFWwindow* window = glfwCreateWindow(appContext.platform->getScreenWidth(), appContext.platform->getScreenHeight(), "main", NULL, NULL);
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ void SoundSystemAL::playAt( const SoundDesc& sound, float x, float y, float z, f
|
|||||||
{
|
{
|
||||||
if (pitch < 0.01f) pitch = 1;
|
if (pitch < 0.01f) pitch = 1;
|
||||||
|
|
||||||
//LOGI("playing sound '%s' with volume/pitch: %f, %f @ %f, %f, %f\n", sound.name.c_str(), volume, pitch, x, y, z);
|
LOGI("playing sound '%s' with volume/pitch: %f, %f @ %f, %f, %f\n", sound.name.c_str(), volume, pitch, x, y, z);
|
||||||
|
|
||||||
ALuint bufferID;
|
ALuint bufferID;
|
||||||
if (!getBufferId(sound, &bufferID)) {
|
if (!getBufferId(sound, &bufferID)) {
|
||||||
@@ -151,7 +151,7 @@ void SoundSystemAL::playAt( const SoundDesc& sound, float x, float y, float z, f
|
|||||||
}
|
}
|
||||||
errIdString = "Get buffer";
|
errIdString = "Get buffer";
|
||||||
checkError();
|
checkError();
|
||||||
//LOGI("playing sound %d - '%s' with volume/pitch: %f, %f @ %f, %f, %f\n", bufferID, sound.name.c_str(), volume, pitch, x, y, z);
|
LOGI("playing sound %d - '%s' with volume/pitch: %f, %f @ %f, %f, %f\n", bufferID, sound.name.c_str(), volume, pitch, x, y, z);
|
||||||
|
|
||||||
int sourceIndex;
|
int sourceIndex;
|
||||||
errIdString = "Get free index";
|
errIdString = "Get free index";
|
||||||
@@ -232,12 +232,12 @@ bool SoundSystemAL::getBufferId(const SoundDesc& sound, ALuint* buf) {
|
|||||||
: (sound.channels==2? AL_FORMAT_STEREO8 : AL_FORMAT_MONO8);
|
: (sound.channels==2? AL_FORMAT_STEREO8 : AL_FORMAT_MONO8);
|
||||||
|
|
||||||
alBufferData(bufferID, format, sound.frames, sound.size, sound.frameRate);
|
alBufferData(bufferID, format, sound.frames, sound.size, sound.frameRate);
|
||||||
//LOGI("Creating %d (%p) from sound: '%s'\n", bufferID, sound.frames, sound.name.c_str());
|
LOGI("Creating %d (%p) from sound: '%s'\n", bufferID, sound.frames, sound.name.c_str());
|
||||||
errIdString = "Buffer data";
|
errIdString = "Buffer data";
|
||||||
//LOGI("Creating buffer with data: %d (%d), %p, %d, %d\n", format, sound.byteWidth, sound.frames, sound.size, sound.frameRate);
|
LOGI("Creating buffer with data: %d (%d), %p, %d, %d\n", format, sound.byteWidth, sound.frames, sound.size, sound.frameRate);
|
||||||
checkError();
|
checkError();
|
||||||
|
|
||||||
//LOGI("Sound ch: %d, fmt: %d, frames: %p, len: %f, fr: %d, sz: %d, numfr: %d\n", sound.channels, format, sound.frames, sound.length(), sound.frameRate, sound.size, sound.numFrames);
|
LOGI("Sound ch: %d, fmt: %d, frames: %p, len: %f, fr: %d, sz: %d, numfr: %d\n", sound.channels, format, sound.frames, sound.length(), sound.frameRate, sound.size, sound.numFrames);
|
||||||
|
|
||||||
|
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
|
|||||||
Reference in New Issue
Block a user