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

Aktuelle Zeit: So Jun 16, 2024 03:51

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



Ein neues Thema erstellen Auf das Thema antworten  [ 28 Beiträge ]  Gehe zu Seite 1, 2  Nächste
Autor Nachricht
BeitragVerfasst: Mo Mär 26, 2007 23:21 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
Hi,

I have one of those starter questions again... I am starting to add OpenGL effects to my main project but have a lot of the normal type graphical / presentation stuff still in there. At the moment, I have a TForm which I display lots of text on (they are Track Lyrics actually) via the TForm.TCanvas with TextOut. Over time I would migrate this to OpenGL but, for now, I simply want to display some added OpenGL effects on this screen.

What I want to display in OpenGL is fine - however, as part of its drawing routine, it obviously erases anything else that is on the TForm - with glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); - and I am wondering if there is any way that I could 'add' OpenGL effects to my TForm with other GDI type stuff already on there, without clearing it all.

I figured the simplest way would be... when I want to display my OpenGL stuff, as it is only for a short time, I just save the current static pixels of my TForm.TCanvas to a texture and then I draw that texture to the OpenGL Device Context before I do all my cool OpenGL stuff... as soon as my OpenGL phase is complete, I can go back to my original rendering without OpenGL.

Does that sound crazy?

High-level pseudocode... I guess:

Code:
  1.       ...
  2.    Label1:
  3.       NormalGDIRenderingOfLyrics;
  4.       IfNoOpenGLRequired then Jump Label1
  5.       SaveGDIScreenToTexture;
  6.    Label2:
  7.       DisplaySavedTexture;
  8.       DoOpenGLRenderingOnTopOfSavedTexture;
  9.       IfOpenGLStillRequired then Jump Label2
  10.       RestoreSavedTexture;
  11.       ...

Appreciate any pointers anyone might have... high-level question is - how best to mix OpenGL effects with GDI effects?

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Mär 27, 2007 09:43 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
Mixing GDI and OpenGL ist difficult. There is no best way to mix it. There only ways. I dosn't really understood what you exactly plan with GDI is but impossible is nothing. The all spanning question is "make it sense or not"? If you want to draw OpenGL only in an small rect of you form you should use an panel to limit OpenGL to his rect. Its the most easy and safe way.

If you only want to draw simple text lyrics in OpenGL i think you should do the right way and implement it in OpenGL from beginning.

If you really need to copy the form with Labels, Buttons etc you have no other chance to copy the form into an texture. Excep you want to create an OpenGL GUI or use one of the existing sources. But most dosnt have much functionallity or they just unfinished. When you copy the form to an texture to use it in OpenGL you must often copy it to OpenGL. This isn't really fast but for your app i think it should be fast enough. But you must consider that most graphiccards need power of two textures. This fact makes it not easier to work with. Or you can use the extension GL_ARB_texture_rectangle. (also available as EXT and NV version).

When you copy your form the ideal way is to draw the form directlly to an bitmap instead of drawing it to the form and copy this into an texture. If you draw with GDI and after with OpenGL in many situations it result in flickering. GDI alone still flickers. The code below shows how you could draw an form to an bitmap. But it dosnt work 100% with edits. You dosn't see the carret. The actual editioning position in an edit/memo.
Code:
  1. var
  2.   Bmp: TBitmap;
  3. begin
  4.   Bmp := TBitmap.Create;
  5.   try
  6.     Bmp.PixelFormat := pf24bit;
  7.     // if you need pot texture you mus make it larger
  8.     Bmp.Width := Form1.ClientWidth;
  9.     Bmp.Height := Form1.ClientHeight;
  10.  
  11.     //  This copy an rect of the screen. Also including the carret and
  12.     //  all other windows at the position.
  13. //    Bmp.Canvas.CopyRect(
  14. //      Rect(0, 0, Form1.ClientWidth -1, Form1.ClientHeight -1),
  15. //      Form1.Canvas,
  16. //      Rect(0, 0, Form1.ClientWidth -1, Form1.ClientHeight -1)
  17. //    );
  18.  
  19.     // Draw an form directlly to an bitmap
  20.     Form1.PaintTo(Bmp.Canvas, 0, 0);
  21.  
  22.     // Do something with it.
  23.   finally
  24.     Bmp.Free;
  25.   end;


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Mär 27, 2007 09:58 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
Thank you for your response - you have given me something to consider and I will let you know if I implement it successfully. Some of your points were very well made and are worth feedback from me I think.

