forked from Kolyah35/minecraft-pe-0.6.1
server compilable
This commit is contained in:
@@ -44,7 +44,7 @@ private:
|
||||
range(b);
|
||||
range(a);
|
||||
}
|
||||
__inline void range(GLfloat& v) {
|
||||
inline void range(GLfloat& v) {
|
||||
if (v < 0) v = 0;
|
||||
if (v > 1) v = 1;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "culling/AllowAllCuller.h"
|
||||
#include "culling/FrustumCuller.h"
|
||||
#include "entity/EntityRenderDispatcher.h"
|
||||
#include "../Minecraft.h"
|
||||
#include <Minecraft.h>
|
||||
#include "../gamemode/GameMode.h"
|
||||
#include "../particle/ParticleEngine.h"
|
||||
#include "../player/LocalPlayer.h"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "entity/EntityRenderDispatcher.h"
|
||||
#include "entity/EntityRenderer.h"
|
||||
#include "entity/MobRenderer.h"
|
||||
#include "../Minecraft.h"
|
||||
#include <Minecraft.h>
|
||||
#include "../player/LocalPlayer.h"
|
||||
#include "../../world/entity/player/Player.h"
|
||||
#include "../../world/item/Item.h"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "DistanceChunkSorter.h"
|
||||
#include "Chunk.h"
|
||||
#include "TileRenderer.h"
|
||||
#include "../Minecraft.h"
|
||||
#include <Minecraft.h>
|
||||
#include "../../util/Mth.h"
|
||||
#include "../../world/entity/player/Player.h"
|
||||
#include "../../world/level/tile/LevelEvent.h"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "gles.h"
|
||||
#include <vector>
|
||||
|
||||
class Minecraft;
|
||||
class MinecraftClient;
|
||||
class Textures;
|
||||
class Culler;
|
||||
class Chunk;
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
float zOld;
|
||||
float destroyProgress;
|
||||
|
||||
LevelRenderer(Minecraft* mc);
|
||||
LevelRenderer(MinecraftClient& mc);
|
||||
~LevelRenderer();
|
||||
|
||||
void setLevel(Level* level);
|
||||
@@ -77,7 +77,7 @@ private:
|
||||
void resortChunks(int xc, int yc, int zc);
|
||||
void deleteChunks();
|
||||
//void checkQueryResults(int from, int to);
|
||||
__inline int getLinearCoord(int x, int y, int z) {
|
||||
inline int getLinearCoord(int x, int y, int z) {
|
||||
return (z * yChunks + y) * xChunks + x;
|
||||
}
|
||||
int noEntityRenderFrames;
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
void add(int list);
|
||||
void addR(const RenderChunk& chunk);
|
||||
|
||||
__inline void next() { ++listIndex; }
|
||||
inline void next() { ++listIndex; }
|
||||
|
||||
void render();
|
||||
void renderChunks();
|
||||
|
||||
@@ -72,18 +72,18 @@ public:
|
||||
|
||||
int getColor();
|
||||
|
||||
__inline void beginOverride() {
|
||||
inline void beginOverride() {
|
||||
begin();
|
||||
voidBeginAndEndCalls(true);
|
||||
}
|
||||
__inline void endOverrideAndDraw() {
|
||||
inline void endOverrideAndDraw() {
|
||||
voidBeginAndEndCalls(false);
|
||||
draw();
|
||||
}
|
||||
__inline bool isOverridden() {
|
||||
inline bool isOverridden() {
|
||||
return _voidBeginEnd;
|
||||
}
|
||||
__inline RenderChunk endOverride(int bufferId) {
|
||||
inline RenderChunk endOverride(int bufferId) {
|
||||
voidBeginAndEndCalls(false);
|
||||
return end(true, bufferId);
|
||||
}
|
||||
|
||||
@@ -4,34 +4,20 @@
|
||||
#include "ptexture/DynamicTexture.h"
|
||||
#include "../Options.h"
|
||||
#include "../../platform/time.h"
|
||||
#include "../../AppPlatform.h"
|
||||
#include "../../util/StringUtils.h"
|
||||
|
||||
/*static*/ int Textures::textureChanges = 0;
|
||||
/*static*/ bool Textures::MIPMAP = false;
|
||||
/*static*/ const TextureId Textures::InvalidId = -1;
|
||||
|
||||
Textures::Textures( Options* options_, AppPlatform* platform_ )
|
||||
: clamp(false),
|
||||
blur(false),
|
||||
options(options_),
|
||||
platform(platform_),
|
||||
lastBoundTexture(Textures::InvalidId)
|
||||
{
|
||||
}
|
||||
|
||||
Textures::~Textures()
|
||||
{
|
||||
Textures::~Textures() {
|
||||
clear();
|
||||
|
||||
for (unsigned int i = 0; i < dynamicTextures.size(); ++i)
|
||||
delete dynamicTextures[i];
|
||||
}
|
||||
|
||||
void Textures::clear()
|
||||
{
|
||||
void Textures::clear() {
|
||||
for (TextureMap::iterator it = idMap.begin(); it != idMap.end(); ++it) {
|
||||
if (it->second != Textures::InvalidId)
|
||||
if (it->second != TEXTURES_INVALID_ID)
|
||||
glDeleteTextures(1, &it->second);
|
||||
}
|
||||
for (TextureImageMap::iterator it = loadedImages.begin(); it != loadedImages.end(); ++it) {
|
||||
@@ -41,7 +27,7 @@ void Textures::clear()
|
||||
idMap.clear();
|
||||
loadedImages.clear();
|
||||
|
||||
lastBoundTexture = Textures::InvalidId;
|
||||
lastBoundTexture = TEXTURES_INVALID_ID;
|
||||
}
|
||||
|
||||
TextureId Textures::loadAndBindTexture( const std::string& resourceName )
|
||||
@@ -51,7 +37,7 @@ TextureId Textures::loadAndBindTexture( const std::string& resourceName )
|
||||
//t.start();
|
||||
TextureId id = loadTexture(resourceName);
|
||||
//t.stop();
|
||||
if (id != Textures::InvalidId)
|
||||
if (id != TEXTURES_INVALID_ID)
|
||||
bind(id);
|
||||
|
||||
//t.printEvery(1000);
|
||||
@@ -59,25 +45,24 @@ TextureId Textures::loadAndBindTexture( const std::string& resourceName )
|
||||
return id;
|
||||
}
|
||||
|
||||
TextureId Textures::loadTexture( const std::string& resourceName, bool inTextureFolder /* = true */ )
|
||||
{
|
||||
TextureId Textures::loadTexture(const std::string& resourceName, bool inTextureFolder) {
|
||||
TextureMap::iterator it = idMap.find(resourceName);
|
||||
if (it != idMap.end())
|
||||
return it->second;
|
||||
|
||||
bool isUrl = Util::startsWith(resourceName, "http://") || Util::startsWith(resourceName, "https://");
|
||||
TextureData texdata = platform->loadTexture(resourceName, isUrl ? false : inTextureFolder);
|
||||
TextureData texdata = m_platform.loadTexture(resourceName, isUrl ? false : inTextureFolder);
|
||||
if (texdata.data)
|
||||
return assignTexture(resourceName, texdata);
|
||||
else if (texdata.identifier != InvalidId) {
|
||||
else if (texdata.identifier != TEXTURES_INVALID_ID) {
|
||||
//LOGI("Adding id: %d for %s\n", texdata.identifier, resourceName.c_str());
|
||||
idMap.insert(std::make_pair(resourceName, texdata.identifier));
|
||||
}
|
||||
else {
|
||||
idMap.insert(std::make_pair(resourceName, Textures::InvalidId));
|
||||
idMap.insert(std::make_pair(resourceName, TEXTURES_INVALID_ID));
|
||||
//loadedImages.insert(std::make_pair(InvalidId, texdata));
|
||||
}
|
||||
return Textures::InvalidId;
|
||||
return TEXTURES_INVALID_ID;
|
||||
}
|
||||
|
||||
TextureId Textures::assignTexture( const std::string& resourceName, const TextureData& img )
|
||||
@@ -87,13 +72,14 @@ TextureId Textures::assignTexture( const std::string& resourceName, const Textur
|
||||
|
||||
bind(id);
|
||||
|
||||
if (MIPMAP) {
|
||||
#ifdef TEXTURES_MIPMAP
|
||||
glTexParameteri2(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri2(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
} else {
|
||||
#else
|
||||
glTexParameteri2(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri2(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (blur) {
|
||||
glTexParameteri2(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri2(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <IPlatform.h>
|
||||
#include "gles.h"
|
||||
#include "TextureData.h"
|
||||
|
||||
#define TEXTURES_INVALID_ID -1
|
||||
#define TEXTURES_MIPMAP 0
|
||||
|
||||
class DynamicTexture;
|
||||
class Options;
|
||||
class AppPlatform;
|
||||
@@ -24,20 +28,21 @@ typedef std::map<TextureId, TextureData> TextureImageMap;
|
||||
class Textures
|
||||
{
|
||||
public:
|
||||
Textures(Options* options_, AppPlatform* platform_);
|
||||
Textures(Options& options, IPlatform& platform) : m_options(options), m_platform(platform) {}
|
||||
~Textures();
|
||||
|
||||
void addDynamicTexture(DynamicTexture* dynamicTexture);
|
||||
|
||||
__inline void bind(TextureId id) {
|
||||
if (id != Textures::InvalidId && lastBoundTexture != id) {
|
||||
inline void bind(TextureId id) {
|
||||
if (id != TEXTURES_INVALID_ID && lastBoundTexture != id) {
|
||||
glBindTexture2(GL_TEXTURE_2D, id);
|
||||
lastBoundTexture = id;
|
||||
++textureChanges;
|
||||
} else if (id == Textures::InvalidId){
|
||||
} else if (id == TEXTURES_INVALID_ID){
|
||||
LOGI("invalidId!\n");
|
||||
}
|
||||
}
|
||||
|
||||
TextureId loadTexture(const std::string& resourceName, bool inTextureFolder = true);
|
||||
TextureId loadAndBindTexture(const std::string& resourceName);
|
||||
|
||||
@@ -49,28 +54,26 @@ public:
|
||||
void clear();
|
||||
void reloadAll();
|
||||
|
||||
__inline static bool isTextureIdValid(TextureId t) { return t != Textures::InvalidId; }
|
||||
inline static bool isTextureIdValid(TextureId t) { return t != TEXTURES_INVALID_ID; }
|
||||
|
||||
private:
|
||||
int smoothBlend(int c0, int c1);
|
||||
int crispBlend(int c0, int c1);
|
||||
|
||||
public:
|
||||
static bool MIPMAP;
|
||||
static int textureChanges;
|
||||
static const TextureId InvalidId;
|
||||
|
||||
private:
|
||||
TextureMap idMap;
|
||||
TextureImageMap loadedImages;
|
||||
|
||||
Options* options;
|
||||
AppPlatform* platform;
|
||||
Options& m_options;
|
||||
IPlatform& m_platform;
|
||||
|
||||
bool clamp;
|
||||
bool blur;
|
||||
bool clamp = false;
|
||||
bool blur = false;
|
||||
|
||||
int lastBoundTexture;
|
||||
int lastBoundTexture = TEXTURES_INVALID_ID;
|
||||
std::vector<DynamicTexture*> dynamicTextures;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "TileRenderer.h"
|
||||
#include "Chunk.h"
|
||||
#include "../Minecraft.h"
|
||||
#include <Minecraft.h>
|
||||
#include "Tesselator.h"
|
||||
|
||||
#include "../../world/level/LevelSource.h"
|
||||
|
||||
Reference in New Issue
Block a user