mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-24 16:24:11 +00:00
203 lines
5 KiB
C++
203 lines
5 KiB
C++
#pragma once
|
|
class Minecraft;
|
|
class Entity;
|
|
class Random;
|
|
class FloatBuffer;
|
|
class ItemInHandRenderer;
|
|
class DataLayer;
|
|
class SparseLightStorage;
|
|
class CompressedTileStorage;
|
|
class SparseDataStorage;
|
|
|
|
#include "../../Minecraft.World/Util/SmoothFloat.h"
|
|
#include "../../Minecraft.World/Util/C4JThread.h"
|
|
#include "../Textures/ResourceLocation.h"
|
|
|
|
class GameRenderer {
|
|
private:
|
|
static ResourceLocation RAIN_LOCATION;
|
|
static ResourceLocation SNOW_LOCATION;
|
|
|
|
public:
|
|
static bool anaglyph3d;
|
|
static int anaglyphPass;
|
|
|
|
private:
|
|
Minecraft* mc;
|
|
float renderDistance;
|
|
|
|
public:
|
|
ItemInHandRenderer* itemInHandRenderer;
|
|
|
|
private:
|
|
int _tick;
|
|
std::shared_ptr<Entity> hovered;
|
|
|
|
// smooth camera movement
|
|
SmoothFloat smoothTurnX;
|
|
SmoothFloat smoothTurnY;
|
|
|
|
// third-person distance etc
|
|
SmoothFloat smoothDistance;
|
|
SmoothFloat smoothRotation;
|
|
SmoothFloat smoothTilt;
|
|
SmoothFloat smoothRoll;
|
|
float thirdDistance;
|
|
float thirdDistanceO;
|
|
float thirdRotation;
|
|
float thirdRotationO;
|
|
float thirdTilt;
|
|
float thirdTiltO;
|
|
float accumulatedSmoothXO, accumulatedSmoothYO;
|
|
float tickSmoothXO, tickSmoothYO, lastTickA;
|
|
Vec3* cameraPos; // 4J added
|
|
|
|
// fov modification
|
|
float fovOffset;
|
|
float fovOffsetO;
|
|
|
|
// roll modification
|
|
float cameraRoll;
|
|
float cameraRollO;
|
|
|
|
// 4J - changes brought forward from 1.8.2
|
|
static const int NUM_LIGHT_TEXTURES = 4; // * 3;
|
|
int lightTexture[NUM_LIGHT_TEXTURES]; // 4J - changed so that we have one
|
|
// lightTexture per level, to support
|
|
// split screen
|
|
int getLightTexture(int iPad, Level* level); // 4J added
|
|
intArray lightPixels[NUM_LIGHT_TEXTURES];
|
|
|
|
float fov[4];
|
|
float oFov[4];
|
|
float tFov[4];
|
|
|
|
float darkenWorldAmount;
|
|
float darkenWorldAmountO;
|
|
|
|
bool isInClouds;
|
|
|
|
float m_fov;
|
|
|
|
public:
|
|
GameRenderer(Minecraft* mc);
|
|
~GameRenderer();
|
|
void SetFovVal(float fov);
|
|
float GetFovVal();
|
|
|
|
public:
|
|
void tick(bool bFirst);
|
|
void pick(float a);
|
|
|
|
private:
|
|
void tickFov();
|
|
float getFov(float a, bool applyEffects);
|
|
void bobHurt(float a);
|
|
void bobView(float a);
|
|
void moveCameraToPlayer(float a);
|
|
double zoom;
|
|
double zoom_x;
|
|
double zoom_y;
|
|
|
|
public:
|
|
void zoomRegion(double zoom, double xa, double ya);
|
|
void unZoomRegion();
|
|
|
|
private:
|
|
void getFovAndAspect(float& fov, float& aspect, float a,
|
|
bool applyEffects); // 4J added
|
|
public:
|
|
void setupCamera(float a, int eye);
|
|
|
|
private:
|
|
void renderItemInHand(float a, int eye);
|
|
int64_t lastActiveTime;
|
|
int64_t lastNsTime;
|
|
// 4J - changes brought forward from 1.8.2
|
|
bool _updateLightTexture;
|
|
|
|
public:
|
|
float blr;
|
|
float blrt;
|
|
float blg;
|
|
float blgt;
|
|
void turnOffLightLayer(double alpha);
|
|
void turnOnLightLayer(
|
|
double alpha,
|
|
bool scaleLight =
|
|
false); // 4jcraft: added scaleLight for entity lighting
|
|
|
|
private:
|
|
void tickLightTexture();
|
|
void updateLightTexture(float a);
|
|
float getNightVisionScale(std::shared_ptr<Player> player, float a);
|
|
|
|
public:
|
|
void render(float a, bool bFirst); // 4J added bFirst
|
|
void renderLevel(float a);
|
|
void renderLevel(float a, __int64 until);
|
|
|
|
private:
|
|
Random* random;
|
|
int rainSoundTime;
|
|
void prepareAndRenderClouds(LevelRenderer* levelRenderer, float a);
|
|
void tickRain();
|
|
|
|
private:
|
|
// 4J - brought forward from 1.8.2
|
|
float* rainXa;
|
|
float* rainZa;
|
|
|
|
protected:
|
|
void renderSnowAndRain(float a);
|
|
volatile int xMod;
|
|
volatile int yMod;
|
|
|
|
public:
|
|
void setupGuiScreen(
|
|
int forceScale = -1); // 4J - added forceScale parameter
|
|
|
|
FloatBuffer* lb;
|
|
float fr;
|
|
float fg;
|
|
float fb;
|
|
|
|
private:
|
|
void setupClearColor(float a);
|
|
float fogBrO, fogBr;
|
|
int cameraFlip;
|
|
|
|
void setupFog(int i, float alpha);
|
|
FloatBuffer* getBuffer(float a, float b, float c, float d);
|
|
static int getFpsCap(int option);
|
|
|
|
public:
|
|
void updateAllChunks();
|
|
|
|
#ifdef MULTITHREAD_ENABLE
|
|
static C4JThread* m_updateThread;
|
|
static int runUpdate(void* lpParam);
|
|
static C4JThread::EventArray* m_updateEvents;
|
|
enum EUpdateEvents {
|
|
eUpdateCanRun,
|
|
eUpdateEventIsFinished,
|
|
eUpdateEventCount,
|
|
};
|
|
static bool nearThingsToDo;
|
|
static bool updateRunning;
|
|
#endif
|
|
static std::vector<uint8_t*> m_deleteStackByte;
|
|
static std::vector<SparseLightStorage*> m_deleteStackSparseLightStorage;
|
|
static std::vector<CompressedTileStorage*>
|
|
m_deleteStackCompressedTileStorage;
|
|
static std::vector<SparseDataStorage*> m_deleteStackSparseDataStorage;
|
|
static CRITICAL_SECTION m_csDeleteStack;
|
|
static void AddForDelete(uint8_t* deleteThis);
|
|
static void AddForDelete(SparseLightStorage* deleteThis);
|
|
static void AddForDelete(CompressedTileStorage* deleteThis);
|
|
static void AddForDelete(SparseDataStorage* deleteThis);
|
|
static void FinishedReassigning();
|
|
void EnableUpdateThread();
|
|
void DisableUpdateThread();
|
|
};
|