Recent

Author Topic: C-Evo game port to FreePascal/Lazarus...  (Read 27600 times)

Wodzu

  • Full Member
  • ***
  • Posts: 171
Re: C-Evo game port to FreePascal/Lazarus underway! =)
« Reply #15 on: November 28, 2009, 07:57:37 pm »
"Since ScanLines property has been temporary removed from TBitmap class" (my emphasis)

Scratch the temporary, it is permanent.

If you know the inner working of a scanline, then you would understand it never will work for a (display) client-server solution like X or for carbon. Both have no notion that a piece of "graphics" memory is changed.



I have no idea what is X or carbon... Why this is connected to the TBitmap? TBitmap should be represented in RAM memory and I should easly obtain a pointer to a given row of this memory and be able to mydify it.

That is how it works under Windows, right?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: C-Evo game port to FreePascal/Lazarus underway! =)
« Reply #16 on: November 29, 2009, 06:57:27 am »
Quote
I have no idea what is X or carbon...
Each OS has its own mechanism to handle graphics (i.e. GUI subsystem). Windows has WinAPI, Linux uses X, Mac uses Carbon (or Cocoa in OS X). The architecture of these systems are different. WinAPI uses message passing, X uses client-server, don't really know about Carbon (I don't have Mac).
Quote
Why this is connected to the TBitmap?
Because TBitmap is part of LCL and LCL is made for cross-platform use, therefore it MUST works on all supported platforms.
Quote
That is how it works under Windows, right?
Yes. But as Marc states, X and Carbon have no notion that a piece of "graphics" memory is changed. Perhaps due to the client-server architecture. I believe Marc can explain it better.

Core

  • Newbie
  • Posts: 6
Re: C-Evo game port to FreePascal/Lazarus underway! =)
« Reply #17 on: September 22, 2014, 07:59:40 am »
I'm wondering if the missing ScanLines property from TBitmap class issue has changed in any way since we last discussed this?

Update: I found this info, still looking for solutions to get this great game fully converted.
http://forum.lazarus.freepascal.org/index.php/topic,19807.msg113286/topicseen.html#msg113286

I have attached the latest game sources if someone is willing to see how far they could get this to fully compile using Lazarus/FPC.  =)
« Last Edit: September 22, 2014, 06:22:48 pm by Core »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: C-Evo game port to FreePascal/Lazarus...
« Reply #18 on: September 22, 2014, 09:28:24 am »
I have no idea what was available back then but today the situation is surmised nicely in the page http://wiki.freepascal.org/Fast_direct_pixel_access although there is no scanline property you can see that there is a scanline like access.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: C-Evo game port to FreePascal/Lazarus...
« Reply #19 on: September 22, 2014, 10:02:21 am »
There is a Scanline property on TBitmap.

Simple test:
Code: [Select]
procedure TForm1.FormPaint(Sender: TObject);
type
  TPixelInfo = packed record
    r, g, b: byte;
  end;
var
  b: TBitmap;
  i, j: integer;
  p: ^TPixelInfo;
begin
  b:=TBitmap.Create;
  b.PixelFormat:=pf24bit;
  b.SetSize(ClientWidth, ClientHeight);
  for j:=0 to ClientHeight-1 do begin
    p:=b.ScanLine[j];
    for i:=0 to ClientWidth-1 do begin
      p[i].r:=i;
      p[i].g:=j;
      p[i].b:=255;
    end;
  end;
  canvas.Draw(0, 0, b);
  b.Free;
end;
It should make repeated 4 color gradient of red, magenta, yellow and white.

And no, it's not good practise to initialize TBitmap inside onPaint. I just tried how it works, and it's incredibly fast for me at least.

Also i know that i made the record wrong, it should've been b, g, r: byte, because bmp is awkward format...
« Last Edit: September 22, 2014, 10:15:21 am by User137 »

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: C-Evo game port to FreePascal/Lazarus...
« Reply #20 on: September 22, 2014, 10:52:52 am »
And (as written) your form can't be bigger than 256x256 pixels, or you'll try to access illegal array indices.
But it's nice - thanks for pointing this out.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: C-Evo game port to FreePascal/Lazarus...
« Reply #21 on: September 22, 2014, 11:29:52 am »
Hmmm... so should this section be updated
http://wiki.lazarus.freepascal.org/Developing_with_Graphics#Direct_pixel_access
then?

(Warning: graphics noob despite dabbling with tiffs)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Core

  • Newbie
  • Posts: 6
Re: C-Evo game port to FreePascal/Lazarus...
« Reply #22 on: January 18, 2017, 09:38:43 am »
We now have the first successful ports of C-evo in FP/Lazarus!!  Author: Chronos http://forum.lazarus.freepascal.org/index.php?action=profile;u=39106

http://c-evo.org/bb/viewtopic.php?f=4&t=174
« Last Edit: January 18, 2017, 11:06:05 am by Core »

 

TinyPortal © 2005-2018