简体   繁体   中英

OpenGL co-ordinate mapping to device co-ordinate

I have gone through so many tutorial & also implemented some small apps in OpenGL.Stil I have confusion over the mapping of OpenGL co-ordinate system to android view co-ordinate system. I faced the problem while I was trying to display a texture as full screen.Somehow by hit&trial method I was able to show the texture as full screen,but has so many doubts for which I could not proceed fast.

  1. In OpenGL co-ordinate system starts with left-bottom(as origin),whereas in device left- top as origin.How things are mapped correctly to device.

  2. In OpenGL we specify vertices range start from -1 to 1.How these range maps to device where it ranges from 0 to width & height.

  3. Can vertices be mapped exactly the same way as the device co-ordinate.Like vertex with 0,100 maps to device co-ordinates with 0,100.

While trying to show texture as fullscreen,I changed the code according to some blogs&it worked.Here is the changes.

glOrtho(0, width, height, 0, -1, 1);  from  glOrtho(0, width, 0, height, -1, 1);  

 &   vertices[] = {                            
       0, 0,
      width, 0,
      width, height,                
      0, height
      };

  from  {-1,-1,
          1,-1,
         -1,1,
           1,1}

Plz help me to understand the co-ordinate mapping.

将glOrtho设置为width和height的值opengl将进行拉伸以适合您使用的设备,例如,当您创建glOrth(0,width,height,0,1,- 1)opengl拉伸以适合您的屏幕,从而通过设置glOrth()的宽度和高度可以使坐标成为您想要的任何坐标

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM