Coder Social home page Coder Social logo

arthursonzogni / smk Goto Github PK

View Code? Open in Web Editor NEW
123.0 8.0 18.0 898 KB

SMK - Simple multimedia kit - C++ WebAssembly

License: MIT License

CMake 1.74% C++ 98.15% Shell 0.11%
cpp multimedia webassembly sfml simple library fast wasm opengl openal

smk's Introduction

SMK (Simple multimedia kit)

travis issues license contributors

header

Features:

  • Compatible with WebAssembly. One build for every platforms!
  • Fast & simple.
  • No dependencies: everything is fetched using cmake FetchContent.

Ready to start?

Open a new Window:

  auto window = smk::Window(640, 480, "Title");

The main loop:

  window.ExecuteMainLoop([&] {
    window.Clear(smk::Color::Black);

    [...] // Draw stuff

    window.Display();
  });

Images

Load textures:

  auto ball_texture = smk::Texture("./ball.png");

Display images:

  auto ball_sprite = smk::Sprite(ball_texture);
  ball_sprite.SetPosition({200,200});
  window.Draw(ball_sprite);

Text

Load font:

  auto font_arial = smk::Font("./arial.ttf", 32);

Display text:

  auto text = smk::Text(font_arial, "hello world");
  text.SetPosition({200,200});
  window.Draw(text);

Sound

Load sound:

  auto sound_buffer = smk:SoundBuffer("./boing.ogg");

Play sound:

  auto sound = smk::Sound(sound_buffer);
  sound.Play();

Transform the view

  auto view = smk::View();
  view.SetCenter({200, 200});
  view.SetSize(320,240);
  window.SetView(view);

Library made using SMK

  • smkflow => A node editor library.

Games made using SMK

Please add yours.

Story

I needed to port several games made using the SFML to WebAssembly. SFML isn't supporting WebAssembly (yet), so I had to reimplement it myself. If you know the SFML, then SMK must be very familiar to you.

Minimal packages to install for building/executing:

They should already be installed. If they aren't you need to execute:

sudo apt install xorg-dev libgl1-mesa-dev libpulse-dev

Thanks

SMK depends directly on many great projects listed below:

SMK is also made possible thanks to:

smk's People

Contributors

arthursonzogni avatar bigous avatar code-factor avatar guerout-arnaud avatar shibasis0801 avatar themaverickprogrammer avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smk's Issues

Script terminated by timeout

Using Firefox with the sample 'draw a circle' code freezes the tab for seconds, only loads the webpage after it prompts you to stop the unresponsible script.

Console output:

Error: Script terminated by timeout at:
_usleep@http://localhost:8000/smkstarter.js:7172:16
_nanosleep@http://localhost:8000/smkstarter.js:7198:14
@http://localhost:8000/smkstarter.wasm:wasm-function[2336]:0x41953
@http://localhost:8000/smkstarter.wasm:wasm-function[2334]:0x41859
@http://localhost:8000/smkstarter.wasm:wasm-function[945]:0x20735
@http://localhost:8000/smkstarter.wasm:wasm-function[941]:0x20440
@http://localhost:8000/smkstarter.wasm:wasm-function[84]:0x1aeb
@http://localhost:8000/smkstarter.wasm:wasm-function[94]:0x1e5f
Module._main@http://localhost:8000/smkstarter.js:7630:32
callMain@http://localhost:8000/smkstarter.js:7967:28
doRun@http://localhost:8000/smkstarter.js:8028:31
run@http://localhost:8000/smkstarter.js:8043:5
runCaller@http://localhost:8000/smkstarter.js:7941:19
removeRunDependency@http://localhost:8000/smkstarter.js:1579:7
receiveInstance@http://localhost:8000/smkstarter.js:1692:24
receiveInstantiatedSource@http://localhost:8000/smkstarter.js:1709:20
smkstarter.js:7172:16

Enforced coding standards?

I see a lot of different coding styles throughout the project and many places where doxygen-style documentation is not enforced.

For instance, the global default shaders use snake case shader_program_2d() while the rest of the code is Pascal case, so shouldn't it be ShaderProgram2D()?

window.input() instead of window.Input() as well.

There are also a number of places where getters/setters are avoided completely by exposing the variable itself. Like in FrameBuffer's color_texture. There ought to be a getter for that smk::Texture& ColorTexture()...

What are the coding standards?

If there are none, I'd like to have your blessing to spruce up the library by enforcing Pascal-case, I'll add more documentation, and proper encapsulation with appropriate getters and setters.

Not to be pushy but let me know soon! I have free time tomorrow to do all of this and I am porting a big project to SMK so it'd be a great use of my free time and SMK would greatly benefit from it!

Resizing Screen On Mac Crashes

OS: Monterrey 12.4 (21F79) Mac Mini M1 2020
Scheme: Framebuffer
Expectations: Resize window and app continues to run in the new window resolution
Outcome: App crashes upon resize

Screen Shot 2022-06-20 at 9 08 18 PM

This could be an issue with GLFW and not SMK.

Resizing

Hey! I've recently started using smk and have really appreciated it. I have a lot of respect for what you've managed to do.

I fully acknowledge that this maybe a personal issue but I haven't been able to figure out how to resize my resolution to the window or canvas. In either a standalone window or a browser. Is there a resize event or anything like that that I haven't been able to find?

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.