Still getting settled in with FreeBasic after a long time of not touching it, and trying to do a basic test combining the GL2D and FBGUI2 library to load an image, and display it as a sprite.
The reason I am using FBGUI to load the image (Rather than staying within the GL2D boundaries) is because I wish to have the ability to load images from memory.
The code I'm using is;
Code: Select all
' - Dependencies
'#inclib "stdc++" Required for Squirrel Lib
#include once "inc/FBGL2D7.bas"
#include once "window9.bi"
const SCR_WIDTH = 800
const SCR_HEIGHT = 600
GL2D.ScreenInit( SCR_WIDTH, SCR_HEIGHT )
GL2D.VsyncON()
Paint (0, 0), RGB(64, 128, 255) ' Prime Graphics
var img = Load_Image("data/invader.png")
GL2D.LoadImageToHW(cast(gl2d.image ptr,img)) ' CRASH HAPPENS HERE
do
GL2D.ClearScreen()
GL2D.Begin2D()
GL2D.sprite(0, 0, GL2D.FLIP_NONE, cast(gl2d.image ptr,img))
GL2D.End2D()
GL2D.LimitFps(60)
sleep 11,1
flip
Loop Until Multikey( FB.SC_ESCAPE )
As a note, creating an image works fine, but as soon as Load_Image is used, it becomes faulty.
I presume there's a memory issue going on, but I am struggling to make heads or tails on how to resolve this as there's no specifics on image data format used within the docs.
Any help would be appreciated :)
Thanks