Hi All,
I'm having problems with GRABSPRITE, If I draw a 3D object in the centre of the screen and use GRABSPRITE then all is OK
but if I do a for next loop 5x and rotate the object + grab 5 sprites then only the first one works.
Ive printed text across the object to prove that GRABSPRITE is working and it is
if i //grabsprite then the object turns so that OK
It grabs the whole screen but I know it works as this is how i written and a 2D unlimited sprites demo.
Any Ideas?
FOR t = 1 TO 5
X_MAKE3D 1, 50, 45
PRINT t, 400, 300
xxx = xxx + 5
//yyy = yyy + 0.5
X_CAMERA 100 / 20, 0, 0, 0, 0, 0
X_SETTEXTURE 1, 1
X_ROTATION xxx, xxx , xxx, zzz
X_DRAWOBJ 0,0
//IF xxx > 360 THEN xxx = 0
//X_SPOT_LT -1, 0, 0,0,50, 0,0,0,90
GRABSPRITE t, 0, 0, 800, 600
//SHOWSCREEN
//KEYWAIT
NEXT
KEYWAIT
t = 0
WHILE TRUE
ZOOMSPRITE t, 100, 100, 1.1, 1.1
t = t +1
IF t = 5 THEN t = 0
SHOWSCREEN
WEND
Yesterday I tried to make a screenshot in 3D mode using grabsprite, and windows work properly, but no android, just a blank screen.
Grabsprite is not very reliable.
Never Had a problem with grabsprite in 2D windows, Just started messing with 3D and doing tricks that look quite technical but again just illusions. once this bit is figured out I'll upload this part ( old school demo effect ).
If worst comes to worst then I may have to SAVEBMP Then loadsprite.
You're wrong, GRABSPRITE works fine with 3D. I could not get your code to work, so I tested it by modifying this code from here (http://www.glbasic.com/forum/index.php?topic=9773) and it works fine:
// --------------------------------- //
// Project: Picktest
// Start: Monday, April 21, 2014
// IDE Version: 12.096
// use systempointer
SYSTEMPOINTER TRUE
SETSCREEN 800,480, 0
GLOBAL array[]
REDIM array[3][3][3]
// normal Cube
CreateCube(1,1,RGB(0x00, 0xff, 0x00))
// debug cube ( RED )
CreateCube(2,1.01,RGB(0xff, 0x00, 0x00))
// fill up
FOR x = 0 TO 2
FOR y = 0 TO 2
FOR z = 0 TO 2
array[x][y][z] = 1
NEXT
NEXT
NEXT
WHILE TRUE
LOCAL mx,my,b1,b2
LOCAL wx1#,wy1#,wz1#, wx2#,wy2#,wz2# // screen2world variables
LOCAL cx%,cy%,cz% // collision-position in array
LOCAL closest_coll# = 100 // set max coll distance
LOCAL coll // collision variable
MOUSESTATE mx,my,b1,b2
// make the window 3D and set up the Cam, position of the cam doesen't matter
X_MAKE3D 1,1000,45
X_CAMERA 5,5,-5, 0.7,0,1.5
// 2 times screen2world, second is Z = 1 to set the direction !
X_SCREEN2WORLD mx,my,0, wx1, wy1, wz1
X_SCREEN2WORLD mx,my,1, wx2, wy2, wz2
FOR x = 0 TO 2
FOR y = 0 TO 2
FOR z = 0 TO 2
IF array[x][y][z]
// move cube and draw
X_MOVEMENT x, y, z
X_DRAWOBJ 1, 0
// check coll
coll = X_COLLISIONRAY(1,0, wx1,wy1,wz1, wx2,wy2,wz2) // shoot up the RAY
IF coll
IF closest_coll > coll // is closest coll larger then coll then set as closest
closest_coll = coll
// save position in array
cx = x
cy = y
cz = z
ENDIF
ENDIF
ENDIF
NEXT
NEXT
NEXT
GRABSPRITE 45, 0,0, 800,480
// draw the debugcube
IF closest_coll < 100
X_MOVEMENT cx, cy, cz
X_DRAWOBJ 2, 0
ENDIF
GRABSPRITE 46, 0,0, 800,480
// some 2D stuff
X_MAKE2D
STRETCHSPRITE 45, 0,380,160,96
STRETCHSPRITE 46, 200,380,160,96
PRINT "X: "+mx+" Y: "+my,10,10
PRINT closest_coll,10,20
GRABSPRITE 47, 0,0, 800,480
STRETCHSPRITE 47, 400,380,160,96
SHOWSCREEN
WEND
END
// ------------------------------------------------------------- //
// -=# CREATECUBE #=-
// -= by KittyHello =-
// ------------------------------------------------------------- //
FUNCTION CreateCube: num, sz, col
// Diese Variablen sind als LOCAL definiert:
// num, sz,
X_AUTONORMALS 1 // For a cube, hard edges
sz=sz/2
X_OBJSTART num
// Front Face
X_OBJADDVERTEX sz, -sz, sz, 1, 0, col
X_OBJADDVERTEX -sz, -sz, sz, 0, 0, col
X_OBJADDVERTEX sz, sz, sz, 1, 1, col
X_OBJADDVERTEX -sz, sz, sz, 0, 1, col
X_OBJNEWGROUP
// Back Face
X_OBJADDVERTEX -sz, sz, -sz, 1, 1, col
X_OBJADDVERTEX -sz, -sz, -sz, 1, 0, col
X_OBJADDVERTEX sz, sz, -sz, 0, 1, col
X_OBJADDVERTEX sz, -sz, -sz, 0, 0, col
X_OBJNEWGROUP
// Top Face
X_OBJADDVERTEX -sz, sz, sz, 0, 0, col
X_OBJADDVERTEX -sz, sz, -sz, 0, 1, col
X_OBJADDVERTEX sz, sz, sz, 1, 0, col
X_OBJADDVERTEX sz, sz, -sz, 1, 1, col
X_OBJNEWGROUP
// Bottom Face
X_OBJADDVERTEX sz, -sz, -sz, 0, 1, col
X_OBJADDVERTEX -sz, -sz, -sz, 1, 1, col
X_OBJADDVERTEX sz, -sz, sz, 0, 0, col
X_OBJADDVERTEX -sz, -sz, sz, 1, 0, col
X_OBJNEWGROUP
// Right face
X_OBJADDVERTEX sz, sz, -sz, 1, 1, col
X_OBJADDVERTEX sz, -sz, -sz, 1, 0, col
X_OBJADDVERTEX sz, sz, sz, 0, 1, col
X_OBJADDVERTEX sz, -sz, sz, 0, 0, col
X_OBJNEWGROUP
// Left Face
X_OBJADDVERTEX -sz, -sz, sz, 1, 0, col
X_OBJADDVERTEX -sz, -sz, -sz, 0, 0, col
X_OBJADDVERTEX -sz, sz, sz, 1, 1, col
X_OBJADDVERTEX -sz, sz, -sz, 0, 1, col
X_OBJNEWGROUP
X_OBJEND
ENDFUNCTION // sz
(Yes it even works with multiple MAKE3Ds and no SHOWSCREEN, but this is not in this example here).
So you must have done something wrong and should try again/ rewrite your code. BTW even if GRABSPRITE would not work you could still try CREATESCREEN (but this has some problems with 3D IIRC, to bad many work that I did on bug reports got lost at forum crash).
Cheers Kanonet for the Example.
I've tested your code and it works proving it was my code.
Ive just got my code working, and what I found was if I used GRABSPRITE in a FOR/NEXT then it didn't work
but If i used WHILE TRUE/WEND then it did, not sure why.
hopefully I'll have time to finish my program tonight
2nd for Create screen used it to replace grabsprite for one of my apps.
Instead of the fore-buffer for scratch work, I recommend preparing a large area by CREATESCREEN'n to reserve a blank memory sprite, then go ahead an drawn on that rather than GRABSPRITE'n! :good:
hmmm...I´d wish I understood it O_O