Bonjour,
En voulant adoucir des rectangles arrondis j'ai obtenu ceci ;
En regardant bien on vois un effet de moiré sur la zone transparente du rectangle. Sachant que toute la forme est censée être transparente à 50%.
Voici mon code :
initialisation
DessinglEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);
J'ai aussi des diagonales sur mes rectangles.. Les bugs sont arrivé avec GL_LINE_SMOOTH.
public void drawCircle(int xx, int yy, int ww, int hh, int p, int sa, int ea) {
final double PI = 3.141592654;
double angle = sa;
int points = 360;
for(int i = 0; i < points;i++){
if(i > sa && i < ea) {
angle = 2*PI * i / points;
glVertex2f(xx + (float)Math.cos(angle)*ww, yy + (float)Math.sin(angle)*hh);
}
}
}
public void fillRoundRect(int x, int y, int ww, int hh, int ra) {
glPointSize(1.0f);
glBegin(GL_POLYGON);
glColor4f(r, g, b, a);
drawCircle(x + ra, y-ra+hh, ra, ra, 5, 90, 180);
drawCircle(x + ra, y+ra, ra, ra, 5, 180, 270);
drawCircle(x - ra + ww, y+ra, ra, ra, 5, 270, 360);
drawCircle(x - ra + ww, y+hh-ra, ra, ra, 5, 0, 90);
glEnd();
}
Si quelqu'un sait pourquoi ça donne ce résultat, et si possible comment obtenir une couleur uniforme, je suis preneur !
Merci à vous !
Partager