//----------------------------------------------------------------------------- void mglCanvas::pxl_primpx(long id, long n, const void *) // NOTE this variant is too slow ... may be later in CUDA??? { mglDrawReg d; d.set(this,1,1,id); #if !MGL_HAVE_PTHREAD #pragma omp parallel for firstprivate(d) #endif for(long ii=0;ii<n;ii+=mglNumThr) { long i=ii%Width, j=ii/Width; for(size_t k=0;k<Prm.size();k++) { if(Stop) break; const mglPrim &p=GetPrm(k); d.PDef = p.n3; d.pPos = p.s; d.ObjId = p.id; d.PenWidth=p.w; d.angle = p.angl; if(p.type==2 || p.type==3) d.PDef = p.m; switch(p.type) { case 0: mark_pix(i,j,Pnt[p.n1],p.n4,p.s,&d); break; case 1: line_pix(i,j,Pnt[p.n1],Pnt[p.n2],&d); break; case 2: trig_pix(i,j,Pnt[p.n1],Pnt[p.n2],Pnt[p.n3],true,&d); break; case 3: quad_pix(i,j,Pnt[p.n1],Pnt[p.n2],Pnt[p.n3],Pnt[p.n4],&d); break; case 4: glyph_pix(i,j,p,&d); break; } } } }
//----------------------------------------------------------------------------- void mglCanvasGL::Finish() { #if MGL_USE_DOUBLE #define MGL_GL_TYPE GL_DOUBLE #else #define MGL_GL_TYPE GL_FLOAT #endif if(Prm.size()>0) { PreparePrim(0); /* glVertexPointer(3, MGL_GL_TYPE, sizeof(mglPnt), &(Pnt[0].x)); // something wrong with arrays glNormalPointer(MGL_GL_TYPE, sizeof(mglPnt), &(Pnt[0].u)); glColorPointer(4, MGL_GL_TYPE, sizeof(mglPnt), &(Pnt[0].r)); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_COLOR_ARRAY);*/ int pdef=PDef; mreal ss=pPos, ww=PenWidth; mglPrim p; for(size_t i=0;i<Prm.size();i++) { p=GetPrm(i); PDef=p.n3; pPos=p.s; PenWidth=p.w; register long n1=p.n1, n2=p.n2, n3=p.n3, n4=p.n4; switch(p.type) { /* case 0: mark_draw(Pnt[n1],n4,p.s,0); break; case 1: line_draw(n1,n2); break; case 2: trig_draw(n1,n2,n3); break; case 3: quad_draw(n1,n2,n3,n4); break;*/ case 0: mark_draw(Pnt[n1],n4,p.s,0); break; case 1: line_draw(Pnt[n1],Pnt[n2],0); break; case 2: trig_draw(Pnt[n1],Pnt[n2],Pnt[n3],true,0); break; case 3: quad_draw(Pnt[n1],Pnt[n2],Pnt[n3],Pnt[n4],0); break; case 4: glyph_draw(p,0); break; } } PDef=pdef; pPos=ss; PenWidth=ww; } glFinish(); // glBegin(GL_LINES); glColor3f(0,0,1); glVertex2f(0.1,0.1); glVertex2f(0.9,0.9); glEnd(); }