int __glXDisp_GetClipPlane(__GLXclientState *cl, GLbyte *pc) { __GLXcontext *cx; ClientPtr client = cl->client; int error; GLdouble answer[4]; cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error); if (!cx) { return error; } pc += __GLX_SINGLE_HDR_SIZE; __glXClearErrorOccured(); glGetClipPlane(*(GLenum *)(pc + 0), answer); if (__glXErrorOccured()) { __GLX_BEGIN_REPLY(0); __GLX_SEND_HEADER(); } else { __GLX_BEGIN_REPLY(32); __GLX_SEND_HEADER(); __GLX_SEND_DOUBLE_ARRAY(4); } return Success; }
int __glXDispSwap_GetClipPlane(__GLXclientState *cl, GLbyte *pc) { __GLXcontext *cx; ClientPtr client = cl->client; int error; GLdouble answer[4]; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag); cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error); if (!cx) { return error; } pc += __GLX_SINGLE_HDR_SIZE; __GLX_SWAP_INT(pc + 0); __glXClearErrorOccured(); glGetClipPlane(*(GLenum *)(pc + 0), answer); if (__glXErrorOccured()) { __GLX_BEGIN_REPLY(0); __GLX_SWAP_REPLY_HEADER(); __GLX_SEND_HEADER(); } else { __GLX_SWAP_DOUBLE_ARRAY((GLbyte *)answer, 4); __GLX_BEGIN_REPLY(32); __GLX_SWAP_REPLY_HEADER(); __GLX_SEND_HEADER(); __GLX_SEND_DOUBLE_ARRAY(4); } return Success; }
static void init_clip_test() { matrix4x4d m; if (glIsEnabled(GL_CLIP_PLANE1)) { glGetClipPlane(GL_CLIP_PLANE1, _clip[0]); glGetClipPlane(GL_CLIP_PLANE3, _clip[1]); glGetDoublev (GL_MODELVIEW_MATRIX, &m[0]); _clipoffset.x = m[12]; _clipoffset.y = m[13]; _clipoffset.z = 0; _do_clip = true; } else { _do_clip = false; } }
static std::string getClippingState() { std::string result; int numPlanes = glGetInteger(GL_MAX_CLIP_PLANES); int C; for(C = 0; C < numPlanes; C++) { result += format("// Clip plane %d\n", C); result += format("%s(GL_CLIP_PLANE0 + %d);\n", glIsEnabled(GL_CLIP_PLANE0 + C) ? "glEnable" : "glDisable", C); double x[4]; glGetClipPlane(GL_CLIP_PLANE0 + C, x); result += format("{double coefficients[]={%4.4e, %4.4e, %4.4e, %4.4e};\n glClipPlane(GL_CLIP_PLANE0 + %d, coefficients);}\n", x[0], x[1], x[2], x[3], C); } return result; }
Polyhedron<Raycaster::Scalar>* Raycaster::clipDomain(const Raycaster::PTransform& pmv,const Raycaster::PTransform& mv) const { /* Clip the render domain against the view frustum's front plane: */ Point fv0=pmv.inverseTransform(Point(-1,-1,-1)); Point fv1=pmv.inverseTransform(Point( 1,-1,-1)); Point fv2=pmv.inverseTransform(Point(-1, 1,-1)); Point fv3=pmv.inverseTransform(Point( 1, 1,-1)); Plane::Vector normal=Geometry::cross(fv1-fv0,fv2-fv0) +Geometry::cross(fv3-fv1,fv0-fv1) +Geometry::cross(fv2-fv3,fv1-fv3) +Geometry::cross(fv0-fv2,fv3-fv2); Scalar offset=(normal*fv0+normal*fv1+normal*fv2+normal*fv3)*Scalar(0.25)-Scalar(1.0e-3); Polyhedron<Scalar>* clippedDomain=renderDomain.clip(Plane(normal,offset)); /* Clip the render domain against all active clipping planes: */ GLint numClipPlanes; glGetIntegerv(GL_MAX_CLIP_PLANES,&numClipPlanes); for(GLint i=0;i<numClipPlanes;++i) if(glIsEnabled(GL_CLIP_PLANE0+i)) { /* Get the clipping plane's plane equation in eye coordinates: */ GLdouble planeEq[4]; glGetClipPlane(GL_CLIP_PLANE0+i,planeEq); /* Transform the clipping plane to model coordinates: */ Geometry::ComponentArray<Scalar,4> hn; for(int i=0;i<3;++i) hn[i]=Scalar(-planeEq[i]); hn[3]=-planeEq[3]; hn=mv.getMatrix().transposeMultiply(hn); /* Clip the domain: */ Polyhedron<Scalar>* newClippedDomain=clippedDomain->clip(Polyhedron<Scalar>::Plane(Polyhedron<Scalar>::Plane::Vector(hn.getComponents()),-hn[3]-Scalar(1.0e-4))); delete clippedDomain; clippedDomain=newClippedDomain; } return clippedDomain; }
void PatternLayer::draw(Graphics* const TheGraphics, const Pnt2f& TopLeft, const Pnt2f& BottomRight, const Real32 Opacity) const { glPushAttrib(GL_ENABLE_BIT | GL_TRANSFORM_BIT); GLdouble Plane0[4], Plane1[4], Plane2[4], Plane3[4]; glGetClipPlane(GL_CLIP_PLANE0, Plane0); glGetClipPlane(GL_CLIP_PLANE1, Plane1); glGetClipPlane(GL_CLIP_PLANE2, Plane2); glGetClipPlane(GL_CLIP_PLANE3, Plane3); glEnable(GL_CLIP_PLANE0); glEnable(GL_CLIP_PLANE1); glEnable(GL_CLIP_PLANE2); glEnable(GL_CLIP_PLANE3); // The clipping plane for the background must get set to inside the // border of the component. It was the outside of the component, // so it has to be reset to the stored values from above at the end. Vec4d LeftPlaneEquation(1.0,0.0,0.0,-TopLeft.x()), RightPlaneEquation(-1.0,0.0,0.0,BottomRight.x()), TopPlaneEquation(0.0,1.0,0.0,-TopLeft.y()), BottomPlaneEquation(0.0,-1.0,0.0,BottomRight.y()); glClipPlane(GL_CLIP_PLANE0,LeftPlaneEquation.getValues()); glClipPlane(GL_CLIP_PLANE1,RightPlaneEquation.getValues()); glClipPlane(GL_CLIP_PLANE2,TopPlaneEquation.getValues()); glClipPlane(GL_CLIP_PLANE3,BottomPlaneEquation.getValues()); //Activate the Texture Transformation if(getTransformation() != NULL) { getTransformation()->activate(TheGraphics->getDrawEnv()); } Vec2f BackgroundSize (BottomRight - TopLeft); Vec2f TopLeftTexCoords(0.0f,0.0f); Vec2f BottomRightTexCoords(1.0f,1.0f); Real32 RepeatHorizontal; switch(getHorizontalRepeat()) { case PATTERN_REPEAT_ABSOLUTE: RepeatHorizontal = getHorizontalRepeatValue(); break; case PATTERN_REPEAT_BY_POINT: default: RepeatHorizontal = static_cast<Real32>(BottomRight.x() - TopLeft.x())/static_cast<Real32>(getCorrectedPatternSize().x()); break; } TopLeftTexCoords[0] = -getHorizontalAlignment() * (RepeatHorizontal -1.0f); BottomRightTexCoords[0] = TopLeftTexCoords[0] + RepeatHorizontal; Real32 RepeatVertical; switch(getVerticalRepeat()) { case PATTERN_REPEAT_ABSOLUTE: RepeatVertical = getVerticalRepeatValue(); break; case PATTERN_REPEAT_BY_POINT: default: RepeatVertical = static_cast<Real32>(BottomRight.y() - TopLeft.y())/static_cast<Real32>(getCorrectedPatternSize().y()); break; } TopLeftTexCoords[1] = -getVerticalAlignment() * (RepeatVertical - 1.0f); BottomRightTexCoords[1] = TopLeftTexCoords[1] + RepeatVertical; TheGraphics->drawQuad(TopLeft, Pnt2f(BottomRight.x(), TopLeft.y()),BottomRight, Pnt2f(TopLeft.x(), BottomRight.y()), TopLeftTexCoords, Vec2f(BottomRightTexCoords.x(), TopLeftTexCoords.y()), BottomRightTexCoords, Vec2f(TopLeftTexCoords.x(), BottomRightTexCoords.y()), getColor(), getTexture(), Opacity); //Deactivate the Texture Transformation if(getTransformation() != NULL) { getTransformation()->deactivate(TheGraphics->getDrawEnv()); } glPopAttrib(); }
M(void, glGetClipPlane, jint plane, jobject equation) { glGetClipPlane(plane, BUFF(GLdouble, equation)); }