[Bprocessor-commit] /gl/src/net/sourceforge/bprocessor/gl/view View.java, 1.201, 1.202
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2007-05-04 11:59:39
|
Update of /cvsroot/bprocessor//gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19172/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Log Message: made tesslator init a single time event should be faster, and tried to use displayLists for cashing of tesslation, seems to work fine, there just have to be introduced some kind og time stamp for geometry to know when to remake the way to draw. There have to be found a settlement for how small displaylist there are reasonable Index: View.java =================================================================== RCS file: /cvsroot/bprocessor//gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.201 retrieving revision 1.202 diff -C2 -d -r1.201 -r1.202 *** View.java 15 Apr 2007 10:43:08 -0000 1.201 --- View.java 4 May 2007 11:59:26 -0000 1.202 *************** *** 377,380 **** --- 377,384 ---- private int maxClippingPlanes; + private GLUtessellator tess; + + private HashMap<Surface, Integer> displayLists = new HashMap<Surface, Integer>(); + static { setTransparency(100); *************** *** 506,510 **** bg.add(but); but.setToolTipText("Wireframe"); ! but.setMnemonic(KeyEvent.VK_F7); } --- 510,514 ---- bg.add(but); but.setToolTipText("Wireframe"); ! but.setMnemonic(KeyEvent.VK_F7); } *************** *** 538,542 **** gld.setGL(new DebugGL(gld.getGL())); glu = new GLU(); ! int[] maxplanes = new int[1]; gl.glGetIntegerv(GL.GL_MAX_CLIP_PLANES, maxplanes, 0); --- 542,556 ---- gld.setGL(new DebugGL(gld.getGL())); glu = new GLU(); ! ! //INITIALIZE TESSELATOR ! tess = glu.gluNewTess(); ! GLUtessellatorCallback cb = new Callback(); ! //Setting callbacks ! glu.gluTessCallback(tess, GLU.GLU_TESS_BEGIN, cb); ! glu.gluTessCallback(tess, GLU.GLU_TESS_END, cb); ! glu.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, cb); ! //Contours contained in an even number of contours are filled ! glu.gluTessProperty(tess, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_ODD); ! int[] maxplanes = new int[1]; gl.glGetIntegerv(GL.GL_MAX_CLIP_PLANES, maxplanes, 0); *************** *** 1601,1605 **** } } ! } } --- 1615,1619 ---- } } ! } } *************** *** 1610,1654 **** */ private void drawSurface(Surface s, boolean hit) { ! GLUtessellator tess = glu.gluNewTess(); ! GLUtessellatorCallback cb = new Callback(); ! ! //Setting callbacks ! glu.gluTessCallback(tess, GLU.GLU_TESS_BEGIN, cb); ! glu.gluTessCallback(tess, GLU.GLU_TESS_END, cb); ! glu.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, cb); ! ! //Contours contained in an even number of contours are filled ! glu.gluTessProperty(tess, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_ODD); ! ! //begining the polygon, we are not using userdata for now (hence the null) ! glu.gluTessBeginPolygon(tess, null); ! //light stuff ! if (drawMode == LIGHTING_MODE) { ! Vertex norm = s.normal(); ! if (norm != null) { ! gl.glNormal3d(norm.getX(), norm.getY(), norm.getZ()); } - } ! //drawing the outer contour ! drawContour(s, tess); ! //drawing the inner conturs ! Collection innerSurfaces = s.getHoles(); ! if (innerSurfaces != null) { ! Iterator innerIt = innerSurfaces.iterator(); ! while (innerIt.hasNext()) { ! Surface surface = (Surface)innerIt.next(); ! if (hit) { ! if (surface.getOwner() == s.getOwner()) { drawContour(surface, tess); } - } else { - drawContour(surface, tess); } } } ! glu.gluTessEndPolygon(tess); ! glu.gluDeleteTess(tess); } --- 1624,1664 ---- */ private void drawSurface(Surface s, boolean hit) { ! Integer list = displayLists.get(s); ! if (list == null) { ! //list = gl.glGenLists(1); ! //displayLists.put(s, list); ! //gl.glNewList(list, GL.GL_COMPILE); ! //begining the polygon, we are not using userdata for now (hence the null) ! glu.gluTessBeginPolygon(tess, null); ! //light stuff ! if (drawMode == LIGHTING_MODE) { ! Vertex norm = s.normal(); ! if (norm != null) { ! gl.glNormal3d(norm.getX(), norm.getY(), norm.getZ()); ! } } ! //drawing the outer contour ! drawContour(s, tess); ! //drawing the inner conturs ! Collection innerSurfaces = s.getHoles(); ! if (innerSurfaces != null) { ! Iterator innerIt = innerSurfaces.iterator(); ! while (innerIt.hasNext()) { ! Surface surface = (Surface)innerIt.next(); ! if (hit) { ! if (surface.getOwner() == s.getOwner()) { ! drawContour(surface, tess); ! } ! } else { drawContour(surface, tess); } } } + glu.gluTessEndPolygon(tess); + //gl.glEndList(); } ! //gl.glCallList(list); } |