使用 glOrtho 自动化 2D 线图视图端口的通用公式
基于动态数据,我需要使用openGL动态绘制2D线图。由于数据会变化,因此还需要调整图表的最终绘制,以便可以查看 X 轴和 Y 轴的最大值和最小值。我尝试了几种使用 glortho 的方法,有人可以建议我这个公式吗,
我的 x 轴最大值是 10,000.0f,Y 轴最大值是 64,468.0f (假设 x 轴 n y 轴最小值约为 1.0f)
glOrtho(-0.0,Winwidth,0.0,Winheight,0.0f,1.0f);
如果我使用上述参数,我无法查看图表的最大值和最小值,
glOrtho(-1.0f,maxXval,1.0,maxYval,0.0f,1.0f);
当最大值很大时,上面的参数可以正常工作,
如果最大值是对于上面的示例,小于 1,那么查看区域将被裁剪,因为 left 值为 1,类似地,bottom 值为 1?
Based on the dynamic data, I need to draw a 2D line graph dynamically using openGL. Since, the data varies, the final drawing of the graph also needs to be adjusted such that both X-axis's and Y-axis's max and min values should be viewed. I tried several ways using glortho, could any one suggest me the formula for this,
My x-axis max value is 10,000.0f and Y-axis max value is 64,468.0f
(assume x-axis n y-axis min val are around 1.0f)
glOrtho(-0.0,Winwidth,0.0,Winheight,0.0f,1.0f);
if I use above parameters I'm unable to view max and min values of the graph
glOrtho(-1.0f,maxXval,1.0,maxYval,0.0f,1.0f);
the above one works fine when max values are large,
what if the maxvalues are less then 1 for the above example, then the viewing area is being clipped because left value is 1 and similarly, bottom value is 1?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
怎么样
How about