Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenGL Beginnings

Status
Not open for further replies.

djjd47130

Programmer
Nov 1, 2010
480
US
I've been teaching myself OpenGL in Delphi XE2, and am having some difficulties learning the main concepts which I need to know. I've started a project wrapping OpenGL into a control and while I can get it to draw, I lack the knowledge to really do something with it. I don't want to use any third-party libraries such as GLScene because this project is intended for me to learn lower-level coding.

What I'm trying to do is simply draw a ground with buildings, and be able to move around this virtual 'city'. No special drawing necessary like textures, just a flat surface for a ground and a grid of square shaped towers. User shall be able to move down the streets from building to building.

What I have done with this control is made a common list of items, where I have a base class `TGLItem` which a number of inherited objects are made, such as `TGLGround` and `TGLBuilding`. These items are added to this list and when the control draws, it iterates through this list and calls the `Draw` procedure for each item. The inherited items then draw their image to the control.

The problems I'm facing is how to keep the ground still, and not rotate it when I rotate the objects. I need to know how to move the camera around on the X/Y/Z axis, as well as rotate the camera up/down/right/left. `TGLCamera` is a class which controls the position of the camera.

With the code I have in the attachment, how do I make this work properly? Comments are in the code where I need help.

Currently, I cannot even get it to lay the ground flat and draw 1 building. Each of these items has a `Position` property as well as a `Direction` property. Position defines where the item is placed, and Direction defines how it is rotated. Each of those properties has 3 properties for X/Y/Z.

The sample application has buttons on the top - currently only the 'Triangle' buttons do anything, the camera buttons haven't been implemented yet. This is what I need help with, how to actually draw this thing correctly and how to move the camera around through it. Each item (ground and buildings) is created as an object declared in the main form's private section (FGround, FBldg1, FBldg2, etc.) and as soon as they're created, they add themselves to a list inside the control. The control then recognizes these items and draws them in a loop.

uMain.pas / uMain.dfm = main form
GLCtrls.pas = main class for my custom control
GLGround.pas = item for drawing ground
GLBuilding.pas = item for drawing a building
GLTri.pas = item for drawing a triangular object

[The triangle comes from the original tutorial I went through to get this far in the first place]

Someone please help, I'm so lost in this thing. As long as I can get the ground and buildings working right, I can learn the rest.

JD Solutions
 
PS - the "TGLTri" is the only thing I can really get to draw properly, so you can enable just "FTri" in the main form and disable the rest from creating - so that this triangle is the only thing that draws.


JD Solutions
 
Things have been figured out and have greatly changed since I asked this, and quite frankly, this wasn't worth asking in the first place. Apologies for this question. However I still have many issues with OpenGL and would like some help, but I will try to be much more specific in the future. The attached source is extremely outdated and I have a completely new project going on now.

Thank you.


JD Solutions
 
Don't worry about asking a question (not that you got any answers). This isn't SO, you know. [wink]
 
^^^ [cheers]

[thumbsup]

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top