PDA

View Full Version : SOLVED: glCallList causes missing polys on NURBS



TBTTyler
04-09-2011, 10:07 PM
http://i.imgur.com/jMpwx.png

EDIT2:
So now I feel like an idiot ... I updated my graphics driver, and it works like a charm. Thanks for all those who looked in!

EDIT:
So I did a little testing, and ran the code on my windows laptop, and it didn't break. Then I rebooted into windows on my desktop (where the problem first arose) and it's fixed there too. This thing still needs to work on Linux though. Any help would be appreciated.


So that's what I keep getting when I use a callList to store my trimmed nurbs surface. If I remove the callList, everything works, but it's extremely slow when I display more trimmed regions.

Does anybody know what's happening? Or perhaps a different technique I could use to speed up rendering a trimmed nurbs surface? The pieces are static once computed.

I'm doing this on Ubuntu Linux with pyOpenGL.
The code I'm posting isn't the full project, but the error still pops up.




#!/usr/bin/python
import sys
from math import *
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *

nurb,cvs,uKnots,vKnots = None,None,None,None
nurbsID = None
trimVerts= [(11.045159254484817, 20.153096558520566),
(9.4673558111927072, 19.230289957856868),
(11.327625540007007, 17.484655504107629),
(12.146721328928535, 19.130205649607337),
(11.045159254484817, 20.153096558520566)]

def initGeom():
global nurb,cvs,uKnots,vKnots
deg = 3
uSides = 16
vSides = uSides * 2
w = 1.0064 #fixes the fact that the cubic curves aren't tangent to the control poly
vAngles = [t * pi * 2 / vSides for t in range(-1,vSides+2)]
uAngles = vAngles[:uSides+deg]
uCurve = [(cos(a) * w, sin(a) * w) for a in uAngles]
cvs = [[[sin(vA)*uCurve[i][1]*w, uCurve[i][0], cos(vA)*uCurve[i][1]*w]
for vA in vAngles] for i in range(len(uCurve))]
vKnots = range(len(cvs[0]) + deg + 1)
uKnots = range(len(uCurve) + deg + 1)
nurb = gluNewNurbsRenderer()
gluNurbsProperty(nurb, GLU_SAMPLING_METHOD,GLU_DOMAIN_DISTANCE)
gluNurbsProperty(nurb, GLU_U_STEP,4)
gluNurbsProperty(nurb, GLU_V_STEP,4)
gluNurbsProperty(nurb, GLU_CULLING,GLU_TRUE)

def arcTest():
global nurb,cvs,uKnots,vKnots,nurbsID
if nurbsID == None:
nurbsID = glGenLists(1)
glNewList(nurbsID,GL_COMPILE)
glLineWidth(1)
gluNurbsProperty(nurb, GLU_DISPLAY_MODE, 1)
gluBeginSurface(nurb)
gluNurbsSurface(nurb,uKnots,vKnots,cvs,GL_MAP2_VER TEX_3)
gluBeginTrim(nurb)
gluPwlCurve(nurb, trimVerts, GLU_MAP1_TRIM_2 )
gluEndTrim(nurb)
gluEndSurface(nurb)
glEndList()
glCallList(nurbsID)

def display():
if True: ###just so I can fold this area
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
glMatrixMode( GL_PROJECTION)
glLoadIdentity()
xsize = glutGet(GLUT_WINDOW_WIDTH)
ysize = glutGet(GLUT_WINDOW_HEIGHT)
gluPerspective(30, float(xsize) / float(ysize), 0.1, 50)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glTranslatef(0,0,-7)
#insert your favorite mouse interaction here
arcTest()
glutSwapBuffers()

def initGLDisp():
glutInit(sys.argv)
glutInitDisplayMode( GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH)
glutInitWindowSize(500,500)
glutInitWindowPosition(100,100)
glutCreateWindow(sys.argv[0])
glClearColor(0,0,0,0)
glEnable(GL_DEPTH_TEST)
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
glEnable(GL_AUTO_NORMAL)
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,1)
#register mouse callbacks here

initGLDisp()
initGeom()
glutDisplayFunc(display)
glutMainLoop()