View Full Version : Very New To GL, specific coordinate mapping.
12-21-2000, 02:23 PM
first let me say I am not very familiar with the definition of command so if you answer please explain, instead of just do this then that, as I've read in other posts, and posting exact sample code would be great.
I am doing this in Delphi not C++, I'm wanting to create a 3D scene not 2D but with specific x,y coordinates on for sending out to a bitmap file(I know how to save as bitmap) so they have to be in exact places, and no i can't do it in 2d because the texture perspective has to be rotated and 2D doesn't do it very well.
What I want is to say go to positon 10 from left edge and 10 down then draw a square with 19 width and 19 height(not those exact figures of course) and then go to next x,y position and do next area, I know how to flip rotate and move object just fine so don't bother going into that much detail http://www.opengl.org/discussion_boards/ubb/smile.gif
Thanks in advance for anyone willing to help.
"Command" is the a generic name. A GL command is a instruction passed with a routine (function, in Delphi). Example: glLoadIdentity is a command. It load the current matrix with the identity. I also use Delphi to compile my programs but what exactly you want to know? If is how to use GL to rendering 2D (like with GDI) I have a sample code.
12-22-2000, 05:04 AM
Ok I'll be more specific, I am envolved in making a 3d(not ture 3D) game the grabs the the images from a file that has all wall images for the specified wall in it. In order to show a close wall it gets within that bmp file from 10,10,20,20 for the furthest viewpoint away from you.
I want to create a program that loads a image to a texture then resizes that texture to specific point on the screen(because I'm saving that screen to a file that the program will use in the way above) I know how to do this using a 2D layout that is easy but it warps the angle walls(the ones you see from a side view that because of being 2D are actually strech to a lesser size on one side of image than the other.)
The current program does this but the above said images lines don't line up with the front view walls because of the 2D resizing.
What I want to do is through up the same info onto a 3D screen and instead of having a swuare with unequal sides for those images just have the z position be a - whatever that will give me the right perspective.
What I can't figure out is how to get the quad to draw from point 10,10 to 10,20 to 20,20 to 20,10(in pixel positions) all i can is tell it to go 1 up but the amount of pixels it goes is undetermined and relative to screen size etc(the program has to change the windows size dynamically for the differnt Resolutions the user wants to make the walls for.)
I want to be able to tell the 3D GL screen to draw the quad to those exact pixel coordinates.
Thanks for you help, if you have any more question or sample code you'd rather send via email you can send them to firstname.lastname@example.org.
12-22-2000, 05:09 AM
oh and i meant I'm not familiar with the definition or use of "every" command. Like the DPtoLP command I really have no clue how to use, If im suppossed to set something equal to it or what, and what it is actually for. The MSN thingy only give C++ examples which I'm only about 2 weeks into playing with c++ so.... and then the examle just say do this doeasn't explain very well what the vars are for etc(at least in the help file I'm looking at.)
I reall yneed to go out and buy a opengl book but ummm....well there is like 10 inches of snow out there http://www.opengl.org/discussion_boards/ubb/frown.gif
12-22-2000, 07:31 AM
Ha ha! Only 10 inches of snow? We've got at least a foot, plus it's been around -20 degrees Ferenheit. That's not considering the windchill, which has been down to -60 a few times this past week. We've had a couple of blizzards with whiteout conditions in the last couple of weeks. And winter didn't even officially start until yesterday. (Sorry... I'm from North Dakota and we love to brag about our weather.) http://www.opengl.org/discussion_boards/ubb/smile.gif
Anyway (to keep this on-topic somewhat), there's a version of the red book online somewhere. I don't remember the URL offhand, but do a search of the forums here and I'm sure you can find it.
12-22-2000, 08:10 AM
I might of seen that the name is familiar the problem is 98% of everything online is c++ coding which gives me an idea of how to do it but the delphi coding defies me.... some procedure don't even exist in the delphis pas http://www.opengl.org/discussion_boards/ubb/frown.gif
if the problem is draw directly with screen (window) coordinates (like glVertex2f(10,10),
glVertex2f(20,10)...) your problem is solved.
To call glVertex with pixels coordinates you will need set an apropriate Viewport and an Projection Matrix.
every frame you will call:
1) GetClientRect(window_hwnd,rect_structure), to get the window client area dimensions;
2) glViewport(0,0,client_area_width,client_area_heigh t);
5) gluOrtho2D(0,client_area_width,client_area_height, 0);
6) glMatrixMode(GL_MODELVIEW) and go on...
At this point you can draw everything just with pixel coordinates. For example, now calling glVertex2f(20,10) and then glVertex(30,10) will draw a line exactly from pixel (20,10) to pixel (30,10), like GDI.
In the above list,
client_area_width := rect_structure.right-rect_structure.left;
client_area_height := rect_structure.bottom-rect_structure.top;
if you are using a delphi form in your application, the "window_hwnd" above is the form_name.Handle;
When you call gluOrtho2D GLU sets a projection matrix ranging from -1 to 1. When you call glVertex2... you draw vertices at z=0. If you need draw vertices at z > 1 or z < -1 then you should call glOrtho(..,..,..,..,first_zplane,last_zplane), where ".." are identical to gluOrhto2D.
I will post a zip file with a sample application at the address you said. Note that this application uses a few help routines I created... I'm sending them too.
12-22-2000, 06:02 PM
thanks http://www.opengl.org/discussion_boards/ubb/smile.gif but the zip is either corupt or yahoo acting up it won't let me dload http://www.opengl.org/discussion_boards/ubb/frown.gif
Do you want I send it again? I'm using winzip8. Here the file extracts right.
12-25-2000, 03:19 PM
I couldn't even dload the file in yahoo it goes to a login.html file instead. BTW do you know why the partially off screen quad is drawn differently?
with lines in the border of screen? because GL clips your polys before drawing them
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.