Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL surface view scaling for different DPIs

I have a device with 800x480 res. When I create GLSurfaceView, I get an onSurfaceChanged call with 533x320 (apparently with 1.5 HDPI modifier applied) and surface is upscaled. So when I draw 1 pixel thick line is looks really bad, and I can't have pixel-perfect rendering.

What I want to have is native resolution surface (800x480).

View is created in this manner (like in NDK OpenGL samples), in Activity's onCreate:

    this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
            WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
            WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
            WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

    view = new MyGLSurfaceView(this);
    setContentView(view);

I don't use any layouts etc.

like image 375
Mark Avatar asked Feb 04 '12 19:02

Mark


1 Answers

I found the solution: when I add

<uses-sdk android:targetSdkVersion="8" android:minSdkVersion="8"/>

to AndroidManifest.xml, I get proper resolution.To be honest, Android is very strange platform for me after few years with iOS...

Solution found here: MonoDroid apps don't use correct density drawables

like image 178
Mark Avatar answered Nov 06 '22 00:11

Mark