Recent

Author Topic: BGRAOpenGL missing functions  (Read 5888 times)

aradeonas

  • Hero Member
  • *****
  • Posts: 824
BGRAOpenGL missing functions
« on: December 02, 2015, 01:34:08 pm »
I can find these function:
1-Pen as discussed here
2-Text functions,I see BGLFont but I dont have clue for how
3-Line width
4-Shapes like Rectangle and Lines rotations
5-Antianalysed functions like Lines like here

I be more than happy if I fond them or know when we have them or how to implement.

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: BGRAOpenGL missing functions
« Reply #1 on: December 02, 2015, 06:43:48 pm »
Hello,

BGLCanvas provide some functions, however aliased.

There may be a way to do some antialiasing using textures.
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: BGRAOpenGL missing functions
« Reply #2 on: December 02, 2015, 06:46:53 pm »
Can you explain more each one?

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: BGRAOpenGL missing functions
« Reply #3 on: December 02, 2015, 11:24:12 pm »
For example I want to draw a rectangle and rotate it.Yes I t can be drawn with points but result will not be correct enough and also it is not antianalysed.

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: BGRAOpenGL missing functions
« Reply #4 on: December 07, 2015, 02:50:16 pm »
To do an antialiased shape that does not need antialiasing when it is not rotated, you can make an texture of how it looks like when it is not rotated, and then draw the rotated texture.