Zitat:
If you want to draw OpenGL only in an small rect of you form you should use an panel to limit OpenGL to his rect. Its the most easy and safe way.

Yes, I tried this and it did work... although my bit of OpenGL stuff had a black background around it - which covered parts of the underlying GDI stuff - to be perfectly expected I guess. If there was a way to draw GDI stuff to the TForm.TCanvas and then have a transparent TPanel background, so I only saw the OpenGL stuff I drew on the TPanel (and any pixels I had not changed you could see the GDI stuff underneath), that would be the best, safest, and cleanest solution - but I couldn't find out hw to do that, and I'm not sure it's possible. Seems, to me, like it would not be possible.

Zitat:
If you only want to draw simple text lyrics in OpenGL i think you should do the right way and implement it in OpenGL from beginning.

I agree - 100% - and if I was starting from the beginning, I would be doing this. My plan is still to get to this position of course but, for now, I have hundreds of lines of legacy code using GDI and I just want to add a bit of OpenGL to it. One of my previous forum posts was all about Lyrics and centering of bitmap fonts on screen... that is all working fine now, but I still have some way to go before I can move this across to OpenGL in its entirety.

So, I will try capturing the details of the screen (there are no TButtons, TEdits or other windowed components on it, it is just a black background with GDI stuff on it - so that simplifies matters I believe) to a TBitmap and then drawing it onto the screen in my OpenGL rendering phase as we have discussed. I have hopes that it will work as I think it will.

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Progress... kinda...
BeitragVerfasst: Di Mär 27, 2007 12:36 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
OK, progress of sorts... firstly, I could only get it to save the screen properly using the below code:

Code:
  1.   ScreenBitmap := TBitmap.Create;
  2.   ScreenBitmap.PixelFormat := pf24bit;
  3.   ScreenBitmap.Width := frmMain.ClientWidth;
  4.   ScreenBitmap.Height := frmMain.ClientHeight;
  5.   ScreenBitmap.Canvas.CopyRect (ClientRect,Canvas,ClientRect);
  6.  

Not using:

Code:
  1.   ScreenBitmap := TBitmap.Create;
  2.   ScreenBitmap.PixelFormat := pf24bit;
  3.   ScreenBitmap.Width := frmMain.ClientWidth;
  4.   ScreenBitmap.Height := frmMain.ClientHeight;
  5.   frmMain.PaintTo (ScreenBitmap.Canvas,0,0);
  6.  
Or...

Code:
  1.   ScreenBitmap := TBitmap.Create;
  2.   ScreenBitmap.PixelFormat := pf24bit;
  3.   ScreenBitmap.Width := frmMain.ClientWidth;
  4.   ScreenBitmap.Height := frmMain.ClientHeight;
  5.   ScreenBitmap := frmMain.GetFormImage;
  6.  

So, I proved that I have saved my GDI TCanvas stuff to a TBitmap that I can draw onto the screen when my OpenGL stuff is complete. That works fine.

The next step is getting all of this GDI stuff to be drawn to the screen while the OpenGL stuff is being rendered. Of course, if I just add a call to "frmMain.Canvas.Draw (0,0,ScreenBitmap);" in my OpenGL render procedure I get all sorts of flicker going on - but you can actually see it is trying to draw it.

So the next question becomes... how do I take a TBitmap and draw it to my form in OpenGL?

This is a similar question to one I've posed before... I originally thought I needed to find some way to convert a TBitmap to a Texture (GLUInt) so draw it via OpenGL. Is this the case? Or can I find some way of using an in-memory TBitmap in OpenGL and drawing it across the background?

I have attached my simple code so far... 12K... in case anyone is interested enough to illustrate to me how I might use the TBitmap I have saved when I start my OpenGL rendering and continue to display it during my OpenGL rendering and display it a final time after my OpenGL rendering is complete. It will compile in a jiffy in Delphi 7.

As always, help is appreciated - I'm still learning this stuff.


Dateianhänge:
SampleCode.zip [12.3 KiB]
368-mal heruntergeladen
SampleCode.zip [12.3 KiB]
379-mal heruntergeladen

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk
Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Mär 27, 2007 12:55 
Offline
Ernährungsberater
Benutzeravatar

Registriert: Sa Jan 01, 2005 17:11
Beiträge: 2067
Programmiersprache: C++
As far as I know you can use Lossy's glBitmap.
With AssignFromBitmap you should be able to load the content of the TBitmap to a Texture.

