Page 1 of 2

SOS FRED multitache plein ecran naze !

Posted: Thu May 08, 2003 9:49 pm
by Marcus
PucKmAn + (Alt+Tab)= :evil: Marcus = :cry:


Bonjours Fred,

Veuillez m'excuser pour ce post en Fr je ne comprends pas l'anglais !
C'est après un mois de recherche personnelle sans succès ,que je me permets de vous adresser cette question :
Comment procéder pour utiliser le multitâche avec une application plein écran en PureBasic ?
Exemple : l'appuis simultané des touche Tab+Alt renvois mon jeu Puckman sous Windows , un retour sur celui-ci provoque la panique dans les graphisme :(
Le jeu Krakout (lien sur votre site) permet un multitâche normal sans ce problème de bug graphique !
j'ai remarqué qu'il faut que le code Pure utilise plusieurs Mo de ram graphique pour déclencher ce problème !
Merci de m'envoyer la procédure à suivre pour permettre le multitâche en plein écran , j'en ferais part à la communauté PureBasic Fr

Merci Fred,

@+
Marcus

Posted: Fri May 09, 2003 6:24 am
by Danilo
Please write english in the public international forum.
French forum is available.

Did you check with IsScreenActive() in your main loop?

Debugger must be turned OFF before you test ALT+TAB switchscreen!!

Code: Select all

;
; by Danilo, 18.04.2003
;
;- Konstanten 
#SCREEN_W       = 800 
#SCREEN_H       = 600 
#SCREEN_TITLE.s = "GraphicTest"

#BALL           = 1 

#ANZAHL         = 150 

;- Variablen 
Dim x.l(#ANZAHL) 
Dim y.l(#ANZAHL) 
Dim a.l(#ANZAHL) 
Dim b.l(#ANZAHL) 
Dim Sprite.l(#ANZAHL) 

;- Init 
If InitKeyboard()=0 Or InitSprite()=0 
  MessageRequester("ERROR","Cant initialize DirectX!",#MB_ICONERROR):End 
EndIf 

If OpenScreen(#SCREEN_W,#SCREEN_H,32,#SCREEN_TITLE) = 0 
  If OpenScreen(#SCREEN_W,#SCREEN_H,24,#SCREEN_TITLE) = 0 
    If OpenScreen(#SCREEN_W,#SCREEN_H,16,#SCREEN_TITLE) = 0 
      MessageRequester("ERROR","Cant open DirectX screen!",#MB_ICONERROR):End 
EndIf:EndIf:EndIf 

For a = 1 To 10 
  If CreateSprite(a,24,24) 
    StartDrawing(SpriteOutput(a)) 
      Circle(12,12,12,RGB(Random($FF),Random($FF),Random($FF))) 
    StopDrawing() 
  Else 
    CloseScreen() 
    MessageRequester("ERROR","Cant create Sprite!",#MB_ICONERROR):End 
  EndIf 
Next a 

For a = 1 To #ANZAHL 
  x(a) = Random(#SCREEN_W/2) : y(a) = Random(#SCREEN_H/2) 
  a(a) = Random(5)+1         : b(a) = Random(5)+1 
  Sprite(a) = Random(9)+1 
Next a 

;- Hauptschleife 
Repeat 
  FlipBuffers() 
  ExamineKeyboard() 
  If IsScreenActive() 
    ClearScreen(0,0,0) 

    For a = 1 To #ANZAHL 
      If x(a)>#SCREEN_W-24 Or x(a)<0 
        a(a)=-a(a) 
      EndIf 
      If y(a)>#SCREEN_H-24 Or y(a)<0 
        b(a)=-b(a) 
      EndIf 
      x(a)+a(a) 
      y(a)+b(a) 
      DisplayTransparentSprite(Sprite(a),x(a),y(a)) 
    Next a 

    If GetTickCount_() => zeit + 1000 
      FrameSek = Frames 
      Frames = 0 
      zeit = GetTickCount_() 
    Else 
      Frames + 1 
    EndIf      

    If StartDrawing(ScreenOutput()) 
      Locate(20,20) 
      DrawingMode(1) 
      FrontColor($FF,$FF,$00) 
      DrawText("Frames/Second: "+Str(FrameSek)) 
      StopDrawing() 
    EndIf 
  Else 
    Delay(10) 
  EndIf 
Until KeyboardPushed(#PB_Key_Escape) 
;- Ende 

Posted: Fri May 09, 2003 12:40 pm
by THCM
Hi Danilo,

nice example, but did you ever try to return to your demo? All sprites are not visible anymore, because they have to be loaded again!

Do you know about a possibility to lock the gfx in the videocard`?

Yours

Multitache plien ecran naze

Posted: Fri May 09, 2003 12:41 pm
by Marcus
:cry:

http://perso.wanadoo.fr/marcus.zone/fic ... e_naze.zip

PURE (OpenScreen()+LoadSprite(1024*768) ) + (TAB+ ALT) = :evil:

Marcus = :cry:

;
; by Danilo, 18.04.2003
;

UseJPEGImageDecoder() ;MARCUS
;- Konstanten
#SCREEN_W = 1024
#SCREEN_H = 768
#SCREEN_TITLE.s = "GraphicTest"
#BALL = 1
#ANZAHL = 150

;- Variablen
Dim x.l(#ANZAHL)
Dim y.l(#ANZAHL)
Dim a.l(#ANZAHL)
Dim b.l(#ANZAHL)
Dim Sprite.l(#ANZAHL)

;- Init
If InitKeyboard()=0 Or InitSprite()=0
MessageRequester("ERROR","Cant initialize DirectX!",#MB_ICONERROR):End
EndIf

If OpenScreen(#SCREEN_W,#SCREEN_H,32,#SCREEN_TITLE) = 0
If OpenScreen(#SCREEN_W,#SCREEN_H,24,#SCREEN_TITLE) = 0
If OpenScreen(#SCREEN_W,#SCREEN_H,16,#SCREEN_TITLE) = 0
MessageRequester("ERROR","Cant open DirectX screen!",#MB_ICONERROR):End
EndIf:EndIf:EndIf

If LoadSprite(100,"planette.jpg",0) ;MARCUS
Else ;MARCUS
End ;MARCUS
EndIf ;MARCUS

For a = 1 To 10
If CreateSprite(a,24,24)
StartDrawing(SpriteOutput(a))
Circle(12,12,12,RGB(Random($FF),Random($FF),Random($FF)))
StopDrawing()
Else
CloseScreen()
MessageRequester("ERROR","Cant create Sprite!",#MB_ICONERROR):End
EndIf
Next a

For a = 1 To #ANZAHL
x(a) = Random(#SCREEN_W/2) : y(a) = Random(#SCREEN_H/2)
a(a) = Random(5)+1 : b(a) = Random(5)+1
Sprite(a) = Random(9)+1
Next a

;- Hauptschleife
Repeat
FlipBuffers()
ExamineKeyboard()
If IsScreenActive()
DisplaySprite(100,0,0) ;MARCUS
; ClearScreen(0,0,0) ;MARCUS

For a = 1 To #ANZAHL
If x(a)>#SCREEN_W-24 Or x(a)<0
a(a)=-a(a)
EndIf
If y(a)>#SCREEN_H-24 Or y(a)<0
b(a)=-b(a)
EndIf
x(a)+a(a)
y(a)+b(a)
DisplayTransparentSprite(Sprite(a),x(a),y(a))
Next a

If GetTickCount_() => zeit + 1000
FrameSek = Frames
Frames = 0
zeit = GetTickCount_()
Else
Frames + 1
EndIf

If StartDrawing(ScreenOutput())
Locate(20,20)
DrawingMode(1)
FrontColor($FF,$FF,$00)
DrawText("Frames/Second: "+Str(FrameSek))
StopDrawing()
EndIf
Else
Delay(10)
EndIf
Until KeyboardPushed(#PB_Key_Escape)
;- Ende

Posted: Fri May 09, 2003 12:55 pm
by Danilo
THCM wrote:nice example, but did you ever try to return to your demo?
LOL... f*cker :D :lol:

Works perfectly on Win2k, 1,5GB mem, DirectX 8, GeForce3 64MB DDR...
yEs, i can switch screens many times... no problem.

The surfaces can get lost in video memory on screen switch,
so it gets restored internally and all is fine.
Fred changed this like 1 year ago... and works fine here now.

Posted: Fri May 09, 2003 2:47 pm
by THCM
Selber lol......

Doesn't work on WinXP SP1 1,0 GB mem DX 9 Ati RadeOn 9800 Pro.

No, I can't switch screens without losing your fancy bouncing balls.

So what's the f*ck!

Posted: Fri May 09, 2003 5:33 pm
by Marcus
LOL... f*cker

Works perfectly on Win2k, 1,5GB mem, DirectX 8, GeForce3 64MB DDR...
yEs, i can switch screens many times... no problem.
to test please:
http://perso.wanadoo.fr/marcus.zone/fic ... e_naze.zip

tested personellement on several PC without successes
:cry:

Posted: Fri May 09, 2003 5:36 pm
by THCM
Here it doesn't work either!

Posted: Fri May 09, 2003 5:59 pm
by Denis
Hi all,

Here it doesn't work either.
After the first switch, the circles becomes squares, there is 2 Earths, not one.
After some switchs (3 or 4), My Desktop image has changed, my image is smaller and oulined with a blue/green color.

Denis


Win98 SE, Celeron 2Ghz, 768 Mb Ram (= 768 Mo Ram in french), NVIDIA GEforce 4 MX 440.

Posted: Fri May 09, 2003 6:09 pm
by Denis
I try on the same computer with XP and it works correctly under XP.


Denis

Posted: Fri May 09, 2003 6:28 pm
by Marcus
98se,2k,Xp P4 2.8 512Mo Gf4ti128Mo
:evil:
98se,2k,Xp Xp2000+ 512Mo Gf4ti128Mo
:evil:
98se,Xp Athlon 1000 256Mo Radeon750064Mo
:evil:
98se,Xp Celeron 400 128Mo 3dfx 16Mo
:evil:
Xp P3 600 128Mo Gf1 32Mo
:evil:
---------------------ect

SOS FRED PURE NAZE !

Posted: Sat May 10, 2003 7:24 am
by Danilo
@THCM:
I was laughing because you asked if i tested it myself...
..and i always test all my stuff. :D :wink:

@Everybody:
Test the following code please, it re-creates and re-loads
the sprites. Works perfectly on all computers here... and
i think it should work everywhere (as a workaround/solution).

Code: Select all

; 
; by Danilo, 18.04.2003 
; 

;UseJPEGImageDecoder() ;MARCUS

;- Konstanten 
#SCREEN_W       = 1024 
#SCREEN_H       = 768 
#SCREEN_TITLE.s = "GraphicTest" 
#BALL           = 1 
#ANZAHL         = 150 

Structure RGBCOLORS
  R.l
  G.l
  B.l
EndStructure

;- Variablen 
Dim x.l(#ANZAHL) 
Dim y.l(#ANZAHL) 
Dim a.l(#ANZAHL) 
Dim b.l(#ANZAHL) 
Dim Sprite.l(#ANZAHL)
Dim SpriteColors.RGBCOLORS(10)

;- Init 
If InitKeyboard()=0 Or InitSprite()=0 
  MessageRequester("ERROR","Cant initialize DirectX!",#MB_ICONERROR):End 
EndIf 

If OpenScreen(#SCREEN_W,#SCREEN_H,32,#SCREEN_TITLE) = 0 
  If OpenScreen(#SCREEN_W,#SCREEN_H,24,#SCREEN_TITLE) = 0 
    If OpenScreen(#SCREEN_W,#SCREEN_H,16,#SCREEN_TITLE) = 0 
      MessageRequester("ERROR","Cant open DirectX screen!",#MB_ICONERROR):End 
EndIf:EndIf:EndIf 

Procedure InitAllSprites()
  ;If LoadSprite(100,"planette.jpg",0)=0 ;MARCUS
  ;    CloseScreen() 
  ;    MessageRequester("ERROR","Cant load sprite!",#MB_ICONERROR):End 
  ;EndIf

  For a = 1 To 10 
    If CreateSprite(a,24,24) 
      StartDrawing(SpriteOutput(a)) 
        Circle(12,12,12,RGB(SpriteColors(a)\R,SpriteColors(a)\G,SpriteColors(a)\B)) 
      StopDrawing() 
    Else 
      CloseScreen() 
      MessageRequester("ERROR","Cant create sprite!",#MB_ICONERROR):End 
    EndIf 
  Next a 
EndProcedure

For a = 1 To 10
  SpriteColors(a)\R = Random($FF)
  SpriteColors(a)\G = Random($FF)
  SpriteColors(a)\B = Random($FF)
Next a

InitAllSprites()

For a = 1 To #ANZAHL 
  x(a) = Random(#SCREEN_W/2) : y(a) = Random(#SCREEN_H/2) 
  a(a) = Random(5)+1         : b(a) = Random(5)+1 
  Sprite(a) = Random(9)+1 
Next a 

;- Hauptschleife 
Repeat 
  FlipBuffers() 
  ExamineKeyboard() 

  ; SCREEN IS ACTIVE AND READY FOR DRAWING
  If IsScreenActive() And ScreenDeActivated=#FALSE

    ;DisplaySprite(100,0,0) ;MARCUS
    ClearScreen(0,0,0)     ;MARCUS

    For a = 1 To #ANZAHL 
      If x(a)>#SCREEN_W-24 Or x(a)<0 
        a(a)=-a(a) 
      EndIf 
      If y(a)>#SCREEN_H-24 Or y(a)<0 
        b(a)=-b(a) 
      EndIf 
      x(a)+a(a) 
      y(a)+b(a) 
      DisplayTransparentSprite(Sprite(a),x(a),y(a)) 
    Next a 

    If GetTickCount_() => zeit + 1000 
      FrameSek = Frames 
      Frames = 0 
      zeit = GetTickCount_() 
    Else 
      Frames + 1 
    EndIf      

    If StartDrawing(ScreenOutput()) 
      Locate(20,20) 
      DrawingMode(1) 
      FrontColor($FF,$FF,$00) 
      DrawText("Frames/Second: "+Str(FrameSek)) 
      StopDrawing() 
    EndIf 

  ; SCREEN IS ACTIVE BUT WASNT ACTIVE BEFORE (just switched back)
  ElseIf IsScreenActive() And ScreenDeActivated=#TRUE

      Delay(20):Beep_(800,20) ; test-delay + short beep
      InitAllSprites()
      Delay(20):Beep_(800,20) ; test-delay + short beep
      ScreenDeActivated=#FALSE

  ; SCREEN IS NOT ACTIVE
  Else

      ScreenDeActivated=#TRUE
      Delay(10)

  EndIf 
Until KeyboardPushed(#PB_Key_Escape) 
;- Ende 

Posted: Sat May 10, 2003 8:22 am
by THCM
Isn't there a possibility that Fred keeps track of the gfx loaded in the videocard? Or that PureBasic locks all the gfx in the VideoCard? I don't think that all the other large games reload all textures after a taskswitch?

Yours

Posted: Sat May 10, 2003 8:58 am
by Danilo
Its too slow to load many sprites from HDD after a screen switch,
so you should load all pics into memory (could be packed)
at program start.
The switch-procedure then reloads from memory, so its much
faster...

THCM, its possible the VideoMemory gets cleared or overwritten
on a screen switch, because the VideoMem is used for the
new screen then (Desktop/Windows) and other applications.

Its officially documented in the DirectX SDK that the surfaces
can get lost in space sometimes, so the application must check it.
Thats why Fred implemented the IsScreenActive() command.

Its now up to Fred:
"Should the user do the reloading from memory like shown above,
or should PureBasic handle this internally?" - thats the question.

Posted: Sat May 10, 2003 9:42 am
by THCM
To hold all gfx in the computer memory is a solution if you have enough memory available. I don't know how Ogre handles this, perhaps we gave to load all meshes textures and other stuff too.

Yours