OpenGL 2D coordinates to Psychtoolbox (pixel) coordinates

穿精又带淫゛_ 提交于 2019-12-12 02:43:54

问题


I'm modifying a matlab code. It displays graphics using the Psychtoolbox, which can basically create an on-screen window. The code I want to adapt uses both higher-level Psychtoolbox commands and lower-level OpenGL calls, as provided by the Matlab OpenGL toolbox. I'm familiar with Psychtoolbox, not at all familiar with OpenGL.

Coordinates in Psychtoolbox are in pixels and start on (0,0) from the top-left corner of the screen and move rightwards (x) and downwards (y).

I simply need the conversion between the Matlab implementation of OpenGL coordinates and Psychtoolbox's pixel-based ones. There are a few questions and answers and many resources online about this, but I am still confused.

For example, as far as I understand OpenGL uses normalized coordinates that range between [-1, 1]. However, in the code I am adapting something is nicely displayed despite y = -1.5.

So my questions are:

  1. How do I convert between Matlab's OpenGL and Matlab's Psychtoobox coordinates?
  2. Can OpenGL coordinates in Matlab go beyond the [-1, 1] range?

来源:https://stackoverflow.com/questions/43005282/opengl-2d-coordinates-to-psychtoolbox-pixel-coordinates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!