_________________
Steppity,steppity,step,step,step! :twisted:
❆ ❄ ❄ ❄ ❅ ❄ ❆ ❄ ❅ ❄ ❅ ❄ ❅ ❄ ❄
❄ ❄ ❄ ❅ ❄ ❄ ❄ ❅ ❄ ❄ ❆ ❄ ❄


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Mär 27, 2007 13:34 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
Yes i0n0s is right.

Some sideinfos. Your form dosn't have power of two sizes so you can't use it directlly. You can use the target GL_TEXTURE_RECTANGLE_ARB. These ist provided by the extensions i told you above. All newer graphicscard's (since 5-8 years i think) should know them. If not you will get an exception from my loader. If you dont want these restrictions you must do an other way.

- Create an TglBitmap2D class
- Set new target via property Target
- Set Bitmap
- Call GenTexture and enjoy your texture.

If you want to Update the Textur you only must assign the bitmap again and call GenTexture again. All handlings will done intern. But its not the fastes way but its okay.

When you use Texture Rectangle the texturcoordinates are not normalized. They are not between 0 and 1. They are between 0 and width or 0 and height.

I forgot something. ATI cards are a bit slow wen you use 24 Bit textures. It is better to use 32 Bit textures and waste 8 bits per pixel. Just set the Pixelformat of the bitmap to pf32Bit. And make sure you draw your textur without alphatest or blending. I think when this happens you dosn't see any texture because the alphachannel is zero.


And dont forget to free you bitmaps if you dosnt need it anymore. In your third code i saw some mistake. You create an bitmap and after that you get an bitmap from the form. In this case you dosn't have to create the previous one.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: More progress... I think...
BeitragVerfasst: Di Mär 27, 2007 14:09 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
Thank you both for your comments. Firstly, my TForm in the sample code is just a simple sandbox environment - but my main project form will not have a power of 2 size either. Anyway, I tried to follow through the steps outlined by Lossy eX and made some progress, I thought...

I changed my 2nd TButton code that tries to a) save the TForm's TCanvas's contents to a TBitmap, b) Convert that TBitmap to a Texture and c) commence the OpenGL rendering phase... to:

Code:
  1. procedure TfrmMain.bStartOpenGLClick ( Sender : TObject
  2.                                      );
  3. var
  4.   tgl2DBitmap : TglBitmap2D;
  5. begin
  6.   { Create Bitmap and copy the Form's contents to it. }
  7.   ScreenBitmap := TBitmap.Create;
  8.   ScreenBitmap.PixelFormat := pf24bit;
  9.   ScreenBitmap.Width := frmMain.ClientWidth;
  10.   ScreenBitmap.Height := frmMain.ClientHeight;
  11.   ScreenBitmap.Canvas.CopyRect (ClientRect,Canvas,ClientRect);
  12.  
  13.   { Convert TBitmap to Texture. }
  14.   tgl2DBitmap := TglBitmap2D.Create;
  15.   tgl2DBitmap.Target := GL_TEXTURE_RECTANGLE_ARB;
  16.   tgl2DBitmap.AssignFromBitmap (ScreenBitmap);
  17.   glGenTextures (1,ScreenTexture);
  18.  
  19.   { Commence the OpenGL rendering... }
  20.   Timer1.Enabled := True;
  21. end;
...and this all seems to work. Is it being done correctly? I didn't worry about free'ing.

I then altered my Draw procedure so that it displays the created Texture behind the characters I am displaying. I didn't think that this would work correctly first time, but I am a little stumped as to why I don't really see anything. What I see is just a square (I just sized it like that for simplicity) of the same colour in the background. Nothing resembling what the contents of my TForm's TCanvas was.

Code:
  1. procedure TfrmMain.Draw;
  2. begin
  3.   glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  4.  
  5.   glLoadIdentity;
  6.  
  7.   glPushMatrix;
  8.     glEnable (GL_TEXTURE_2D);
  9.     glBindTexture (GL_TEXTURE_2D,ScreenTexture);
  10.     glTranslatef (0,0,-5);
  11.     glBegin (GL_QUADS);
  12.       glTexCoord2f (0,0); glVertex3f (-1.0,-0.9,0);
  13.       glTexCoord2f (1,0); glVertex3f (+1.0,-0.9,0);
  14.       glTexCoord2f (1,1); glVertex3f (+1.0,+0.9,0);
  15.       glTexCoord2f (0,1); glVertex3f (-1.0,+0.9,0);
  16.     glEnd;
  17.     glDisable (GL_TEXTURE_2D);
  18.   glPopMatrix;
  19.  
  20.   glTranslatef (0,-0.33,-1);
  21.   glRotatef (Rotation,0,1.0,0.0);
  22.   glRotatef (Sin (Changer / 600) * 10,0,1,0);
  23.   glRotatef (Sin (Changer / 600) * 10,1,0,0);
  24.   glPrint (ToPrint);
  25.  
  26.   SwapBuffers (wglGetCurrentDC);
  27. end;
...I see:

Bild

Instead of what I want to see... which is obviously my GDI stuff (you see after pressing the first button) in the background - the same size and location as it was previously... I figured I might have to do this with Orthographic projection... but I'm getting a bit confused now to be honest.

Questions...

1) Is my TBitmap actually being converted successfully to a Texture?
2) How can I display my Texture behind my Text in the correct location and size?

