1

OpenGL で色を適切に機能させるのに問題があります。私は自分の形を適切に描画し、それらはうまく見えますが、glColor4d(r,g,b,a)を呼び出すと、RGB が指示するはずの色を正しく使用しませんが、代わりに異なるが類似した色を描画します。たとえば、ほとんどの緑は完全な黄色または完全な緑として描画され、グレーは純白として描画されます。

Color[r=132,g=234,b=208,a=255,hexa=84EAD0]
Color[r=150,g=1,b=59,a=255,hexa=96013B]
Color[r=88,g=117,b=170,a=255,hexa=5875AA]
Color[r=219,g=190,b=26,a=255,hexa=DBBE1A]
Color[r=208,g=51,b=164,a=255,hexa=D033A4]
Color[r=85,g=43,b=228,a=255,hexa=552BE4]
Color[r=167,g=123,b=184,a=255,hexa=A77BB8]
Color[r=241,g=183,b=25,a=255,hexa=F1B719]

このランダムな色の値の短いリストでは、白​​であってはならないにもかかわらず、すべての値が FFFFFF の純白として描かれています。

長方形を描画するために使用しているコード:

public void drawRectangle(Color fill, double x, double y, double width, double height, double rot){
    GL11.glPushMatrix();
    GL11.glTranslated(x, y, 0);
    GL11.glRotated(rot, 0, 0, 1);
    GL11.glTranslated(-x, -y, 0);
    GL11.glBegin(GL11.GL_TRIANGLES);
    if(fill != null)GL11.glColor4d(fill.getRed(), fill.getGreen(), fill.getBlue(), fill.getAlpha());
    double width2 = width/2;
    double height2 = height/2;
    GL11.glVertex2d(x - width2, y + height2);
    GL11.glVertex2d(x - width2, y - height2);
    GL11.glVertex2d(x + width2, y + height2);
    GL11.glEnd();
    GL11.glBegin(GL11.GL_TRIANGLES);
    if(fill != null)GL11.glColor4d(fill.getRed(), fill.getGreen(), fill.getBlue(), fill.getAlpha());
    GL11.glVertex2d(x - width2, y - height2);
    GL11.glVertex2d(x + width2, y + height2);
    GL11.glVertex2d(x + width2, y - height2);
    GL11.glEnd();
    GL11.glPopMatrix();
}
4

1 に答える 1

4

glColor4d()は 0.0 から 1.0 までのパラメータを取ります。255 までではglColor4i()ありません。上記のすべて1.0が変更され1.0、ほとんどの場合、白色になります。
変化する

GL11.glColor4d(fill.getRed(), fill.getGreen(), fill.getBlue(), fill.getAlpha());

GL11.glColor4d(fill.getRed() / 255.0, fill.getGreen() / 255.0, fill.getBlue() / 255.0, fill.getAlpha() / 255.0);
于 2013-06-28T06:51:41.577 に答える