Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Fr Jul 18, 2025 11:13

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 7 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Converting an 2D App in 3D
BeitragVerfasst: So Mär 26, 2006 21:46 
Offline
DGL Member

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.

Any advice would be very appreciated.

10x
Ionut Muntean


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mär 27, 2006 09:57 
Offline
Fels i.d. Brandung
Benutzeravatar

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..."


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mär 27, 2006 15:20 
Offline
DGL Member

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.

Thank's again for your answer.

Ionut Muntean


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mär 27, 2006 15:31 
Offline
DGL Member
Benutzeravatar

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 ;) ).

with glbitmap.pas ( http://dev-center.de, glbitmap.pas ) you can load and bind textures very easily.

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.

_________________
Bild

"User Error. Replace User and hit Continue."


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mär 27, 2006 17:21 
Offline
Fels i.d. Brandung
Benutzeravatar

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..."


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Mär 27, 2006 23:43 
Offline
DGL Member

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 ...

_________________
---
Ionut Muntean


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Mär 28, 2006 11:09 
Offline
Fels i.d. Brandung
Benutzeravatar

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
Code:
  1. // In die Projektionsmatrix wechseln
  2. glMatrixMode(GL_PROJECTION);
  3. // Identit�smatrix laden
  4. glLoadIdentity;
  5. // Viewport an Clientareal des Fensters anpassen
  6. glViewPort(0, 0, ClientWidth, ClientHeight);
  7. // Perspective, FOV und Tiefenreichweite setzen
  8. gluPerspective(60, ClientWidth/ClientHeight, 1, 128);
  9.  
  10. // In die Modelansichtsmatrix wechseln
  11. glMatrixMode(GL_MODELVIEW);
  12. // Identit�smatrix laden
  13. glLoadIdentity;
  14. // Farb- und Tiefenpuffer l�chen
  15. glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  16.  
  17. ShowText;
  18.  
  19. // Hinteren Puffer nach vorne bringen
  20. SwapBuffers(DC);
  21.  
  22. // Windows denken lassen, das wir noch nicht fertig w�en
  23. Done := False;
  24.  
  25. // Nummer des gezeichneten Frames erh�en
  26. inc(Frames);
  27. // FPS aktualisieren
  28. if GetTickCount - StartTick >= 500 then
  29.  begin
  30.  FPS       := Frames/(GetTickCount-StartTick)*1000;
  31.  Frames    := 0;
  32.  StartTick := GetTickCount
  33.  end;

Code:
  1.  
  2.     glMatrixMode(GL_PROJECTION);
  3.     glLoadIdentity;
  4.     glOrtho(0,800,0,600, 0,128);
  5.     glMatrixMode(GL_MODELVIEW);
  6.     glClearColor(0.0,0.0,0.0,1);
  7.     glClear( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT );
  8.  
  9.     glLineWidth(2);
  10.     glLoadIdentity;
  11.     glDisable(GL_TEXTURE_2D);
  12.    
  13.     glBegin(GL_LINE_STRIP);
  14.         glColor3f(1,0,0);
  15.         glVertex2f(0,0);
  16.         glColor3f(0,1,0);
  17.         glVertex2f(100,100);
  18.         glColor3f(0,0,1);
  19.         glVertex2f(200,100);
  20.     glEnd;
  21.  
  22. // Hinteren Puffer nach vorne bringen
  23. SwapBuffers(DC);
  24.  
  25. // Windows denken lassen, das wir noch nicht fertig w�en
  26. Done := False;
  27.  
  28. // Nummer des gezeichneten Frames erh�en
  29. inc(Frames);
  30. // FPS aktualisieren
  31. if GetTickCount - StartTick >= 500 then
  32.  begin
  33.  FPS       := Frames/(GetTickCount-StartTick)*1000;
  34.  Frames    := 0;
  35.  StartTick := GetTickCount
  36.  end;
  37.  


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..."


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 7 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 2 Gäste


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.

Suche nach:
Gehe zu:  
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.010s | 15 Queries | GZIP : On ]