Skip to content

Commit

Permalink
Merge pull request #54 from JuliaMultimedia/add-generator-script
Browse files Browse the repository at this point in the history
RFC: Resurrect the package
  • Loading branch information
Gnimuc authored May 19, 2021
2 parents 2cb3f6b + 7988e84 commit 87f5bd5
Show file tree
Hide file tree
Showing 39 changed files with 7,377 additions and 7,368 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: TagBot
on:
schedule:
- cron: 14 12 * * *
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
version:
- '1.6'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
- x86
exclude:
- os: macOS-latest
arch: x86
steps:
- uses: actions/checkout@v2
- run: sudo apt-get install xvfb && Xvfb :99 &
if: matrix.os == 'ubuntu-latest'
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
env:
DISPLAY: :99
- uses: julia-actions/julia-uploadcodecov@latest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# docs:
# name: Documentation
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - run: sudo apt-get install xvfb && Xvfb :99 &
# - uses: julia-actions/setup-julia@v1
# with:
# version: '1.6'
# - run: |
# julia --project=docs -e '
# using Pkg
# Pkg.develop(PackageSpec(path=pwd()))
# Pkg.instantiate()'
# - run: julia --project=docs docs/make.jl
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
# DISPLAY: :99
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
*.jl.*.cov
*.jl.mem
*DS_Store
Manifest.toml
/Manifest.toml
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018: Jonathan Bieler, Nathan Daly
Copyright (c) 2018: Jonathan Bieler, Nathan Daly and other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
22 changes: 0 additions & 22 deletions LICENSE.md

This file was deleted.

5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ repo = "https://github.com/jonathanBieler/SimpleDirectMediaLayer.jl.git"
version = "0.2.1"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
SDL2_image_jll = "41f3cfe1-fd11-58ad-8074-b9730c29438b"
SDL2_jll = "ab825dc5-c88e-5901-9575-1e5e20358fcf"
SDL2_mixer_jll = "7e88e5ca-120e-58e7-9660-b2187fd466c0"
SDL2_ttf_jll = "ca9d4746-8a27-5104-babe-80f83b336947"

[compat]
julia = "1.3"
CEnum = "0.4"
ColorTypes = "0.8, 0.9, 0.10"
SDL2_image_jll = "2.0.5"
SDL2_jll = "2.0.10"
SDL2_mixer_jll = "2.0.4"
SDL2_ttf_jll = "2.0.15"
julia = "1.3"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
91 changes: 79 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,91 @@
# Simple DirectMedia Layer

