Original date:2019-08-01 23:04:07 Edited by: Icy_Viking Subject: Help Wrapping TTF_Font for EuSDL[SOLVED SORTA]

Hello all,

I am trying to wrap SDL_TTF for EuSDL2. Everything seems to be going fine, except for this. The window closes right away after the command to open a font is issued.

EDIT: I forgot to put the "+" before the function name. However I am having trouble displaying the text correctly on the screen. Any help would be appericated.

--wrapper code 
public function TTF_Init() 
 return c_func(xTTF_Init,{}) 
end function 
public constant xTTF_OpenFont = define_c_func(ttf,"+TTF_OpenFont",{C_POINTER,C_INT},C_POINTER), 
				xTTF_OpenFontIndex = define_c_func(ttf,"+TTF_OpenFontIndex",{C_POINTER,C_INT,C_LONG},C_POINTER), 
				xTTF_OpenFontRW = define_c_func(ttf,"+TTF_OpenFontRW",{C_POINTER,C_INT,C_INT},C_POINTER), 
				xTTF_OpenFontIndexRW = define_c_func(ttf,"+TTF_OpenFontIndexRW",{C_POINTER,C_INT,C_INT,C_LONG},C_POINTER) 
public function TTF_OpenFontRW(atom src,atom xfree,atom size,atom idx) 
 return c_func(xTTF_OpenFontRW,{src,xfree,size,idx}) 
end function 
public function TTF_OpenFontIndexRW(atom src,atom xfree,atom size,atom idx) 
 return c_func(xTTF_OpenFontIndexRW,{src,xfree,size,idx}) 
end function 
public function TTF_OpenFont(sequence file,integer size) 
 atom str = allocate_string(file,1) 
 return c_func(xTTF_OpenFont,{str,size}) 
end function 
public function TTF_OpenFontIndex(sequence file,atom size,atom idx) 
 atom str = allocate_string(file,1) 
 return TTF_OpenFontIndexRW(SDL_RWFromFile(str,"rb"),1,10,1) 
end function 
without warning 
include std/machine.e 
include EuSDL2.ew 
include EuSDLTTF.ew 
include flags.e 
atom x = SDL_Init(SDL_INIT_VIDEO) 
atom ren = SDL_CreateRenderer(win,-1,SDL_RENDERER_ACCELERATED) 
atom running = 1 
atom key = 0 
atom f = TTF_Init() 
--f = TTF_OpenFont("arial.ttf",20) --cause window to close right away 
while running = 1 do 
	key = SDL_GetKeyboardState(key) 
	if peek(key+SDL_SCANCODE_ESCAPE) > 0 then 
		running = 0 
	end if 
end while 

I also tried this:

public function TTF_OpenFont(sequence file,integer size) 
 atom str = allocate_string(file,1) 
 return TTF_OpenFontRW(SDL_RWFromFile(str,"rb"),1,20,1) 
end function 

When I try to use the TTF_OpenFont command, it gives me the error fname is 7638376 from SDL_RWFromFile (type_check failure error)

Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu