Passing a bank to a GL function

BlitzMax Forums/BlitzMax Programming/Passing a bank to a GL function

JoshK(Posted 2006) [#1]
	temp:tbank=CreateBank(Len(s$)+1)
	PokeString temp,0,s$
	glListBase listBase
	'glRasterPos2f x,y
	glCallLists BankSize(temp)-1,GL_UNSIGNED_BYTE,bank buf(temp)


I get an error on the last line:
Unable to convert from 'Int' to 'Byte Ptr'.


N(Posted 2006) [#2]
Try this.

Local buffer@ Ptr = s.ToCString( ) ' Null-terminated
glListBase( listBase )
glCallLists( s.Length, GL_UNSIGNED_BYTE, buffer )
MemFree( buffer )



ImaginaryHuman(Posted 2006) [#3]
It's because you put a space between the words `bank` and `buf`, it should be BankBuf(temp).


JoshK(Posted 2006) [#4]
How do I make this into a string? How do I make it say "Hello"?

I just get an error saying "Identifier 'ToCString' not found".
Local buffer@ Ptr = s.ToCString( ) ' Null-terminated
glListBase( listBase )
glCallLists( s.Length, GL_UNSIGNED_BYTE, buffer )
MemFree( buffer )



N(Posted 2006) [#5]
Assuming s is a string, that will create a null-terminated C string (strings in BMax use UTF-16).

Aside from that, I'm not sure what you're asking now.


AntonyWells(Posted 2006) [#6]
s has to be an already created string.

local s = "Test string"
Local buffer@ Ptr = s.ToCString( ) ' Null-terminated
glListBase( listBase )
glCallLists( s.Length, GL_UNSIGNED_BYTE, buffer )
MemFree( buffer )

or you could do it on a string constant,

local buffer:Byte ptr = "Test string.".toCstring()