Recent

Poll

Vote: What's the best project of this year?

"ball" by raw
1 (3.7%)
"bgragraphics" by j-g (pocket watch)
2 (7.4%)
"duplo6" by bylaardt
7 (25.9%)
"glslideshow" by handoko
2 (7.4%)
"mariocronch" by ericktux
0 (0%)
"movingdots" by lainz
1 (3.7%)
"movingdotsgl" by lainz
0 (0%)
"relogio" by bylaardt
5 (18.5%)
"starsfieldshooter" by turrican
0 (0%)
"steampunkclock" by bylaardt
1 (3.7%)
"sudoku" by user137
5 (18.5%)
"furiouspaladin" by handoko
3 (11.1%)
"educrace" by lulu
0 (0%)

Total Members Voted: 26

Author Topic: Graphics Contest 2017, please vote now!  (Read 201086 times)

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Graphics Contest 2017, please vote now!
« Reply #225 on: August 03, 2017, 05:16:21 pm »
@J-G, when you launch Educ'Race, please go to the second screen where you hear the music and could you say me what is the Frame per seconds please ? you could see this information at the top left windows game
That is undoubtedly the 'issue' - - - even as a non-gamer I can appreciate that 1 to 7 FPS is hardly going to provide a good experience :)

I did once see 11fps but over three runs of the music the general figure is between 3 & 5. The music is played at what I would consider 'normal' speed.
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

Lulu

  • Full Member
  • ***
  • Posts: 230
Re: Graphics Contest 2017, please vote now!
« Reply #226 on: August 03, 2017, 05:42:26 pm »
Thanks J-G for your informations, but I have no idea and no solution for this...
This is the first time I publish a program here, I have no experience in cross platform programming.
Even with the same OS, hardware can cause issue...  %)
The people who wrote lazarus and freepascal are amazing !
wishing you a nice life

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Graphics Contest 2017, please vote now!
« Reply #227 on: August 03, 2017, 06:09:21 pm »
Did the white image issue happen on certain images only or all images? Can you provide me the 'problem' image? Did you test it on Win7 64-bit? I will tried to get a Win7 64-bit machine to test.
Yes it was all images. Yes I have found an image which ALWAYS causes an error at line 108 of your latest BGRAtoRGBA Procedure :
Code: Pascal  [Select][+][-]
  1. Temp := Data^.rgbBlue;
and would be happy to send it to you......   I've looked at attaching it to an e-mail but can't see a means of doing that via the forum facility. Therefore I've put it on my web-site :
www.crescentcomputing.co.uk/handoko
Nothing special - a .TIF file of 797k but too large to 'attach' here.

Quote from: Handoko
For your information, the program needs OpenGL to run properly. I guess the hardware should at least supports OpenGL 1.2. It used only the very basic OpenGL functions, I believe I didn't use any functions of version 1.5 nor above.

My graphics card is an NVIDIA GeForce 9500 GT with 1Gb GDDR2 and the spec. tells me that it supports Open GL 2.1.

I presume that I don't need to 'install' Open GL explicitly, I would anticipate that would be have been done when I installed the video drivers for the card - but since I have never needed to 'use' Open GL what would I know? ;D
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: Graphics Contest 2017, please vote now!
« Reply #228 on: August 03, 2017, 06:50:38 pm »
My graphics card is an NVIDIA GeForce 9500 GT with 1Gb GDDR2 and the spec. tells me that it supports Open GL 2.1.

I presume that I don't need to 'install' Open GL explicitly, I would anticipate that would be have been done when I installed the video drivers for the card - but since I have never needed to 'use' Open GL what would I know? ;D

Usually with NVIDIA graphics cards, the Windows driver provided by Windows, or Windows Update doesn't come with latest OpenGL support. I always used to install the NVIDIA drivers from his website.

I had that problem years ago, with my NVIDIA graphics card, exactly the same: with lazarus opengl applications not working, now I use the Intel HD Graphics that comes with the processor.

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus
Re: Graphics Contest 2017, please vote now!
« Reply #229 on: August 03, 2017, 08:31:32 pm »
I have fixed 2 issues. Sorry I had not tested it properly. :-[
- Order error no #4 and #5
- Now support 24-bit TIFF format

However, if I load 5 images, sequence is
N°1, N°2, N°3, N°5   N°4 is skipped
at this point, if I reload another image on N°4, sequence become
N°1, N°2, N°3, N°4  , now N°5 is skipped

Fixed, just a typing mistake.

Yes I have found an image which ALWAYS causes an error at line 108 of your latest BGRAtoRGBA Procedure :
Code: Pascal  [Select][+][-]
  1. Temp := Data^.rgbBlue;

That happens because that image is 24-bit TIFF format. Now I added support for it by manually convert it to 32-bit before calling BGRAtoRGBA:

Code: Pascal  [Select][+][-]
  1.   // Convert 24-bit TIFF image to 32-bit
  2.   S := UpperCase(ExtractFileExt(OpenPictureDialog1.FileName));
  3.   if ((S = '.TIFF') or (S = '.TIF')) and (SlideImages[Index].PixelFormat = pf24bit) then
  4.     begin
  5.       TmpBitmap := TBitmap.Create;
  6.       TmpBitmap.PixelFormat := pf32bit;
  7.       TmpBitmap.Width := SlideImages[Index].Width;
  8.       TmpBitmap.Height := SlideImages[Index].Height;
  9.       Data32bit := Pointer(TmpBitmap.RawImage.Data);
  10.       Data24bit := Pointer(SlideImages[Index].RawImage.Data);
  11.       for y := 0 to (TmpBitmap.Height-1) do
  12.       begin
  13.         Data32bit := TmpBitmap.ScanLine[y];
  14.         Data24bit := SlideImages[Index].ScanLine[y];
  15.         for x := 1 to TmpBitmap.Width do
  16.         begin
  17.           Data32bit^.rgbRed   := Data24bit^.rgbtRed;
  18.           Data32bit^.rgbGreen := Data24bit^.rgbtGreen;
  19.           Data32bit^.rgbBlue  := Data24bit^.rgbtBlue;
  20.           Inc(Data24bit);
  21.           Inc(Data32bit);
  22.         end;
  23.       end;
  24.       SlideImages[Index].Assign(TmpBitmap);
  25.       TmpBitmap.Free;
  26.     end;

circular

  • Hero Member
  • *****
  • Posts: 4221
    • Personal webpage
Re: Graphics Contest 2017, please vote now!
« Reply #230 on: August 03, 2017, 09:03:33 pm »
Hi everyone.

I had no time for anything. So anyway I will vote for the Sudoku. I find it very classy.

If it can help, here is a sudoku program I made that gives hints (or try to solve it) using human-like methods. This could be added to provide hints in the sudoko program already submitted.

Regards
Conscience is the debugger of the mind

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Graphics Contest 2017, please vote now!
« Reply #231 on: August 04, 2017, 12:13:45 pm »
Sorry, handoko, I've found another 'exception' that causes a SIGSEGV error but this time at line 109.

What I am pleased about is that I think I can tell you exactly what the problem is - - - the .TIF image is ......... MONOCHROME ............   ie. 8-bit       and I don't see any reference in your code to 8-bit images.

I'm assuming that you (or Open GL) interpret CMYK images as 32-bit and RGB images as 24-bit   ie. 8 bits per 'colour'.

I could be completely wrong here but it is an interesting exercise - and exactly what this 'contest' is about.

FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus
Re: Graphics Contest 2017, please vote now!
« Reply #232 on: August 04, 2017, 12:45:03 pm »
Please send me the image, so I can inspect and test.

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Graphics Contest 2017, please vote now!
« Reply #233 on: August 04, 2017, 01:08:57 pm »
If it can help, here is a sudoku program I made that gives hints (or try to solve it) using human-like methods. This could be added to provide hints in the sudoko program already submitted.
Thanks, but it was just a matter of finding time  ;)  The TSudoku class has a results-array that is generated also. Application could as a hint show any one of those numbers that isn't already filled in place. But there is also 1 flaw in generation algorithm, that it doesn't verify yet if there only is only 1 solution when numbers are removed from original. So i left fill ratio to just 0.5 which makes so easy sudoku's i can always solve them myself. In difficulty ratio in general sudoku magazines from 1 to 5 stars (5 hardest), i would class these about 2 or 3.

circular

  • Hero Member
  • *****
  • Posts: 4221
    • Personal webpage
Re: Graphics Contest 2017, please vote now!
« Reply #234 on: August 04, 2017, 02:04:10 pm »
@User137 do as you wish. I will just mention that with my algorithm, you get only suggestions that have only one possibility and gives a hint on the method to use : either it is constraint on a square, on a column or on a cell.
Conscience is the debugger of the mind

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Graphics Contest 2017, please vote now!
« Reply #235 on: August 04, 2017, 06:52:16 pm »
Please send me the image, so I can inspect and test.
Sorry for the delay - I had a customer to visit.

The mono file is 'Snowflake BW.png' and is now on my web-site.
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus
Re: Graphics Contest 2017, please vote now!
« Reply #236 on: August 05, 2017, 11:33:29 am »
Please send me the image, so I can inspect and test.
Sorry for the delay - I had a customer to visit.

The mono file is 'Snowflake BW.png' and is now on my web-site.

There is something I cannot explain. Try this code on your 'snowflake BW.png':

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   Image1.Picture.LoadFromFile('snowflake BW.png');
  4. end;

I tested the code above using Lazarus 1.6.4 Gtk2 on Linux 64-bit. It quit immediately without showing any error. I tried to use GIMP to re-save the image (File > Overwrite snowflake BW.png) without modifying anything. The re-saved file can be open using the code above.

