Trouble with opengl vertex arrays

Started by
5 comments, last by mountain_ike 20 years, 1 month ago
I am rendering a piece of terrain based on real data (from USGS DLG files). My first run through I used triangle strips and a bunch of glbegin/glend statements. It worked fine, but tended to run slow when the terrain files got big (>600k vertices). I''ve rewritten my code to use vertex arrays, but now the terrain is coming in really dark. In fact, after playing around with it I''ve found that it will only get as bright as the color (0.25,0.25,0.25), regardless of what color I specify. My first estimate was that the normal calcs were wrong, but I do get the correct shading from the terrain, only too dark. Any ideas?
Advertisement
hmm... do you save color information for each vertex too or set it once at the beginning of the vertex run or what?
any code perhaps???
Before I go into changing the colors (which I will need to do) I have just used a single call to glcolor. Here is a sample of the code:

call glcolor3f(1.0,1.0,1.0)
call glVertexPointer(3, GL_FLOAT, 0,loc(zmesh))
call glNormalPointer(GL_FLOAT, 0,loc(fnormals))

call glnewlist(1,GL_COMPILE)
call glclearcolor(.25,.25,.25,1.0)
call glcleardepth(dble(1.0))
call glclear(ior(GL_COLOR_BUFFER_BIT,GL_DEPTH_BUFFER_BIT))

call glcolormaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE)

call glDrawElements(GL_TRIANGLE_STRIP,npoints,GL_UNSIGNED_INT,loc(indexarray))
call glendlist()

Is the problem that I am using the display list? I thought that was legal, and it makes other pars of the code (ie. pan, tilt and zoom) work muzh faster...
Did you do this: glEnable(GL_COLOR_MATERIAL) ?
ummmmm........ why is your clear color (0.25,0.25,0.25) ??? perhaps this is the reason you are gettin the anomoly you saw. just a guess, cus from the code I see... it shouldn''t matter... but what a strange coincedence, isn''t it ????
How are your lights setup?
If you will note at the top of the code I set the color to (1.0,1.0,1.0). The clear color of (0.25,0.25,0.25) is the background color. I set it to that to test what color my material was. When the clear color is set as shown the material and the background are the same.
I did set up glEnable(GL_COLOR_MATERIAL) and my lighting setup is identical for the vertex array case as it was for my display list case. In fact, everything is the same accept the technique for assigning the vertices.
Could there be an edge detection issue here? I haven''t set up any definition of the edges but I didn''t think I needed to...

This topic is closed to new replies.

Advertisement