Not ideal, but it can be simplified. For example, you can have a texture where the shape is white and then you can draw the texture with any color (it is one parameter to draw a texture).
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: BGRAOpenGL missing functions
« Reply #5 on: December 07, 2015, 03:38:08 pm »
Quote
To do an antialiased shape that does not need antialiasing when it is not rotated, you can make an texture of how it looks like when it is not rotated, and then draw the rotated texture.
I tested it and it is not good, rectangle will be ugly and not even OK.
I just made an rectangle with BGRABitmao and make a texture and rotate it but it will got problems and maybe it can good for some cases but not for cases when you want smooth thing.
If you have a way to for example draw a clock handle without any problem and in OpenGL so you can rotate it fast please let me know.

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: BGRAOpenGL missing functions
« Reply #6 on: December 07, 2015, 06:34:55 pm »
Maybe you need to add some margin (1 pixel transparent border around the rectangle). Do you have a screenshot of how it looks like?
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: BGRAOpenGL missing functions
« Reply #7 on: December 07, 2015, 08:05:47 pm »
I tried that and here is the result.

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: BGRAOpenGL missing functions
« Reply #8 on: December 08, 2015, 06:33:27 pm »
Try doing a rectangle not from the corner of the bitmap but 1 pixel or 2 pixels away from the corner, if that makes sense. Can you show me the code?
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: BGRAOpenGL missing functions
« Reply #9 on: December 08, 2015, 09:10:35 pm »
Aha!
Now it is good,with a 2 pixel margin it good enough but not as drawing a perfect rectangle with angle that was my goal.
It si interesting that increasing margin can solve the issue.My requests stand but with lower priority below text and line   :D
Thanks Circular.

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   StdCtrls, OpenGLContext, BGRABitmap, BGRABitmapTypes, BGRAOpenGL;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     Panel1: TPanel;
  18.     Timer1: TTimer;
  19.     procedure Button1Click(Sender: TObject);
  20.     procedure FormCreate(Sender: TObject);
  21.     procedure OpenGLControl1Paint(Sender: TObject);
  22.     procedure Timer1Timer(Sender: TObject);
  23.   private
  24.     { private declarations }
  25.   public
  26.     bgl1, bgl2: TBGLBitmap;
  27.     OpenGLControl1: TOpenGLControl;
  28.     DataLoaded: boolean;
  29.     angle:single;
  30.     procedure Load;
  31.   end;
  32.  
  33. var
  34.   Form1: TForm1;
  35.  
  36. implementation
  37.  
  38. {$R *.lfm}
  39.  
  40. { TForm1 }
  41.  
  42. procedure TForm1.FormCreate(Sender: TObject);
  43. begin
  44.   OpenGLControl1 := TOpenGLControl.Create(Self);
  45.   with OpenGLControl1 do
  46.   begin
  47.     Align := alClient;
  48.     Parent := Self;
  49.     OnPaint := @OpenGLControl1Paint;
  50.     AutoResizeViewport := True;
  51.   end;
  52.   DataLoaded := False;
  53. end;
  54.  
  55. procedure TForm1.Button1Click(Sender: TObject);
  56. begin
  57.   Timer1.Enabled:=not Timer1.Enabled;
  58. end;
  59.  
  60.  
  61. procedure TForm1.OpenGLControl1Paint(Sender: TObject);
  62. begin
  63.   Load;
  64.   BGLViewPort(OpenGLControl1.Width, OpenGLControl1.Height, BGRAWhite);
  65.  
  66.   BGLCanvas.PutImage(100, 100, bgl1.Texture);
  67.   BGLCanvas.PutImageAngle(100, 100, bgl1.Texture, angle);
  68.  
  69.   BGLCanvas.PutImage(400, 100, bgl2.Texture);
  70.   BGLCanvas.PutImageAngle(400, 100, bgl2.Texture, angle);
  71.  
  72.  
  73.   OpenGLControl1.SwapBuffers;
  74. end;
  75.  
  76. procedure TForm1.Timer1Timer(Sender: TObject);
  77. begin
  78.   angle:=angle+1;
  79.   if angle=360 then
  80.   angle:=0;
  81.   OpenGLControl1.DoOnPaint;
  82. end;
  83.  
  84. procedure TForm1.Load;
  85. begin
  86.   if not DataLoaded then
  87.   begin
  88.     bgl1 := TBGLBitmap.Create(10, 200, BGRABlack);
  89.     bgl2 := TBGLBitmap.Create(14, 200);
  90.     bgl2.Rectangle(1, 1, bgl2.Width - 1, bgl2.Height - 1, BGRABlack, BGRABlack, dmSet);
  91.  
  92.     DataLoaded := True;
  93.   end;
  94. end;
  95.  
  96. end.

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: BGRAOpenGL missing functions
« Reply #10 on: December 11, 2015, 08:30:55 pm »
A simple question about rotate.
Now we rotate on ImageCenter but what should I do if I want to rotate according to another point?
I did an example but this is not what I want, I want to make a simple clock handle so it should rotate according to begin point of handle.
I hope its clear what I want,just a clock handle with rotation.
I attached an example project too.
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, OpenGLContext, BGRABitmap, BGRABitmapTypes, BGRAOpenGL;
  9.  
  10. { TForm1 }
  11.  
  12. type
  13.   TForm1 = class(TForm)
  14.     Button1: TButton;
  15.     Panel1: TPanel;
  16.     Timer1: TTimer;
  17.     procedure Button1Click(Sender: TObject);
  18.     procedure FormCreate(Sender: TObject);
  19.     procedure OpenGLControl1Paint(Sender: TObject);
  20.     procedure Timer1Timer(Sender: TObject);
  21.   private
  22.     { private declarations }
  23.   public
  24.     bgl1, bgl2: TBGLBitmap;
  25.     OpenGLControl1: TOpenGLControl;
  26.     DataLoaded: boolean;
  27.     angle: single;
  28.     procedure Load;
  29.   end;
  30.  
  31. var
  32.   Form1: TForm1;
  33.  
  34. implementation
  35.  
  36. {$R *.lfm}
  37.  
  38. { TForm1 }
  39.  
  40. procedure TForm1.FormCreate(Sender: TObject);
  41. begin
  42.   OpenGLControl1 := TOpenGLControl.Create(Self);
  43.   with OpenGLControl1 do
  44.   begin
  45.     Align := alClient;
  46.     Parent := Self;
  47.     OnPaint:=@OpenGLControl1Paint;
  48.     AutoResizeViewport := True;
  49.   end;
  50.   DataLoaded := False;
  51. end;
  52.  
  53. procedure TForm1.OpenGLControl1Paint(Sender: TObject);
  54. var
  55.   w,h,x,y:single;
  56. begin
  57.   Load;
  58.   BGLViewPort(OpenGLControl1.Width, OpenGLControl1.Height, BGRAWhite);
  59.   w:=OpenGLControl1.Width;
  60.   h:=OpenGLControl1.Height;
  61.   //BGLCanvas.PutImage(100, 100, bgl1.Texture);
  62.   //BGLCanvas.PutImageAngle(100, 100, bgl1.Texture, angle);
  63.  
  64.   //BGLCanvas.PutImage(400, 100, bgl2.Texture);
  65.   x:=100;
  66.   Y:=100;
  67.   //BGLCanvas.PutImageAngle(x, y, bgl2.Texture, angle);
  68.   bgl2.Texture.DrawAngle(x,y,angle,PointF(x,y),True);
  69.   BGLCanvas.RoundRect(x-1,y-1,x+1,y+1,2,2,BGRA(120,120,120),BGRA(120,120,120));
  70.  
  71.   OpenGLControl1.SwapBuffers;
  72. end;
  73.  
  74. procedure TForm1.Timer1Timer(Sender: TObject);
  75. begin
  76.   angle := angle + 1;
  77.   if angle = 360 then
  78.     angle := 0;
  79.   OpenGLControl1.DoOnPaint;
  80. end;
  81.  
  82. procedure TForm1.Button1Click(Sender: TObject);
  83. begin
  84.   Timer1.Enabled := not Timer1.Enabled;
  85. end;
  86.  
  87. procedure TForm1.Load;
  88. begin
  89.   if not DataLoaded then
  90.   begin
  91.     //bgl1 := TBGLBitmap.Create(10, 200, BGRABlack);
  92.     bgl2 := TBGLBitmap.Create(14, 200);
  93.     bgl2.Rectangle(1, 1, bgl2.Width - 1, bgl2.Height - 1, BGRABlack, BGRABlack, dmSet);
  94.  
  95.     DataLoaded := True;
  96.   end;
  97. end;
  98.  
  99. end.
  100.  

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: BGRAOpenGL missing functions
« Reply #11 on: December 14, 2015, 07:17:33 pm »
In the case of the clock hand, the imageCenter parameter would be something like PointF((bgl2.Width-1)/2, (bgl2.Width-1)/2)
(twice using the width)
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: BGRAOpenGL missing functions
« Reply #12 on: December 14, 2015, 08:01:52 pm »
Just works.Thanks.
The full procedure it should be like this to rotate over center :
Quote
bgl2.Texture.DrawAngle(x-((bgl2.Width-1)/2),y-((bgl2.Width-1)/2),angle,PointF((bgl2.Width-1)/2, (bgl2.Width-1)/2),True);   

 

TinyPortal © 2005-2018