So I'm learning OpenGL on my own and I have to say I'm really liking it. I really have not been able to do much, you'd laugh if i told you how much i knew but are there any real techniques for drawing shapes? I'm having trouble trying to figure out the coordinates. Is it something you just eventually get used to? Do any of you know about any good sites i could visit to help learn OpenGL? Thanks
Khoanyneosr 0 Junior Poster in Training
sfuo 111 Practically a Master Poster
I'd say the best way to learn is by trying to draw it out on paper with all the vertices labeled and make all the basic shapes outta quads to start with or jump use triangles if you feel a bit braver.
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
>>are there any real techniques for drawing shapes?
Of course there are. But what "shapes" are you talking about? When it comes to shapes made of polygons, we usually talk about a mesh. Typically people use 3D design programs (like 3D studio max, or Blender3D, or Milkshape), and create 3D models (with animations) and load and draw them into their programs. But then, there are several other techniques to draw other kinds of objects. For example, heightmaps can be used to create land-scapes. This is pretty easy, you can create a grey-scale bitmap in your image editor of choice (GIMP or Paint), then load the image in your program with your image loading library of choice (FreeImage, OpenCV, or GLUT) and treat each pixel grey value as the height (hence, a "heightmap") and then draw a quad between each 4 neighbouring pixels (and apply some grass texture or some blend of different textures). Another important technique is so-called "procedural generation" of meshes (and other things). Techniques like "Perlin Noise" can be used to general natural looking artifacts (including dynamic ones) such as random (but natural looking) landscapes, dynamic cloud formations, dynamic water surfaces, and even natural looking random textures (like wood-grain, or grass). Finally, for very nice "shapes" you can also use built-in interpolation algorithms, like Non-Uniform Rational B-Splines (NURBS) curves and surfaces. These allow you to prescribe the general shape of an object with few points and let OpenGL general a smooth surface with high point-density (hence, the name "interpolation", it takes a few points and interpolates smoothly between them).
In addition to shapes, you can use bump-maps to make rough-edges shapes look more round by telling OpenGL to interpret one of the blended textures as a map of small deformation of the surface, which artificially make the surface more smooth, once proper lighting is applied.
>>Is it something you just eventually get used to?
When it comes to doing any kind of 3D rendering, it is paramount to have a good grasp of 3D geometry and transformations. This is unavoidable. If you don't like math, then bad luck chummy. But playing around with trying to render 3D objects using OpenGL is a great way to get to learn a lot about how 3D geometry works. You have to get to know and be comfortable with certain aspects of that, such as coordinate systems (Cartesian, polar, spherical, and cylindrical), coordinate transformations and their composition (translation and rotation in 3D), and Projective Geometry (something they don't teach you in school, but is massively important in 3D graphics, things like Field-of-View, Frustum, lens equations, etc.). There is a lot of math to learn, but if you go about it incrementally, it should be fine (start from tutorial example code and experiment with changing different things and seeing the effects of it).
>>Do any of you know about any good sites i could visit to help learn OpenGL?
It's a bit out-dated, well, I'm outdated on this topic anyways, but I would recommend the NeHe tutorials (they might show some techniques, especially in the basic tutorials, that are "deprecated" in the newer versions of OpenGL, but it is still very relevant for knowing the basics).
I might also recommend a very nice and simple rendering engine, Ogre3D, which has plenty of tutorials and let you not worry too much about the underlying details and get great stuff and effects to the screen quickly and easily.
n.cramp 0 Newbie Poster
If you are looking for a simple way to create triangle meshes, i have found using a program called Anim8tor to be useful. Simply make your model, save, then go to export on the menu and export as a .c file. Then you end up with a file containing a number of arrays- one for coords, texcoords, normals, material etc, which work really well with vertex arrays, glDrawElements and so on.
The only drawback is that once exported to a .c you cannot load the file in Anim8tor again, so its good to make a copy in .3Ds or the Anim8tor format. Tex coords can be quite well manipulated in the program, but really its only good for basic shapes. I often use it for making terrains, rocks and so on.
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.