Norris's picture

program architecture for a modeling/editing app. few questions.

Hi !
I like modeling, and my main goal to play with OpenTK is to create some 3D utility softwares like modeling app or "mesh tools" like MeshLab. I'm not planning to create a game.

So, in this context, I have a few questions about the architecture of the program.

1) I know that, sometimes I need to have different normals on the same vertex, so I need as many vertices as normals vectors. But this is not always the case. So I think it's good to delete duplicate vertices and use this "clean" list with an indexed VBO. I know how to do, and that works.
But I think it may complicate things when I'd work on the vertices. On the other side, If I have 3 or more vertices at the same position, how to deal with this when I want to move a vertex for example ?
For modeling, I work with MAXON Cinema 4D, and for a simple example of a cube, I only have 8 vertices, but I have a flat shading as if it has a vertex for each triangle !
This is the opposite of what we read in OpenGL tutorials.
And if I have a "merged vertex" for some polygons and I want to modify the normal for only one polygon or vertex, I need to duplicate this ?

How modeling package deal with it ?
My first idea is to keep a dirty vertice list in memory with duplicates vertices, and send a cleaned list to VBO for rendering.

2) In my programm, I want a "Materials manager" with thumbnails of my materials. Each thumbnail show a small sphere with the material apply to it. (a thumbnail is a UserControl)
Actually I fake a 3D sphere with GDI+ drawing API. I'm happy with it as I can identify a material quickly. But for complex materials, it's hard to draw it. So my first idea is my Thumbnails control need to inherit from GLControl.
Is it a good idea ?
for performance, is it good to have many GLControl, each one with enough triangles to have a good image ?
I heard that we can use a "Graphic context" for off-screen rendering like in GDI+ with the Graphics class. Is it better then the first idea ?
In GDI, I understand that I need to choose the Graphics to draw on, and drawing methods are parts of this Graphics. How to do this in OpenTK ?
When I call "GL.Vertex3", how to know on wich context I draw ?


Comment viewing options

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

I don't know the answer to your first question, but for your second:

  • It's perfectly natural to inherit from GLControl
  • Unlike GDI+, OpenGL contexts are implicit. You set the current context (per thread) with MakeCurrent - check the GraphicsContenxt documentation.
  • Multiple GraphicsContexts are difficult to work with and reduce compatibility (Intel doesn't support resource sharing between contexts). One good solution is to create multiple GLControls but use the GraphicsContext of the first one to render all of them (use glControl1.Context.MakeCurrent(glControl_n.WindowInfo) to switch the 1st context to the n-th GLControl).
  • Off-screen rendering is possible but has the same compatibility issues as multiple GLControls (limited support on Intel graphics).