kdb's picture

Display lists and quadrics

Hi,

I haven't programmed in OpenGL in a while, but I do remember the basics of creating display lists and quadrics. I've tried to use them using .NET calls and they're not working. Are they built yet? If they are, could someone provide an example (e.g. a call to GLu.Cylinder or something)?

Kyle


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Technolithic's picture

In reply to Fiddler's last post, would incorporating the use of CallLists with Quadrics create code of equivalent efficiency if every call to render an object was contained in the call list or does using Quadrics create more complexities underneath that impose slower processing?

the Fiddler's picture

It depends on the implementation of GLU, and on how efficient the drivers are in optimizing display lists. You'd have to profile a range of different implementations before drawing any safe conclusions.

Regarding GL.CallLists(), OpenTK simply passes the values to the underlying implementation. Unlike quadrics, this is well tested code. I suspect the problem with lighting does not lie there - if you can provide a test case, we'll be able to find the cause and fix it.

Technolithic's picture

I'll have to come up with a simpler test-case than the project I'm working on... the CallList-generating code is rather intermingled into the source and the project is not OpenSource. I'll put this on my to-do list. It'll be good to do something to help out with the development of this cool framework.

Inertia's picture

You're welcome, that function was part of a solar system simulation written to get a grip on Tao, but like you said I had to invert the texcoords for proper coordinates to texture the sphere. GL.TexCoord2( 1f - i * OneThroughPrecision, ...
When you try to model more than the simple planets (i.e. Saturn) it starts getting hackish to display it's rings.
You could also take a look at the PQ Torusknots application in the Personal Projects section of the forum, which gives you a more complex object to work with than a sphere.

Technolithic's picture

Inertia, I noticed something with your spheres algorithm...

It makes beautiful spheres, but when I use a prime number for precision... or so it seems (since I haven't tested the all the numbers) like 13, 17, 19, 23, 53, 97... I think those are all primes... anyhow, after rotating the spheres around their own axis, they seem to have a small hole in them. Not that it matters much, but I thought it was interesting. Prime numbers don't divide by two very nicely, so I bet that's why the spheres don't like primes.

I've seen precisions of 64, 32, and 16 without any defects. Those are very nice spheres.

Oh, I'm using a radius of 1.0. The holes show up after zooming in a bit. It's just that I'm using so many of them and rotating them all at the same angle that they all expose this hole at the same time. I shouldn't rotate them, but I was trying to keep their holes from being seen. LOL, I guess I don't have to bother with rotating anymore.

Anyhow, nothing a bit of common-sense can't avoid. I seem to lose a bit of that from time to time. LOL

Inertia's picture

Not sure if it's restricted to primes, the line for ( uint j = 0 ; j < Precision / 2 ; j++ ) should cause problems with anything that's not a multiple of 2. Another problem with this function is that it will call GL.Begin() multiple times, which is not ideal. If this solution is not satisfying, there's code for some geometric objects located at /Source/Examples/Shapes/, but I'm uncertain if that is deprecated or will be continued at some point.

Technolithic's picture

Inertia, your solution is great. I just needed something that worked for now. I'm working via an Agile development environment using prototyping and working closely with my client, so the timely solution was perfect. We're using the separation-of-concerns paradigm that Djikstra wrote about in the 70s... I don't remember the exact date, but Wikipedia has a nice article on it. Anyhow, if Djikstra wrote about it, it must be good. I hear the industry has just recently started to use it.

So, really, anyway, the separation of concerns is all about abstraction, which we are using to simplify things and this goes along with optimizing things later, after we find out what's really bogging down performance to a rate of hindering the use of the program.

I made a nice cone object that utilizes a triangle fan. It's very basic, but seeing how I could make my own graphical objects was a nice experience.

Going off that, I like the triangle strips technique of how you created the sphere algorithm. I've had a few thoughts about how to make a more optimized sphere algorithm, after your suggestion about calling Gl.Begin() isn't so great for performance. What about creating two triangle fans, for the top and bottom, and then creating a spiraling triangle strip from the top fan down to the bottom? Maybe even creating the entire sphere out of a single spiraling triangle strip.

Inertia's picture

Credits for the function go to Sascha Willems, I just ported it to C#. It sure would be best to draw the sphere with a single spiral strip instead of multiple strips, I came to the same conclusion when looking into tesselate the Torusknot more effectively. While better for the graphics API, the spiral has a serious drawback when it comes to people using the function: it's way more intuitive to have a few parameters to control ring/loop precision and radii rather than picturing what the final result of a spiral strip might look like. Another thing that gets way more complicated is supplying texture coordinates for the object. Not sure if the optimization is worth it, it might be better to change the naive approach to output BeginMode.Triangles rather than a strip, and wrap that into a display list or VBO.

Technolithic's picture

Fiddler, it looks like the GL.CallLists are working properly, at least for my object drawings. I'm using GL.Color to alter the colors of the objects and "manually" changing the lighting of the objects using GL.Materialv(). If the program needs more optimization, I'll use more call lists for setting the material properties of the objects instead of hard coding it. It seems that since I hard coded it, the program renders properly, but it's difficult to determine the conclusion why it makes a difference with all the other experiments I've been performing to get OpenGL to do what I need it to.

At any rate, I feel like I'm almost a Novice with this stuff and I can really apply it to the next level of awesome graphics programming!

georgedurack's picture

Hi !!

I have recently looked at GLU ES but that contains only a few basic glu functions. I did had a look at the SQI reference of OpenGl but it uses GL_QUAD_STRIP extensively, and I have no idea how to get the drawing that to work in ES.

If I get more information on it, i'll surely put up here.