Author |
Topic: Using OpenGL in LBB (Read 616 times) |
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Using OpenGL in LBB
« Thread started on: Apr 14th, 2015, 11:50am » |
|
Over at the LB Community Forum there's been some renewed interest in Rob's OpenGL demos here:
OpenGL 3D Graphics in Liberty BASIC
Please note that there's a bug in the 'OpenGL in LB.bas' framework which can cause it to crash in LBB. Specifically, in the SUB CreateBMPTexture the following line needs to be changed (in the gluBuild2DMipmaps call):
Was: Code: Needs to be: Code: This also makes the STRUCT arr unnecessary. Why the original code seemed to work in LB4.04 I have no idea.
Richard.
|
|
Logged
|
|
|
|
RobM
Junior Member
member is online
Posts: 91
|
|
Re: Using OpenGL in LBB
« Reply #1 on: Apr 14th, 2015, 2:56pm » |
|
Actually, the whole sub can be changed as below. There are a few calls in the original code that aren't necessary. I think you pointed this out when we were porting my program over to LBB :)
Code:SUB CreateBMPTexture filename$ , texture
call glBindTexture GL.TEXTURE.2D , texture
OPEN "DevIL.dll" FOR dll AS #dev
CALLDLL #dev , "ilInit" , ret AS long
'CALLDLL #dev , "ilGenImages" , 1 AS long , ret AS long
CALLDLL #dev , "ilBindImage" , 1 AS long , ret AS long
CALLDLL #dev , "ilLoadImage" , filename$ AS ptr , ret AS long
CALLDLL #dev , "ilConvertImage" , 6408 AS long , 5121 AS long , ret AS long
CALLDLL #dev , "ilGetData" , array AS long
'STRUCT arr , bitmaparray AS long
'arr.bitmaparray.struct = array
CALLDLL #dev , "ilGetInteger" , 3560 AS long , IL.IMAGE.BPP AS long
CALLDLL #dev , "ilGetInteger" , 3556 AS long , IL.IMAGE.WIDTH AS long
CALLDLL #dev , "ilGetInteger" , 3557 AS long , IL.IMAGE.HEIGHT AS long
CALLDLL #dev , "ilGetInteger" , 3562 AS long , IL.IMAGE.FORMAT AS long
'CALLDLL #gl , "glTexImage2D" , 3553 AS long , 0 AS long , IL.IMAGE.BPP AS long , IL.IMAGE.WIDTH AS long , IL.IMAGE.HEIGHT AS long , IL.IMAGE.FORMAT AS long , 5121 AS long , array AS long , ret AS long
CALLDLL #glu , "gluBuild2DMipmaps" , 3553 AS long , 4 AS long , IL.IMAGE.WIDTH AS long , IL.IMAGE.HEIGHT AS long , 6408 AS long , 5121 AS long , array AS long , ret AS long
CALLDLL #dev , "ilDeleteImages" , 1 AS long , ret AS long
CLOSE #dev
END SUB
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Using OpenGL in LBB
« Reply #2 on: Apr 14th, 2015, 3:40pm » |
|
on Apr 14th, 2015, 2:56pm, RobM wrote:There are a few calls in the original code that aren't necessary. |
|
Indeed, but I wanted to list the minimum change necessary for it to run without crashing. Leaving the 'superfluous' calls doesn't seem to do any obvious harm.
More importantly, are you able to correct the version available for download from the link at LBPE?
Richard.
|
|
Logged
|
|
|
|
RobM
Junior Member
member is online
Posts: 91
|
|
Re: Using OpenGL in LBB
« Reply #3 on: Apr 14th, 2015, 3:49pm » |
|
on Apr 14th, 2015, 3:40pm, Richard Russell wrote:More importantly, are you able to correct the version available for download from the link at LBPE?
Richard. |
|
Not sure. I see that the current file was uploaded by Rod. I will have to see if I can figure it out.
|
|
Logged
|
|
|
|
RobM
Junior Member
member is online
Posts: 91
|
|
Re: Using OpenGL in LBB
« Reply #4 on: Apr 14th, 2015, 4:06pm » |
|
Done! Took a few tries but I got it.
|
|
Logged
|
|
|
|
|