fie*_*age 4 opengl graphics sdl
我最近一直在学习OpenGL和SDL,而且我对SDL和glOrtho中的坐标系感到困惑.我已经阅读了一些关于SDL坐标系的教程,其中坐标从(0,0)到(w,h),这对我来说没有意义.如果宽度从0变为w,那么这意味着有一个额外的像素.
此外,使用OpenGL glOrtho函数,我已经看到所有将坐标系更改为类似于SDL的示例,采用以下形式:
glOrtho (0, screenWidth, screenHeight, 0, 1, -1);
Run Code Online (Sandbox Code Playgroud)
但是,这样做是否更有意义?:
glOrtho (0, screenWidth-1, screenHeight-1, 0, 1, -1);
Run Code Online (Sandbox Code Playgroud)
希望你们能为我澄清一下,谢谢.
像新千年的开始一样混乱.我会试着解释一下:
取一些网格规则的纸张并标记一些网格交叉作为原点,即0,0坐标.测量一个方向上的9个网格单位的宽度,标记它.现在计算您测量的细胞数量.让我说明一下:
0 1 2 3 4 5 6 7 8 9 <- grid lines; coordinate range
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
|0|1|2|3|4|5|6|7|8| <- cell index/offset
Run Code Online (Sandbox Code Playgroud)
所以你有一个宽度为9的网格,但其中只有9-1 = 8个单元格(例如像素).你给glOrtho的范围是范围的限制.