DGL https://delphigl.com/forum/ |
|
...one of those beginner questions... https://delphigl.com/forum/viewtopic.php?f=19&t=6318 |
Seite 1 von 1 |
Autor: | dpm_dpmartin [ Fr Jan 26, 2007 18:15 ] |
Betreff des Beitrags: | ...one of those beginner questions... |
Hi all, This is one of those 'get me started please' questions I'm afraid. I'm a relatively experienced Delphi coder but just starting getting into OpenGL - I want to signficantly imrprove the user interface of my Media Centre. Up to now I have been using my spare time to bring myself up to speed with the 3D side of things... all my stuff is on a Delphi form, rendered onto a TPanel... by coding all the vertexes and normals and default lighting for a 3D "H" that I have put into the title bar of my custom forms - it adds a bit of eye-candy to my program. Now I want to move on (surely going backwards?) to 2D stuff - Orthographic Projection - as that's simply all I need for the time being, I'm not interested in perspective, I just want to use OpenGL to provide my application with some very slick and polished graphics that the users can manipulate easily - my program's screen has CD covers all over it (see the following URL for an idea of what I'm referring to - http://www.hmusiccentre.org.uk) and I would like to imagine these CDs covers could quickly slide left, right, up and down (according to the position of the mouse) bringing new CD covers into view. I've started a small project to set up Orthographic Projection... in the startup, I do: Code:
Code:
Code:
Code:
Code:
Code:
In addition, knowing how I can get my middle square to rotate around its centre - so it's spinning on a point, rather than spinning around a point - would be good to know... Also... my next question... I'm working in 2D... I'm not interested in perspective (yet!) and I much prefer to work in units of pixels. How do I go about setting up OpenGL so that I can reference all my drawing on a TPanel (of any dimensions) by saying that I want to draw something at 100,100 pixels? Is that an easy situation to get to? Sorry that my questions are not that interesting or 3D related... I'll get there. I can post the .dpr, .pas and .dfm is anyone needs it... nothing special at all. Cheers, DpM http://www.hmusiccentre.org.uk |
Autor: | i0n0s [ Fr Jan 26, 2007 18:56 ] |
Betreff des Beitrags: | Re: ...one of those beginner questions... |
What do you meen with "decrease" when you talking about the middle square? It will rotate around the x-axis which should look like its getting a rectancle and at last a line. You have to use the z-axis to rotate the square like a paper on a table. glLoadIdentity is not needed at all at this point. It is just resetting the matrix and is undoing all your rotations and transations. For your second question: Just type: Code:
|
Autor: | dpm_dpmartin [ Fr Jan 26, 2007 19:10 ] |
Betreff des Beitrags: | |
Thank-you. Yes, you're right - glLoadIdentity is not required. Having... Code:
Also, I changed the code to: Code:
P.S. Answering the question of "decrease", I believe it was disappearing to a line, yes - but, once again, the rotation wasn't around the centre axis - it seemed to fall over... i.e. 'cos it wasn't 3D and there's no lighting, it appeared to decrease in height until it was 0 pixels high - but not equally moving in from the top and bottom - just moving down from the top. |
Autor: | i0n0s [ Fr Jan 26, 2007 19:25 ] |
Betreff des Beitrags: | |
glrotate is rotating around the current position. If you don't use glTranslate the current position will be (0,0,0), the bottom left of the panel. For Square (4,4,2,2) you have do the following: Code:
If you don't translate back to the old position you have to adjust the coordinates of the square. This is because the OpenGL functions are working with relativ coordinates, just like if you draw on canvas. |
Autor: | dpm_dpmartin [ Fr Jan 26, 2007 19:29 ] |
Betreff des Beitrags: | Nice one! |
Sweet. Code:
|
Autor: | Flash [ Di Jan 30, 2007 23:26 ] |
Betreff des Beitrags: | |
You can simplify your code by leave out the position of the quad in your draw function. You can set the position of the quad with glTranslate. Just make the draw funktion drawing the quad relativ to (0,0), than you can do something like that: glTranslate(middleX, middleY, 0); drawQuad(width, height); Its nothing big, but with less parameters your code is maybe easier to interprete if you look on it in a few days. ![]() |
Autor: | dpm_dpmartin [ Sa Feb 03, 2007 17:22 ] |
Betreff des Beitrags: | Agreed. |
Yes, this makes sense. Thank you. |
Seite 1 von 1 | Alle Zeiten sind UTC + 1 Stunde |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |