En effet: mes données en entrée sont de la forme: un polygone passant par les points [p1;p2;p3;p4;p5] de couleur de remplissage cr avec un contour de couleur cc de largeur L. Dessiner un polygone à coups de lignes me semble légèrement sous-optimal, non ? Par exemple dans la spec que j'affiche dans la capture, il y a un triangle peint en noir avec un bord rosâtre, ou le losange gris plein centre. Je peux aussi avoir à afficher des disques ou des couronnes, avec les mêmes contraintes (remplissage + bordure).
Sinon c'est peut-être dû à mes bindings, mais j'en doute ( http://glcaml.sourceforge.net/ ).
Sinon je t'ajoute aussi le code qui fait effectivement le rendu (le point d'entrée est la dernière fonction: render) :
module Gl = Glcaml
type line_cmd = | Lines | LineLoop |LineStrip
type color = float * float * float * float
type width = float
type depth = float
type point = float * float
type shape_cmd = | Quad | Polygon
type matrix_cmd = | Translate of float * float |Scale of float*float | Rotate of float
type cmd =
|Line of line_cmd * point list * color * width * depth
|Shape of shape_cmd * point list * color * depth
|Matrix of matrix_cmd list * cmd list
let color = function |(r,g,b,a)->Gl.glColor4f r g b a
let set_alpha a = function |(r,g,b,_)->(r,g,b,a)
let width w = Gl.glLineWidth w
let line_prim = function | Lines -> Gl.GL_LINES | LineLoop -> Gl.GL_LINE_LOOP | LineStrip -> Gl.GL_LINE_STRIP
let shape_prim = function | Quad -> Gl.GL_QUADS | Polygon -> Gl.GL_POLYGON
let vertex depth p2D = match p2D with | (x,y)-> Gl.glVertex3f x y depth
let push_matrix transfos =
let trans = function
| Translate(dx,dy) -> Gl.glTranslatef dx dy 0.
| Scale (sx,sy) -> Gl.glScalef sx sy 0.
| Rotate angle -> Gl.glRotatef angle 0. 0. 0.
in
begin
Gl.glPushMatrix ();
List.iter trans transfos;
end
let pop_matrix () = Gl.glPopMatrix ()
let rec render_line= function
|Line(prim,pts,c,w,d) ->
begin
color c ;
width w ;
Gl.glBegin (line_prim prim);
List.iter (vertex d) pts;
Gl.glEnd ();
end
|Shape _ -> ()
|Matrix(transfos, subshapes) -> begin
push_matrix transfos;
List.iter render_line subshapes;
pop_matrix ()
end
let rec render_shape= function
|Line _ -> ()
|Shape(prim,pts,c,d) ->
begin
color c ;
Gl.glBegin (shape_prim prim);
List.iter (vertex (100.)) pts;
Gl.glEnd ();
end
|Matrix(transfos, subshapes) -> begin
push_matrix transfos;
List.iter render_shape subshapes;
pop_matrix ()
end
let render cmd_list =
begin
List.iter render_line cmd_list;
List.iter render_shape cmd_list;
end
[^] # Re: re:
Posté par Obi MO (site web personnel) . En réponse au message [OpenGL] Antialiasing sur fond coloré. Évalué à 1.