我正在尝试将纹理绑定到完美的多边形像素(绘制纹理的一部分但不大于多边形本身)
例如(编辑:这些是多边形的图片而不是四边形)
我的代码如下
//example usage
// drawRectangle((1D * 100D) + 110D, 5, 0D, 25);
//draws a 100px width, 20px height, 0px from left most screen and 5px from top most screen
public static void drawRectangle(double par1, double par2, double par3, double par4)
{
//glRectd(par1, par2, par3, par4);
glBegin(GL_POLYGON);
{
glVertex2d(par1, par2);
glTexCoord2d(0, 0);
glVertex2d(par3, par2);
glTexCoord2d(1, 0);
glVertex2d(par3, par4);
glTexCoord2d(1, 1);
glVertex2d(par1, par4);
glTexCoord2d(0, 1);
}
glEnd();
}
openGL 启动代码
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, finals.GAME_WIDTH, finals.GAME_HEIGHT, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);