0

As I am new to OpenGL I want to make operations to be performed on solid objects I made use stencils but dint get the output as expected. can any one help?

Code:

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glScalef(zx,zy,zz);
glRotatef(xrot,1.0,0.0,0.0);
glRotatef(yrot,0.0,1.0,0.0);
glMatrixMode(GL_PROJECTION);

glEnable(GL_DEPTH);
glEnable(GL_STENCIL_TEST);
glColorMask(false,false,false,false);
glStencilOp(GL_REPLACE,1,1);
glStencilFunc(GL_EQUAL,1,1);
//  glRenderMode(GL_FLAT||GL_PROJECTION);

GLUquadricObj *quadratic;
    quadratic = gluNewQuadric();
    glutSolidCylinder(rtri,.50,15,15);

    glColorMask(true,true,true,true);
    glStencilFunc(GL_NOTEQUAL,1,1);
    glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);
    glBegin(GL_QUADS);

//code for cube!!




   glFlush();
  glutSwapBuffers();

   }
CoolMonster
  • 2,258
  • 25
  • 50
  • Dupelicate: http://stackoverflow.com/q/22526534/694576 ? – alk Mar 20 '14 at 09:14
  • You should perhaps include a screenshot. Also note that the stencil buffer, of course, is an image-space thing. Boolean operators for solid geometry are typically object-space. – unwind Mar 20 '14 at 09:15
  • i basically want to provide Boolean operations on objects how can i do? trying hard but am not able to.. – user2833415 Mar 20 '14 at 09:17
  • That's not that easy. Boolean operations need an inside and outside. In OpenGL, objects are just represented as faces. No inside or outside. They need not even be connected. So that's the first thing you have to figure out. Then it depends on the kind of objects and operations you want to support. Mostly you need to find intersection lines and cut the faces appropriately. If you have implicit representations of your objects (which is very easy for cubes or spheres), most boolean operations reduce to simple mathematical operations like multiplication or min. – Nico Schertler Mar 20 '14 at 15:01

0 Answers0