GLBasic forum

Main forum => GLBasic - en => Topic started by: mich19 on 2006-Mar-23

Title: multiple textures
Post by: mich19 on 2006-Mar-23
how to have several textures with only one file.ddd
Title: multiple textures
Post by: Kitty Hello on 2006-Mar-23
You can't you have to split the .ddd in 2 objects and assign the textures before rendering using X_SETTEXTURE. You can write a function that renders them in one call like:

Code: (glbasic) [Select]
// Ini - file:
[obj]
count=2
ob1 = obj1.ddd
tx1 = texture1.bmp
ob2 = obj2.ddd
tx2 = texture2.bmp
/// end ini file

GLOBAL obj[]
LoadMultiObject("kungfu.ini", 1, obj[])
X_MOVEMENT 100,0,100
Render(obj[])
SHOWSCREEN
MOUSEWAIT
END


FUNCTION LoadMutiObject: ini_name$, id, obj[]
INIOPEN ini_name$
num = INIGET("obj", "count")
DIM obj[num]
FOR i=1 TO num
   X_LOADOBJ INIGET("obj", "ob"+i), i+100*id
  LOADSPRITE INIGET("obj", "tx"+i), i+100*id
  obj[i-1] = i+100*id
NEXT
ENDFUNCTION

FUNCTION Render: obj[]
FOR i=0 TO BOUNDS(obj[],0)-1
   X_SETTEXTURE obj[i], -1
   X_DRAWOBJ obj[i], 0
NEXT
ENDFUNCTION