【发布时间】:2013-11-28 22:09:04
【问题描述】:
我正在编写的程序有问题。目前我正在读取一个 OBJ 文件并正确渲染它。但我的问题是,有些图片不适合我的窗口。
我尝试使用 glScalef 对其进行缩放,但图像仍然变形。 (几乎总是在 Z 上)
这是我设置窗口的方式:
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
float w = gLDrawable.getWidth();
float h = gLDrawable.getHeight();
if(w > h) gl.glOrtho(-1.0*(w/h), 1.0*w/h, -1.0, 1.0, -1.0, 1.0);
else gl.glOrtho(-1.0, 1.0, -1.0*(h/w), 1.0*h/w, -1.0, 1.0);
这是我的 Scale 尝试
if(m.getXVertexMax() - m.getXVertexMin() > w) gl.glScalef(w/(m.getXVertexMax() - m.getXVertexMin()), 1, 1);
else gl.glScalef(1/(m.getXVertexMax() - m.getXVertexMin()), 1, 1);
if(m.getYVertexMax() - m.getYVertexMin() > h) gl.glScalef(1, h/(m.getYVertexMax() - m.getYVertexMin()), 1);
else gl.glScalef(1, 1/(m.getYVertexMax() - m.getYVertexMin()), 1);
gl.glScalef(1, 1, (1/(m.getZVertexMax() - m.getZVertexMin())));
无论我尝试什么,图像总是在 x 上很短或在 z 上非常大!
有人可以帮忙吗?谢谢:-)
【问题讨论】:
标签: java opengl resize image-resizing wavefront