My apologies that this is all such simple stuff... I hope to get proficient at this and put it to good use in my main project. Latest source is attached...


Dateianhänge:
Sample1.zip [34.31 KiB]
377-mal heruntergeladen

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk
Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Mär 27, 2007 14:35 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
If you are sure that your texture is pot then you dont need to use GL_TEXTURE_RECTANGLE_ARB.

No you Code isnt right. It should look like so. You also can use the instance of TglBitmap2D global to handle the texture. You easilly can use the function bind and unbind to bind or unbind an texture. I prefer the use of theses classes.

Code:
  1. procedure TfrmMain.bStartOpenGLClick ( Sender : TObject);
  2. var
  3.   tgl2DBitmap : TglBitmap2D;
  4. begin
  5.   { Create Bitmap and copy the Form's contents to it. }
  6.   ScreenBitmap := TBitmap.Create;
  7.   ScreenBitmap.PixelFormat := pf24bit;
  8.   ScreenBitmap.Width := frmMain.ClientWidth;
  9.   ScreenBitmap.Height := frmMain.ClientHeight;
  10.   ScreenBitmap.Canvas.CopyRect (ClientRect,Canvas,ClientRect);
  11.  
  12.   { Convert TBitmap to Texture. }
  13.   tgl2DBitmap := TglBitmap2D.Create;
  14.   // this line only if you have NPOT. Without GL_TEXTURE_2D will be used as target.
  15.   tgl2DBitmap.Target := GL_TEXTURE_RECTANGLE_ARB;
  16.   tgl2DBitmap.AssignFromBitmap (ScreenBitmap);
  17.   tgl2DBitmap.GenTexture;
  18.  
  19.   { to "extract" the ID }
  20.   ScreenTexture := tgl2DBitmap.ID;
  21.   TextureWidth := tgl2DBitmap.Width;
  22.   TextureHeight := tgl2DBitmap.Height;
  23.   tgl2DBitmap.DeleteTextureOnFree := False; // protect opengl texture
  24.   tgl2DBitmap.Free;  // Free instance of TglBitmap2D
  25.  
  26.   ScreenBitmap.Free; (????)
  27.  
  28.   { Commence the OpenGL rendering... }
  29.   Timer1.Enabled := True;
  30. end;


If you are using GL_TEXTURE_RECTANGLE_ARB as target the code to draw should look so.
Code:
  1.   glEnable (GL_TEXTURE_RECTANGLE_ARB);
  2.   glBindTexture (GL_TEXTURE_RECTANGLE_ARB, ScreenTexture);
  3.  
  4.   glTranslatef (0,0,-5);
  5.   glBegin (GL_QUADS);
  6.     glTexCoord2f (0, 0);                        glVertex3f (-1.0,-0.9,0);
  7.     glTexCoord2f (TextureWidth, 0);             glVertex3f (+1.0,-0.9,0);
  8.     glTexCoord2f (TextureWidth, TextureHeight); glVertex3f (+1.0,+0.9,0);
  9.     glTexCoord2f (0, TextureHeight);            glVertex3f (-1.0,+0.9,0);
  10.   glEnd;
  11.   glDisable (GL_TEXTURE_RECTANGLE_ARB);


To draw the Screen in the Background you only need to disable the Depthtest or you translate the quad in the back or you are using the Z value of glVertex3f. At this moment it is allways zero.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Tum-te-tum...
BeitragVerfasst: Di Mär 27, 2007 15:55 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
OK, I'm getting nowhere fast now and I'm trying to take this back to first principles.

Problem:
1) Saving a TForm's TCanvas's contents to a TBitmap.
2) Converting that TBitmap to an OpenGL Texture.
3) Displaying that Texture using OpenGL so it looks just like the stuff I saved in step 1.

1 is complete and is proven to work.

2 has had the code updated as has been suggested, here:

Code:
  1. procedure TfrmMain.bSaveAndConvertClick ( Sender : TObject
  2.                                         );
  3. var
  4.   tgl2DBitmap : TglBitmap2D;
  5. begin
  6.   { Create Bitmap and copy the Form's contents to it. }
  7.   ScreenBitmap := TBitmap.Create;
  8.   ScreenBitmap.PixelFormat := pf24bit;
  9.   ScreenBitmap.Width := frmMain.ClientWidth;
  10.   ScreenBitmap.Height := frmMain.ClientHeight;
  11.   ScreenBitmap.Canvas.CopyRect (ClientRect,Canvas,ClientRect);
  12.  
  13.   { Convert TBitmap to Texture. }
  14.   tgl2DBitmap := TglBitmap2D.Create;
  15.   tgl2DBitmap.Target := GL_TEXTURE_RECTANGLE_ARB;
  16.   tgl2DBitmap.AssignFromBitmap (ScreenBitmap);
  17.   tgl2DBitmap.GenTexture;
  18.   ScreenTexture := tgl2DBitmap.ID;
  19.   TextureWidth := tgl2DBitmap.Width;
  20.   TextureHeight := tgl2DBitmap.Height;
  21.   tgl2DBitmap.DeleteTextureOnFree := False;
  22.   tgl2DBitmap.Free;
  23. end;
  24.  

3 I cannot get to work. I have removed my Text drawing code to keep it all as simple as possible - now I am only trying to re-show the Texture that contains the TBitmap that I saved in 1, here:

Code:
  1. procedure TfrmMain.Draw;
  2. begin
  3.   glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  4.  
  5.   glLoadIdentity;
  6.  
  7.   glPushMatrix;
  8.     glEnable (GL_TEXTURE_RECTANGLE_ARB);
  9.     glBindTexture (GL_TEXTURE_RECTANGLE_ARB,ScreenTexture);
  10.     glTranslatef (0,0,-3);
  11.     glBegin (GL_QUADS);
  12.       glTexCoord2f (0,0);
  13.       glVertex3f (-1.0,-0.9,-3);
  14.       glTexCoord2f (TextureWidth,0);
  15.       glVertex3f (+1.0,-0.9,-3);
  16.       glTexCoord2f (TextureWidth,TextureHeight);
  17.       glVertex3f (+1.0,+0.9,-3);
  18.       glTexCoord2f (0,TextureHeight);
  19.       glVertex3f (-1.0,+0.9,-3);
  20.     glEnd;
  21.     glDisable (GL_TEXTURE_RECTANGLE_ARB);
  22.   glPopMatrix;
  23.  
  24.   SwapBuffers (wglGetCurrentDC);
  25. end;
  26.  
...I would expect (hope) to see some representation of my saved TBitmap - but I see nothing - well, I see a black screen.

The strange thing is that if I forget about saving my TForm's TCanvas's contents as a TBitmap and converting it to a Texture and I just load a Texture from a JPG - using Textures.LoadTexture ('Background.jpg',ScreenTexture,False); then I can see the Texture being displayed in the background - of course, my Draw procedure needs to change somewhat. However, I can see the loaded background Texture.

Even though it has the same colouring as the Text in the foreground... another problem that I'd like to understand.

So, right now... I have a small application with 5 TButtons... like this:

Bild

Pressing Button1 draws some GDI stuff all over the TCanvas.
Pressing Button2 is supposed to save the TCanvas contents to a TBitmap and then convert that to a Texture.
Pressing Button3 starts the Timer that controls the OpenGL rendering - this shows nothing of the saved Texture.
Pressing Button4 stops OpenGL rendering and re-draws the saved TBitmap over the TCanvas.
Pressing Button5 exits the application - at least that works!

Anyway... what else can I say to help you guys who are helping me?

1) I am definitely not using PoT images.
2) I would really like this to work for me.
3) I obviously don't know what I'm doing.

Latest source attached...


Dateianhänge:
Sample3.zip [34.39 KiB]
367-mal heruntergeladen

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk
Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Mär 27, 2007 17:07 
Offline
Ernährungsberater
Benutzeravatar

Registriert: Sa Jan 01, 2005 17:11
Beiträge: 2067
Programmiersprache: C++
If you add
Code:
  1. glColor3f(1,1,1);

in your drawing routine it works fine.

And you should add
Code:
  1. tgl2DBitmap.FlipVert;

before generating the texture.

_________________
Steppity,steppity,step,step,step! :twisted:
❆ ❄ ❄ ❄ ❅ ❄ ❆ ❄ ❅ ❄ ❅ ❄ ❅ ❄ ❄
❄ ❄ ❄ ❅ ❄ ❄ ❄ ❅ ❄ ❄ ❆ ❄ ❄


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Really?
BeitragVerfasst: Di Mär 27, 2007 17:28 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
It does???

It doesn't for me. My Draw procedure is:

Code:
  1. procedure TfrmMain.Draw;
  2. begin
  3.   glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  4.   glLoadIdentity;
  5.  
  6.   glPushMatrix;
  7.     glEnable (GL_TEXTURE_RECTANGLE_ARB);
  8.     glBindTexture (GL_TEXTURE_RECTANGLE_ARB,ScreenTexture);
  9.     glTranslatef (0,0,-3);
  10.     glBegin (GL_QUADS);
  11.       glTexCoord2f (0,0);
  12.       glVertex3f (-1.0,-0.9,-3);
  13.       glTexCoord2f (TextureWidth,0);
  14.       glVertex3f (+1.0,-0.9,-3);
  15.       glTexCoord2f (TextureWidth,TextureHeight);
  16.       glVertex3f (+1.0,+0.9,-3);
  17.       glTexCoord2f (0,TextureHeight);
  18.       glVertex3f (-1.0,+0.9,-3);
  19.     glEnd;
  20.     glDisable (GL_TEXTURE_RECTANGLE_ARB);
  21.   glPopMatrix;
  22.  
  23.   SwapBuffers (wglGetCurrentDC);
  24. end;
If I add glColor3f(1,1,1); to it, it still does absolutely nothing for me when I press the Start OpenGL button - except clear the screen to Black as defined by glClear. Of course, the screen is returned OK when pressing the Stop OpenGL button - but that's just a re-drawing of the Bitmap saved when I pressed the Bitmap -> Texture. Are you seeing something different?

I see...

Bild

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Mär 27, 2007 17:37 
Offline
Ernährungsberater
Benutzeravatar

Registriert: Sa Jan 01, 2005 17:11
Beiträge: 2067
Programmiersprache: C++
glColor after glPushMatrix and starting OpenGL:
Bild

_________________
Steppity,steppity,step,step,step! :twisted:
❆ ❄ ❄ ❄ ❅ ❄ ❆ ❄ ❅ ❄ ❅ ❄ ❅ ❄ ❄
❄ ❄ ❄ ❅ ❄ ❄ ❄ ❅ ❄ ❄ ❆ ❄ ❄


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: I must be going insane...
BeitragVerfasst: Di Mär 27, 2007 17:47 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
Wow - obviously it does work for you.

It still does not work for me though and this is becoming intensely frustrating.

Can you please post a quick forum entry with the entire contents of MainForm.pas included? I would appreciate it very much as it would probably help to get past this issue quickly - either it will work for me, or it won't.

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Mär 27, 2007 18:46 
Offline
Ernährungsberater
Benutzeravatar

Registriert: Sa Jan 01, 2005 17:11
Beiträge: 2067
Programmiersprache: C++
In attachment, including an exe.


Dateianhänge:
Sample3.rar [248.52 KiB]
382-mal heruntergeladen

_________________
Steppity,steppity,step,step,step! :twisted:
❆ ❄ ❄ ❄ ❅ ❄ ❆ ❄ ❅ ❄ ❅ ❄ ❅ ❄ ❄
❄ ❄ ❄ ❅ ❄ ❄ ❄ ❅ ❄ ❄ ❆ ❄ ❄
Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: At least I'm not insane...
BeitragVerfasst: Di Mär 27, 2007 19:03 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
Thank-you.

On my system the .exe you posted works as I describe; and not how it works on your system - after pressing the "Start OpenGL" button I get a blank, black screen.

I am completely stumped now. There's obviously something fundamentally wrong with my system. All sorts of other stuff work fine, including many OpenGL games and demos, and my video card drivers are up to date.

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 28 Beiträge ]  Gehe zu Seite 1, 2  Nächste
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 11 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:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.084s | 16 Queries | GZIP : On ]