This commit is contained in:
parent
c069c1966b
commit
77a8a242bf
9 changed files with 47 additions and 67 deletions
30
example/Makefile
Normal file
30
example/Makefile
Normal file
|
@ -0,0 +1,30 @@
|
|||
CC := gcc
|
||||
|
||||
THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
REPO_ROOT := $(THIS_DIR)/..
|
||||
|
||||
build: out/example
|
||||
|
||||
clean:
|
||||
rm -r out || true
|
||||
rm include/servicepoint.h || true
|
||||
cargo clean
|
||||
|
||||
run: out/example
|
||||
out/example
|
||||
|
||||
PHONY: build clean dependencies run
|
||||
|
||||
out/example: dependencies main.c
|
||||
mkdir -p out || true
|
||||
${CC} main.c \
|
||||
-I $(REPO_ROOT)/include \
|
||||
-L $(REPO_ROOT)/target/release \
|
||||
-Wl,-Bstatic -lservicepoint_binding_c \
|
||||
-Wl,-Bdynamic -llzma \
|
||||
-o out/example
|
||||
|
||||
dependencies: FORCE
|
||||
cargo build --manifest-path=$(REPO_ROOT)/Cargo.toml --release
|
||||
|
||||
FORCE: ;
|
17
example/main.c
Normal file
17
example/main.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <stdio.h>
|
||||
#include "servicepoint.h"
|
||||
|
||||
int main(void) {
|
||||
SPConnection *connection = sp_connection_open("localhost:2342");
|
||||
if (connection == NULL)
|
||||
return 1;
|
||||
|
||||
SPBitmap *pixels = sp_bitmap_new(SP_PIXEL_WIDTH, SP_PIXEL_HEIGHT);
|
||||
sp_bitmap_fill(pixels, true);
|
||||
|
||||
SPCommand *command = sp_command_bitmap_linear_win(0, 0, pixels, SP_COMPRESSION_CODE_UNCOMPRESSED);
|
||||
sp_connection_send_command(connection, command);
|
||||
|
||||
sp_connection_free(connection);
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue