Registriert: So Mär 26, 2006 21:44 Beiträge: 3 Wohnort: Brasov, Romania
Hi,
I am developing an vector graphics applicatiion for some time now. The app. displays a vector map loaded from SHP files. I am wondering if it would pe possible to put some 3D features in the mode how the map is displayed on the screen, and I mean, for the start, only a perspective transformation with some blurring. How difficult would it be? I have no experience in 3d graphics or OpenGL.
Registriert: Sa Mai 04, 2002 19:48 Beiträge: 3830 Wohnort: Tespe (nahe Hamburg)
How hard is it to drive a car? Some people say it is easy as breathing some other are learning their whole life No, just kidding. In fact the real problem in using opengl is to math for calculating matrices. If you are just using a fixed position from above to display some data on the screen, it might be even easier than using simple 2d. But if you move into the scene, able to rotate arround all three axis with some blending etc. it will get more and more complicate. However, I think you should give OpenGL a try and will find it quite comfortable to realize a vector program with it.
_________________ "Light travels faster than sound. This is why some people appear bright, before you can hear them speak..."
Registriert: So Mär 26, 2006 21:44 Beiträge: 3 Wohnort: Brasov, Romania
Thank you for your response.
Question: Is there any Delphi component that emulates a TCanvas but translates any line, lineto, brush, etc. into opengl?
I'm asking this because I am using a TCanvas for drawing all 2D maps. I think that if there is such component, I will be able to do a Z axis rotation (perspective) and then add some blurring on the top of the screen. I'm not shure if you are familiar with the way TomTom or Route66 do the drawing of maps on PDA's.
Registriert: Fr Mai 14, 2004 18:56 Beiträge: 804 Wohnort: GER/OBB/TÖL-WOR/Greiling
I think I know what you want to do....
Maybe it's enough to write it all to a Tbitmap.canvas and use this Bitmap as a texture on a quad in 3d mode. you can then scale, rotate and translate that quad with the map on it just the way you could with a map on a sheet of paper (well, scaling would have to be shown yet ).
EDIT: if you want to edit that map in real time, it could get a little bit more difficult... but with todays hardware ti shouldn't be too performance-killing to just edit and rebind it.
Registriert: Sa Mai 04, 2002 19:48 Beiträge: 3830 Wohnort: Tespe (nahe Hamburg)
Yes, I know TomTom... but I out of my mind I don't know a canvas to opengl component for doing this job and I also think that you will not find much like these in the net. However, a port to opengl should be quite easy as long as you have all points your need to draw. You even can switch opengl into an orthogonal projection mode to simulate something like a 2D canvas. The orgin will be different (opengl orgin is 0/0 in the left bottom, instead of top), but then you should be able to draw lines as easy as you would use a canvas.
_________________ "Light travels faster than sound. This is why some people appear bright, before you can hear them speak..."
Registriert: So Mär 26, 2006 21:44 Beiträge: 3 Wohnort: Brasov, Romania
Are there any simple examples for this? I mean examples that shows me how to draw lines, polygons, etc. like I would on a simple tcanvas? Something to start with ...
Registriert: Sa Mai 04, 2002 19:48 Beiträge: 3830 Wohnort: Tespe (nahe Hamburg)
In fact there are quite some documentation, however currently only in german. However, let us try a small example.
To get sure you have everything you need: http://files.delphigl.com/Download/dglsdk_2005_2.exe This is our DGLSDK Installer. It installs several common headers you might find interesting (OpenGL Header from us, SDL from the JEDIs, several Texture loader). It also add these headers to the search path of delphi.
http://www.delphigl.com/download.php?cat=1 There you find our templates for a really basic opengl init. You will find especially the VCL example usefull:
http://www.delphigl.com/do_download.php?f=8
Search there the method ApplicationEventsIdle and replace
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
ShowText;
// Hinteren Puffer nach vorne bringen
SwapBuffers(DC);
// Windows denken lassen, das wir noch nicht fertig w�en
Done :=False;
// Nummer des gezeichneten Frames erh�en
inc(Frames);
// FPS aktualisieren
if GetTickCount - StartTick >=500then
begin
FPS := Frames/(GetTickCount-StartTick)*1000;
Frames :=0;
StartTick := GetTickCount
end;
Code:
glMatrixMode(GL_PROJECTION);
glLoadIdentity;
glOrtho(0,800,0,600,0,128);
glMatrixMode(GL_MODELVIEW);
glClearColor(0.0,0.0,0.0,1);
glClear( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT );
glLineWidth(2);
glLoadIdentity;
glDisable(GL_TEXTURE_2D);
glBegin(GL_LINE_STRIP);
glColor3f(1,0,0);
glVertex2f(0,0);
glColor3f(0,1,0);
glVertex2f(100,100);
glColor3f(0,0,1);
glVertex2f(200,100);
glEnd;
// Hinteren Puffer nach vorne bringen
SwapBuffers(DC);
// Windows denken lassen, das wir noch nicht fertig w�en
Done :=False;
// Nummer des gezeichneten Frames erh�en
inc(Frames);
// FPS aktualisieren
if GetTickCount - StartTick >=500then
begin
FPS := Frames/(GetTickCount-StartTick)*1000;
Frames :=0;
StartTick := GetTickCount
end;
You might to change the arguments of glOrtho. I am not using VCL, but SDL under Linux with a fixed windows size of 800/600. So you might want to set in the size of the forum instead. You should then be able to see a colored line from 0/0 (left bottom) to 100/100 then straight ahead to 200/100. This way you easily could draw lines with opengl in "2D mode". Using GL_QUAD allows to draw filled rectangles even with texture for drawing "images". GL_POLYGON might be intersting if you have to fill out some unconvential area. Just circles are not that easy, cause they are not a shape a 3D card really likes. However, if you a drawing most times lines, triagles or quads, you can greatly benefit from your 3D card. Also notice our (old) template for using two render context: http://www.delphigl.com/do_download.php?f=3333 You might find it usefull, if you need two viewports on your frame. Also notice that there is shown how you could use a panel as opengl viewport instead of the whole form. Hope this helps a little bit.
_________________ "Light travels faster than sound. This is why some people appear bright, before you can hear them speak..."
Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.