高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】how to improve speed in hatch drawing
how to improve speed in hatch drawing?
how to improve speed in hatch drawing?
hi all,
i want to draw hatch in my own context using opengl.
but when the number of hatch is large or the hatch pattern is dense, the frame rate is very low.
here is my method in brief:
1, in the 1st frame:
a: get the boundingbox(2d, left, right, bottom, top)from the hatch's
boundary.
b: break hatch's boundary into a series of triangles
(if there is any curve in boundary i just break it into line segments first)
c: store the thriangles and the boundingbox for other frame's use.
2, in other frame:
a, get the triangles stored in 1st frame.
set stencil buffer options.
draw these triangles to the stencil buffer
b, get the boundingbox store in 1st frame
set stencil buffer options
for (double x=left; x<right; x+=offestx)
for (double y=bottom; y<top; y+=offesty)
{
draw a series of lines according to hatch's patternname;
}
// in some cases the bounding box is expanded for not using clip
// algorithm, e.g. when the pattern name is ansi31.
i don't know if i express clearly.(sorry for my poor english.)
how to improve the frame rate, can anyone give me some ideas?
or can anyone tell me the method in dwgdirect or autocad in drawing
hatch?
thanks in advacne.
best regards
laoguai0001
last edited by laoguai0001; 6th march 2007 at 12:11 amfff">.
|