i love retina wtf
This commit is contained in:
@@ -58,8 +58,8 @@ public class GuiClick extends GuiScreen {
|
|||||||
double mx = mc.mouseHelper.getMouseX();
|
double mx = mc.mouseHelper.getMouseX();
|
||||||
double my = mc.mouseHelper.getMouseY();
|
double my = mc.mouseHelper.getMouseY();
|
||||||
my = mc.mainWindow.getHeight() - my;
|
my = mc.mainWindow.getHeight() - my;
|
||||||
my *= 2;
|
my *= mc.mainWindow.getFramebufferHeight() / (double) mc.mainWindow.getHeight();
|
||||||
mx *= 2;
|
mx *= mc.mainWindow.getFramebufferWidth() / (double) mc.mainWindow.getWidth();
|
||||||
Vec3d near = toWorld(mx, my, 0);
|
Vec3d near = toWorld(mx, my, 0);
|
||||||
Vec3d far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - leijurv
|
Vec3d far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - leijurv
|
||||||
if (near != null && far != null) {
|
if (near != null && far != null) {
|
||||||
@@ -126,7 +126,7 @@ public class GuiClick extends GuiScreen {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3d toWorld ( double x, double y, double z){
|
public Vec3d toWorld(double x, double y, double z) {
|
||||||
boolean result = gluUnProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, (FloatBuffer) TO_WORLD_BUFFER.clear());
|
boolean result = gluUnProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, (FloatBuffer) TO_WORLD_BUFFER.clear());
|
||||||
if (result) {
|
if (result) {
|
||||||
return new Vec3d(TO_WORLD_BUFFER.get(0), TO_WORLD_BUFFER.get(1), TO_WORLD_BUFFER.get(2));
|
return new Vec3d(TO_WORLD_BUFFER.get(0), TO_WORLD_BUFFER.get(1), TO_WORLD_BUFFER.get(2));
|
||||||
@@ -169,14 +169,14 @@ public class GuiClick extends GuiScreen {
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static boolean gluUnProject (
|
public static boolean gluUnProject(
|
||||||
float winx,
|
float winx,
|
||||||
float winy,
|
float winy,
|
||||||
float winz,
|
float winz,
|
||||||
FloatBuffer modelMatrix,
|
FloatBuffer modelMatrix,
|
||||||
FloatBuffer projMatrix,
|
FloatBuffer projMatrix,
|
||||||
IntBuffer viewport,
|
IntBuffer viewport,
|
||||||
FloatBuffer obj_pos){
|
FloatBuffer obj_pos) {
|
||||||
FloatBuffer finalMatrix = BufferUtils.createFloatBuffer(16);
|
FloatBuffer finalMatrix = BufferUtils.createFloatBuffer(16);
|
||||||
float[] in = new float[4];
|
float[] in = new float[4];
|
||||||
float[] out = new float[4];
|
float[] out = new float[4];
|
||||||
@@ -214,7 +214,7 @@ public class GuiClick extends GuiScreen {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void __gluMultMatrixVecf (FloatBuffer m,float[] in, float[] out){
|
private static void __gluMultMatrixVecf(FloatBuffer m, float[] in, float[] out) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
out[i] =
|
out[i] =
|
||||||
in[0] * m.get(m.position() + 0 * 4 + i)
|
in[0] * m.get(m.position() + 0 * 4 + i)
|
||||||
@@ -225,7 +225,7 @@ public class GuiClick extends GuiScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void __gluMultMatricesf (FloatBuffer a, FloatBuffer b, FloatBuffer r){
|
private static void __gluMultMatricesf(FloatBuffer a, FloatBuffer b, FloatBuffer r) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
r.put(r.position() + i * 4 + j,
|
r.put(r.position() + i * 4 + j,
|
||||||
@@ -234,7 +234,7 @@ public class GuiClick extends GuiScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean __gluInvertMatrixf (FloatBuffer src, FloatBuffer inverse){
|
private static boolean __gluInvertMatrixf(FloatBuffer src, FloatBuffer inverse) {
|
||||||
int i, j, k, swap;
|
int i, j, k, swap;
|
||||||
float t;
|
float t;
|
||||||
FloatBuffer temp = BufferUtils.createFloatBuffer(16);
|
FloatBuffer temp = BufferUtils.createFloatBuffer(16);
|
||||||
@@ -312,9 +312,9 @@ public class GuiClick extends GuiScreen {
|
|||||||
0.0f, 0.0f, 1.0f, 0.0f,
|
0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
0.0f, 0.0f, 0.0f, 1.0f};
|
0.0f, 0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
private static void __gluMakeIdentityf (FloatBuffer m){
|
private static void __gluMakeIdentityf(FloatBuffer m) {
|
||||||
int oldPos = m.position();
|
int oldPos = m.position();
|
||||||
m.put(IDENTITY_MATRIX);
|
m.put(IDENTITY_MATRIX);
|
||||||
m.position(oldPos);
|
m.position(oldPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user