mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-21 18:43:00 +00:00
fix(linux): restore UI GL state handoff for core renderer
This commit is contained in:
parent
fa24812582
commit
9680753f5e
|
|
@ -5,8 +5,6 @@
|
|||
#include "../../Minecraft.Client/Minecraft.h"
|
||||
#include "UIScene_EnchantingMenu.h"
|
||||
|
||||
#include <print>
|
||||
|
||||
UIScene_EnchantingMenu::UIScene_EnchantingMenu(int iPad, void* _initData,
|
||||
UILayer* parentLayer)
|
||||
: UIScene_AbstractContainerMenu(iPad, parentLayer) {
|
||||
|
|
|
|||
|
|
@ -776,6 +776,7 @@ GDrawFunctions* gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples) {
|
|||
|
||||
real_RenderingBegin = funcs->RenderingBegin;
|
||||
funcs->RenderingBegin = hooked_RenderingBegin;
|
||||
funcs->ClearID = gdraw_ClearID;
|
||||
|
||||
gdraw->tex_formats = tex_formats;
|
||||
gdraw->has_mapbuffer = true;
|
||||
|
|
@ -815,4 +816,4 @@ void gdraw_GL_BeginCustomDraw_4J(IggyCustomDrawCallbackRegion* region,
|
|||
void gdraw_GL_CalculateCustomDraw_4J(IggyCustomDrawCallbackRegion* region,
|
||||
F32* matrix) {
|
||||
gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, 0.0f, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@
|
|||
#undef glActiveTexture
|
||||
|
||||
// _4j suffix shit (todo: make ts better)
|
||||
int glGenTextures() {
|
||||
GLuint id = 0;
|
||||
::glGenTextures(1, &id);
|
||||
return (int)id;
|
||||
}
|
||||
|
||||
void glGenTextures_4J(IntBuffer* buf) {
|
||||
GLuint id = 0;
|
||||
::glGenTextures(1, &id);
|
||||
|
|
@ -35,6 +41,11 @@ void glGenTextures_4J(IntBuffer* buf) {
|
|||
buf->flip();
|
||||
}
|
||||
|
||||
void glDeleteTextures(int id) {
|
||||
GLuint uid = (GLuint)id;
|
||||
::glDeleteTextures(1, &uid);
|
||||
}
|
||||
|
||||
void glDeleteTextures_4J(IntBuffer* buf) {
|
||||
if (buf && buf->limit() > 0) {
|
||||
int id = buf->get(0);
|
||||
|
|
@ -218,4 +229,4 @@ void LinuxGLLogLightmapState(const char* stage, int textureId,
|
|||
unit1Enabled ? 1 : 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,42 +1,35 @@
|
|||
// should we keep Linux_UIController.cpp?*
|
||||
#include "../../../Minecraft.World/Platform/stdafx.h"
|
||||
#include "Linux_UIController.h"
|
||||
|
||||
// Temp
|
||||
#include "../../Minecraft.h"
|
||||
#include "../../Textures/Textures.h"
|
||||
|
||||
// GDraw GL backend for Linux
|
||||
#include "Iggy/gdraw/gdraw.h"
|
||||
#include "4J_Render.h"
|
||||
|
||||
ConsoleUIController ui;
|
||||
|
||||
static void restoreFixedFunctionStateAfterIggy() {
|
||||
RenderManager.StateSetColour(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
RenderManager.StateSetAlphaTestEnable(true);
|
||||
RenderManager.StateSetAlphaFunc(GL_GREATER, 0.1f);
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, 0.1f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
RenderManager.StateSetDepthTestEnable(true);
|
||||
RenderManager.StateSetDepthFunc(GL_LEQUAL);
|
||||
RenderManager.StateSetDepthMask(true);
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
|
||||
RenderManager.StateSetFaceCull(true);
|
||||
RenderManager.StateSetActiveTexture(GL_TEXTURE1);
|
||||
RenderManager.StateSetTextureEnable(false);
|
||||
RenderManager.MatrixMode(GL_TEXTURE);
|
||||
RenderManager.MatrixSetIdentity();
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
|
||||
RenderManager.StateSetActiveTexture(GL_TEXTURE0);
|
||||
RenderManager.StateSetTextureEnable(true);
|
||||
RenderManager.MatrixMode(GL_TEXTURE);
|
||||
|
||||
RenderManager.MatrixSetIdentity();
|
||||
RenderManager.MatrixMode(GL_MODELVIEW);
|
||||
glDisable(GL_SCISSOR_TEST); // iggy is mean
|
||||
RenderManager.Set_matrixDirty();
|
||||
Minecraft::GetInstance()->textures->clearLastBoundId();
|
||||
// 4jcraft: clears the last bound id, dumb fix but fine
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
void ConsoleUIController::init(S32 w, S32 h) {
|
||||
|
|
@ -69,11 +62,8 @@ void ConsoleUIController::render() {
|
|||
if (!gdraw_funcs) return;
|
||||
|
||||
gdraw_GL_SetTileOrigin(0, 0, 0);
|
||||
if (!app.GetGameStarted()) {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glClearDepth(1.0);
|
||||
glDepthMask(GL_TRUE);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
if (!app.GetGameStarted() && gdraw_funcs->ClearID) {
|
||||
gdraw_funcs->ClearID();
|
||||
}
|
||||
|
||||
// render
|
||||
|
|
@ -144,4 +134,4 @@ void ConsoleUIController::shutdown() {
|
|||
gdraw_funcs = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,4 +130,4 @@ bool FrustumData::cubeInFrustum(double x1, double y1, double z1, double x2,
|
|||
bool FrustumData::isVisible(AABB* aabb) {
|
||||
return cubeInFrustum(aabb->x0, aabb->y0, aabb->z0, aabb->x1, aabb->y1,
|
||||
aabb->z1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1779,6 +1779,7 @@ void GameRenderer::renderSnowAndRain(float a) {
|
|||
#endif
|
||||
t->offset(0, 0, 0);
|
||||
t->end();
|
||||
|
||||
} else {
|
||||
if (mode != 1) {
|
||||
if (mode >= 0) t->end();
|
||||
|
|
|
|||
|
|
@ -2472,7 +2472,7 @@ void LevelRenderer::renderHitOutline(std::shared_ptr<Player> player,
|
|||
// 4J-PB - If Display HUD is false, don't render the hit outline
|
||||
if (app.GetGameSettings(iPad, eGameSetting_DisplayHUD) == 0) return;
|
||||
RenderManager.StateSetLightingEnable(false);
|
||||
RenderManager.StateSetTextureEnable(false);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
// draw hit outline
|
||||
RenderManager.StateSetColour(0.0f, 0.0f, 0.0f, 0.4f);
|
||||
|
|
@ -2502,7 +2502,7 @@ void LevelRenderer::renderHitOutline(std::shared_ptr<Player> player,
|
|||
// restore
|
||||
glDisable(GL_POLYGON_OFFSET_LINE);
|
||||
RenderManager.StateSetColour(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
RenderManager.StateSetTextureEnable(true);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
RenderManager.StateSetLightingEnable(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -2510,7 +2510,7 @@ void LevelRenderer::renderHitOutline(std::shared_ptr<Player> player,
|
|||
void LevelRenderer::render(AABB* b) {
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
RenderManager.StateSetLightingEnable(false);
|
||||
RenderManager.StateSetTextureEnable(false);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
RenderManager.StateSetColour(0.0f, 0.0f, 0.0f, 0.4f);
|
||||
|
||||
// prevent zfight
|
||||
|
|
@ -2541,7 +2541,7 @@ void LevelRenderer::render(AABB* b) {
|
|||
t->end();
|
||||
glDisable(GL_POLYGON_OFFSET_LINE);
|
||||
RenderManager.StateSetLightingEnable(true);
|
||||
RenderManager.StateSetTextureEnable(true);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
RenderManager.StateSetColour(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue