Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - neseir

#1
GLBasic - en / screen2world
2012-Jan-17
Hi

Looking through the forum and testing different parameters to the screen2world command I ended up with this that works perfect on Windows but on iPad the Y-coord is wrong making the lines miss by a significant distance (to high). I can add the difference but why does this behave different on iPad vs Windows when the screen is in both tests set to 1024x768 (portrait) ? The aspect ratio of the height and width seems correct in both cases compared to 1024 x 768 screen).

(the test-program just draws a line from 0,0,0 to mousepointer on windows. On iPad it draws a line/polygon using the multitouch feature).

Code (glbasic) Select

// --------------------------------- //
// Project: MyTest
// Start: Saturday, January 14, 2012
// IDE Version: 10.231


SETCURRENTDIR("Media")

SYSTEMPOINTER TRUE

CLEARSCREEN

LOCAL points#[]
DIM points#[20][3]

WHILE TRUE
X_MAKE3D 1, 1000, 45
X_CAMERA 0, 0, 100, 0, 0, 0

LOCAL mouse%, mx%, my%, b1%, b2%, maxMouse%, currentMouse%
LOCAL wx#, wy#, wz#, lastX%, lastY%

maxMouse = GETMOUSECOUNT()
currentMouse = 0
FOR mouse = 0 TO  maxMouse - 1
      SETACTIVEMOUSE mouse
      MOUSESTATE mx, my, b1, b2
      IF b1
      lastX = mx
      lastY = my
      X_SCREEN2WORLD mx, my, 1, wx#, wy#, wz#
      points[currentMouse][0] = wx# / 10.0
      points[currentMouse][1] = wy# / 10.0
      points[currentMouse][2] = wz#
      INC currentMouse, 1
      ENDIF
    NEXT

LOCAL drawMouse%
IF currentMouse > 1
FOR drawMouse = 0 TO currentMouse - 2
X_LINE points[drawMouse][0], points[drawMouse][1], 0, points[drawMouse+1][0], points[drawMouse+1][1], 0, 5, RGB(255, 0, 0)
NEXT
X_LINE points[currentMouse - 1][0], points[currentMouse - 1][1], 0, points[0][0], points[0][1], 0, 5, RGB(255, 0, 0)
ELSE
X_LINE points[currentMouse - 1][0], points[currentMouse - 1][1], 0, 0,0,0, 5, RGB(0, 255, 0)
ENDIF

X_MAKE2D
PRINT "Mouse   : " + maxMouse, 10, 10
PRINT "Current : " + currentMouse, 10, 20
PRINT "Last    : " + lastX + ", " + lastY, 10, 30
LOCAL index%
FOR index = 0 TO currentMouse - 1
PRINT "Coords : " + points[index][0] + " , " + points[index][1] + ", " + points[index][2], 10, 40 + index * 10
NEXT
SHOWSCREEN
WEND

END





Regards
Eirik

#2
Hi

I'm struggling with adding new entries in an array of types. The compiler complains about the DIMPUSH statment in line 68 (marked with <=---) :

Code (glbasic) Select

// IDE Version: 10.113
// Tile
CONSTANT TS_FREE% = 0

// Brick
CONSTANT BS_NORMAL% = 0

TYPE TBrick
pX%; pY%
dX; dY
image%
status%

FUNCTION Init: aX%, aY%, aImage%
self.pX = aX
self.pY = aY
self.image = aImage
self.status = BS_NORMAL

self.dX = aX * 48
self.dY = aY * 48
ENDFUNCTION
ENDTYPE

//GLOBAL newBrick AS TBrick

TYPE TTile
pX; pY
status%

FUNCTION SetPosition : aX, aY
self.pX = aX
self.pY = aY
ENDFUNCTION

ENDTYPE

TYPE TGrid
width% ; height;
tiles[] AS TTile
bricks[] AS TBrick

FUNCTION SetSize : aWidth%, aHeight%
self.width = aWidth
self.height = aHeight
DIM self.tiles[aWidth][aHeight]
ENDFUNCTION

FUNCTION Init:
LOCAL iY%
LOCAL iX%
IF self.width > 0 AND self.height > 0
FOR iY = 0 TO self.height - 1
FOR iX = 0 TO self.width - 1
self.tiles[iX][iY].status = TS_FREE
NEXT
NEXT
ENDIF
ENDFUNCTION

FUNCTION AddBrick : aX%, aY%, aType%
IF aX < self.width AND aY < self.height
LOCAL newBrick AS TBrick
newBrick.Init(aX, aY, aType)
DIMPUSH bricks[], newBrick                             // <=-- "Wrong argument type"
ENDIF
ENDFUNCTION
ENDTYPE


#3
Hi

How can I pass vectors to uniform defined vectors in shares (like "uniform vec3 fvLightPosition") ? Passing simple float values seems ok but I would prefer to pass vectors in one statement. I think Hemlos have asked for this before but I could not find any example or information for this (if it is possible).

//Eirik
#4
Hi

I'm trying to set color (override) on an external defined object (ddd format) that I want to be displayd multiple times but with different colors. I can not see any commands in the x_ set of commands to make this work. What is the best approach to do this ?

Regards
Eirik
#5
Hi

I'm trying to run the examples provided with the 6.x edition of GLBasic but all the examples involving the Newton physics library fails to compile. Is this a known issue or are there some workarounds that are not set up by the IDE during the installation. I saw in the forum that there were some ongoing development to addapt to the Newton 2.0 edition but I could not find anything related to the current edition (I tested these examples ok in the 5.x edition of GLBasic).

Regards
Eirik