snowkit / linc_sdl Goto Github PK
View Code? Open in Web Editor NEWhttp://snowkit.github.io/linc/ Haxe/hxcpp @:native bindings for SDL
License: Other
http://snowkit.github.io/linc/ Haxe/hxcpp @:native bindings for SDL
License: Other
These lines
#ifndef HXCPP_H
#include <hxcpp.h>
#endif
are not valid on windows with cl.exe. Anything before the include statement for a precompiled header is ignored, making the #endif a syntax error
Implementing a switch to offer wrapped calls would mean compatibility with Cppia hosts and scripts. Is this too out of scope for this library, and a wrapper library implemented separately?
I can't seem to get the test to compile. Getting the same error when compiling on Mac and Windows.
Error: ./src/Test.cpp:1571:20: error: no member named 'sym' in 'cpp::Struct<SDL_Keysym, cpp::DefaultStructHandler>'; did you mean to use '->' instead of '.'?
int tmp10 = tmp9.sym; HX_STACK_VAR(tmp10,"tmp10");
^
->
So I was using this (really nice) library to port my code from C++ to Haxe but I see that there's no SDL_image support.
I need to use PNG and JPG images, but the SDL library only accepts BMPs.
I wanted to implement it myself, but I the library isn't on native-toolkit's GitHub.
Any ideas?
Error: While running :cl.exe -Iinclude -DLINC_SDL -IC:/HaxeToolkit/haxe/lib/linc_sdl/git//linc/ -IC:/HaxeToolkit/haxe/lib/linc_sdl/git//lib/sdl/include/ -IC:/HaxeToolkit/haxe/lib/linc_sdl/git//lib/sdl/include/configs/windows/ -DHAVE_LIBC -DNATIVE_TOOLKIT_SDL -nologo -O2 /WX- /fp:precise -DHX_WINDOWS -D_USING_V120_SDK71_ -GR -FS -Oy- -c -EHs -GS- -arch:SSE -IC:/Projects/hxcpp/include -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=330 -D_CRT_SECURE_NO_DEPRECATE -D_ALLOW_MSC_VER_MISMATCH -D_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH -DHX_WIN_MAIN -wd4996 -MT ./src/Main.cpp -FoC:/Projects/Flow-Basic-Test-01/bin/windows.build/cpp/obj/msvc18-ncxp/2159692e_Main.obj
Main.cpp
C:/Projects/hxcpp/include\cpp/Pointer.h(150) : error C2027: use of undefined type 'SDL_Window'
c:\haxetoolkit\haxe\lib\linc_sdl\git\lib\sdl\include\SDL_video.h(89) : see declaration of 'SDL_Window'
./src/Main.cpp(39) : see reference to class template instantiation 'cpp::Pointer<SDL_Window>' being compiled
Getting this error with the latest Haxe and HXCpp.
I am using the latest HXCPP and Linc-SDL, using this code (the test):
import sdl.SDL;
import sdl.Window;
import sdl.Renderer;
class Main {
static var state : { window:Window, renderer:Renderer };
//Haxe entry point
static function main() {
SDL.init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
state = SDL.createWindowAndRenderer(320, 320, SDL_WINDOW_RESIZABLE);
update();
}
static function update() {
while(SDL.hasAnEvent()) {
var e = SDL.pollEvent();
if(e.type == SDL_QUIT) return false;
SDL.setRenderDrawColor(state.renderer, 255,255,255,255);
SDL.renderClear(state.renderer);
SDL.renderPresent(state.renderer);
SDL.delay(4);
}
return true;
}
}
I get the following error upon compilation:
Error: ./src/Main.cpp:52:16: error: no matching function for call to 'SDL_SetRenderDrawColor'
HXLINE( 24) SDL_SetRenderDrawColor( ::Dynamic(::Main_obj::state->__Field(HX_("renderer",43,c5,db,b2),hx::paccDynamic)),(int)255,(int)255,(int)255,(int)255);
^~~~~~~~~~~~~~~~~~~~~~
/usr/local/lib/haxe/lib/linc_sdl/git//lib/sdl/include/SDL_render.h:633:29: note: candidate function not viable: no known conversion from '::Dynamic' to 'SDL_Renderer *' for 1st argument
extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer,
^
./src/Main.cpp:53:16: error: no matching function for call to 'SDL_RenderClear'
HXLINE( 25) SDL_RenderClear( ::Dynamic(::Main_obj::state->__Field(HX_("renderer",43,c5,db,b2),hx::paccDynamic)));
^~~~~~~~~~~~~~~
/usr/local/lib/haxe/lib/linc_sdl/git//lib/sdl/include/SDL_render.h:690:29: note: candidate function not viable: no known conversion from '::Dynamic' to 'SDL_Renderer *' for 1st argument
extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
^
./src/Main.cpp:54:16: error: no matching function for call to 'SDL_RenderPresent'
HXLINE( 26) SDL_RenderPresent( ::Dynamic(::Main_obj::state->__Field(HX_("renderer",43,c5,db,b2),hx::paccDynamic)));
^~~~~~~~~~~~~~~~~
/usr/local/lib/haxe/lib/linc_sdl/git//lib/sdl/include/SDL_render.h:856:30: note: candidate function not viable: no known conversion from '::Dynamic' to 'SDL_Renderer *' for 1st argument
extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
^
3 errors generated.
Any assistance would be appreciated.
First, this is a nice binding working out of the box, congrats.
Seems to me there is no reference to SDL_OpenAudio. I need it for the ffmpeg binding.
Is it already done somewhere or should I send a pull request ?
( I'll start to write something while waiting for response )
Thanks and see ya!
OMG, I'm sorry! I found what caused this error. Main function must return boolean value. The while block may or may not be executed, so there may not be any returns at all.
Hi,
Since switch does no pattern match variables but only constants (static inline), the whole Keycode class is a potential disaster (at least with recent haxe versions).
for example : key_1 is static var and thus the pattern matcher will use every work key_1 as switch traps and all the code in the switch is a potential switch trap.
I suggest obliterating the code (asap) and replacing the old implementation switch with an Int Map matching keycodes and scancodes.
Xoxo
I tried compiling linc_nanovg
test/snow
example on android target: I am getting this error
E/Exception: error(runtime / sdl / failed to create platform window, unable to recover / `Could not initialize OpenGL / GLES library`)
The error seems to be coming from SDL, so I am hoping you might be able to help.
Keycodes.hx:26: characters 17-31 : Only inline or read-only (default, never) fields can be used as a pattern
Solution is to inline all constants. Preparing PR.
So I am trying to us SDL.blitSurface
this is my function
public function apply_surface(?x:Int = null, ?y:Int = null, source:Surface, destination:Surface, clip:SDLRect){
//Holds offsets
var shift:SDLRect = {y:0, x:0, w:0, h:0};
//Get offsets
shift.x = offSetX;
shift.y = offSetY;
//Blit
SDL.blitSurface(source, clip, destination, shift);
}
I am getting this error
error C2664: 'int SDL_UpperBlit(SDL_Surface *,const SDL_Rect *,SDL_Surface *,SDL_Rect *)': cannot convert argument 2 from 'Dynamic' to 'const SDL_Rect *'
as title, not overly important immediately, thanks (:
Nico
So i've decided to finally give it a try but unfortunately run into some problems.
First the example is missing imports for Window, Renderer then it is missing a final return for the update method and Haxe will complain. After finally being able to compile it with -D HXCPP_M64 and running hxcpp on the generated Build files it gets compiled into an application but this application autocloses right away upon being run.
Any ideas?
Example.hx:1: characters 8-15 : Type not found : sdl.SDL
Example.hx:2: characters 8-18 : Type not found : sdl.Window
Example.hx:3: characters 8-20 : Type not found : sdl.Renderer
Example.hx:7: characters 33-39 : Type not found : Window
The code is completely the same as the one on README. I have the library installed, tried the "If you run into SDL build errors first try:" method. Tried compiling to C++.
I tried to compile your example on my mac but I get a bunch of "duplicate symbol" errors.
Full log: https://gist.github.com/icek/951790c5ec9f489b56c2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.