Permalink
Browse files

expose Gfx to plugins

  • Loading branch information...
UnknownShadow200 committed Feb 10, 2019
1 parent 3e2ec57 commit abb2a7f32c7b3c5a1eefcbb086e65c1f02d1d5cf
Showing with 90 additions and 90 deletions.
  1. +1 −1 src/AxisLinesRenderer.c
  2. +1 −1 src/Camera.c
  3. +3 −3 src/Entity.c
  4. +10 −10 src/EnvRenderer.c
  5. +8 −8 src/Game.c
  6. +28 −33 src/Graphics.c
  7. +14 −9 src/Graphics.h
  8. +2 −2 src/Gui.c
  9. +5 −5 src/HeldBlockRenderer.c
  10. +2 −2 src/Menus.c
  11. +4 −4 src/Model.c
  12. +2 −2 src/Particle.c
  13. +1 −1 src/PickedPosRenderer.c
  14. +2 −2 src/Screens.c
  15. +1 −1 src/SelectionBox.c
  16. +1 −1 src/Server.c
  17. +5 −5 src/TexturePack.c
@@ -29,7 +29,7 @@ void AxisLinesRenderer_Render(double delta) {
VertexP3fC4b* ptr = vertices;
int i, count;

if (!Game_ShowAxisLines || Gfx_LostContext) return;
if (!Game_ShowAxisLines || Gfx.LostContext) return;
/* Don't do it in a ContextRecreated handler, because we only want VB recreated if ShowAxisLines in on. */
if (!axisLines_vb) {
axisLines_vb = Gfx_CreateDynamicVb(VERTEX_FORMAT_P3FC4B, AXISLINES_NUM_VERTICES);
@@ -19,7 +19,7 @@ static bool cam_isForwardThird;
static void PerspectiveCamera_GetProjection(struct Matrix* proj) {
float fovy = Game_Fov * MATH_DEG2RAD;
float aspectRatio = (float)Game.Width / (float)Game.Height;
Matrix_PerspectiveFieldOfView(proj, fovy, aspectRatio, Gfx_MinZNear, (float)Game_ViewDistance);
Matrix_PerspectiveFieldOfView(proj, fovy, aspectRatio, Gfx.MinZNear, (float)Game_ViewDistance);
}

static void PerspectiveCamera_GetView(struct Matrix* mat) {
@@ -517,7 +517,7 @@ void Player_UpdateNameTex(struct Player* player) {
struct Entity* e = &player->Base;
e->VTABLE->ContextLost(e);

if (Gfx_LostContext) return;
if (Gfx.LostContext) return;
Player_MakeNameTexture(player);
}

@@ -544,7 +544,7 @@ static void Player_DrawName(struct Player* p) {
size.X = p->NameTex.Width * scale; size.Y = p->NameTex.Height * scale;

if (Entities.NamesMode == NAME_MODE_ALL_UNSCALED && LocalPlayer_Instance.Hacks.CanSeeAllNames) {
Matrix_Mul(&mat, &Gfx_View, &Gfx_Projection); /* TODO: This mul is slow, avoid it */
Matrix_Mul(&mat, &Gfx.View, &Gfx.Projection); /* TODO: This mul is slow, avoid it */
/* Get W component of transformed position */
scale = pos.X * mat.Row0.W + pos.Y * mat.Row1.W + pos.Z * mat.Row2.W + mat.Row3.W;
size.X *= scale * 0.2f; size.Y *= scale * 0.2f;
@@ -730,7 +730,7 @@ static void Player_CheckSkin(struct Player* p) {
Player_EnsurePow2(p, &bmp);
e->SkinType = Utils_GetSkinType(&bmp);

if (bmp.Width > Gfx_MaxTexWidth || bmp.Height > Gfx_MaxTexHeight) {
if (bmp.Width > Gfx.MaxTexWidth || bmp.Height > Gfx.MaxTexHeight) {
Chat_Add1("&cSkin %s is too large", &skin);
} else if (e->SkinType != SKIN_INVALID) {
if (e->Model->UsesHumanSkin) Player_ClearHat(&bmp, e->SkinType);
@@ -183,7 +183,7 @@ static void EnvRenderer_UpdateClouds(void) {
int extent;
int x1, z1, x2, z2;

if (!World.Blocks || Gfx_LostContext) return;
if (!World.Blocks || Gfx.LostContext) return;
Gfx_DeleteVb(&clouds_vb);
if (EnvRenderer_Minimal) return;

@@ -223,15 +223,15 @@ void EnvRenderer_RenderSky(double deltaTime) {
if (skyY == normY) {
Gfx_DrawVb_IndexedTris(sky_vertices);
} else {
m = Gfx_View;
m = Gfx.View;
dy = skyY - normY;
/* inlined Y translation matrix multiply */
m.Row3.X += dy * m.Row1.X; m.Row3.Y += dy * m.Row1.Y;
m.Row3.Z += dy * m.Row1.Z; m.Row3.W += dy * m.Row1.W;

Gfx_LoadMatrix(MATRIX_VIEW, &m);
Gfx_DrawVb_IndexedTris(sky_vertices);
Gfx_LoadMatrix(MATRIX_VIEW, &Gfx_View);
Gfx_LoadMatrix(MATRIX_VIEW, &Gfx.View);
}
}

@@ -262,7 +262,7 @@ static void EnvRenderer_UpdateSky(void) {
int extent, height;
int x1, z1, x2, z2;

if (!World.Blocks || Gfx_LostContext) return;
if (!World.Blocks || Gfx.LostContext) return;
Gfx_DeleteVb(&sky_vb);
if (EnvRenderer_Minimal) return;

@@ -318,7 +318,7 @@ void EnvRenderer_RenderSkybox(double deltaTime) {
Gfx_DrawVb_IndexedTris(SKYBOX_COUNT);

Gfx_SetTexturing(false);
Gfx_LoadMatrix(MATRIX_VIEW, &Gfx_View);
Gfx_LoadMatrix(MATRIX_VIEW, &Gfx.View);
Gfx_SetDepthWrite(true);
}

@@ -345,7 +345,7 @@ static void EnvRenderer_UpdateSkybox(void) {
};
int i;

if (Gfx_LostContext) return;
if (Gfx.LostContext) return;
Gfx_DeleteVb(&skybox_vb);
if (EnvRenderer_Minimal) return;

@@ -576,7 +576,7 @@ void EnvRenderer_RenderMapEdges(double delta) {

static void EnvRenderer_MakeBorderTex(GfxResourceID* texId, BlockID block) {
TextureLoc loc = Block_Tex(block, FACE_YMAX);
if (Gfx_LostContext) return;
if (Gfx.LostContext) return;

Gfx_DeleteTexture(texId);
*texId = Atlas_LoadTile(loc);
@@ -694,7 +694,7 @@ static void EnvRenderer_UpdateMapSides(void) {
VertexP3fT2fC4b* ptr;
VertexP3fT2fC4b* cur;

if (!World.Blocks || Gfx_LostContext) return;
if (!World.Blocks || Gfx.LostContext) return;
Gfx_DeleteVb(&sides_vb);
block = Env_SidesBlock;

@@ -753,7 +753,7 @@ static void EnvRenderer_UpdateMapEdges(void) {
VertexP3fT2fC4b* ptr;
VertexP3fT2fC4b* cur;

if (!World.Blocks || Gfx_LostContext) return;
if (!World.Blocks || Gfx.LostContext) return;
Gfx_DeleteVb(&edges_vb);
block = Env_EdgeBlock;

@@ -815,7 +815,7 @@ static void EnvRenderer_UpdateAll(void) {
EnvRenderer_UpdateSkybox();
EnvRenderer_UpdateFog();

if (Gfx_LostContext) return;
if (Gfx.LostContext) return;
/* TODO: Don't allocate unless used? */
weather_vb = Gfx_CreateDynamicVb(VERTEX_FORMAT_P3FT2FC4B, WEATHER_VERTS_COUNT);
/* TODO: Don't need to do this on every new map */
@@ -135,7 +135,7 @@ bool Game_ChangeTerrainAtlas(Bitmap* atlas) {
Chat_AddRaw("&c Its height is less than its width.");
return false;
}
if (Gfx_LostContext) return false;
if (Gfx.LostContext) return false;

Atlas_Free();
Atlas_Update(atlas);
@@ -161,9 +161,9 @@ void Game_UserSetViewDistance(int distance) {

void Game_UpdateProjection(void) {
Game_DefaultFov = Options_GetInt(OPT_FIELD_OF_VIEW, 1, 179, 70);
Camera.Active->GetProjection(&Gfx_Projection);
Camera.Active->GetProjection(&Gfx.Projection);

Gfx_LoadMatrix(MATRIX_PROJECTION, &Gfx_Projection);
Gfx_LoadMatrix(MATRIX_PROJECTION, &Gfx.Projection);
Event_RaiseVoid(&GfxEvents.ProjectionChanged);
}

@@ -236,7 +236,7 @@ bool Game_UpdateTexture(GfxResourceID* texId, struct Stream* src, const String*
}

bool Game_ValidateBitmap(const String* file, Bitmap* bmp) {
int maxWidth = Gfx_MaxTexWidth, maxHeight = Gfx_MaxTexHeight;
int maxWidth = Gfx.MaxTexWidth, maxHeight = Gfx.MaxTexHeight;
if (!bmp->Scan0) {
Chat_Add1("&cError loading %s from the texture pack.", file);
return false;
@@ -429,7 +429,7 @@ static void Game_Load(void) {
Gfx_Init();
Gfx_SetVSync(true);
Gfx_MakeApiInfo();
Gfx_Mipmaps = Options_GetBool(OPT_MIPMAPS, false);
Gfx.Mipmaps = Options_GetBool(OPT_MIPMAPS, false);

Game_UpdateClientSize();
Game_LoadOptions();
@@ -525,9 +525,9 @@ static void Game_LimitFPS(uint64_t frameStart) {
}

static void Game_UpdateViewMatrix(void) {
Camera.Active->GetView(&Gfx_View);
Gfx_LoadMatrix(MATRIX_VIEW, &Gfx_View);
FrustumCulling_CalcFrustumEquations(&Gfx_Projection, &Gfx_View);
Camera.Active->GetView(&Gfx.View);
Gfx_LoadMatrix(MATRIX_VIEW, &Gfx.View);
FrustumCulling_CalcFrustumEquations(&Gfx.Projection, &Gfx.View);
}

static void Game_Render3D(double delta, float t) {
Oops, something went wrong.

0 comments on commit abb2a7f

Please sign in to comment.