Author Topic: Graphic bug I can't understand!  (Read 206 times)

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *****
  • Posts: 3772
  • O Rly?
    • View Profile
Re: Graphic bug I can't understand!
« Reply #15 on: July 29, 2010, 01:16:09 pm »
GLOBAL b = 3 WORKS, Ocean ! You can do that....


NEVER call functions with GLOBAL:

GLOBAL b = foo() //<----- BAM, doesen't work!

I <3 DGArray's :D

PC:
AMD Phenom II x4 @ 3.6ghz, 4gb Ram, GTX 260 1GB, Windows 7 64Bit

Laptop:
AMD Athlon 64 X2 Dual QL62, 17" WXGA+, 4gb Ram, ATI Mobile Radeon HD 3200 512MB, 250gb HD, Windows Vista 32Bit

Offline Ocean

  • Prof. Inline
  • *****
  • Posts: 945
  • I'd rather be flying...
    • View Profile
    • Forex Trading Ideas
Re: Graphic bug I can't understand!
« Reply #16 on: July 29, 2010, 01:45:20 pm »
GLOBAL b = 3 WORKS, Ocean ! You can do that....


NEVER call functions with GLOBAL:

GLOBAL b = foo() //<----- BAM, doesen't work!

it would be nice if GLB supports that nowadays...   I have stopped using that idiom altogether - it's a trap I fell in once too often...

Offline Moru

  • HelpEditors
  • Prof. Inline
  • ****
  • Posts: 1075
    • View Profile
    • GameCorner
Re: Graphic bug I can't understand!
« Reply #17 on: July 29, 2010, 01:58:29 pm »
It has been working now for a while again so I started using it.
My silly homepage: Gamecorner

Online MrTAToad

  • HelpEditors
  • Prof. Inline
  • ****
  • Posts: 1849
  • Its me!
    • View Profile
    • The Un-Map Website
Re: Graphic bug I can't understand!
« Reply #18 on: July 29, 2010, 02:10:18 pm »
Quote
don't do that in GLB (assigning a value when initialising/defining variables) as this is only guaranteed to work when used in conjunction with the RGB() function...
Constants should be used for things like that...
« Last Edit: July 29, 2010, 02:12:41 pm by MrTAToad »
GLBasic Command List : Command List Visit My Website Twitter : FishyMcFlipFlop YouTube : My Channel

Offline Kitty Hello

  • Useless Servant
  • Administrator
  • Prof. Inline
  • *****
  • Posts: 6768
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Graphic bug I can't understand!
« Reply #19 on: July 29, 2010, 02:24:05 pm »
You can assign GLOBAL a = foo(), but you are not able to use strings or any of the GLBasic commands inside. The problem is, that this foo() is called in the constructor _before_ the GLBasic engine is set up, whereas
GLOBAL g
g=foo() // this assignement is done during runtime.
DELL Precision M6300: Core 2 Duo 2.20GHz, 2GB ram, NVIDIA Quadro FX 1600M, Vista Business
GLBasic SDK premium, Version: next update (beta)

Online MrTAToad

  • HelpEditors
  • Prof. Inline
  • ****
  • Posts: 1849
  • Its me!
    • View Profile
    • The Un-Map Website
Re: Graphic bug I can't understand!
« Reply #20 on: July 29, 2010, 02:45:33 pm »
You can assign GLOBAL a = foo(), but you are not able to use strings or any of the GLBasic commands inside. The problem is, that this foo() is called in the constructor _before_ the GLBasic engine is set up, whereas
GLOBAL g
g=foo() // this assignement is done during runtime.
I tried that, but the program didn't actually run :)

Code: [Select]
GLOBAL a%=foo()

DEBUG a%
END

FUNCTION foo%:
RETURN 12
ENDFUNCTION
GLBasic Command List : Command List Visit My Website Twitter : FishyMcFlipFlop YouTube : My Channel

Offline okee

  • Mr. Drawsprite
  • **
  • Posts: 60
    • View Profile
Re: Graphic bug I can't understand!
« Reply #21 on: July 29, 2010, 04:15:38 pm »
Regarding the scope of Global Local
From tests this is what i gathered:

2 files in a project
main.gbas //the main code file
include.gbas //included file

Global  declared in main.gbas is available to main.gbas and include.gbas
Global declared in include.gbas must have an assignment otherwise the compiler throws variable is not explicitly defined error
once declared with an assignment it's available to main.gbas and include.gbas

Local declared outside a function/sub in main.gbas is only available to functions/subs in main.gbas
Local outside a function/sub in include.gbas  is not allowed

Also using GENSPRITE() as described in the manual
Code: [Select]
GLOBAL gImgFoo = GENSPRITE(); LOADSPRITE "foo.png", gImgFooused to cause problems when declaring and assigning has this changed ?
or do we still have to do
Code: [Select]
GLOBAL gImgFoo
gImgFoo = GENSPRITE()


okee

Online MrTAToad

  • HelpEditors
  • Prof. Inline
  • ****
  • Posts: 1849
  • Its me!
    • View Profile
    • The Un-Map Website
Re: Graphic bug I can't understand!
« Reply #22 on: July 29, 2010, 04:28:43 pm »
RGB is the only command that be used with variable initialisation.
GLBasic Command List : Command List Visit My Website Twitter : FishyMcFlipFlop YouTube : My Channel

Offline matchy

  • Dr. Type
  • ****
  • Posts: 281
  • Gem Rain
    • View Profile
    • Matchy Games
Re: Graphic bug I can't understand!
« Reply #23 on: July 29, 2010, 06:30:02 pm »
Oh yeah! Even this works...
Code: [Select]
CONSTANT rnd_color=RGB(RND(255),RND(255),RND(255))
CONSTANT rnd_red=RND(255)