back to the programming

Linux specific forum
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

back to the programming

Post by heartbone »

About a year and a half ago I posted this sample working peer2peer networking chat snippet.
http://www.purebasic.fr/english/viewtop ... 92#p460892
Now I want to get back into it and have downloaded 5.43 LTS x64 compiler.

This code worked well a year and a half ago.
It still compiles, but now all that I get is a white screen.
If I hit the H key I get the name input window, so the program is running.
Does any Linux programmer know what has happened?

Just booted to Windows® 7 and checked in 5.42 LTS (x64), and yes it still displays just fine.
Just installed 5.43 LTS (x86) while here, and again it still runs fine.
Good old Windows®.
Back to Linux to see what's up with the goofy display.
Keep it BASIC.
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: back to the programming

Post by heartbone »

I figure that something this basic is something that has already been solved.

I'm surprised that after 50+ views, no one knows what the new problem is with the previously working software.

No big deal, and if there is no quick answer then eventually I will have to try to debug it.

Or if I remain unmotivated to track down these sort of compiler flux issues,
perhaps I'll just go back to the old compiler.
Keep it BASIC.
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: back to the programming

Post by heartbone »

OK it looks I got the display working.
I knew it was something simple.
I just needed to add a line just before the first Repeat statement.

Code: Select all

FILESAV$= "Press Ctrl+S at any time to save the current chat text display into a file."
FlipBuffers() 
Repeat
Now to get the other computer out to test the networking functions.
Keep it BASIC.
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: back to the programming

Post by heartbone »

Still looking at simple graphics problems even before I get to the networking.

To test this problem, download the 1600x1000 .jpg graphic at the next link,
http://wallpicshd.com/download.php?file ... 0x1000.jpg

and snag this 800 x 400 .png graphic.
http://www.udpac.org/wp-content/uploads ... 00x400.png

If you place the following source in the same folder that has both pictures,
and compile it, then it will run as expected in Windows®.

The program creates a 800x600 window.
and converts the 800 x 400 .png into a 800x400 sprite
The display is built when the REFRESH variable is set,
when it grabs a date based 200x200 texture selection from the big 1600x1000 wallpaper file,
and tile pastes it into the 800x600 window as its background,
The 800x400 sprite is then pasted into the top 2/3 of the window.

You can press the escape key to end the program.

Code: Select all

UsePNGImageDecoder()
UseJPEGImageDecoder()

; Load graphics data from files. 40 textures and one header.
CatchImage(100,?BITMAP1) 
For YIND= 0 To 4 : For XIND= 0 To 7 
   GrabImage(100,YIND*8+XIND+1,XIND*200,YIND*200,200,200)
Next XIND : Next YIND
FreeImage(100)
CatchImage(100,?BITMAP2) : GrabImage(100,41,0,0,800,400) : FreeImage(100)

; Initialize the graphical environment.
InitSprite()
OpenWindow(0,0,0,800,600,"PROGRAM",#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget)
OpenWindowedScreen(WindowID(0),0,0,800,600,#True,0,0) : CreateSprite(0,800,600) 
StartDrawing(ScreenOutput()) : DrawImage(ImageID(41),0,0) : StopDrawing()
;GrabSprite(1,0,0,800,400)   
; Broken GrabSprite() command replaced with the following LoadSprite() line
LoadSprite(1,"Comcast-Logo-800x400.png",#PB_Sprite_AlphaBlending)
If InitKeyboard() = 0 : MessageRequester("PROGRAM","Could Not initialize keyboard.") : End : EndIf
FlipBuffers()
REFRESH= 1 : BYEBYE= 0

; Draw the screen and wait for escape or exit.
Repeat
   RELEASE= ElapsedMilliseconds()+ 20
   Repeat 
      X= WindowEvent() : If X = #PB_Event_CloseWindow : End : EndIf   
   Until X = 0  
   If REFRESH
      StartDrawing(SpriteOutput(0))
      DrawingMode(#PB_2DDrawing_Transparent) 
; Draw date based 200x200 texture selection from wallpaper as background 
      For YIND= 0 To 2 : For XIND= 0 To 4 
         DrawImage(ImageID((DayOfYear(Date()) % 40)+ 1),XIND*200,YIND*200)     
      Next XIND : Next YIND
      StopDrawing() : DisplaySprite(0,0,0)
      DisplayTransparentSprite(1,0,0)
;      DisplaySprite(1,0,0)
      FlipBuffers() 
      REFRESH= 0
   EndIf
   ExamineKeyboard()
   If KeyboardPushed(#PB_Key_Escape) : BYEBYE+ 1 : EndIf  
   If ElapsedMilliseconds() < RELEASE
      Repeat : Delay(2) : Until ElapsedMilliseconds() > RELEASE
   EndIf
Until BYEBYE   

DataSection
BITMAP1: : IncludeBinary "2013_05_Awesome-City-Wallpaper-HD-1600x1000.jpg"
; http://wallpicshd.com/download.php?filename=2013/05/Awesome-City-Wallpaper-HD-1600x1000.jpg
BITMAP2: : IncludeBinary "Comcast-Logo-800x400.png"
; http://www.udpac.org/wp-content/uploads/2013/05/Comcast-Logo-800x400.png
EndDataSection
The problem is that the DisplaySprite(1,0,0) command produces a black box, and the
DisplayTransparentSprite(1,0,0) shows nothing (black is transparent) using the 5.43 LTS Linux x64 compiler.
It looks as if the GrabSprite() command is not working.
I've stripped the above snippet out of some code that worked well in last year's Linux compiler.

I'd considered using the alphablend drawing modes to obtain the transparency needed in the 800x400 graphics,
but those modes only work with the CanvasOutput() or ImageOutput(), :?
while this snippet uses the ScreenOutput() and SpriteOutput().

Fellow Linux programmers, if anyone has a few extra minutes and experience with basic BASIC graphics programming,
then I'm requesting an example to be posted of the least change to my extremely simple code above.
I want the minimum change necessary to make it actually work as it is supposed to, using the current 5.43 Linux compiler.
If you don't have access to a Windows® computer to see how it's supposed to run,
the colorful peacock from the Comcast graphic is superimposed over the tiled background that you do see in Linux.

{edit} Now 100% sure that the GrabSprite() command does not work in Linux, as it creates a sprite of depth 0.
Replacing the GrabSprite() with LoadSprite() gets the program to properly display in Linux.
Keep it BASIC.
Post Reply