   JAVA and OpenGL
  I know that it''s possible to use OpenGL or Java3D in java.But is it possible in Java to apply CSG? (Constructive Solid Geometry)I could make it possible in C but if i port it to C# (for easy userinterface) then it draws the primitives above each other. Instead of substracting them. csgl (opengl lib for C#) does not support it.Is there also a lib between Java and Opengl or can you access it directly ? Or if there is a lib, binding , does it support CSG?Thanks in advanceFilip aka Whizzo   -= EmergE =- 
  CSG is a mathematical problem, not a language problem. It shouldn''t matter what language or API you use to display the actual result.If it doesn''t work with C# then you''ve probably ported it wrong. Unless you''re doing psuedo-CSG with stencil buffer hacks, in which case it''ll work anywhere that a stencil buffer works. I find it hard to believe that C#''s csgl would not have a working stencil buffer. ;  i Also made a .dll of the c code, and imported it in C#,same result.the command for opengl are the same in c# and c, only another prefix, so it should work, but doesn''t./* * sub() *  boolean A subtract B (draw wherever A is and B is NOT) *  algorithm: find where a is inside B, then find where *   the BACK faces of B are NOT in A */void COpenglWnd::sub(void (*a) (void), void (*b) (void)){    inside(a, b, GL_FRONT, GL_NOTEQUAL);#if 1  /* set to 0 for faster, but incorrect results */    fixup(b);#endif    inside(b, a, GL_BACK, GL_EQUAL);}void COpenglWnd::fixup(void (*a) (void)){    /* fix up the depth buffer */    glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);    glEnable(GL_DEPTH_TEST);    glDisable(GL_STENCIL_TEST);    glDepthFunc(GL_ALWAYS);    a();    /* reset depth func */    glDepthFunc(GL_LESS);}void COpenglWnd::inside(int a, int b, GLenum face, GLenum test){    /* draw A into depth buffer, but not into color buffer */    glEnable(GL_DEPTH_TEST);    glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);    glCullFace(face);if (a == 1)DrawBox1();elseDrawBox2();/* use stencil buffer to find the parts of A that are inside of B* by first incrementing the stencil buffer wherever B''s front faces* are...*/    glDepthMask(GL_FALSE);    glEnable(GL_STENCIL_TEST);    glStencilFunc(GL_ALWAYS, 0, 0);    glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);    glCullFace(GL_BACK);    if (b == 1)DrawBox1();elseDrawBox2();    /* ...then decrement the stencil buffer wherever B''s back faces are */    glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);    glCullFace(GL_FRONT);    if (b == 1)DrawBox1();elseDrawBox2();    /* now draw the part of A that is inside of B */    glDepthMask(GL_TRUE);    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);    glStencilFunc(test, 0, 1);    glDisable(GL_DEPTH_TEST);    glCullFace(face);    if (a == 1)DrawBox1();elseDrawBox2();    /* reset stencil test */    glDisable(GL_STENCIL_TEST);}Thats the C version for subtracking objects (works in C);  But when i put it in a dll wrapper and use it in C#, then it does''nt work anymore. 