Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...At last there is indeed a website/forum that deals with professional and serious matters. Keep up with the good work!!"

Geography

Where in the world do Tek-Tips members come from?
djjd47130 (Programmer)
20 May 12 19:36
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

djjd47130 (Programmer)
20 May 12 19:43
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

djjd47130 (Programmer)
23 May 12 14:54
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

DjangMan (Programmer)
24 May 12 10:54
Don't worry about asking a question (not that you got any answers). This isn't SO, you know. wink
whosrdaddy (Vendor)
26 May 12 8:13
^^^ cheers

thumbsup

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close