hollow tube with wall thickness

hi,
i am very new to open gl programming and need to create a straight tube with a certain wall thickness. from 3dsmax i would think to create two cylinders with different radii and boolean subtract the narrow one from the wide one. i also read about creating a circle und extruding it along a path.
what would be the best way and can someone give me a code example? i will have to create hundreds of tubes on one canvas, so efficiency is quite important.
thank you!

[QUOTE=mael15;1284018]hi,
i am very new to open gl programming and need to create a straight tube with a certain wall thickness. from 3dsmax i would think to create two cylinders with different radii and boolean subtract the narrow one from the wide one.[/QUOTE]

sure, but openGL is a graphics API, not a modelling software
what you have to do is to provide the vertices of the tube yourself, for example you model a tube (in blender, 3dsmax or whatever) and export it into a file format from which you are able to load the vertices (for example .obj)
then put those vertices into a “buffer object”, create a “vertex aray object” and a “program object” (shaders), then you can render the tube
“instanced rendering” is a way to render effciently the same model multiple times

thank you, i just mentioned 3dsmax as an example for how i know an object might be constructed. i do not plan to use any modelling software with opengl.
what i want to do is enable my program to visualize a bundle of hundreds of tubes. tubes of one bundle all have the same diameter, wall thickness and length, but another bundle might have different tubes. so i have to custom create the tubes for every bundle. additionally, every tube will get its individual texture.
so what is the best way?

Just do that the same than with your modeler. Maths are not that complicated. It’s just two disks, and you just join each vertex of the two disks. Then join the vertices of the inner and outter cylinders.

Here I found an old topic about this. It uses fixed-pipeline OpenGL but it will be easy to adapt it to use VBOs if needed.

ok, thank you, and with “join” you mean put everything between glBegin(GL_TRIANGLE_STRIP) and glEnd()? sorry, but i am VERY new to this.

“join” means how you create “primitives” (like triangles of quads)
GL_QUADS gives you a quad for each 4 vertices
GL_TRIANGLE_STRIP gives you a triangle for the first 3 vertices, then for each addidional vertex

i would recommend you to first understand 2D rendering (simple triangle / quad / line / etc), then make a simple 3D task (cube with camera)
after you have understood these basic things, it is just a “math problem” to make a tube (a simple for-loop), you just have to calculate the “corner points” of the tube (inner and outer circle points), but them into a buffer an issue a drawcall

Find a tutorial (or book) on modern OpenGL (using shaders and VBOs) rather than legacy OpenGL (glBegin/glEnd).

If you’re rendering many of these tubes, instanced rendering is likely to be useful, and you can’t do that with the legacy approach.

[QUOTE=mael15;1284030]thank you, i just mentioned 3dsmax as an example for how i know an object might be constructed. i do not plan to use any modelling software with opengl.
what i want to do is enable my program to visualize a bundle of hundreds of tubes. tubes of one bundle all have the same diameter, wall thickness and length, but another bundle might have different tubes. so i have to custom create the tubes for every bundle. additionally, every tube will get its individual texture.
so what is the best way?[/QUOTE]

So each individual tube is straight, not bent like a strand of hair?

If you have a starting program written in Legacy GL, post the code, and I’ll help you.

This is not that hard.

Exactly. You just swap from one cylinder vertex to the other cylinder vertex until you reach the first point again.

thank you everyone! i think i am on my way now. my boss just changed the requirements from “hollow tube” to “plain cylinders” but it is good to know how a hollow tube with a specific wall thickness can be made :slight_smile:

that sounds very helpful and i will look into that.

that is very kind, thank you. i think i can handle it :slight_smile: