opengl es - android glsurfaceview stretch to fit -


i using glsurfaceview , it's renderer display gles device full screen. works expected.

now want add option "zoom" output size. mean (for example) render gles viewport quarter of screen , stretch full screen when displaying. allow slower shaders rendered faster little blockiness.

i can shrink gles size altering glviewport , renders on lower left corner of screen. how can lower quarter stretch fill whole screen?

many tips/answers.

solution after more trial , error , googling. render quarter sized image full screen.

just after glsurfaceview created;

glsurfaceview.getholder().setfixedsize(glwidth,glheight); 

glheight , glwidth internal gles render size. render image 1/4 of screen use glwidth=screenwidth/2 , glheight=screenheight/2

and within onsurfacechanged set glviewport;

glviewport(0, 0, screenwidth/2, screenheight/2); 

bingo. faster rendering (but 2x2 blocky pixels) output.

hope helps else issue.

you have answer in question, i'll elaborate links.

the size of surface independent of size of view. if different, display hardware scales surface on way display. means can set arbitrary size surface setfixedsize() call, can used reduce number of pixels must updated canvas or gles.

if you're drawing in software canvas, can allow avoid having re-scale bitmaps, because can rely on surface being same size on every device.

there official blog post feature, , example of use in grafika (video here).


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -