ZenGLOriginally Posted by Ray
Yes, this is the fastest way to draw image on the screen, but with any 2d engine you will not have to worry about this.Originally Posted by Ray
Is there an example for doing the following with GLDirectOpengL:
1. Draw some lines. - Done
2. Draw some test. - Done
3. Draw a bitmap or dib on the GLDirectOpengl surface.
For the last one, I do not see any bitmap type functions in the unit for GLDirectOpengl. What would the code be to draw a simple bitmap? Or do I need to use all the 3D stuff.
Ok, did it like this:
//put a glplane onto the viewing area (orientate it so that it looks 2d) and assign a bitmap to it. Is there a faster way?
procedure TForm1.SpeedButton2Click(Sender: TObject);
var
rbitmap : tbitmap;
begin
rbitmap:=tbitmap.Create;
rbitmap.SetSize(200,200);
// glplane1.Material.Texture.Image.AssignToBitmap(rbi tmap);
glplane1.Material.Texture.Image.Assign(rbitmap);
end;
Okay I've been experimenting with this:
procedure TForm1.GLDirectOpenGL1Render(Sender: TObject;
var rci: TRenderContextInfo);
var
i,j, x, y : Integer;
color : TColor;
begin
glc:=TGLCanvas.Create(glsceneviewer1.width,glscene viewer1.height);
//method 1
with glc do
begin
for x:=0 to 499 do
for y:=0 to 499 do
begin
PenColor:=rgb(random(255),random(255),random(255)) ;
plotpixel(x,y);
end;
end;
glc.Free;
//method 2
for x:=0 to 499 do
for y:=0 to 499 do
begin
testdib.Pixels[x,y]:=rgb(random(255),random(255),random(255));
end;
glplane1.Material.Texture.Image.Assign(testdib);
end;
I am drawing 2 blocks using different methods. Method 1 is to use the glcanvas. Method 2 is to use a glplane, draw the pixels on the dib and then copy them to the glplane's material. Writing to the DIB itself is very very fast and doesn't slow things sown much at all. The problem is trying to get the dib onto the plane.
Method 1 by itself I get 50FPS.
Method 2 by itself I get 15 FPS
Method 2 without assigning the testdib to the plane's material, I get 60FPS.
So I conclude that Method 2 has a bottleneck of glplane1.Material.Texture.Image.Assign(testdib);
My questions are:
1. Is there any way to get the tdib into the glplane faster than using assign?
2. OR is there a completely different (and much faster) way of putting pixels on the screen than using the 2 methods above?
Bookmarks