[![Build Status](https://travis-ci.org/jonathanBieler/SimpleDirectMediaLayer.jl.svg?branch=master)](https://travis-ci.org/jonathanBieler/SimpleDirectMediaLayer.jl)
[![Build Status](https://ci.appveyor.com/api/projects/status/kg3gx5ngbbewjstr?svg=true)](https://ci.appveyor.com/project/jonathanBieler/sdl2-jl)

[![Coverage Status](https://coveralls.io/repos/github/jonathanBieler/SimpleDirectMediaLayer.jl/badge.svg?branch=master)](https://coveralls.io/github/jonathanBieler/SimpleDirectMediaLayer.jl?branch=master)
[![Project Status: Unsupported – The project has reached a stable, usable state but the author(s) have ceased all work on it. A new maintainer may be desired.](https://www.repostatus.org/badges/latest/unsupported.svg)](https://www.repostatus.org/#unsupported)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)

Bindings for the [Simple DirectMedia Layer](https://www.libsdl.org/) library. The bindings were generated using [Clang.jl](https://github.com/ihnorton/Clang.jl).

It's recommended to declare a shorthand for the package after using it:
Bindings for the [Simple DirectMedia Layer](https://www.libsdl.org/) library. The bindings were generated using [Clang.jl](https://github.com/JuliaInterop/Clang.jl).

## Installation
```
using SimpleDirectMediaLayer
const SDL = SimpleDirectMediaLayer
add SimpleDirectMediaLayer
```

The `SDL_` prefix was trimmed from names so functions and types can be accessed as `SDL.foo` instead of `SDL_foo`. Documentation can be found on the [SDL wiki](https://wiki.libsdl.org/FrontPage).
Documentation can be found on the [SDL wiki](https://wiki.libsdl.org/FrontPage).

## Quick start
```
using SimpleDirectMediaLayer.LibSDL2
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 16)
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 16)
@assert SDL_Init(SDL_INIT_EVERYTHING) == 0 "error initializing SDL: $(unsafe_string(SDL_GetError()))"
win = SDL_CreateWindow("Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1000, 1000, SDL_WINDOW_SHOWN)
SDL_SetWindowResizable(win, SDL_TRUE)
renderer = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC)
surface = IMG_Load(joinpath(@__DIR__, "..", "assets", "cat.png"))
tex = SDL_CreateTextureFromSurface(renderer, surface)
SDL_FreeSurface(surface)
w_ref, h_ref = Ref{Cint}(0), Ref{Cint}(0)
SDL_QueryTexture(tex, C_NULL, C_NULL, w_ref, h_ref)
try
w, h = w_ref[], h_ref[]
x = (1000 - w) ÷ 2
y = (1000 - h) ÷ 2
dest_ref = Ref(SDL_Rect(x, y, w, h))
close = false
speed = 300
while !close
event_ref = Ref{SDL_Event}()
while Bool(SDL_PollEvent(event_ref))
evt = event_ref[]
evt_ty = evt.type
if evt_ty == SDL_QUIT
close = true
break
elseif evt_ty == SDL_KEYDOWN
scan_code = evt.key.keysym.scancode
if scan_code == SDL_SCANCODE_W || scan_code == SDL_SCANCODE_UP
y -= speed / 30
break
elseif scan_code == SDL_SCANCODE_A || scan_code == SDL_SCANCODE_LEFT
x -= speed / 30
break
elseif scan_code == SDL_SCANCODE_S || scan_code == SDL_SCANCODE_DOWN
y += speed / 30
break
elseif scan_code == SDL_SCANCODE_D || scan_code == SDL_SCANCODE_RIGHT
x += speed / 30
break
else
break
end
end
end
A few examples are available [here](https://github.com/jonathanBieler/SimpleDirectMediaLayer.jl/blob/master/src/examples/).
x + w > 1000 && (x = 1000 - w;)
x < 0 && (x = 0;)
y + h > 1000 && (y = 1000 - h;)
y < 0 && (y = 0;)
# License
This project is licensed under the terms of the MIT license.
dest_ref[] = SDL_Rect(x, y, w, h)
SDL_RenderClear(renderer)
SDL_RenderCopy(renderer, tex, C_NULL, dest_ref)
dest = dest_ref[]
x, y, w, h = dest.x, dest.y, dest.w, dest.h
SDL_RenderPresent(renderer)
SDL_Delay(1000 ÷ 60)
end
finally
SDL_DestroyTexture(tex)
SDL_DestroyRenderer(renderer)
SDL_DestroyWindow(win)
SDL_Quit()
end
42 changes: 0 additions & 42 deletions appveyor.yml

This file was deleted.

File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions examples/audio_example/lesson11.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file transformed from Lazy Foo' Productions "Playing Sounds" tutorial:
# http://lazyfoo.net/SDL_tutorials/lesson11/index.php

using SimpleDirectMediaLayer.LibSDL2

SDL_Init(SDL_INIT_AUDIO)

#Load the music
aud_files = dirname(@__FILE__)
music = Mix_LoadMUS("$aud_files/beat.wav")

if (music == C_NULL)
error("$aud_files/beat.wav not found.")
end

scratch = Mix_LoadWAV_RW(SDL_RWFromFile("$aud_files/scratch.wav", "rb"), 1)
high = Mix_LoadWAV_RW(SDL_RWFromFile("$aud_files/high.wav", "rb"), 1)
med = Mix_LoadWAV_RW(SDL_RWFromFile("$aud_files/medium.wav", "rb"), 1)
low = Mix_LoadWAV_RW(SDL_RWFromFile("$aud_files/low.wav", "rb"), 1)
Mix_PlayChannelTimed(-1, med, 0, -1)

Mix_PlayMusic(music, -1)
sleep(1)
Mix_PauseMusic()
sleep(1)
Mix_ResumeMusic()
sleep(1)
Mix_HaltMusic()
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 87f5bd5

Please sign in to comment.