testing... what's wrong with this?

BlitzMax Forums/BlitzMax Beginners Area/testing... what's wrong with this?

Apollonius(Posted 2006) [#1]
Guess I'm not loading the image correctly or something?

Graphics 800,600

Incbin "images/background.bmp"

Global g_background = LoadImage("IncBin::images/background.bmp")

Repeat
Cls

DrawImage g_background,0,0

	Flip
Until KeyHit(KEY_ESCAPE

error at drawimage.


undomiel(Posted 2006) [#2]
Global g_background:TImage = LoadImage("IncBin::images/background.bmp")


You have to make sure it is part of the TImage type as that way you have it in your code snippet there is that you're trying to load an image into an int.


Apollonius(Posted 2006) [#3]
still the same error...

Unhandled Exception: Attempt to access field or method of null object?And it's pointing at the drawimage line.


Triforce Guardian(Posted 2006) [#4]
Graphics 800,600,0,60 'the 0 stands for debugging, 60 is the herts(FPS)

Incbin "images/background.bmp"

Global g_background:TImage = LoadImage("IncBin::images/background.bmp")
while not keyhit(key_escape)

DrawImage g_background,0,0
flip
cls
wend
would be proper


undomiel(Posted 2006) [#5]
I copied and pasted your code Kaisuo, substitute one of my own bmp files and it worked just fine here. And interestingly enough it also worked just fine without declaring g_background to be a TImage. Maybe someone else with more experience than me with Blitz MAX would be to explain why that works? Oh wait, I think I figured that answer out on my own, neither strict nor superstrict mode are being declared here so it automatically figures out its own type? I'm just too used to programming in those modes hehe.

Anyhow, digressing. I experimented and it looks like the problem is that g_background isn't loading the bitmap file. But something is being included otherwise your program wouldn't even compile. So maybe your bitmap file is corrupted then? Because the " Attempt to access field or method of null object" error is thrown when attempting to display the object without anything having been loaded into it first.


Triforce Guardian(Posted 2006) [#6]
yes that code does work for me too, but what OS is he using, did he update his mods, what are his compu specs? kaisuo post your specs and stuff. also did you update your mods?
programs>sync mods
user: your forum user
pass: your forum pass
then try your code.


Apollonius(Posted 2006) [#7]
mods? I just downloaded the Bmax demo a few days ago.

specs?
3ghz intel, 512mb DDR400, radeon 9250 256mb...

still wont work with any of ur codes, can you imagine what the newbies think of blitz max when they try it for the first time and can't get an image displayed? That leaves a very bad impression. BMax looks cool.. but this is weird.
Or maybe I'm the only one with this problem?

Guys download teh demo and try it :P


tonyg(Posted 2006) [#8]
Post the image.


Apollonius(Posted 2006) [#9]
IMAGE REMOVED
ŠKaisuo, 2005-2006 .. lol

My first project is to make a 2D Game's entrance menu.. simple somewhat but I get errors.. :(


Helios(Posted 2006) [#10]
Graphics(800,600)

Incbin "images/background.bmp"
Global g_background:TImage = LoadImage("incbin::images/background.bmp")

While Not KeyHit(key_escape)
	DrawImage g_background,0,0
	Flip;Cls
Wend


Im pretty sure incbin is case-sensitive. The above works fine here.


tonyg(Posted 2006) [#11]
OK, no problems here using...
Graphics 800,600
Incbin "images/background.png"
Global g_background = LoadImage("IncBin::images/background.png")
Repeat
	Cls
	DrawImage g_background,0,0
	Flip
Until KeyHit(KEY_ESCAPE)


I am assuming you changed it from bmp to png for posting.... didn't you?


Apollonius(Posted 2006) [#12]
nope still same error, download the demo start it and past he code, you'll see I'm right :o


tonyg(Posted 2006) [#13]
Would if I could but used my 30 days testing MaxGui?
Can't remember having any image problems though.


undomiel(Posted 2006) [#14]
I just downloaded the demo and tried it with your image to see if it was a problem with the demo. Nope, it worked, no error. Try using the image that you posted in here, it seems to work just fine as a png. I am pretty sure that the problem you're running into is that the bmp being incbin'd into your program is corrupt.


Apollonius(Posted 2006) [#15]
how is it corrupted? I posted it here, it's not corrupted? or are you saying it's being corrupted when it's being incbin? So change the format? Doesn't bmax support bmps?


Apollonius(Posted 2006) [#16]
I tested it by changing its format and it works!


undomiel(Posted 2006) [#17]
bmax supports bmps I tested earlier using one. It could be that the bmp you have saved is corrupted (even though your image processing program treats it as fine) but when you converted it to png it was fixed. Try the png you posted here and see if it works fine then.


Apollonius(Posted 2006) [#18]
I tryed resaving it to bmp and now it works lol


Yan(Posted 2006) [#19]
Bmax doesn't support RLE compressed BMPs. That was probably the problem.


Apollonius(Posted 2006) [#20]
woooch, the background loads slow, any way to make it draw faster before the window opens or something?

draws even slowers then b+


Dreamora(Posted 2006) [#21]
Depending on the system, SetGraphicsDriver GLMax2DDriver() before graphics can help.


tonyg(Posted 2006) [#22]
GL seems to be quicker to set-up than DX but what do you mean by 'slow'.
GL is instantaneous while DX takes a fraction (maybe 1/2) of a second.


Apollonius(Posted 2006) [#23]
like, the window appears and the bg is black then it take about 1sec and 1/2 or so, for my image/background to appear, id like it to appear as the window appear


---
SetGraphicsDriver GLMax2DDriver() <- with this, it seems to eliminate my problem, what is that lol


tonyg(Posted 2006) [#24]
By default Bmax uses a DX driver. That command sets an OPenGL driver.
DX seems to be slower initialising. A few people have commented that DX driver implementation in Bmax is poor as if it was an afterthought while OpenGl was selected for X-platform.
In addition, when comparing B+ with Bmax, be aware that Bmax is 2D in 3D using DX7 Direct3D while B+ is DX1 using DirectDraw.


Dreamora(Posted 2006) [#25]
Instance loading is not really possible if you use large images (keep in mind that only power of 2 is supported. if you give it something else, it will create the next larger power of 2 and just use the data you loaded). It first loads the pixeldata and then creates a texture out of it (depending on the flags it even creates mipmaps). This just takes its time.

BlitzPlus only needed to load the stuff straight to a DX surface, no further work ...