SFML2 Demo Dilema - Solved

new topic     » topic index » view thread      » older message » newer message

Hello,

I am having a bit of dilema trying to make a demo after wrapping SFML2. It involves trying to make a render window. Here is my euphoria code.

This is the C code I am trying wrap into Euphoria code.

sfVideoMode mode = {800,600,32}; 
sfRenderWindow* win; 
 
win = sfRenderWindow_create(mode,"SFML Win", sfResize | sfClose, NULL); 
 
if(!window) 
 return EXIT_FAILURE 
 
while (sfRenderWindow_isOpen(window)) 
{ 
  while(sfRenderWindow_pollEvent(window,&event)) 
  { 
   if(event.type == sfEvtClosed) 
   sfRenderWindow_close(window); 
  } 
 
  sfRenderWindow_clear(win,sfBlack); 
 
  sfRenderWindow_display(window); 
} 
 
sfRenderWindow_destroy(window); 
 
return EXIT_SUCCESS; 

--Flags 
public atom	sfNone = 0 
public atom	sfTitlebar = 1 
public atom     sfResize = 2 
public atom	sfClose = 4 
public atom	sfFullscreen = 8 
public atom	sfDefaultStyle = or_all({sfTitlebar,sfResize,sfClose}) 
 
public sequence sfWindowStyle = {sfNone,sfTitlebar,sfResize,sfClose,sfFullscreen,sfDefaultStyle} 
 
public enum type sfColor 
 
	sfBlack, 
	sfWhite, 
	sfRed, 
	sfGreen, 
	sfBlue, 
	sfYellow, 
	sfMagenta, 
	sfCyan, 
	sfTransparent 
	 
end type 
 
public enum type sfEventType 
 
	sfEvtClosed, 
	sfEvtResized, 
	sfEvtLostFocus, 
	sfEvtGainedFocus, 
	sfEvtTextEntered, 
	sfEvtKeyPressed, 
	sfEvtKeyReleased, 
	sfEvtMouseWheelMoved, 
	sfEvtMouseButtonPressed, 
	sfEvtMouseButtonReleased, 
	sfEvtMouseMoved, 
	sfEvtMouseEntered, 
	sfEvtMouseLeft, 
	sfEvtJoystickButtonPressed, 
	sfEvtJoystickButtonReleased, 
	sfEvtJoystickMoved, 
	sfEvtJoystickConnected, 
	sfEvtJoystickDisconnected, 
	sfEvtTouchBegan, 
	sfEvtTouchMoved, 
	sfEvtTouchEnded, 
	sfEvtSensorChanged, 
	sfEvtCount 
	 
end type 
--Graphics wrapper code 
public constant xsfRenderWindow_create = define_c_func(gfx,"sfRenderWindow_create",{C_POINTER,C_POINTER,C_UINT,C_POINTER},C_POINTER) 
 
public function sfRenderWindow_create(atom mode,sequence title,sfWindowStyle style,atom sett) 
 
 return c_func(xsfRenderWindow_create,{mode,allocate_string(title,1),style,sett}) 
	 
end function 
--Actual demo 
without warning 
 
include std/machine.e 
include EuSys2.ew 
include EuGfx2.ew 
 
include sfFlags.e 
 
sequence s 
 
--how to make the video mode sequence euphoria friendly? 
atom win = sfRenderWindow_create(s = {peeks(800),peeks(600),peeks(32)},"My Window", sfClose,0) 
 
if not win = 0 then 
	puts(1,"Could not create window!\n") 
	abort(0) 
end if 
 
while(sfRenderWindow_isOpen(win)) 
 
 while(sfRenderWindow_pollEvent(win,--what to put here?) 
 --key input 
end while 
 
sfRenderWindow_clear(win,sfBlack) 
 
sfRenderWindow_display(win) 
end while 
 
sfRenderWindow_destroy(win) 

Any help is greatly appericated. I'm mostly stuck with how to put the video mode in euphoria syntax and what to do about the event system using euphoria commands. I can post more code if it is needed.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu