本文整理汇总了C++中draw_primitive_end函数的典型用法代码示例。如果您正苦于以下问题:C++ draw_primitive_end函数的具体用法?C++ draw_primitive_end怎么用?C++ draw_primitive_end使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了draw_primitive_end函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_sector
void draw_sector(gs_scalar x, gs_scalar y, gs_scalar rx, gs_scalar ry, float a1, float a2, bool outline)
{
// TODO(JoshDreamland): Replace with settings macro to get from preferred unit to radians
a1 *= M_PI/180;
a2 *= M_PI/180;
gs_scalar pr = 2*M_PI/enigma::circleprecision;
if (outline) {
draw_primitive_begin(pr_linestrip);
draw_vertex(x, y);
for (float a = a1; a < a2; a += pr) {
draw_vertex(x + rx * cos(a), y - ry * sin(a));
}
draw_vertex(x + rx * cos(a2), y - ry * sin(a2));
draw_vertex(x, y);
draw_primitive_end();
} else {
draw_primitive_begin(pr_trianglefan);
draw_vertex(x, y);
for (float a = a1; a < a2; a += pr) {
draw_vertex(x + rx * cos(a), y - ry * sin(a));
}
draw_primitive_end();
}
}
示例2: draw_ellipse
void draw_ellipse(gs_scalar x1, gs_scalar y1, gs_scalar x2, gs_scalar y2, bool outline)
{
gs_scalar
x=(x1+x2)/2,y=(y1+y2)/2,
hr=fabs(x2-x),vr=fabs(y2-y),
pr=2*M_PI/enigma::circleprecision;
if (outline)
{
draw_primitive_begin(pr_linelist);
for(gs_scalar i=pr;i<M_PI;i+=pr)
{
gs_scalar xc1 = cos(i)*hr, yc1 = sin(i)*vr;
i += pr;
gs_scalar xc2=cos(i)*hr,yc2=sin(i)*vr;
draw_vertex(x+xc1,y+yc1);draw_vertex(x+xc2,y+yc2);
draw_vertex(x-xc1,y+yc1);draw_vertex(x-xc2,y+yc2);
draw_vertex(x+xc1,y-yc1);draw_vertex(x+xc2,y-yc2);
draw_vertex(x-xc1,y-yc1);draw_vertex(x-xc2,y-yc2);
}
draw_primitive_end();
} else {
for(float i = pr; i < M_PI; i += pr)
{
float xc1=cos(i)*hr,yc1=sin(i)*vr;
i+=pr;
float xc2=cos(i)*hr,yc2=sin(i)*vr;
draw_primitive_begin(pr_trianglestrip);
draw_vertex(x-xc1,y+yc1);draw_vertex(x+xc1,y+yc1);draw_vertex(x-xc2,y+yc2);draw_vertex(x+xc2,y+yc2);
draw_primitive_end();
draw_primitive_begin(pr_trianglestrip);
draw_vertex(x-xc1,y-yc1);draw_vertex(x+xc1,y-yc1);draw_vertex(x-xc2,y-yc2);draw_vertex(x+xc2,y-yc2);
draw_primitive_end();
}
}
}
示例3: draw_button
void draw_button(gs_scalar x1, gs_scalar y1,gs_scalar x2, gs_scalar y2, gs_scalar border_width, bool up)
{
if(x1>x2) {
x2=x1;
x1=x2;
}
if(y1>y2) {
y2=y1;
y1=y2;
}
if (x2-x1<border_width*2){border_width=(x2-x1)/2;}
if (y2-y1<border_width*2){border_width=(y2-y1)/2;}
draw_primitive_begin(pr_trianglestrip);
draw_vertex(x1,y1);
draw_vertex(x2,y1);
draw_vertex(x1,y2);
draw_vertex(x2,y2);
draw_primitive_end();
int color;
float alpha = 0.5;
if (up == true){ color = make_color_rgb(127,127,127); } else { color = make_color_rgb(255,255,255); }
draw_primitive_begin(pr_trianglestrip);
draw_vertex_color(x1+border_width,y2-border_width,color,alpha);
draw_vertex_color(x2-border_width,y1-border_width,color,alpha);
draw_vertex_color(x1,y2,color,alpha);
draw_vertex_color(x2,y2,color,alpha);
draw_primitive_end();
draw_primitive_begin(pr_trianglestrip);
draw_vertex_color(x2-border_width,y1+border_width,color,alpha);
draw_vertex_color(x2,y1,color,alpha);
draw_vertex_color(x1-border_width,y1-border_width,color,alpha);
draw_vertex_color(x2,y2,color,alpha);
draw_primitive_end();
if (up == true){ color = make_color_rgb(255,255,255); } else { color = make_color_rgb(127,127,127); }
draw_primitive_begin(pr_trianglestrip);
draw_vertex_color(x1,y1,color,alpha);
draw_vertex_color(x2,y1,color,alpha);
draw_vertex_color(x1+border_width,y1+border_width,color,alpha);
draw_vertex_color(x2-border_width,y2+border_width,color,alpha);
draw_primitive_end();
draw_primitive_begin(pr_trianglestrip);
draw_vertex_color(x1,y1,color,alpha);
draw_vertex_color(x1+border_width,y1+border_width,color,alpha);
draw_vertex_color(x1,y2,color,alpha);
draw_vertex_color(x1+border_width,y2-border_width,color,alpha);
draw_primitive_end();
}
示例4: draw_roundrect_precise
void draw_roundrect_precise(gs_scalar x1, gs_scalar y1,gs_scalar x2, gs_scalar y2, float rad, bool outline)
{
if (x1>x2) {
float t=x2;
x2=x1;
x1=t;
}
if (y1>y2) {
float t=y2;
y2=y1;
y1=t;
}
if (x2-x1<rad*2){rad=(x2-x1)/2;}
if (y2-y1<rad*2){rad=(y2-y1)/2;}
if (rad<0){rad=0;}
float r2=rad*rad,r12=rad*M_SQRT1_2,
bx1=x1+rad,by1=y1+rad,
bx2=x2-rad,by2=y2-rad;
if (outline) {
draw_primitive_begin(pr_linelist);
draw_vertex(x1,by1);draw_vertex(x1,by2);
draw_vertex(x2,by1);draw_vertex(x2,by2);
draw_vertex(bx1,y1);draw_vertex(bx2,y1);
draw_vertex(bx1,y2);draw_vertex(bx2,y2);
draw_primitive_end();
draw_primitive_begin(pr_pointlist);
for(float xc=0,yc=rad;xc<=r12;xc++) {
if (xc*xc+yc*yc>r2) yc--;
draw_vertex(bx2+xc,by2+yc);
draw_vertex(bx2+xc,by1-yc);
draw_vertex(bx1-xc,by2+yc);
draw_vertex(bx1-xc,by1-yc);
draw_vertex(bx2+yc,by2+xc);
draw_vertex(bx2+yc,by1-xc);
draw_vertex(bx1-yc,by2+xc);
draw_vertex(bx1-yc,by1-xc);
}
draw_primitive_end();
} else {
draw_primitive_begin(pr_linelist);
for(float xc=0,yc=rad;xc<=r12;xc++) {
if (xc*xc+yc*yc>r2) yc--;
draw_vertex(bx2+xc,by2+yc);
draw_vertex(bx2+xc,by1-yc);
draw_vertex(bx1-xc,by2+yc);
draw_vertex(bx1-xc,by1-yc);
draw_vertex(bx2+yc,by2+xc);
draw_vertex(bx2+yc,by1-xc);
draw_vertex(bx1-yc,by2+xc);
draw_vertex(bx1-yc,by1-xc);
}
draw_primitive_end();
draw_rectangle(bx1,y1,bx2,y2,false);
}
}
示例5: draw_background_general
void draw_background_general(int back, gs_scalar left, gs_scalar top, gs_scalar width, gs_scalar height, gs_scalar x, gs_scalar y, gs_scalar xscale, gs_scalar yscale, double rot, int c1, int c2, int c3, int c4, gs_scalar alpha)
{
alpha=clamp_alpha(alpha);
get_background(bck2d, back);
const gs_scalar tbx = bck2d->texturex, tby = bck2d->texturey,
tbw = bck2d->texturew, tbh = bck2d->textureh,
ttbw = bck2d->width/tbw, ttbh = bck2d->height/tbh,
tbx1 = tbx+left/ttbw, tby1 = tby+top/ttbh,
tbx2 = tbx+(left+width)/ttbw, tby2 = tby+(top+height)/ttbh,
w = width*xscale, h = height*yscale;
rot *= M_PI/180;
const gs_scalar wcosrot = w*cos(rot), wsinrot = w*sin(rot);
gs_scalar ulcx = x + xscale * cos(M_PI+rot) + yscale * cos(M_PI/2+rot),
ulcy = y - yscale * sin(M_PI+rot) - yscale * sin(M_PI/2+rot);
draw_primitive_begin_texture(pr_trianglestrip, bck2d->texture);
draw_vertex_texture_color(ulcx, ulcy, tbx1, tby1,c1,alpha);
draw_vertex_texture_color((ulcx + wcosrot), (ulcy - wsinrot), tbx2,tby1, c2, alpha);
ulcx += h * cos(3*M_PI/2 + rot);
ulcy -= h * sin(3*M_PI/2 + rot);
draw_vertex_texture_color(ulcx, ulcy, tbx1, tby2,c3,alpha);
draw_vertex_texture_color((ulcx + wcosrot), (ulcy - wsinrot), tbx2, tby2,c4,alpha);
draw_primitive_end();
}
示例6: draw_line
void draw_line(gs_scalar x1, gs_scalar y1,gs_scalar x2, gs_scalar y2)
{
draw_primitive_begin(pr_linestrip);
draw_vertex(x1, y1);
draw_vertex(x2, y2);
draw_primitive_end();
}
示例7: draw_circle_color_perfect
void draw_circle_color_perfect(gs_scalar x, gs_scalar y, float rad, int c1, int c2, bool outline)
{
gs_scalar r2=rad*rad;
gs_scalar alpha = draw_get_alpha();
if (outline)
{
draw_primitive_begin(pr_pointlist);
gs_scalar r12=rad*M_SQRT1_2;
for(gs_scalar xc=0,yc=rad;xc<=r12;xc++)
{
if(xc*xc+yc*yc>r2) yc--;
draw_vertex_color(x+xc, y+yc, c2, alpha);
draw_vertex_color(x+xc, y-yc, c2, alpha);
draw_vertex_color(x-xc, y+yc, c2, alpha);
draw_vertex_color(x-xc, y-yc, c2, alpha);
draw_vertex_color(x+xc, y+yc, c2, alpha);
draw_vertex_color(x+xc, y-yc, c2, alpha);
draw_vertex_color(x-xc, y+yc, c2, alpha);
draw_vertex_color(x-xc, y-yc, c2, alpha);
}
} else {
draw_primitive_begin(pr_trianglefan);
draw_vertex_color(x,y,c1,alpha);
draw_vertex_color(x-rad,y,c2,alpha);
for(gs_scalar xc=-rad+1;xc<rad;xc++)
draw_vertex_color(x+xc,y+sqrt(r2-(xc*xc)),c2,alpha);
for(gs_scalar xc=rad;xc>-rad;xc--)
draw_vertex_color(x+xc,y-sqrt(r2-(xc*xc)),c2,alpha);
draw_vertex_color(x-rad,y,c2,alpha);
}
draw_primitive_end();
}
示例8: draw_sprite_tiled
void draw_sprite_tiled(int spr, int subimg, gs_scalar x, gs_scalar y, int color, gs_scalar alpha)
{
get_spritev(spr2d,spr);
const int usi = subimg >= 0 ? (subimg % spr2d->subcount) : int(((enigma::object_graphics*)enigma::instance_event_iterator->inst)->image_index) % spr2d->subcount;
x = ((spr2d->xoffset+x)<0?0:spr2d->width)-fmod(spr2d->xoffset+x,spr2d->width);
y = ((spr2d->yoffset+y)<0?0:spr2d->height)-fmod(spr2d->yoffset+y,spr2d->height);
const gs_scalar tbx = spr2d->texbordxarray[usi], tby = spr2d->texbordyarray[usi];
const int
hortil = int(ceil((view_enabled ? (gs_scalar)(view_xview[view_current] + view_wview[view_current]) : (gs_scalar)room_width) / ((gs_scalar)spr2d->width))) + 1,
vertil = int(ceil((view_enabled ? (gs_scalar)(view_yview[view_current] + view_hview[view_current]) : (gs_scalar)room_height) / ((gs_scalar)spr2d->height))) + 1;
gs_scalar xvert1 = -x, xvert2 = xvert1 + spr2d->width, yvert1, yvert2;
for (int i=0; i<hortil; ++i)
{
yvert1 = -y; yvert2 = yvert1 + spr2d->height;
for (int c=0; c<vertil; ++c)
{
draw_primitive_begin_texture(pr_trianglestrip, spr2d->texturearray[usi]);
draw_vertex_texture_color(xvert1,yvert1,0,0,color,alpha);
draw_vertex_texture_color(xvert2,yvert1,tbx,0,color,alpha);
draw_vertex_texture_color(xvert1,yvert2,0,tby,color,alpha);
draw_vertex_texture_color(xvert2,yvert2,tbx,tby,color,alpha);
draw_primitive_end();
yvert1 = yvert2;
yvert2 += spr2d->height;
}
xvert1 = xvert2;
xvert2 += spr2d->width;
}
}
示例9: draw_background_tiled
void draw_background_tiled(int back, gs_scalar x, gs_scalar y, int color, gs_scalar alpha)
{
alpha=clamp_alpha(alpha);
get_background(bck2d,back);
x = (x<0?0:bck2d->width)-fmod(x,bck2d->width);
y = (y<0?0:bck2d->height)-fmod(y,bck2d->height);
const gs_scalar tbx = bck2d->texturex, tby = bck2d->texturey,
tbw = bck2d->texturew, tbh = bck2d->textureh;
const int hortil = int (ceil((gs_scalar)room_width/((gs_scalar)bck2d->width))) + 1,
vertil = int (ceil((gs_scalar)room_height/((gs_scalar)bck2d->height))) + 1;
gs_scalar xvert1 = -x, xvert2 = xvert1 + bck2d->width, yvert1, yvert2;
for (int i=0; i<hortil; ++i)
{
yvert1 = -y; yvert2 = yvert1 + bck2d->height;
for (int c=0; c<vertil; ++c)
{
draw_primitive_begin_texture(pr_trianglestrip, bck2d->texture);
draw_vertex_texture_color(xvert1,yvert1,tbx,tby,color,alpha);
draw_vertex_texture_color(xvert2,yvert1,tbx+tbw,tby,color,alpha);
draw_vertex_texture_color(xvert1,yvert2,tbx,tby+tbh,color,alpha);
draw_vertex_texture_color(xvert2,yvert2,tbx+tbw,tby+tbh,color,alpha);
draw_primitive_end();
yvert1 = yvert2;
yvert2 += bck2d->height;
}
xvert1 = xvert2;
xvert2 += bck2d->width;
}
}
示例10: draw_background_ext
void draw_background_ext(int back, gs_scalar x, gs_scalar y, gs_scalar xscale, gs_scalar yscale, double rot, int color, gs_scalar alpha)
{
alpha=clamp_alpha(alpha);
get_background(bck2d,back);
rot *= M_PI/180;
const gs_scalar tbw = bck2d->texturew, tbh = bck2d->textureh,
tbx = bck2d->texturex, tby = bck2d->texturey,
w = bck2d->width*xscale, h = bck2d->height*yscale,
wsinrot = w*sin(rot), wcosrot = w*cos(rot);
draw_primitive_begin_texture(pr_trianglestrip, bck2d->texture);
gs_scalar ulcx = x + xscale * cos(M_PI+rot) + yscale * cos(M_PI/2+rot),
ulcy = y - yscale * sin(M_PI+rot) - yscale * sin(M_PI/2+rot);
draw_vertex_texture_color(ulcx, ulcy, tbx, tby,color,alpha);
draw_vertex_texture_color(ulcx + wcosrot, ulcy - wsinrot, tbx+tbw, tby,color,alpha);
const double mpr = 3*M_PI/2 + rot;
ulcx += h * cos(mpr);
ulcy -= h * sin(mpr);
draw_vertex_texture_color(ulcx, ulcy, tbx, tby+tbh,color,alpha);
draw_vertex_texture_color(ulcx + wcosrot, ulcy - wsinrot, tbx+tbw, tby+tbh,color,alpha);
draw_primitive_end();
}
示例11: draw_healthbar
//Mind that health is 1-100
void draw_healthbar(gs_scalar x1, gs_scalar y1,gs_scalar x2, gs_scalar y2, float amount, int backcol, int mincol, int maxcol, int dir, bool showback, bool showborder)
{
if (x1>x2) { // Swap them
gs_scalar t = x2;
x2 = x1, x1 = t;
}
if (y1>y2) { // Swap them
gs_scalar t = y2;
y2 = y1, y1 = t;
}
amount = amount>=100 ? 1 : (amount<=0 ? 0 : amount/100);
gs_scalar alpha = draw_get_alpha();
if (showback) {
draw_primitive_begin(pr_trianglestrip);
draw_vertex_color(x1,y1,backcol,alpha);
draw_vertex_color(x2,y1,backcol,alpha);
draw_vertex_color(x1,y2,backcol,alpha);
draw_vertex_color(x2,y2,backcol,alpha);
draw_primitive_end();
}
switch (dir) {
case 1:x1=x2-(x2-x1)*amount;break;
case 2:y2=y1+(y2-y1)*amount;break;
case 3:y1=y2-(y2-y1)*amount;break;
default:x2=x1+(x2-x1)*amount;
}
int col = merge_color(mincol, maxcol, amount);
draw_primitive_begin(pr_trianglestrip);
draw_vertex_color(x1,y1,col,alpha);
draw_vertex_color(x2,y1,col,alpha);
draw_vertex_color(x1,y2,col,alpha);
draw_vertex_color(x2,y2,col,alpha);
draw_primitive_end();
if (showborder) {
draw_primitive_begin(pr_linestrip);
draw_vertex_color(x1,y1,0,alpha);
draw_vertex_color(x2,y1,0,alpha);
draw_vertex_color(x2,y2,0,alpha);
draw_vertex_color(x1,y2,0,alpha);
draw_vertex_color(x1,y1,0,alpha);
draw_primitive_end();
}
}
示例12: draw_line_color
void draw_line_color(gs_scalar x1, gs_scalar y1,gs_scalar x2, gs_scalar y2, int c1, int c2)
{
gs_scalar alpha = draw_get_alpha();
draw_primitive_begin(pr_linestrip);
draw_vertex_color(x1, y1, c1, alpha);
draw_vertex_color(x2, y2, c2, alpha);
draw_primitive_end();
}
示例13: draw_triangle
void draw_triangle(gs_scalar x1, gs_scalar y1,gs_scalar x2, gs_scalar y2, gs_scalar x3, gs_scalar y3, bool outline)
{
if (outline) {
draw_primitive_begin(pr_linestrip);
draw_vertex(x1, y1);
draw_vertex(x2, y2);
draw_vertex(x3, y3);
draw_vertex(x1, y1);
draw_primitive_end();
} else {
draw_primitive_begin(pr_trianglestrip);
draw_vertex(x1, y1);
draw_vertex(x2, y2);
draw_vertex(x3, y3);
draw_primitive_end();
}
}
示例14: draw_polygon_end
void draw_polygon_end(bool outline, bool allowHoles)
{
std::list<enigma::PolyVertex>& currPoly = enigma::currComplexPoly;
if (outline) {
if (currPoly.size() >= 2) {
int color = draw_get_color();
gs_scalar alpha = draw_get_alpha();
//Close it, ensure the correct color.
currPoly.push_back(currPoly.front());
if (currPoly.back().color==-1) { currPoly.back().color = color; }
//Draw it.
draw_primitive_begin(pr_linestrip);
for (std::list<enigma::PolyVertex>::const_iterator it = currPoly.begin(); it!=currPoly.end(); it++) {
color = (it->color!=-1 ? it->color : color);
draw_vertex_color(it->x, it->y, color, alpha);
}
//Close it.
draw_primitive_end();
}
} else {
if (currPoly.size() >= 3) {
//Self-intersecting polygons makes this much harder than "outline" mode; we need to make a call
// to the platform-specific Graphics backend.
if (!enigma::fill_complex_polygon(currPoly, draw_get_color(), allowHoles)) {
//If drawing failed, try using a triangle fan as a backup. This will work for concave polygons only.
int color = draw_get_color();
gs_scalar alpha = draw_get_alpha();
//Draw it.
draw_primitive_begin(pr_trianglefan);
for (std::list<enigma::PolyVertex>::const_iterator it = currPoly.begin(); it!=currPoly.end(); it++) {
color = (it->color!=-1 ? it->color : color);
draw_vertex_color(it->x, it->y, color, alpha);
}
//Close it.
draw_primitive_end();
}
}
}
currPoly.clear();
}
示例15: draw_spline4c
void draw_spline4c(gs_scalar x1, gs_scalar y1, gs_scalar x2, gs_scalar y2, gs_scalar x3, gs_scalar y3, gs_scalar x4, gs_scalar y4, gs_scalar x5, gs_scalar y5, gs_scalar x6, gs_scalar y6)
{
draw_primitive_begin(pr_curve_mode);
draw_spline_part(x1, y1, x2, y2, x3, y3, x4, y4);
draw_spline_part(x2, y2, x3, y3, x4, y4, x5, y5);
draw_spline_part(x3, y3, x4, y4, x5, y5, x6, y6);
draw_primitive_end();
}