question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Camera related documentation needs improvement regarding touch/screenspace

See original GitHub issue

Issue details

Camera.unproject does not return original value

Reproduction steps/code

    public void create() {
        Vector2 tmpvec = new Vector2();
        tmpvec.set(0, 0);

        Stage stage = new Stage(new ScreenViewport());
        stage.stageToScreenCoordinates(tmpvec); // has the correct screen coords;
        stage.screenToStageCoordinates(tmpvec);
        System.out.println(tmpvec); // prints (0, -1), should be (0, 0)
    }

Due to the following line in Camera (-1 at the end):

https://github.com/libgdx/libgdx/blob/c0c1f515df54092cb47717f43f022db02cf7e328/gdx/src/com/badlogic/gdx/graphics/Camera.java#L197

Intended?

Version of LibGDX and/or relevant dependencies

1.9.10

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jusw85commented, Nov 29, 2019

OpenGL for reference, specifically gluProject and gluUnProject, compiled and run on Arch Linux/Mesa 3D.

gluProject — map object coordinates to window coordinates gluUnProject — map window coordinates to object coordinates

The window size is 300x300, and (0,0) is the point at the centre of the screen.

#include <stdio.h>
#include <GL/gl.h>
#include <GL/glut.h>

void displayFunc(void)
{
    GLdouble posX, posY, posZ;
    GLdouble winX, winY, winZ;
    GLdouble resX, resY, resZ;
    GLdouble modelview[16];
    GLdouble projection[16];
    GLint viewport[4];
    glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
    glGetDoublev(GL_PROJECTION_MATRIX, projection);
    glGetIntegerv(GL_VIEWPORT, viewport);
    posX = 0.0;
    posY = 0.0;
    posZ = 0.0;

    gluProject(posX, posY, posZ, modelview, projection, viewport, &winX, &winY, &winZ);
    printf("window: %f %f %f\n", winX, winY, winZ);
    // window: 150.000000 150.000000 0.500000

    gluUnProject(winX, winY, winZ, modelview, projection, viewport, &resX, &resY, &resZ);
    printf("pos: %f %f %f\n", resX, resY, resZ); 
    // pos: 0.000000 0.000000 0.000000
}

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE);
    glutInitWindowSize(300, 300);
    glutCreateWindow("Test glProject glUnProject");
    glutDisplayFunc(displayFunc);
    glutMainLoop();
    return 0;
}

0reactions
NathanSweetcommented, Apr 4, 2020

@mark6412 Don’t ask for help on an issue tracker. See: https://github.com/libgdx/libgdx/wiki/Getting-help

Seems a bit unfortunate to need to think about touch space coordinates. Ideally we’d have only screen space and world space.

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Tips for Improving Documentation | CloudApp Blog
But improving documentation is essential for any business looking to grow and achieve a high level of success. In this article, we'll cover...
Read more >
MODEL 3 - device.report
For the latest and greatest information that is customized to your vehicle, view the Owner's Manual on your vehicle's touchscreen by touching Controls ......
Read more >
US20120319989A1 - Video-game controller assemblies designed ...
Remote-controller assemblies for touchscreens provide for the capture, ... Cited by (35); Legal events; Similar documents; Priority and Related Applications ...
Read more >
Travel in a smart and safe style whilst staying focussed on the road ...
XAV-AX8050D featuring a large 8.95” display and 1-DIN installation, 3-way adjustable mount, and the latest smartphone connectivity alongside DAB radio ...
Read more >
TouchViZ App Reviews & Download - Music App Rankings!
Added support for modern iOS devices - Added Bonjour OSC network browsing permissions - Fixed application hang when accessing Camera Roll - Fixed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found