Re: Help Solving SDL2 Wrapper Example
- Posted by Icy_Viking Sep 24, 2017
- 1759 views
petelomax said...
Icy_Viking said...
xSDL_CreateRenderer = define_c_func(sdl2,"SDL_CreateRender",{C_POINTER,C_INT,C_UINT},C_POINTER)
Does this help?
xSDL_CreateRenderer = define_c_func(sdl2,"SDL_CreateRenderer",{C_POINTER,C_INT,C_UINT},C_POINTER)
Yes it does. Thank you. The solution was so simple.
OK, need help with one more. I get the same error as before, but I don't see any typos in this one.
-Wrapper Code
xSDL_BlitSurface = define_c_func(sdl2,"SDL_BlitSurface",{C_POINTER,C_POINTER,C_POINTER,C_POINTER},C_INT) public function SDL_BlitSurface(atom src,atom srcr,atom dst,atom dstr) return c_func(xSDL_BlitSurface,{src,srcr,dst,dstr}) end function
-Example
--Demo currently not working include std/machine.e include EuSDL2.ew include flags.e atom width = 800, height = 600 atom buffer,format atom x x = SDL_Init(SDL_INIT_EVERYTHING) if x = -1 then puts(1,"Failed to load initialize SDL!\n") abort(0) end if atom win = SDL_CreateWindow("Window Image",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,width,height,SDL_WINDOW_SHOWN) if win = -1 then puts(1,"Failed to create window!\n") abort(0) end if atom surf = SDL_GetWindowSurface(win) atom img = SDL_LoadBMP("SDL.bmp") if img = -1 then puts(1,"Failed to load image!\n") abort(0) end if procedure calc_rect(atom rect,integer sx,integer sy,integer tx,integer ty) poke4(rect,sx) poke4(rect+2,sy) poke4(rect+4,tx) poke4(rect+6,ty) end procedure atom srect = allocate(10) atom drect = allocate(10) calc_rect(srect,0,0,100,100) calc_rect(drect,0,0,100,100) format = peek4u(surf+4) buffer = SDL_ConvertSurface(surf,format,0) x = SDL_BlitSurface(img,srect,surf,drect) if x = 0 then puts(1,"Failed to blit image!\n") abort(0) end if SDL_UpdateWindowSurface(win) SDL_Delay(3000) SDL_FreeSurface(img) SDL_FreeSurface(surf) SDL_DestroyWindow(win) SDL_Quit()