Comments (7)
You could in the meantime try linc_stb which supports more formats.
The key thing to note here is that linc_sdl will not and should not include external dependency (like SDL_image).
The ideal path would be:
- make a native-toolkit version of the sdl image lib
- make a linc library using it
- use it alongside linc_sdl
I've never needed nor used SDL_image myself, so I don't know how dependent or independent it is from SDL and it's headers, but since they're both libraries, linc SDL image would just import linc SDL types on the haxe level, which would rope in the headers as needed I think.
from linc_sdl.
Thanks! I'll try to use linc_stb.
from linc_sdl.
No, it doesn't work. linc_sdl doesn't implement some crucial methods like createRGBSurfaceFrom and even if I implement this myself, something else crashes the program (createTextureFromSurface fails).
So I can't use StbImage...
Have you done this before?
Here's my code:
package com.sgtek.sengine;
import haxe.io.Bytes;
import sdl.SDL;
import sdl.Texture;
import stb.Image in IMG;
class Image {
public var width(default, null) : Int;
public var height(default, null) : Int;
public var data(default, null) : Texture;
public function new(game: Game, data: Bytes) {
var sdata = IMG.load_from_memory(data.getData(), data.length, 4);
var pitch = sdata.w * sdata.comp;
pitch = (pitch + 3) & ~3;
// Missing byte order check...
var rm, gm, bm, am = 0;
rm = 0x000000FF;
gm = 0x0000FF00;
bm = 0x00FF0000;
am = (sdata.comp == 4) ? 0xFF000000 : 0;
width = sdata.w;
height = sdata.h;
var tmp = SDL.createRGBSurfaceFrom(sdata.bytes, sdata.w, sdata.h,
sdata.comp * 8, pitch, rm, gm, bm, am); // I implemented this in the linc_sdl sources.
if (tmp != null) {
this.data = SDL.createTextureFromSurface(game.renderer, tmp); // Crash!!!
}
}
}
from linc_sdl.
I haven't directly, as I don't use the SDL renderer. Did you build with -debug
flag? You can have a look at the callstack when it crashes - it's just c++, so you can use gdb/xcode/visual studio and attach to the process and then see where it's crashing and probably why. It's probably something simple enough to resolve at least.
from linc_sdl.
This is my implementation in SDL.hx; I'm almost sure it's wrong.
I just need to pass the pixel data, which is of type BytesData, to the function, but the functions only accepts void*
static inline function createRGBSurfaceFrom(data:BytesData, w:Int, h:Int, depth:Int, pitch:Int, rm:UInt32, gm:UInt32, bm:UInt32, am:UInt32):Surface {
return untyped __cpp__('SDL_CreateRGBSurfaceFrom(&{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8})', data[0], w, h, depth, pitch, rm, gm, bm, am);
}
from linc_sdl.
It should be along the lines of (void*)&data[0]
to the function. I don't see anything else obviously wrong with your function though. Don't forget SDL error handling. You can check if it disliked what you gave it.
btw, it's less ideal to implement it in untyped, rather put it in the linc cpp file.
from linc_sdl.
Cool! thanks!
I implemented it in linc_sdl.cpp and it worked just fine 👍
from linc_sdl.
Related Issues (15)
- Compilation fails under OSX Yosemite HOT 2
- Implement #if cppia #end to generate Haxe wrapper functions around native calls?
- SDLRect Compile Error HOT 3
- Fails to Compile using Test Code HOT 4
- SDL.hasAnEvent signature is not recognized
- Trying it out for the first time. HOT 1
- Windows builds broken with cl.exe HOT 5
- Android target error: SDL could not create window.
- Can't compile HOT 4
- SDL Audio ? HOT 3
- linc_sdl : SDL.Keycode: Pattern matching havoc
- showMessageBox() binding missing
- Compiling linc_sdl on latest Haxe+HXCpp HOT 1
- sdl.Keycodes not inlined - Compiler error (Haxe 3.3.0)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linc_sdl.