Original size of 'snowflake BW.png' : 33396 bytes
Re-saved size of 'snowflake BW.png' : 40228 bytes

My guess is maybe that mono png file format is not supported by TPicture or maybe that file is using non-standard format. Or maybe there is a bug on Linux Gt2 only? Can anyone test it on other OSes?

So, because the original 'snowflake BW.png' cannot be opened using TImage.Picture.LoadFromFile, nothing I can do now.
« Last Edit: August 05, 2017, 11:40:08 am by Handoko »

Lulu

  • Full Member
  • ***
  • Posts: 230
Re: Graphics Contest 2017, please vote now!
« Reply #237 on: August 05, 2017, 12:52:51 pm »
@Handoko
I tested a simple project with  TImage.Picture.LoadFromFile('snowflake BW.png')

It work fine on my computer, the image of the flake appears on the screen.

Windows 10, Lazarus 1.6.4
wishing you a nice life

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Graphics Contest 2017, please vote now!
« Reply #238 on: August 05, 2017, 04:47:15 pm »
There is something I cannot explain. Try this code on your 'snowflake BW.png':

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   Image1.Picture.LoadFromFile('snowflake BW.png');
  4. end;

I tested the code above using Lazarus 1.6.4 Gtk2 on Linux 64-bit. It quit immediately without showing any error. I tried to use GIMP to re-save the image (File > Overwrite snowflake BW.png) without modifying anything. The re-saved file can be open using the code above.

Original size of 'snowflake BW.png' : 33396 bytes
Re-saved size of 'snowflake BW.png' : 40228 bytes
The ORIGINAL file was 40228 bytes   -  Curiouser and curiouser !!  -  unless you have accidentally transposed the two figures.

It opens in Photoshop/CorelDRAW! without problem and of course displays in the preview pane of Windows Explorer.

Quote from: Handoko
My guess is maybe that mono png file format is not supported by TPicture or maybe that file is using non-standard format. Or maybe there is a bug on Linux Gt2 only? Can anyone test it on other OSes?

So, because the original 'snowflake BW.png' cannot be opened using TImage.Picture.LoadFromFile, nothing I can do now.
I tried inserting that line of code at the start of your TForm1.BackgroundClick Procedure with the intention of 'stepping through'  - -  having declared   Image1 : TImage   locally. As soon as it tries to execute that line it throws a SIGSEGV error pointing to Line 770 in picture.inc.

I've done nothing with the image regarding the format, it's a straight Mode change in Photoshop, removing the colour information and then converting the 'Grey Scale' to 'Bitmap' - but it was saved with 'Interleave' on. I've now re-saved with  interleaving = none  and the size is 30245 bytes  -  so that is a difference  -  the new file is on my web-site if you want to test that, though it threw the same error.

FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

Akira1364

  • Hero Member
  • *****
  • Posts: 561
Re: Graphics Contest 2017, please vote now!
« Reply #239 on: August 05, 2017, 05:27:48 pm »
One recommendation I might make for Handoko's Slideshow project that would immediately solve all image-format issues is to simply use BGRABitmap! The TBGRABitmap class is capable of loading pretty much any image file type that you'd ever want to, and it exposes a "Data" property that can be used to load it into OpenGL. Here's a modified version of the texture creation routine I've been using in DeleD, that loads an image (of any format supported by BGRABitmap) from file and returns an OpenGL handle that you can then bind with glBindTexture.

Code: Pascal  [Select][+][-]
  1. function CreateOpenGLTexture(FileName: String; WrapMode: Cardinal = GL_REPEAT; MinLODBias: Single = 0;
  2.   MaxLODBias: Single = 0; AnisotropyLevel: Single = 0): Cardinal;
  3. var
  4.   TextureHandle: Cardinal;
  5.   TempBitmap: TBGRABitmap;
  6. begin
  7.   TempBitmap := TBGRABitmap.Create(FileName);
  8.   glGenTextures(1, @TextureHandle);
  9.   glBindTexture(GL_TEXTURE_2D, TextureHandle);
  10.   glTexParameterI(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, WrapMode);
  11.   glTexParameterI(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, WrapMode);
  12.   glTexParameterF(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, MinLODBias);
  13.   glTexParameterF(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, MaxLODBias);
  14.   glTexParameterI(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
  15.   glTexParameterI(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  16.   if AnisotropyLevel <> 0 then
  17.     glTexParameterF(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, AnisotropyLevel);
  18.   glTexParameterI(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
  19.   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, TempBitmap.Width, TempBitmap.Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, TempBitmap.Data);
  20.   glBindTexture(GL_TEXTURE_2D, 0);
  21.   TempBitmap.Free;
  22.   Result := TextureHandle;
  23. end;
« Last Edit: August 06, 2017, 12:22:54 am by Akira1364 »

 

TinyPortal © 2005-2018