namespace VASErin
{ //VASEr internal namespace
/*visual testes:
* A. points (geometry test)
* 1. arbitrary polyline of only 2 point
* 2. polylines of 3 points, making arbitrary included angle
* 3. arbitrary polyline of 4 or more points
* B. colors
* 1. different colors on each point
* C. weight
* 1. varying weight
* D. other drawing options
* 1. feathering
* 2. different joint types
* 3. different cap types
* E. memory test
* 1. drawing a polyline of 1000 points
*/
/*known visual bugs: ( ",," simply means "go wild" as it is too hard to describe)
* 1. [solved]when 2 segments are exactly at 90 degrees, the succeeding line segment is reflexed.
* 1.1 [solved]when 2 segments are exactly at 180 degrees,,
* 2. [solved]when polyline is dragged, caps seem to have pseudo-podia.
* 3. [solved]when 2 segments are exactly horizontal/ vertical, both segments are reflexed.
* 3.1 [solved]when a segment is exactly horizontal/ vertical, the cap disappears
* 4. [solved]when 2 segments make < 5 degrees,,
* 4.1 [solved]when 2 segments make exactly 0 degree,,
* 5. when a segment is shorter than its own width,,
*/
/* const double vaser_actual_PPI = 96.0;
const double vaser_standard_PPI = 111.94; //the PPI I used for calibration
*/
//critical weight to do approximation rather than real joint processing
const double cri_segment_approx=1.6;
void determine_t_r ( double w, double& t, double& R)
{
//efficiency: can cache one set of w,t,R values
// i.e. when a polyline is of uniform thickness, the same w is passed in repeatedly
double f=w-static_cast<int>(w);
/* */if ( w>=0.0 && w<1.0) {
t=0.05; R=0.768;//R=0.48+0.32*f;
} else if ( w>=1.0 && w<2.0) {
t=0.05+f*0.33; R=0.768+0.312*f;
} else if ( w>=2.0 && w<3.0){
t=0.38+f*0.58; R=1.08;
} else if ( w>=3.0 && w<4.0){
t=0.96+f*0.48; R=1.08;
} else if ( w>=4.0 && w<5.0){
t=1.44+f*0.46; R=1.08;
} else if ( w>=5.0 && w<6.0){
t=1.9+f*0.6; R=1.08;
} else if ( w>=6.0){
double ff=w-6.0;
t=2.5+ff*0.50; R=1.08;
}
/* //PPI correction
double PPI_correction = vaser_standard_PPI / vaser_actual_PPI;
const double up_bound = 1.6; //max value of w to receive correction
const double start_falloff = 1.0;
if ( w>0.0 && w<up_bound)
{ //here we gracefully apply the correction
// so that the effect of correction diminishes starting from w=start_falloff
// and completely disappears when w=up_bound
double correction = 1.0 + (PPI_correction-1.0)*(up_bound-w)/(up_bound-start_falloff);
t *= PPI_correction;
R *= PPI_correction;
} */
}
float get_PLJ_round_dangle(float t, float r)
{
float dangle;
float sum = t+r;
if ( sum <= 1.44f+1.08f) //w<=4.0, feathering=1.0
dangle = 0.6f/(t+r);
else if ( sum <= 3.25f+1.08f) //w<=6.5, feathering=1.0
dangle = 2.8f/(t+r);
else
dangle = 4.2f/(t+r);
return dangle;
}
void make_T_R_C( Point& P1, Point& P2, Point* T, Point* R, Point* C,
double w, const polyline_opt& opt,
double* rr, double* tt, float* dist,
bool seg_mode=false)
{
double t=1.0,r=0.0;
Point DP=P2-P1;
//calculate t,r
determine_t_r( w,t,r);
if ( opt.feather && !opt.no_feather_at_core && opt.feathering != 1.0)
r *= opt.feathering;
else if ( seg_mode)
{
//TODO: handle correctly for hori/vert segments in a polyline
if ( Point::negligible(DP.x) && P1.x==(int)P1.x) {
if ( w>0.0 && w<=1.0) {
t=0.5; r=0.0;
P2.x = P1.x = (int)P1.x+0.5;
}
} else if ( Point::negligible(DP.y) && P1.y==(int)P1.y) {
if ( w>0.0 && w<=1.0) {
t=0.5; r=0.0;
P2.y = P1.y = (int)P1.y+0.5;
}
}
}
//output t,r
if (tt) *tt = t;
if (rr) *rr = r;
//calculate T,R,C
double len = DP.normalize();
if (dist) *dist = (float)len;
if (C) *C = DP;
DP.perpen();
if (T) *T = DP*t;
if (R) *R = DP*r;
}
void same_side_of_line( Point& V, const Point& ref, const Point& a, const Point& b)
{
double sign1 = Point::signed_area( a+ref,a,b);
double sign2 = Point::signed_area( a+V, a,b);
if ( (sign1>=0) != (sign2>=0))
{
V.opposite();
}
}
struct st_polyline
//the struct to hold info for anchor_late() to perform triangluation
{
//for all joints
Point vP; //vector to intersection point
Point vR; //fading vector at sharp end
//all vP,vR are outward
//for djoint==PLJ_bevel
Point T; //core thickness of a line
Point R; //fading edge of a line
Point bR; //out stepping vector, same direction as cap
Point T1,R1; //alternate vectors, same direction as T21
//all T,R,T1,R1 are outward
//for djoint==PLJ_round
float t,r;
//for degeneration case
bool degenT; //core degenerated
bool degenR; //fade degenerated
bool pre_full; //draw the preceding segment in full
Point PT,PR;
float pt; //parameter at intersection
bool R_full_degen;
char djoint; //determined joint
// e.g. originally a joint is PLJ_miter. but it is smaller than critical angle, should then set djoint to PLJ_bevel
};
struct st_anchor
//the struct to hold memory for the working of anchor()
{
Point P[3]; //point
Color C[3]; //color
double W[3];//weight
Point cap_start, cap_end;
st_polyline SL[3];
vertex_array_holder vah;
};
void inner_arc( vertex_array_holder& hold, const Point& P,
const Color& C, const Color& C2,
float dangle, float angle1, float angle2,
float r, float r2, bool ignor_ends,
Point* apparent_P) //(apparent center) center of fan
//draw the inner arc between angle1 and angle2 with dangle at each step.
// -the arc has thickness, r is the outer radius and r2 is the inner radius,
// with color C and C2 respectively.
// in case when inner radius r2=0.0f, it gives a pie.
// -when ignor_ends=false, the two edges of the arc lie exactly on angle1
// and angle2. when ignor_ends=true, the two edges of the arc do not touch
// angle1 or angle2.
// -P is the mathematical center of the arc.
// -when apparent_P points to a valid Point (apparent_P != 0), r2 is ignored,
// apparent_P is then the apparent origin of the pie.
// -the result is pushed to hold, in form of a triangle strip
// -an inner arc is an arc which is always shorter than or equal to a half circumference
{
const double& m_pi = vaser_pi;
bool incremental=true;
if ( angle2 > angle1)
{
if ( angle2-angle1>m_pi)
{
angle2=angle2-2*m_pi;
}
}
else
{
if ( angle1-angle2>m_pi)
{
angle1=angle1-2*m_pi;
}
}
if ( angle1>angle2)
{
incremental = false; //means decremental
}
if ( incremental)
{
if ( ignor_ends)
{
int i=0;
for ( float a=angle1+dangle; a<angle2; a+=dangle, i++)
{
float x=cos(a);
float y=sin(a);
#define INNER_ARC_PUSH \
hold.push( Point(P.x+x*r,P.y-y*r), C);\
if ( !apparent_P)\
hold.push( Point(P.x+x*r2,P.y-y*r2), C2);\
else\
hold.push( *apparent_P, C2);
INNER_ARC_PUSH
if ( i>100) {
DEBUG("trapped in loop: inc,ig_end angle1=%.2f, angle2=%.2f, dangle=%.2f\n", angle1, angle2, dangle);
break;
}
}
//DEBUG( "steps=%d ",i); fflush(stdout);
}
else
{
int i=0;
for ( float a=angle1; ; a+=dangle, i++)
{
if ( a>angle2)
a=angle2;
float x=cos(a);
float y=sin(a);
INNER_ARC_PUSH
if ( a>=angle2)
break;
if ( i>100) {
DEBUG("trapped in loop: inc,end angle1=%.2f, angle2=%.2f, dangle=%.2f\n", angle1, angle2, dangle);
break;
}
}
}
}
else //decremental
{
if ( ignor_ends)
{
int i=0;
for ( float a=angle1-dangle; a>angle2; a-=dangle, i++)
{
float x=cos(a);
float y=sin(a);
INNER_ARC_PUSH
if ( i>100) {
DEBUG("trapped in loop: dec,ig_end angle1=%.2f, angle2=%.2f, dangle=%.2f\n", angle1, angle2, dangle);
break;
}
}
}
else
{
int i=0;
for ( float a=angle1; ; a-=dangle, i++)
{
if ( a<angle2)
a=angle2;
float x=cos(a);
float y=sin(a);
INNER_ARC_PUSH
#undef INNER_ARC_PUSH
if ( a<=angle2)
break;
if ( i>100) {
DEBUG("trapped in loop: dec,end angle1=%.2f, angle2=%.2
没有合适的资源?快使用搜索试试~ 我知道了~
opengl_test.zip
共71个文件
sisc:20个
h:13个
cpp:7个
需积分: 11 20 下载量 45 浏览量
2019-07-19
18:23:06
上传
评论
收藏 1.87MB ZIP 举报
温馨提示
1)Vaserenderer是一个开源抗锯齿绘线库,github主页:https://github.com/tyt2y3/vaserenderer 2)在原始代码上做了部分改动,使其支持OpenGL2.0及其以上版本,即可编程管道渲染;可以在config.h中通过定义USE_OPENGL_VERSION_1_1或者USE_OPENGL_VERSION_2_0来选择使用固定管道渲染或是可编程管道渲染
资源推荐
资源详情
资源评论
收起资源包目录
opengl_test.zip (71个子文件)
opengl_test
Debug
vc140.pdb 564KB
opengl_test.log 13KB
vc140.idb 699KB
opengl_test.tlog
CL.read.1.tlog 29KB
link.read.1.tlog 4KB
opengl_test.lastbuildstate 211B
link.write.1.tlog 558B
CL.write.1.tlog 580B
link.command.1.tlog 1KB
CL.command.1.tlog 844B
main.obj 925KB
3rdParty
vaser
backend.h 76B
curve.cpp 3KB
gradient.cpp 2KB
color.h 3KB
opengl.cpp 7KB
polyline.cpp 51KB
vaser.cpp 687B
config.h 522B
point.h 5KB
vertex_array_holder.h 5KB
agg_curve4.cpp 7KB
vaser.h 5KB
SI4.0
opengl_tet.si4project
opengl_tet.sip_xab 1.16MB
opengl_tet.sip_xm 80B
opengl_tet.SearchResults 3KB
opengl_tet.sip_xad 12KB
opengl_tet.sip_xc 40KB
opengl_tet.sip_sym 2.58MB
opengl_tet.sip_xf 40KB
opengl_tet.siproj_settings.xml 512B
opengl_tet.sip_xsd 3KB
cache
parse
main.cpp.sisc 12KB
3rdParty_vaser_vaser.h.sisc 49KB
3rdParty_vaser_agg_curve4.cpp.sisc 23KB
3rdParty_vaser_backend.h.sisc 3KB
Include_GL_glew.h.sisc 1.8MB
3rdParty_vaser_config.h.sisc 3KB
Include_vase_rend_draft_2.h.sisc 26KB
3rdParty_vaser_vaser.cpp.sisc 4KB
Include_GL_wglew.h.sisc 111KB
3rdParty_vaser_curve.cpp.sisc 21KB
3rdParty_vaser_opengl.cpp.sisc 30KB
Include_GL_glxew.h.sisc 146KB
3rdParty_vaser_gradient.cpp.sisc 10KB
3rdParty_vaser_polyline.cpp.sisc 180KB
3rdParty_vaser_vertex_array_holder.h.sisc 26KB
3rdParty_vaser_point.h.sisc 38KB
Include_GL_freeglut_std.h.sisc 117KB
Include_GL_freeglut.h.sisc 1KB
3rdParty_vaser_color.h.sisc 22KB
Include_GL_freeglut_ext.h.sisc 44KB
opengl_tet.sip_xsb 264KB
opengl_tet.siproj 7KB
opengl_tet.bookmarks.xml 162B
opengl_tet.siwork 50KB
opengl_tet.sip_xr 40KB
Include
vase_rend_draft_2.h 9KB
GL
freeglut_std.h 26KB
glew.h 881KB
glxew.h 66KB
wglew.h 61KB
freeglut.h 703B
freeglut_ext.h 9KB
main.cpp 5KB
Lib
glew32.dll 315KB
freeglut.lib 36KB
freeglut.dll 200KB
glew32.lib 523KB
opengl_test.vcxproj.filters 945B
opengl_test.vcxproj 8KB
共 71 条
- 1
资源评论
Mega_Li
- 粉丝: 7503
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功