Giter VIP home page Giter VIP logo

rust-inkview's Introduction

rust-inkview

Rust-bindings for the PocketBook InkView library

Setup

Clone https://github.com/pocketbook/SDK_6.3.0/tree/5.19 and set it up as described.

Set target and library directory via .cargo/config, replacing $SDK_ROOT_DIR accordingly:

[build]
target = "arm-unknown-linux-gnueabi"

[target.arm-unknown-linux-gnueabi]
linker = "$SDK_ROOT_DIR/SDK-B288/usr/bin/arm-obreey-linux-gnueabi-clang"
rustflags = [
	"-C", "target-cpu=cortex-a7",
	"-L", "$SDK_ROOT_DIR/SDK-B288/usr/arm-obreey-linux-gnueabi/sysroot/usr/local/lib/"
]

Set environment variables for bindgen, replacing $SDK_ROOT_DIR accordingly:

$ export BINDGEN_EXTRA_CLANG_ARGS="--sysroot=$SDK_ROOT_DIR/SDK-B288/usr/arm-obreey-linux-gnueabi/sysroot/ -I$SDK_ROOT_DIR/SDK-B288/usr/arm-obreey-linux-gnueabi/sysroot/usr/include/freetype2"

Building

For build with debugging info:

$ cargo build --release

For optimized build:

$ RUSTFLAGS="-C link-arg=-s" cargo build --release

Using

Add inkview as dependency to your Crate.toml:

[dependencies]
inkview = { path = "path/to/inkview", version = "0.1" }

rust-inkview's People

Contributors

oliverhaag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ihsahn

rust-inkview's Issues

Please add license

I want to use your bindings in my rust pocketbook game. Please add a license so I can do this

Question regarding the implementation of more functions

Hey,

thanks for the binding. :)
When I want to use a function that is currently not in the lib.rs (e.g. DrawString), should I implement it into the file or use the plain c_api?

pub fn draw_string(x: i32, y: i32, s: &str) {
		let c_str = CString::new(s).expect("CString::new failed");
	unsafe {
		c_api::DrawString(x,y,c_str.as_ptr());
	}
}

Regarding the font functions --> do I need to call the close_font function to free the pointer or how does this work regarding C and Rust? Can you tell me how inkview handles this internally?

pub fn open_font(name: &str, size: i32, aa: i32) -> *mut c_api::ifont_s {
	let c_str = CString::new(name).expect("CString::new failed");
	unsafe {
		c_api::OpenFont(c_str.as_ptr(),size,aa)
	}
}

pub fn set_font(font: *const c_api::ifont_s, color: Color) {
	unsafe{
		c_api::SetFont(font, color.0)
	}
}

pub fn close_font(f: *mut c_api::ifont_s) {
	unsafe{
		c_api::CloseFont(f);
	} 
}

Thanks in advance ๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.