If the image was rotated you can see every polygon getting drawn on the screen and with lots of polygons, it just wasn't any good.Then you are doing it differently from what I intended. My intention was to paint everything into a bitmap and draw the bitmap to the paintbox canvas only when the bitmap is complete. I cannot imagine how this strategy, if drawing gets slow, should show painting of the individual polygons. I do expect, though, that rotation with the mouse will be sluggish.
As for OpenGL, I cannot find any good tutorials anywhere for Pascal, the demo that comes with the Lazarus install is way to complicated to pick through and the wiki.freepascal.org/OpenGL_Tutorial is of little help where it talks about OpenGL LCL program then jumps into GLUT. Plus the example code is not really complete and hard to know (for me anyway) where it should be positioned.I know this is a bit complicated. I once had found a book in the library, I cannot rember its title, maybe "OpenGL for Delphi", and this was quite good. The most difficult part is to get started, I use the TOpenGLControl which comes with Lazarus in the LazOpenGLContext package, it does all the initialization for embedding an OpenGL control in a form and leaves you with the OnPaint where you can place the OpenGL code.
I would like to try it, but there is really no help for such a powerful feature.
The clipboard routine worked in principle, but the image is inverted, like flipped around the horizontal axis.Ah, I had too many false pictures yesterday and finally was happy that the colors appeared correctly with one set of parameters so that I did not look at the alignment. But it works correctly when you add the line
Now my remaining challenge is to try to get text on screen which I see is a bit of a headache but has to be doneYes, drawing text by itself is not supported by OpenGL directly. Since you are on Windows you can use the routines in the attached "OpenGL_utils" units. The font routines work only on Windows; in other operating systems you'd have to access the fonts directly, for example by using the FreeType lib which comes with FPC/Laz - in this case the OpenGL support in TAChart could be helpful (units TAOpenGL and TAFonts).
and also drawing spheres which without glut seems to be involved as well.I had to deal with spheres in a recent project and am adding the related procedure to the "OpenGL_Tools" as well. It creates the vertices on longitude and latitude circles and stores them in a "DisplayList" which is very useful because then the calculation of the vertices must be done only once. The calculated sphere has unit radius and sits in the origin. To give it the size required you must apply a Scaling operation ("glScalef(..)'), and a translation to move it to the desired location ("glTranslate(...)"). The way a lot of spheres can be drawn! Be careful to apply these operations in the right order - scale first, then translate. BUT: in OpenGL you write them in the opposite order - you must read OpenGL code from bottom upward! This is due to the way the transformation matrices are multiplied to the current overall transformation matrix.
I know that the arrays are zero based but zero is never used as an index.Don't do this, I guarantee that it will go wrong at some place. When you need n elements (1..n) you still have to create the array for n+1 elements! This is very easily overlooked.
I can see in your demo that the spheres are "lit" but the cube is not.I suppose that you refer to the demo of reply #13... No, both are lit programmatically (when the "Light" checkbox is marked, but because lighting effects are calculated per surface element each face of the cube gets a uniform color.
I assume that the cube has no specified normals. So how do you create normals for quads or polygons? is there a way they are generated based on the creation of the quad/polygon?Look at the cube generation code:
I am looking to show a surface in a single colour but with shading based on light direction.As I said the surface must be divided into many patches, and normals must be given for each vertex, or at least for each patch (which will make the patches being rendered as flat). The lighting effects in OpenGL are determined by the properties of the light source and the material of the object. There are three classes of such properties: ambient (light coming from everywhere), diffuse (diffuse scattering), specular (specular scattering).
Don't know how to properly insert a quote!Select the post that you want to quote and click on the "Insert Quote" at the top/right of the post - this will copy the post into your message. You should delete the parts that are not needed.
For refreshing my OpenGL knowledge I stumbled across the site http://www.songho.ca/opengl/index.html which appears rather good to me. I ported some of his demo programs to Lazarus, unfortunately with additional files they are too large for an upload here.Song gave me the permission that I can modify, port and redistribute his codes without any restrictions. Therefore, I uploaded the adapted Lazarus versions to my github (https://github.com/wp-xyz/OpenGL_SongHoAhn).
Is this expected, in that checking the status of an object is slow?No. It must be something else that you are doing. Without seeing any code, I cannot tell.