M
M
Maxim Moseychuk2012-11-08 11:19:21
Android
Maxim Moseychuk, 2012-11-08 11:19:21

Are the linear dimensions of the polygon in the emulator increased by 1.5 times?

Debian Sid / SDK 20.0.3 / Emulator + kvm + GPU Emulation
I'm using GLES20. I'm making a sprite class that would save linear dimensions (in pixels) at any screen resolution (and when changing orientation too). Everything is fine, only the linear dimensions are increased by 1.5 times. I can't test it on a real device.
I set the orthogonal projection like this:

float sp = 0.5f;
Matrix.orthoM(mProjMatrix,0 ,-sp, sp, -sp, sp, -sp, sp);

Those. we will project a cube with side 1, center at (0,0,0);
I move the camera. I recalculate the size of the polygons
:
vertexBuffer = createPlane(width/_width/2, height/_height/2);

Those. I calculate the ratio of the sprite size / the size of the drawing area, because cube of a unit size, then the resulting percentage in theory should give the original size. Divide by two - the function takes the coordinates of the upper right corner of the square centered at (0,0,0).
The function code itself:
private FloatBuffer createPlane(float _width, float _height)
    {
        float quard[] = 
        {
            -_width,  _height, 0.0f,
             _width,  _height, 0.0f,
            -_width, -_height, 0.0f,
             _width, -_height, 0.0f
        };
        return floatbufferFactory(quard);
    }

    private FloatBuffer floatbufferFactory(float[] buffer)
    {
        ByteBuffer bb = ByteBuffer.allocateDirect(buffer.length*4);
        bb.order(ByteOrder.nativeOrder());
        FloatBuffer result = bb.asFloatBuffer();
        result.put(buffer);
        result.position(0);
        return result;
    }

I tried everything - and different resolutions, and DPI in the emulator substituted, and googled. Pixels are 1.5 times more.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew Pozunyk, 2014-06-25
@Upeek

genymotion I advise you to try this emulator, I like it the most ;)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question