summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/drawpath3.cc
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-03-27 22:27:57 +0000
committerKarl Berry <karl@freefriends.org>2019-03-27 22:27:57 +0000
commit9121faed0cf54a08882acf41120cf28fc3a32998 (patch)
treefe7f0c5e9ed02fe4a1fc389c27c88750c2807e43 /Build/source/utils/asymptote/drawpath3.cc
parentb8e24fbf964b4030f68a8484a53d405869693266 (diff)
asy 2.48 sources
git-svn-id: svn://tug.org/texlive/trunk@50622 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/drawpath3.cc')
-rw-r--r--Build/source/utils/asymptote/drawpath3.cc106
1 files changed, 71 insertions, 35 deletions
diff --git a/Build/source/utils/asymptote/drawpath3.cc b/Build/source/utils/asymptote/drawpath3.cc
index 5d102975ffb..878a58a66fb 100644
--- a/Build/source/utils/asymptote/drawpath3.cc
+++ b/Build/source/utils/asymptote/drawpath3.cc
@@ -6,12 +6,23 @@
#include "drawpath3.h"
#include "drawsurface.h"
+#include "material.h"
+
+#include <glm/glm.hpp>
+#include <glm/gtc/matrix_transform.hpp>
+#include <glm/gtc/type_ptr.hpp>
namespace camp {
using vm::array;
using namespace prc;
+#ifdef HAVE_GL
+using gl::modelView;
+
+BezierCurve drawPath3::R;
+#endif
+
bool drawPath3::write(prcfile *out, unsigned int *, double, groupsmap&)
{
Int n=g.length();
@@ -43,9 +54,8 @@ bool drawPath3::write(prcfile *out, unsigned int *, double, groupsmap&)
return true;
}
-void drawPath3::render(GLUnurbs *nurb, double size2,
- const triple& b, const triple& B,
- double perspective, bool lighton, bool transparent)
+void drawPath3::render(double size2, const triple& b, const triple& B,
+ double perspective, bool transparent)
{
#ifdef HAVE_GL
Int n=g.length();
@@ -71,13 +81,8 @@ void drawPath3::render(GLUnurbs *nurb, double size2,
const pair size3(s*(B.getx()-b.getx()),s*(B.gety()-b.gety()));
- double t[16]; // current transform
- glGetDoublev(GL_MODELVIEW_MATRIX,t);
-// Like Fortran, OpenGL uses transposed (column-major) format!
- run::transpose(t,4);
- run::inverse(t,4);
bbox3 box(m,M);
- box.transform(t);
+ box.transform(modelView.Tinv);
m=box.Min();
M=box.Max();
@@ -86,19 +91,8 @@ void drawPath3::render(GLUnurbs *nurb, double size2,
Max.getz() < m.getz() || Min.getz() > M.getz()))
return;
- drawBezierPatch::S.draw();
-
- GLfloat Diffuse[]={0.0,0.0,0.0,(GLfloat) color.A};
- glMaterialfv(GL_FRONT,GL_DIFFUSE,Diffuse);
- static GLfloat Black[]={0.0,0.0,0.0,1.0};
- glMaterialfv(GL_FRONT,GL_AMBIENT,Black);
- GLfloat Emissive[]={(GLfloat) color.R,(GLfloat) color.G,(GLfloat) color.B,
- (GLfloat) color.A};
- glMaterialfv(GL_FRONT,GL_EMISSION,Emissive);
- glMaterialfv(GL_FRONT,GL_SPECULAR,Black);
- glMaterialf(GL_FRONT,GL_SHININESS,128.0);
-
-
+ RGBAColour Black(0.0,0.0,0.0,color.A);
+ setcolors(false,Black,Black,color,Black,1.0);
if(billboard) {
for(Int i=0; i < n; ++i) {
@@ -214,9 +208,8 @@ void drawNurbsPath3::displacement()
#endif
}
-void drawNurbsPath3::render(GLUnurbs *nurb, double, const triple&,
- const triple&, double, bool lighton,
- bool transparent)
+void drawNurbsPath3::render(double, const triple&, const triple&,
+ double, bool transparent)
{
#ifdef HAVE_GL
if(invisible || ((color.A < 1.0) ^ transparent))
@@ -235,20 +228,63 @@ void drawNurbsPath3::render(GLUnurbs *nurb, double, const triple&,
glMaterialfv(GL_FRONT,GL_SPECULAR,Black);
glMaterialf(GL_FRONT,GL_SHININESS,128.0);
+#endif
+}
+
+bool drawPixel::write(prcfile *out, unsigned int *, double, groupsmap&)
+{
+ if(invisible)
+ return true;
+
+ out->addPoint(v,color,width);
- if(weights)
- gluNurbsCallback(nurb,GLU_NURBS_VERTEX,(_GLUfuncptr) glVertex4fv);
- else gluNurbsCallback(nurb,GLU_NURBS_VERTEX,(_GLUfuncptr) glVertex3fv);
+ return true;
+}
+
+void drawPixel::render(double size2, const triple& b, const triple& B,
+ double perspective, bool transparent)
+{
+#ifdef HAVE_GL
+ if(invisible || ((color.A < 1.0) ^ transparent)) return;
+ triple m,M;
+
+ double f,F,s;
+ if(perspective) {
+ f=Min.getz()*perspective;
+ F=Max.getz()*perspective;
+ m=triple(min(f*b.getx(),F*b.getx()),min(f*b.gety(),F*b.gety()),b.getz());
+ M=triple(max(f*B.getx(),F*B.getx()),max(f*B.gety(),F*B.gety()),B.getz());
+ s=max(f,F);
+ } else {
+ m=b;
+ M=B;
+ s=1.0;
+ }
+
+ const pair size3(s*(B.getx()-b.getx()),s*(B.gety()-b.gety()));
+
+ bbox3 box(m,M);
+ box.transform(modelView.Tinv);
+ m=box.Min();
+ M=box.Max();
- gluBeginCurve(nurb);
- int order=degree+1;
- gluNurbsCurve(nurb,order+n,Knots,weights ? 4 : 3,Controls,order,
- weights ? GL_MAP1_VERTEX_4 : GL_MAP1_VERTEX_3);
- gluEndCurve(nurb);
+ if((Max.getx() < m.getx() || Min.getx() > M.getx() ||
+ Max.gety() < m.gety() || Min.gety() > M.gety() ||
+ Max.getz() < m.getz() || Min.getz() > M.getz()))
+ return;
- if(weights)
- gluNurbsCallback(nurb,GLU_NURBS_VERTEX,(_GLUfuncptr) glVertex3fv);
+ RGBAColour Black(0.0,0.0,0.0,color.A);
+ setcolors(false,color,Black,color,Black,1.0);
+
+ glPointSize(1.0+width);
+ R.draw(v);
+ glPointSize(1.0);
#endif
}
+drawElement *drawPixel::transformed(const double* t)
+{
+ return new drawPixel(t*v,p,width,KEY);
+}
+
} //namespace camp