we do a little bit of merging

This commit is contained in:
UnknownUser1789 2023-01-19 02:49:21 +00:00
parent 190e053b80
commit be7ad251dd
3 changed files with 28029 additions and 27991 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,5 @@
package net.lax1dude.eaglercraft.v1_8.opengl;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
@ -10,6 +7,9 @@ import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f;
import net.lax1dude.eaglercraft.v1_8.vector.Vector3f;
import net.lax1dude.eaglercraft.v1_8.vector.Vector4f;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
/**
* Copyright (c) 2022-2023 LAX1DUDE. All Rights Reserved.
*
@ -94,7 +94,10 @@ public class GlStateManager {
static int activeTexture = 0;
static final boolean[] stateTexture = new boolean[16];
static final int[] boundTexture = new int[] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
static final int[] boundTexture = new int[] {
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1
};
static float stateAnisotropicFixW = -999.0f;
static float stateAnisotropicFixH = -999.0f;
@ -117,14 +120,12 @@ public class GlStateManager {
static float clearDepth = -999.0f;
public static enum TexGen {
S,
T,
R,
Q;
S, T, R, Q;
int source = GL_OBJECT_LINEAR;
int plane = GL_OBJECT_PLANE;
Vector4f vector = new Vector4f();
}
static int stateTexGenSerial = 0;
@ -160,20 +161,20 @@ public class GlStateManager {
}
static void populateStack(Matrix4f[] stack) {
for (int i = 0; i < stack.length; ++i) {
for(int i = 0; i < stack.length; ++i) {
stack[i] = new Matrix4f();
}
}
static void populateStack(Matrix4f[][] stack) {
for (int i = 0; i < stack.length; ++i) {
for(int i = 0; i < stack.length; ++i) {
populateStack(stack[i]);
}
}
static void populateStack(Vector4f[][] stack) {
for (int i = 0; i < stack.length; ++i) {
for (int j = 0; j < stack[i].length; ++j) {
for(int i = 0; i < stack.length; ++i) {
for(int j = 0; j < stack[i].length; ++j) {
stack[i][j] = new Vector4f(0.0f, -1.0f, 0.0f, 0.0f);
}
}
@ -181,32 +182,34 @@ public class GlStateManager {
public static final void pushLightCoords() {
int push = stateLightsStackPointer + 1;
if (push < stateLightsStack.length) {
if(push < stateLightsStack.length) {
Vector4f[] copyFrom = stateLightsStack[stateLightsStackPointer];
boolean[] copyFrom2 = stateLightsEnabled[stateLightsStackPointer];
Vector4f[] copyTo = stateLightsStack[push];
boolean[] copyTo2 = stateLightsEnabled[push];
for (int i = 0; i < copyFrom.length; ++i) {
if (copyFrom2[i]) {
for(int i = 0; i < copyFrom.length; ++i) {
if(copyFrom2[i]) {
copyTo[i].set(copyFrom[i]);
copyTo2[i] = true;
} else {
}else {
copyTo2[i] = false;
}
}
stateLightingSerial[push] = stateLightingSerial[stateLightsStackPointer];
stateLightsStackPointer = push;
} else {
Throwable t = new IndexOutOfBoundsException("GL_LIGHT direction stack overflow!" + " Exceeded " + stateLightsStack.length + " calls to GlStateManager.pushLightCoords");
}else {
Throwable t = new IndexOutOfBoundsException("GL_LIGHT direction stack overflow!" +
" Exceeded " + stateLightsStack.length + " calls to GlStateManager.pushLightCoords");
logger.error(t);
}
}
public static final void popLightCoords() {
if (stateLightsStackPointer > 0) {
if(stateLightsStackPointer > 0) {
--stateLightsStackPointer;
} else {
Throwable t = new IndexOutOfBoundsException("GL_LIGHT direction stack underflow!" + " Called GlStateManager.popLightCoords on an empty light stack");
}else {
Throwable t = new IndexOutOfBoundsException("GL_LIGHT direction stack underflow!" +
" Called GlStateManager.popLightCoords on an empty light stack");
logger.error(t);
}
}
@ -220,9 +223,9 @@ public class GlStateManager {
}
public static final void alphaFunc(int func, float ref) {
if (func != GL_GREATER) {
if(func != GL_GREATER) {
throw new UnsupportedOperationException("Only GL_GREATER alphaFunc is supported");
} else {
}else {
stateAlphaTestRef = ref;
}
}
@ -236,12 +239,12 @@ public class GlStateManager {
}
private static final Vector4f paramVector4 = new Vector4f();
public static final void enableMCLight(int light, float diffuse, double dirX, double dirY, double dirZ, double dirW) {
paramVector4.x = (float) dirX;
paramVector4.y = (float) dirY;
paramVector4.z = (float) dirZ;
paramVector4.w = (float) dirW;
public static final void enableMCLight(int light, float diffuse, double dirX,
double dirY, double dirZ, double dirW) {
paramVector4.x = (float)dirX;
paramVector4.y = (float)dirY;
paramVector4.z = (float)dirZ;
paramVector4.w = (float)dirW;
Matrix4f.transform(modelMatrixStack[modelMatrixStackPointer], paramVector4, paramVector4);
paramVector4.normalise();
Vector4f dest = stateLightsStack[stateLightsStackPointer][light];
@ -274,14 +277,14 @@ public class GlStateManager {
}
public static final void disableDepth() {
if (stateDepthTest) {
if(stateDepthTest) {
_wglDisable(GL_DEPTH_TEST);
stateDepthTest = false;
}
}
public static final void enableDepth() {
if (!stateDepthTest) {
if(!stateDepthTest) {
_wglEnable(GL_DEPTH_TEST);
stateDepthTest = true;
}
@ -289,7 +292,7 @@ public class GlStateManager {
public static final void depthFunc(int depthFunc) {
int rev = depthFunc;
switch (depthFunc) {
switch(depthFunc) {
case GL_GREATER:
rev = GL_LESS;
break;
@ -306,28 +309,28 @@ public class GlStateManager {
rev = GL_GREATER;
break;
}
if (rev != stateDepthFunc) {
if(rev != stateDepthFunc) {
_wglDepthFunc(rev);
stateDepthFunc = rev;
}
}
public static final void depthMask(boolean flagIn) {
if (flagIn != stateDepthMask) {
if(flagIn != stateDepthMask) {
_wglDepthMask(flagIn);
stateDepthMask = flagIn;
}
}
public static final void disableBlend() {
if (stateBlend) {
if(stateBlend) {
_wglDisable(GL_BLEND);
stateBlend = false;
}
}
public static final void enableBlend() {
if (!stateBlend) {
if(!stateBlend) {
_wglEnable(GL_BLEND);
stateBlend = true;
}
@ -348,6 +351,10 @@ public class GlStateManager {
}
public static final void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFactorAlpha, int dstFactorAlpha) {
if(stateEnableOverlayFramebufferBlending) { // game overlay framebuffer in EntityRenderer.java
srcFactorAlpha = GL_ONE;
dstFactorAlpha = GL_ONE_MINUS_SRC_ALPHA;
}
int srcBits = (srcFactor | (srcFactorAlpha << 16));
int dstBits = (dstFactor | (dstFactorAlpha << 16));
if(srcBits != stateBlendSRC || dstBits != stateBlendDST) {
@ -357,6 +364,14 @@ public class GlStateManager {
}
}
public static final void enableOverlayFramebufferBlending() {
stateEnableOverlayFramebufferBlending = true;
}
public static final void disableOverlayFramebufferBlending() {
stateEnableOverlayFramebufferBlending = false;
}
public static final void setShaderBlendSrc(float r, float g, float b, float a) {
stateShaderBlendSrcColorR = r;
stateShaderBlendSrcColorG = g;
@ -410,42 +425,42 @@ public class GlStateManager {
}
public static final void enableCull() {
if (!stateCull) {
if(!stateCull) {
_wglEnable(GL_CULL_FACE);
stateCull = true;
}
}
public static final void disableCull() {
if (stateCull) {
if(stateCull) {
_wglDisable(GL_CULL_FACE);
stateCull = false;
}
}
public static final void cullFace(int mode) {
if (stateCullFace != mode) {
if(stateCullFace != mode) {
_wglCullFace(mode);
stateCullFace = mode;
}
}
public static final void enablePolygonOffset() {
if (!statePolygonOffset) {
if(!statePolygonOffset) {
_wglEnable(GL_POLYGON_OFFSET_FILL);
statePolygonOffset = true;
}
}
public static final void disablePolygonOffset() {
if (statePolygonOffset) {
if(statePolygonOffset) {
_wglDisable(GL_POLYGON_OFFSET_FILL);
statePolygonOffset = false;
}
}
public static final void doPolygonOffset(float factor, float units) {
if (factor != statePolygonOffsetFactor || units != statePolygonOffsetUnits) {
if(factor != statePolygonOffsetFactor || units != statePolygonOffsetUnits) {
_wglPolygonOffset(-factor, units);
statePolygonOffsetFactor = factor;
statePolygonOffsetUnits = units;
@ -456,9 +471,13 @@ public class GlStateManager {
System.err.println("TODO: rewrite text field cursor to use blending");
}
public static final void disableColorLogic() {}
public static final void disableColorLogic() {
public static final void colorLogicOp(int opcode) {}
}
public static final void colorLogicOp(int opcode) {
}
public static final void enableTexGen() {
stateTexGen = true;
@ -476,7 +495,7 @@ public class GlStateManager {
public static final void func_179105_a(GlStateManager.TexGen coord, int plane, FloatBuffer vector) {
coord.plane = plane;
coord.vector.load(vector);
if (plane == GL_EYE_PLANE) {
if(plane == GL_EYE_PLANE) {
tmpInvertedMatrix.load(GlStateManager.modelMatrixStack[GlStateManager.modelMatrixStackPointer]).invert().transpose();
Matrix4f.transform(tmpInvertedMatrix, coord.vector, coord.vector);
}
@ -485,7 +504,7 @@ public class GlStateManager {
public static final void setActiveTexture(int texture) {
int textureIdx = texture - GL_TEXTURE0;
if (textureIdx != activeTexture) {
if(textureIdx != activeTexture) {
_wglActiveTexture(texture);
activeTexture = textureIdx;
}
@ -514,7 +533,7 @@ public class GlStateManager {
}
public static final void bindTexture(int texture) {
if (texture != boundTexture[activeTexture]) {
if(texture != boundTexture[activeTexture]) {
_wglBindTexture(GL_TEXTURE_2D, EaglercraftGPU.mapTexturesGL.get(texture));
boundTexture[activeTexture] = texture;
}
@ -524,16 +543,20 @@ public class GlStateManager {
return boundTexture[activeTexture];
}
public static final void shadeModel(int mode) {}
public static final void shadeModel(int mode) {
}
public static final void enableRescaleNormal() {
// still not sure what this is for
}
public static final void disableRescaleNormal() {}
public static final void disableRescaleNormal() {
}
public static final void viewport(int x, int y, int w, int h) {
if (viewportX != x || viewportY != y || viewportW != w || viewportH != h) {
if(viewportX != x || viewportY != y || viewportW != w || viewportH != h) {
_wglViewport(x, y, w, h);
viewportX = x;
viewportY = y;
@ -544,7 +567,7 @@ public class GlStateManager {
public static final void colorMask(boolean red, boolean green, boolean blue, boolean alpha) {
int bits = (red ? 1 : 0) | (green ? 2 : 0) | (blue ? 4 : 0) | (alpha ? 8 : 0);
if (bits != colorMaskBits) {
if(bits != colorMaskBits) {
_wglColorMask(red, green, blue, alpha);
colorMaskBits = bits;
}
@ -552,14 +575,14 @@ public class GlStateManager {
public static final void clearDepth(float depth) {
depth = 1.0f - depth;
if (depth != clearDepth) {
if(depth != clearDepth) {
_wglClearDepth(depth);
clearDepth = depth;
}
}
public static final void clearColor(float red, float green, float blue, float alpha) {
if (red != clearColorR || green != clearColorG || blue != clearColorB || alpha != clearColorA) {
if(red != clearColorR || green != clearColorG || blue != clearColorB || alpha != clearColorA) {
_wglClearColor(red, green, blue, alpha);
clearColorR = red;
clearColorG = green;
@ -577,7 +600,7 @@ public class GlStateManager {
}
public static final void loadIdentity() {
switch (stateMatrixMode) {
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].setIdentity();
@ -589,46 +612,50 @@ public class GlStateManager {
break;
case GL_TEXTURE:
textureMatrixStack[activeTexture][textureMatrixStackPointer[activeTexture]].setIdentity();
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
}
public static final void pushMatrix() {
int push;
switch (stateMatrixMode) {
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
push = modelMatrixStackPointer + 1;
if (push < modelMatrixStack.length) {
if(push < modelMatrixStack.length) {
modelMatrixStack[push].load(modelMatrixStack[modelMatrixStackPointer]);
modelMatrixStackAccessSerial[push] = modelMatrixStackAccessSerial[modelMatrixStackPointer];
modelMatrixStackPointer = push;
} else {
Throwable t = new IndexOutOfBoundsException("GL_MODELVIEW matrix stack overflow!" + " Exceeded " + modelMatrixStack.length + " calls to GlStateManager.pushMatrix");
}else {
Throwable t = new IndexOutOfBoundsException("GL_MODELVIEW matrix stack overflow!" +
" Exceeded " + modelMatrixStack.length + " calls to GlStateManager.pushMatrix");
logger.error(t);
}
break;
case GL_PROJECTION:
push = projectionMatrixStackPointer + 1;
if (push < projectionMatrixStack.length) {
if(push < projectionMatrixStack.length) {
projectionMatrixStack[push].load(projectionMatrixStack[projectionMatrixStackPointer]);
projectionMatrixStackAccessSerial[push] = projectionMatrixStackAccessSerial[projectionMatrixStackPointer];
projectionMatrixStackPointer = push;
} else {
Throwable t = new IndexOutOfBoundsException("GL_PROJECTION matrix stack overflow!" + " Exceeded " + projectionMatrixStack.length + " calls to GlStateManager.pushMatrix");
}else {
Throwable t = new IndexOutOfBoundsException("GL_PROJECTION matrix stack overflow!" +
" Exceeded " + projectionMatrixStack.length + " calls to GlStateManager.pushMatrix");
logger.error(t);
}
break;
case GL_TEXTURE:
push = textureMatrixStackPointer[activeTexture] + 1;
if (push < textureMatrixStack.length) {
if(push < textureMatrixStack.length) {
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][push].load(textureMatrixStack[activeTexture][ptr]);
textureMatrixStackAccessSerial[activeTexture][push] = textureMatrixStackAccessSerial[activeTexture][ptr];
textureMatrixStackPointer[activeTexture] = push;
} else {
Throwable t = new IndexOutOfBoundsException("GL_TEXTURE #" + activeTexture + " matrix stack overflow!" + " Exceeded " + textureMatrixStack.length + " calls to GlStateManager.pushMatrix");
}else {
Throwable t = new IndexOutOfBoundsException("GL_TEXTURE #" + activeTexture + " matrix stack overflow!" +
" Exceeded " + textureMatrixStack.length + " calls to GlStateManager.pushMatrix");
logger.error(t);
}
break;
@ -636,29 +663,32 @@ public class GlStateManager {
}
public static final void popMatrix() {
switch (stateMatrixMode) {
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
if (modelMatrixStackPointer > 0) {
if(modelMatrixStackPointer > 0) {
--modelMatrixStackPointer;
} else {
Throwable t = new IndexOutOfBoundsException("GL_MODELVIEW matrix stack underflow!" + " Called GlStateManager.popMatrix on an empty matrix stack");
}else {
Throwable t = new IndexOutOfBoundsException("GL_MODELVIEW matrix stack underflow!" +
" Called GlStateManager.popMatrix on an empty matrix stack");
logger.error(t);
}
break;
case GL_PROJECTION:
if (projectionMatrixStackPointer > 0) {
if(projectionMatrixStackPointer > 0) {
--projectionMatrixStackPointer;
} else {
Throwable t = new IndexOutOfBoundsException("GL_PROJECTION matrix stack underflow!" + " Called GlStateManager.popMatrix on an empty matrix stack");
}else {
Throwable t = new IndexOutOfBoundsException("GL_PROJECTION matrix stack underflow!" +
" Called GlStateManager.popMatrix on an empty matrix stack");
logger.error(t);
}
break;
case GL_TEXTURE:
if (textureMatrixStackPointer[activeTexture] > 0) {
if(textureMatrixStackPointer[activeTexture] > 0) {
--textureMatrixStackPointer[activeTexture];
} else {
Throwable t = new IndexOutOfBoundsException("GL_TEXTURE #" + activeTexture + " matrix stack underflow! Called GlStateManager.popMatrix on an empty matrix stack");
}else {
Throwable t = new IndexOutOfBoundsException("GL_TEXTURE #" + activeTexture +
" matrix stack underflow! Called GlStateManager.popMatrix on an empty matrix stack");
logger.error(t);
}
break;
@ -666,7 +696,7 @@ public class GlStateManager {
}
public static final void getFloat(int pname, float[] params) {
switch (pname) {
switch(pname) {
case GL_MODELVIEW_MATRIX:
modelMatrixStack[modelMatrixStackPointer].store(params);
break;
@ -683,7 +713,7 @@ public class GlStateManager {
public static final void ortho(double left, double right, double bottom, double top, double zNear, double zFar) {
Matrix4f matrix;
switch (stateMatrixMode) {
switch(stateMatrixMode) {
case GL_MODELVIEW:
matrix = modelMatrixStack[modelMatrixStackPointer];
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
@ -696,35 +726,35 @@ public class GlStateManager {
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
matrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
matrix.m00 = 2.0f / (float) (right - left);
matrix.m00 = 2.0f / (float)(right - left);
matrix.m01 = 0.0f;
matrix.m02 = 0.0f;
matrix.m03 = 0.0f;
matrix.m10 = 0.0f;
matrix.m11 = 2.0f / (float) (top - bottom);
matrix.m11 = 2.0f / (float)(top - bottom);
matrix.m12 = 0.0f;
matrix.m13 = 0.0f;
matrix.m20 = 0.0f;
matrix.m21 = 0.0f;
matrix.m22 = 2.0f / (float) (zFar - zNear);
matrix.m22 = 2.0f / (float)(zFar - zNear);
matrix.m23 = 0.0f;
matrix.m30 = (float) (-(right + left) / (right - left));
matrix.m31 = (float) (-(top + bottom) / (top - bottom));
matrix.m32 = (float) ((zFar + zNear) / (zFar - zNear));
matrix.m30 = (float)(-(right + left) / (right - left));
matrix.m31 = (float)(-(top + bottom) / (top - bottom));
matrix.m32 = (float)((zFar + zNear) / (zFar - zNear));
matrix.m33 = 1.0f;
}
private static final Vector3f paramVector = new Vector3f();
private static final float toRad = 0.0174532925f;
public static final void rotate(float angle, float x, float y, float z) {
paramVector.x = x;
paramVector.y = y;
paramVector.z = z;
switch (stateMatrixMode) {
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].rotate(angle * toRad, paramVector);
@ -737,7 +767,8 @@ public class GlStateManager {
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].rotate(angle * toRad, paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
}
@ -746,7 +777,7 @@ public class GlStateManager {
paramVector.x = x;
paramVector.y = y;
paramVector.z = z;
switch (stateMatrixMode) {
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].scale(paramVector);
@ -759,16 +790,17 @@ public class GlStateManager {
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].scale(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
}
public static final void scale(double x, double y, double z) {
paramVector.x = (float) x;
paramVector.y = (float) y;
paramVector.z = (float) z;
switch (stateMatrixMode) {
paramVector.x = (float)x;
paramVector.y = (float)y;
paramVector.z = (float)z;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].scale(paramVector);
@ -781,7 +813,8 @@ public class GlStateManager {
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].scale(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
}
@ -790,7 +823,7 @@ public class GlStateManager {
paramVector.x = x;
paramVector.y = y;
paramVector.z = z;
switch (stateMatrixMode) {
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].translate(paramVector);
@ -803,16 +836,17 @@ public class GlStateManager {
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].translate(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
}
public static final void translate(double x, double y, double z) {
paramVector.x = (float) x;
paramVector.y = (float) y;
paramVector.z = (float) z;
switch (stateMatrixMode) {
paramVector.x = (float)x;
paramVector.y = (float)y;
paramVector.z = (float)z;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].translate(paramVector);
@ -825,17 +859,17 @@ public class GlStateManager {
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].translate(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
}
private static final Matrix4f paramMatrix = new Matrix4f();
public static final void multMatrix(float[] matrix) {
Matrix4f modeMatrix;
switch (stateMatrixMode) {
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modeMatrix = modelMatrixStack[modelMatrixStackPointer];
@ -848,7 +882,8 @@ public class GlStateManager {
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
modeMatrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
@ -887,7 +922,7 @@ public class GlStateManager {
public static final void gluPerspective(float fovy, float aspect, float zNear, float zFar) {
Matrix4f matrix;
switch (stateMatrixMode) {
switch(stateMatrixMode) {
case GL_MODELVIEW:
matrix = modelMatrixStack[modelMatrixStackPointer];
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
@ -900,7 +935,8 @@ public class GlStateManager {
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
matrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
float cotangent = (float) Math.cos(fovy * toRad * 0.5f) / (float) Math.sin(fovy * toRad * 0.5f);
@ -925,13 +961,14 @@ public class GlStateManager {
private static final Matrix4f unprojA = new Matrix4f();
private static final Matrix4f unprojB = new Matrix4f();
private static final Vector4f unprojC = new Vector4f();
public static final void gluUnProject(float p1, float p2, float p3, float[] modelview, float[] projection, int[] viewport, float[] objectcoords) {
public static final void gluUnProject(float p1, float p2, float p3, float[] modelview, float[] projection,
int[] viewport, float[] objectcoords) {
unprojA.load(modelview);
unprojB.load(projection);
Matrix4f.mul(unprojA, unprojB, unprojB);
unprojB.invert();
unprojC.set(((p1 - (float) viewport[0]) / (float) viewport[2]) * 2f - 1f, ((p2 - (float) viewport[1]) / (float) viewport[3]) * 2f - 1f, p3, 1.0f);
unprojC.set(((p1 - (float)viewport[0]) / (float)viewport[2]) * 2f - 1f,
((p2 - (float)viewport[1]) / (float)viewport[3]) * 2f - 1f, p3, 1.0f);
Matrix4f.transform(unprojB, unprojC, unprojC);
objectcoords[0] = unprojC.x / unprojC.w;
objectcoords[1] = unprojC.y / unprojC.w;