My code denies to appear in full screen
Blitz3D Forums/Blitz3D Beginners Area/My code denies to appear in full screen
| ||
My code denies to appear in full screen and I am not enable to discover why. I am sure I have missing something, but I do not know what is it. Can anyone tell me why this code works fine in windowed and images do not appear in full screen please? My example code: Graphics 800,600,32,1 ; <----- in mode 2 works, but not in full screen?? Global imgWide,imgHeight,PicCore Global Index, NumCartas Global Col_A, Col_B SetBuffer BackBuffer() NumCartas=3 ;PicCore=LoadAnimImage("core24X3b.bmp",128,128,0,NumCartas+1) imgWide=128 imgHeight=128 PicCore=CreateImage(imgWide*NumCartas+128,imgHeight,NumCartas+1) : SetBuffer BackBuffer() x=0 :y =0 For n=1 To 4 For a=1 To 150 r=Rand(0,255) :g=Rand(0,255) :b=Rand(0,255) For b=1 To 150 r=Rand(0,255) :g=Rand(0,255) :b=Rand(0,255) Color r,g,b Plot Rand(x+1,x+127),Rand(1,127) Next Next x=x+128 Next x=0 :y =0 For n=0 To NumCartas GrabImage PicCore,x,y,Index Index=Index+1 x=x+128 Next MaskImage PicCore,255,0,255 Dim PixCore(imgWide,imgHeight,NumCartas) MoveMouse 520,640 x=1: y=1 For Index=0 To NumCartas DrawImage PicCore,x,y,Index x=x+128 Next Flip LockBuffer BackBuffer() ; Use ReadPixel to get all the color information of the screen xst=0 :yst=0 For Index=0 To NumCartas For x=0 To imgHeight For y=0 To imgWide PixCore(x,y,Index)=ReadPixel(x+xst,y+yst) Next Next xst=xst+128 Next UnlockBuffer BackBuffer() Cls Index=0 SeedRnd MilliSecs() While Not KeyDown(1) x=1:y=1 For j=0 To NumCartas CambiaPinxels(x,y,j) x = x + 128 Next Flip ; < --- image not appera in mode 1 orfull screen why? Wend End Function CambiaPinxels(Xcore,Ycore,Index) ;****************************** hacer que los pinxels avancen sus posiciones hacie el exterior Color 255,255,255 num=0 For y=1 To imgHeight-1 For x=1 To imgWide-1 ytemp=y xtemp=x Col_A=PixCore(xtemp,ytemp,Index) xz=Rand(-1,1) :yz=Rand(-1,1) Col_B=PixCore(xtemp+xz,ytemp+yz,Index) hecho=False If Col_A = -16777216 And Col_B <> -16777216 Then If y=2 And yz=-1 Then r1=imgHeight-3 ;place color near origen PixCore(x,y,Index)=Col_A ; black color PixCore(xtemp+xz,ytemp+yz,Index)=Col_A ; color is not black ytemp=imgHeight-2 .up1 If r1>3 Then r1=r1-1 If PixCore(xtemp,ytemp,Index)=Col_A Then ;if a black pinxel PixCore(xtemp,ytemp,Index)=Col_B ; el color no negro Else ytemp=Rand(3,r1) ; if a color pinxlel... random again Goto up1 EndIf hecho =True Goto we EndIf If y=imgHeight-2 And yz=1 Then r2=3 ;place color near origen PixCore(x,y,Index)=Col_A ; black color PixCore(xtemp+xz,ytemp+yz,Index)=Col_A ; color is not black ytemp=2 .up2 If r2<imgHeight-3 Then r2=r2+1 If PixCore(xtemp,ytemp,Index)=Col_A Then ;if a black pinxel PixCore(xtemp,ytemp,Index)=Col_B ; el color no negro Else ytemp=Rand(3,r2) ; if a color pinxlel... random again Goto up2 EndIf hecho =True Goto we EndIf If x=2 And xz=-1 Then r3=imgWide-3 ;place color near origen PixCore(x,y,Index)=Col_A ; black color PixCore(xtemp+xz,ytemp+yz,Index)=Col_A ; el color no-negro xtemp=imgWide-2 .up3 If r3>3 Then r3=r3-1 If PixCore(xtemp,ytemp,Index)=Col_A Then ;if a black pinxel PixCore(xtemp,ytemp,Index)=Col_B ; el color no negro Else xtemp=Rand(3,r3) ; if a color pinxlel... random again Goto up3 EndIf hecho =True Goto we EndIf If x=imgWide-2 And xz=1 Then r4=3 ;place color near origen PixCore(x,y,Index)=Col_A ; black color PixCore(xtemp+xz,ytemp+yz,Index)=Col_A ; color is not black xtemp=2 .up4 If r4<imgWide-3 Then r4=r4+1 If PixCore(xtemp,ytemp,Index)=Col_A Then ;if a black pinxel PixCore(xtemp,ytemp,Index)=Col_B ; el color no negro Else xtemp=Rand(3,r4) ; if a color pinxlel... random again Goto up4 EndIf hecho =True Goto we EndIf If hecho = False Then PixCore(xtemp+xz,ytemp+yz,Index)=Col_A PixCore(xtemp,ytemp,Index)=Col_B EndIf .we EndIf Next Next ; Use WritePixel to redraw the screen LockBuffer BackBuffer() For y=0 To imgHeight For x=0 To imgWide WritePixelFast x+Xcore,y+Ycore,PixCore(x,y,Index) Next Next UnlockBuffer BackBuffer() GrabImage PicCore,0+Xcore,0+Ycore,Index End Function Last edited 2011 Last edited 2011 |
| ||
It is unlikely that your screen resolution is set to 16bit or 8bit but usually this fixes this known problem. Here is a list of things to check for: 1. Resolution is set above 1024x768 2. You have applied updates to the screen 3. If you had Graphics3D you might could UpdateWorld 4. It could be the version of blitz that you are running Ex: V1.106 as I have found many bugs in this version. 5. You must have the most recent DirectX 9.0c Installed to run smoothly If you have these all correct then all I can suggest is to rewrite the code and try to Include a code file instead of typing it all in one source. |
| ||
Alright... I'm... Well, I'm not quite sure what Captain Wicker was on about. However, if you add this code to line 88 and 89, just inside your main loop:ClsColor Rand(255),Rand(255),Rand(255) Cls Now, if you run your program again in mode 1, you can see that the image is there, and it's being drawn, but its contents are all erased, making it completely black. I don't have time right now to go through the complete CambiaPixels() function, but I would say that your problem is probably somewhere in there, in the logic. |
| ||
In this part of your code...Flip LockBuffer BackBuffer() ; Use ReadPixel to get all the color information of the screen xst=0 :yst=0 For Index=0 To NumCartas For x=0 To imgHeight For y=0 To imgWide PixCore(x,y,Index)=ReadPixel(x+xst,y+yst) Next Next xst=xst+128 Next UnlockBuffer BackBuffer() ...Readpixel is reading from the active drawing buffer, i.e. the back buffer. So you just need to move Flip to after UnlockBuffer BackBuffer(). |
| ||
@Captain Wicker Screen Resolution is correct This code do not use grapics 3D, it is only 2D Direct X version is correct I think It is a problem of bad written code mine I think. Thank you @Adam Novagen Yes, this two comands you give me helps to see that you are right, my code runs, but bad still. Thank you @Floyd place flip commad into Function would not work for me purpose because I need all draws or frames was draw at same time each screen update. Thank you But experimenting with your all ideas, Finally I realize were was this bug even I don't understand why bugs "works" so, hehe I change SetBuffer BackBuffer() from line 10 and place it in line 61 after a flip and now works!! I place code again for you can see SetBuffer BackBuffer() has changed and now it woks. I appreciate you all help an inspiration believe me!! Corrected code (I hope): Graphics 800,600,32,1 Global imgWide,imgHeight,PicCore Global Index, NumCartas Global Col_A, Col_B ; SetBuffer BackBuffer() <---------------------------- Here was de damned problem!!!!!!!!! seems to be a bad site for placing BackBuffer() NumCartas=3 ;PicCore=LoadAnimImage("core24X3b.bmp",128,128,0,NumCartas+1) imgWide=128 imgHeight=128 PicCore=CreateImage(imgWide*NumCartas+128,imgHeight,NumCartas+1) x=0 :y =0 For n=1 To 4 For a=1 To 150 r=Rand(0,255) :g=Rand(0,255) :b=Rand(0,255) For b=1 To 150 r=Rand(0,255) :g=Rand(0,255) :b=Rand(0,255) Color r,g,b Plot Rand(x+1,x+127),Rand(1,127) Next Next x=x+128 Next x=0 :y =0 For n=0 To NumCartas GrabImage PicCore,x,y,Index Index=Index+1 x=x+128 Next MaskImage PicCore,255,0,255 Dim PixCore(imgWide,imgHeight,NumCartas) MoveMouse 520,640 x=1: y=1 For Index=0 To NumCartas DrawImage PicCore,x,y,Index x=x+128 Next Flip SetBuffer BackBuffer() ; <------------------ I resolved finaly placing SetBuffer BackBuffer() here!!! LockBuffer BackBuffer() ; Use ReadPixel to get all the color information of the screen xst=0 :yst=0 For Index=0 To NumCartas For x=0 To imgHeight For y=0 To imgWide PixCore(x,y,Index)=ReadPixel(x+xst,y+yst) Next Next xst=xst+128 Next UnlockBuffer BackBuffer() Cls Index=0 SeedRnd MilliSecs() ClsColor Rand(255),Rand(255),Rand(255) While Not KeyDown(1) Cls x=1:y=1 For j=0 To NumCartas CambiaPinxels(x,y,j) x = x + 128 Next Flip ; < --- image not appera in mode 1 orfull screen why? Wend End Function CambiaPinxels(Xcore,Ycore,Index) ;****************************** hacer que los pinxels avancen sus posiciones hacie el exterior Color 255,255,255 num=0 For y=1 To imgHeight-1 For x=1 To imgWide-1 ytemp=y xtemp=x Col_A=PixCore(xtemp,ytemp,Index) xz=Rand(-1,1) :yz=Rand(-1,1) Col_B=PixCore(xtemp+xz,ytemp+yz,Index) hecho=False If Col_A = -16777216 And Col_B <> -16777216 Then If y=2 And yz=-1 Then r1=imgHeight-3 ;place color near origen PixCore(x,y,Index)=Col_A ; black color PixCore(xtemp+xz,ytemp+yz,Index)=Col_A ; color is not black ytemp=imgHeight-2 .up1 If r1>3 Then r1=r1-1 If PixCore(xtemp,ytemp,Index)=Col_A Then ;if a black pinxel PixCore(xtemp,ytemp,Index)=Col_B ; el color no negro Else ytemp=Rand(3,r1) ; if a color pinxlel... random again Goto up1 EndIf hecho =True Goto we EndIf If y=imgHeight-2 And yz=1 Then r2=3 ;place color near origen PixCore(x,y,Index)=Col_A ; black color PixCore(xtemp+xz,ytemp+yz,Index)=Col_A ; color is not black ytemp=2 .up2 If r2<imgHeight-3 Then r2=r2+1 If PixCore(xtemp,ytemp,Index)=Col_A Then ;if a black pinxel PixCore(xtemp,ytemp,Index)=Col_B ; el color no negro Else ytemp=Rand(3,r2) ; if a color pinxlel... random again Goto up2 EndIf hecho =True Goto we EndIf If x=2 And xz=-1 Then r3=imgWide-3 ;place color near origen PixCore(x,y,Index)=Col_A ; black color PixCore(xtemp+xz,ytemp+yz,Index)=Col_A ; el color no-negro xtemp=imgWide-2 .up3 If r3>3 Then r3=r3-1 If PixCore(xtemp,ytemp,Index)=Col_A Then ;if a black pinxel PixCore(xtemp,ytemp,Index)=Col_B ; el color no negro Else xtemp=Rand(3,r3) ; if a color pinxlel... random again Goto up3 EndIf hecho =True Goto we EndIf If x=imgWide-2 And xz=1 Then r4=3 ;place color near origen PixCore(x,y,Index)=Col_A ; black color PixCore(xtemp+xz,ytemp+yz,Index)=Col_A ; color is not black xtemp=2 .up4 If r4<imgWide-3 Then r4=r4+1 If PixCore(xtemp,ytemp,Index)=Col_A Then ;if a black pinxel PixCore(xtemp,ytemp,Index)=Col_B ; el color no negro Else xtemp=Rand(3,r4) ; if a color pinxlel... random again Goto up4 EndIf hecho =True Goto we EndIf If hecho = False Then PixCore(xtemp+xz,ytemp+yz,Index)=Col_A PixCore(xtemp,ytemp,Index)=Col_B EndIf .we EndIf Next Next ; Use WritePixel to redraw the screen LockBuffer BackBuffer() For y=0 To imgHeight For x=0 To imgWide WritePixelFast x+Xcore,y+Ycore,PixCore(x,y,Index) ,BackBuffer() Next Next UnlockBuffer BackBuffer() GrabImage PicCore,0+Xcore,0+Ycore,Index End Function Last edited 2011 |