BlitzMax Question!

Discussion in 'Game Development (Technical)' started by bob123, Sep 19, 2005.

  1. bob123

    Original Member

    Joined:
    Sep 13, 2005
    Messages:
    44
    Likes Received:
    0
    (My first post!)

    I started learnming BlitzMax(pretty easy) and I did the basics,oop,etc...,but now Im trying to draw an image onto the screen,but it dosnt seem to be working :confused:
    Here is my code:

    Graphics 800,600;

    SetMaskColor 0,0,0;
    Global test = LoadImage("test.bmp");


    While Not KeyDown(key_escape)

    SetColor(255,255,255);
    SetAlpha(1);
    SetRotation(90);
    SetScale(1,1);
    DrawImage(test,100,100);

    Wend;

    Thanks for any help! :eek:
    Sorry if this is the wrong forum!
     
  2. Ricardo C

    Original Member

    Joined:
    Sep 11, 2004
    Messages:
    1,349
    Likes Received:
    3
    I haven't touched BlitzMax yet, but the problem might be that you're calling up "test" as if it were a previously defined element, yet there's no such definition in your code. So you should either add:

    Code:
    bmap test = "test.bmp";
    (adapted to BM's syntax of course) at the start of your code, or call up the bitmap directly:

    Code:
    DrawImage("test.bmp",100,100);
     
  3. bob123

    Original Member

    Joined:
    Sep 13, 2005
    Messages:
    44
    Likes Received:
    0
    I did define the object test as an image in the line:
    Global test = LoadImage("test.bmp");

    I also tried defining it directly but it didnt work out.
     
  4. Ricardo C

    Original Member

    Joined:
    Sep 11, 2004
    Messages:
    1,349
    Likes Received:
    3
    Oh yeah, I see it now :eek:

    Again, not sure about BM's syntax, but it looks like you're calling the LoadImage function within the definition. Is this correct? It just seems like you should load the bitmap, then define it as Global, and then draw it.
     
  5. simonh

    Indie Author

    Joined:
    Jul 26, 2004
    Messages:
    293
    Likes Received:
    0
    You need to use the 'Flip' command somewhere in your main loop (usually at the end), to flip the contents of the backbuffer to the frontbuffer.

    The Flip command is usually followed by the Cls command to clear the screen.

    Hope that helps :)
     
  6. Anthony Flack

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    2,176
    Likes Received:
    0
    Heh, you know damn well it does.
     
  7. Nexic

    Indie Author

    Joined:
    Nov 5, 2004
    Messages:
    2,437
    Likes Received:
    0
    Yeh you really need to Flip those buffers :)
     
  8. bob123

    Original Member

    Joined:
    Sep 13, 2005
    Messages:
    44
    Likes Received:
    0
    :eek: Wow..............how could I forget that!? :p
    I did programs without images like it before....o well it works now
    Thanks for the help!
     
  9. DGuy

    Original Member

    Joined:
    Jul 28, 2004
    Messages:
    131
    Likes Received:
    0
    Ok, raise your hands ...

    How many of us, from when just starting programming or using a new API, have wondered why nothing was being displayed on screen only to find out later that we were not flipping or swapping the hidden/visible surfaces?

    <raises hand> :eek:
     
  10. Indiepath.T

    Original Member Indie Author

    Joined:
    Sep 4, 2004
    Messages:
    329
    Likes Received:
    0
    Yeah, or forgot to make a camera and point it at the objects.
     
  11. joe

    joe
    Original Member

    Joined:
    Sep 28, 2004
    Messages:
    420
    Likes Received:
    0
    @bob123:

    You should also add the FlushMem() Command in your main loop. It's required from BlitzMax to remove unused object from the memory.

    I would also suggest to use Strict mode and define each variable exactly. This will help you if your game/application source grows.

    For example like this:

    Code:
    
    Strict 
    
    Graphics 800,600
    
    SetMaskColor (0,0,0)
    Global test:TImage = LoadImage("test.bmp");
    
    
    While Not KeyDown(key_escape)
      Cls
    
      SetColor(255,255,255);
      SetAlpha(1);
      SetRotation(90);
      SetScale(1,1);
    
      DrawImage(test,100,100);
    
      Flip()
      FlushMem()
    Wend
    
     
  12. bob123

    Original Member

    Joined:
    Sep 13, 2005
    Messages:
    44
    Likes Received:
    0
    Thanks for the tip :D I added that in.
     
  13. roopie

    Original Member

    Joined:
    Sep 27, 2005
    Messages:
    3
    Likes Received:
    0
    Window title

    Another question:
    i Have trial version of BlitzMax
    The window title always says BlitzGL window
    How do I change that?
    I want to be sure of this stuff before I buy the full version. U see...if we can't change the window title, we can't possibly make commercial games with it...
     
  14. Savant

    Original Member

    Joined:
    Feb 8, 2005
    Messages:
    1,674
    Likes Received:
    0
    The next version, whenever that will be, will let you change the title bar.
     
  15. Leper

    Original Member

    Joined:
    Sep 9, 2005
    Messages:
    757
    Likes Received:
    0
    Currently using bmax too. Gotta question.. why is it using so much cpu after time? My program runs fine for the first 10 minutes and after deleting / creating objects (over and over and over) it gets slower... and slower.... and slower... until it freezes... it even does that with the Asteroids tutorial that you can download over at the bmax official site. I put flushmem() everywhere and ended up getting a memory exception error. So now I gotta remove the flushmems and figure out what else I can do to make sure it doesn't slow down!


    I'm running it on a 2400mhz machine with 1 gig of ram with nvidia 6800GT card so I'm kinda worried.
     
  16. Sharpfish

    Original Member

    Joined:
    Feb 25, 2005
    Messages:
    1,309
    Likes Received:
    0
    Actually you can set the window title (and the icon) using a few simple work-arounds, I picked these up in my trial week I spent with BMax before going back to C++ so I thought most people would already know about them?
    This code also lets you set an APP ICON which is also important. So I posted more than is needed for just the title in case it helps someone.

    Do a search on the blitz forums - but from my code (from what I can remember) is:
    Code:
    Extern "win32"
    	Function LoadIcon(hWnd, file:Byte Ptr, index) = "ExtractIconA@12"
    	Function GetActiveWindow()
    	Function GetDesktopWindow()
    	Function GetWindowRect(hWnd, lpRect:Byte Ptr)
    	Function SetWindowText(hWnd, lpString$z) = "SetWindowTextA@8"
    	Function SetWindowPos(hWnd, after, x, y, w, h, flags)
    	Function GetWindowLong(hwnd, nIndex) = "GetWindowLongA@8"
    	Function SetWindowLong(hwnd, index, nIndex) = "SetWindowLongA@12"
    	Function SetClassLong(hWnd, nIndex, dwNewLong) = "SetClassLongA@12"
    	Function GetSystemMenu(hWnd, revert)
    	Function GetMenuItemCount(hMenu)
    	Function RemoveMenu(hMenu, position, flags)
    End Extern
    
    Local hWnd% = GetActiveWindow()     ' Get Window Handle
    Local style = GetWindowLong(hWnd, -16)           ' Add system menu to window style
    SetWindowLong hWnd, -16, style + $80000 + $20000 ' so that it supports a task icon
    
    Local hMenu = GetSystemMenu(hWnd, 0)      ' Remove close from the system 
    Local iMenu = GetMenuItemCount(hMenu)     ' menu to disable the non-working
    RemoveMenu hMenu, iMenu - 1, $1000 + $400 ' close button
    RemoveMenu hMenu, iMenu - 2, $1000 + $400
    
    SetWindowText hWnd, "BRILLIANT BMAX GAME BY SUPER SOFTWARE WARRIORS OR YOUR OWN TITILE HERE :)"      ' Give it a title
    Local icon = LoadIcon(hWnd, "icon.ico", 0) ' Assign it an icon
    SetClassLong hWnd, -14, icon
    
    Local desk_hWnd% = GetDesktopWindow(), l:lpRect = New lpRECT
    GetWindowRect desk_hWnd, l:lpRECT 
    
    ' Center it on-screen
    SetWindowPos hWnd, -2, (l.r / 2) - (GFX_WIDTH / 2), (l.b / 2) - (GFX_HEIGHT / 2), 0, 0, 1
    l:lpRECT = Null
    
    
    And you call SetWindowText hWnd,"TITLE HERE"
     
  17. Michael Flad

    Indie Author

    Joined:
    Aug 4, 2004
    Messages:
    190
    Likes Received:
    0
    AppTitle = "YourGreatestWindowTitle"
    will do the trick
     
  18. joe

    joe
    Original Member

    Joined:
    Sep 28, 2004
    Messages:
    420
    Likes Received:
    0
    Are you using strict mode? If you for example create objects, for example images like that

    Code:
    image = LoadImage("bitmap.png")
    
    it won't be released by the following lines:

    Code:
    image = NULL
    FlushMem()
    
    because image-variable is an integer and in this case only the integer is flushed not the image itself. You should remove this using ReleaseImage (I think this was the name of the command) before. In Strict-Mode you have to define it like that

    Code:
    Global image:TIMage = LoadImage("bitmap.png")
    
    And with this technique you can remove it from memory by set it to NULL.
     
  19. Barlok

    Original Member

    Joined:
    Nov 15, 2004
    Messages:
    61
    Likes Received:
    0
    Greetings!
    I shall be glad to help with studying BlitzMax, be knocked in ICQ (178106496). :cool:
     
  20. Jay_Kyburz

    Original Member

    Joined:
    Nov 21, 2004
    Messages:
    180
    Likes Received:
    0
    or if using Windows Messenger add me jay-at-irrational.com.au. Tho I'm a grumpy bastard and not very helpfull.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer