Giter Club home page Giter Club logo

cute_framework's People

Contributors

apirux avatar benjamingu avatar bullno1 avatar chunqian avatar condzi avatar edmondburnett avatar eliasdaler avatar empyreanx avatar jamiecrisman avatar jmw327 avatar jonstvns avatar linkzzy avatar maximiliankk avatar metalmaxmx avatar ogam avatar randygaul avatar user113333 avatar waldnercharles 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  avatar  avatar  avatar

cute_framework's Issues

Tutorial : Setting Up Cute Framework as a Beginner to C++

This setup tutorial is for anyone unfamiliar with cmake to build C++ projects. We will go through some steps to have cmake setup Cute Framework (CF) to build along with your game project.

Project Setup with Cmake

Writing your own CmakeLists.txt file will be pretty difficult as a beginner, so instead I really recommend to copy my list file from the example game Cute Snake here. Go ahead and rename things from snake to your own game's name.

  • Under add_executable you can list out all of your source code.
  • You can toggle between using Cute Framework as a static or dynamic library by toggling this cmake switch set(CUTE_FRAMEWORK_STATIC ON) from ON to OFF.
  • target_include_directories tells cmake where your source code is. For Cute Snake I have it set to the src folder.
  • The rest of the cmake file tells cmake where to download a copy of CF and some other useful things.

Building your Project

Here are the steps to follow to build your game.

  1. Download and install cmake.
  2. Create a folder for your project.
  3. Place your CmakeLists.txt file and your source code into this folder.
  4. Place your source code into this folder. Make sure target_include_directories in your CmakeLists.txt points to the folder you've placed all your source code into (e.g. a src folder).
  5. Open a terminal in your folder (command prompt for windows users).
  6. Create a folder called build_msvc_2019. This is where cmake will store your generated build files.
  7. Run this command: cmake -G "Visual Studio 16 2019" -A x64 -Bbuild_msvc_2019 .

And that's it! Your visual studio solution has been generated for version 2019. For other versions of visual studio you will want to use slightly different cmake commands. Here are some I have used in the past.

  • cmake -G "Visual Studio 14 2015" -A x64 -Bbuild_msvc_2015 .
  • cmake -G "Visual Studio 15 2017" -A x64 -Bbuild_msvc_2017 .
  • cmake -G "Visual Studio 16 2019" -A x64 -Bbuild_msvc_2019 .
  • cmake -G "Visual Studio 17 2022" -A x64 -Bbuild_msvc_2022 .

You can also generate your build for makefiles, or even other types of build systems. Here's a bunch of information about various kinds of builds if you're not using visual studio.

Building your game can be done in a bunch of ways. If you're using visual studio I recommend to open up your solution and build it from within visual studio. It will be in your build_msvc_20XX folder. You can optionally have cmake do your build from the command line with cmake --build build_msvc_20XX.

Cute Snake Example

If you're stuck I highly recommend downloading a copy of Cute Snake to see as a reference. For Windows users you can simply click on the msvc2019.cmd batch file if you're using Visual Studio 2019, and the script is trivial to modify for other Visual Studio versions.

If this seems overwhelming or you still need help I recommend asking for help here in a GitHub Issue, or hopping onto the CF discord server to ask for help.

ECS advanced system registration

Based on the suggestion by RoiG :)

The purpose is to add type safety to the system function pointer, making it difficult to crash in the event the entity composition is adjusted but the system has not yet been.

image

choose gl/dx on windows

accidentally disabled gl via macros so it doesn't work on windows -- needs mainly a macro fix (probably just in cute_defines.h) -- has implications for the shaders and app_init flags

create_*** make_***

There's a mismatch in the APIs on make_xxx vs xxx_make and create_xxx vs xxx_create functions. Should just stick with one verb and one convention. I'm leaning towards make_xxx. Just be consistent.

dynamic library hotload support

expose app context pointer
audit code and look for other breakage points, such as function pointers or other statically stored pointers
provide a reset all routine to patch in new pointers

error_t ambiguous on linux

Super annoying but error_t is defined in error_t.h, so anyone doing using namespace cute will have this problem, or also C people will have this proplem. A good solution would be to rename cute::error_t to cute:err_t, which should also work well in C mode.

platform detection

happens in cmake -- but, users will want this to happen in a header (which has not yet been written)

entity simpler shit

add this

struct entity_config_t
{
	const char* entity_name;
	array<const char*> component_types;
};

void app_register_entity_type(app_t* app, entity_config_t entity_config);

kv bool should not require quotes

bool is hacked into kv as a string "true" or false" requiring quotes to be present
should be natively supported as simply true or false when serialized

this would require a small refactor and extra parsing, but, definitely worth it

math file rename

cute_math_2d.h -> cute_math ?
cute_math.h -> cute_collision ?

high dpi stuff

high dpi flag should probably be exposed to app options

needs to be documented -- seems mostly just relevant to apple devices?

C interface with optional C++ API

What are we doing?

Converting cute_framework headers to be C compatible, while leaving an optional namespaced C++ API in place.

What work is remaining?

  • Prefix all types, functions, and globals with cf_
  • Remove the cute namespace from everything part of the C api
  • Wrap the namespaced c++ api inside #ifdef CUTE_CPP
  • Alias cf_ prefixed types inside namespaces with their original short name
  • Move member function implementations into free functions
  • Replace default arguments in functions
  • Rename overloaded functions with a numerical or type postfix
  • Replace usage of templated types in C api
  • Replace using statements with typedefs
  • Typedef all structs
  • Surround C api with extern "C"
  • Add #ifdef CUTE_NO_CPP to cute_defines.h for C-only mode when compiling as C++
  • Merge latest from cute_framework/main
  • Verify that all cute headers compile in a C99 project
  • Verify that all changes compile using emscripten

Per-file progress

  • cute_a_star.h
  • cute_aabb_tree.h
  • cute_alloc.h
  • cute_app.h
  • cute_array.h
  • cute_aseprite_cache.h
  • cute_audio.h
  • cute_base64.h
  • cute_batch.h
  • cute_c_runtime.h
  • cute_circular_buffer.h
  • cute_clipboard.h
  • cute_color.h
  • cute_concurrency.h
  • cute_coroutine.h
  • cute_debug_printf.h
  • cute_defer.h
  • cute_defines.h
  • cute_dictionary.h
  • cute_doubly_list.h
  • cute_ecs.h
  • cute_error.h
  • cute_file_system.h
  • cute_file_system_utils.h
  • cute_font.h
  • cute_gfx.h
  • cute_handle_table.h
  • cute_haptics.h
  • cute_hashtable.h
  • cute_https.h
  • cute_image.h
  • cute_input.h
  • cute_joypad.h
  • cute_kv.h
  • cute_kv_utils.h
  • cute_lru_cache.h
  • cute_math.h
  • cute_memory_pool.h
  • cute_networking.h
  • cute_png_cache.h
  • cute_priority_queue.h
  • cute_rnd.h
  • cute_sprite.h
  • cute_string.h
  • cute_string_utils.h
  • cute_strpool.h
  • cute_symbol.h
  • cute_timer.h
  • cute_typeless_array.h
  • cute_utf8.h
  • cute_version.h
  • cute_window.h

Notes from discord chat

[10:20 PM] Randy: The main problem would be the usage of templated data structures in the implementation of some of the features, like the serialization and the ECS
[10:21 PM] Randy: However, it's possible to compile a C interface and leave the implementation using some C++
[10:21 PM] Randy: Then the main pain point is just some of the templated stuff in the API, but it's not too much
[10:21 PM] Limyc: I'm mostly interested in a c interface, and if it's just some grunt work, I might just do it
[10:22 PM] Randy: It's not a big deal to write C versions of function overloads and whatnot
[10:22 PM] Randy: I would absolutely support you here. I would do it myself, but priorities dictate I work on the other things first, like docs and bugs
[10:22 PM] Randy: So if you do it, that would super awesome
[10:25 PM] Limyc: is there a particular way you would want the interface work done?
[10:26 PM] Randy: https://github.com/RandyGaul/cute_headers/blob/master/cute_sound.h
GitHub
[cute_headers/cute_sound.h at master · RandyGaul/cute_headers](https://github.com/RandyGaul/cute_headers/blob/master/cute_sound.h)
Collection of cross-platform one-file C/C++ libraries with no dependencies, primarily used for games - cute_headers/cute_sound.h at master · RandyGaul/cute_headers
cute_headers/cute_sound.h at master · RandyGaul/cute_headers
[10:27 PM] Randy: This is a pretty good way to create C versions without default arguments
[10:27 PM] Randy:
cs_audio_source_t* cs_load_wav(const char* path, cs_error_t* err /* = NULL */);
cs_audio_source_t* cs_read_mem_wav(const void* memory, size_t size, cs_error_t* err /* = NULL */);
[10:27 PM] Randy: In each header you can #ifdef __cplusplus the C++ header, and in the #else have the C versions
[10:28 PM] Randy: For overloaded functions you can append 2 to the name
[10:28 PM] Randy: Should probably also have a macro to force C-only as an optional macro
[10:29 PM] Limyc: Would you want to keep the namespaced C++ functions wrapped with #ifdef _cplusplus, and those just call into the cf_* functions?
[10:29 PM] Randy: Yeah I think that's a good way to do it
[10:29 PM] Randy: In the places where an array<T> is returned there's a few options on what to do
[10:30 PM] Randy: We can probably discuss those case-by-case
[10:33 PM] Randy: cute_string.h should probably not have a C version at all
[10:33 PM] Randy: I see array<T> in cute_ecs.h and cute_https.h
[10:33 PM] Randy: but those should be easy to change to a C-style implementation
[10:35 PM] Randy: Overall it's a straightforward port to C
[10:35 PM] Limyc: okay, so globals, functions, types all get cf_
overloads get a numerical postfix.
keep the namespaced functions wrapped by an ifdef
deal with templates on a case-by-case basis
[10:35 PM] Randy: sounds pretty good
[10:35 PM] Randy: And ask questions if you need help with anything, we can always discuss things if you're unsure which option to take
[10:37 PM] Limyc: do you want to alias types inside the cpp namespace for convenience and not breaking anyone who updates?
namespace cute {
using ecs_entity_t = cf_ecs_entity_t;
}
 
[10:37 PM] Randy: yeah that's a good idea
[10:38 PM] Randy: that works well
[10:38 PM] Randy: Probably the big one here would be the sprite
[10:39 PM] Randy: https://github.com/RandyGaul/cute_framework/blob/master/include/cute_handle_table.h
[10:39 PM] Randy: Here's a similar example to how the sprite can be implemented. The C version is the "main" version and the C++ one just calls into the C functions and holds the struct instance
[10:40 PM] Randy: But the sprite would still just be POD style as opposed to the handle_table is heap allocated

Refactor time simulation

Noel Berry has a good abstraction for time that provides super useful functions for time based events like on_interval. It's also a great abstraction for supporting fixed timestep as well.

  • Refactor CF's time to store centralized time state variables
  • Provide useful event helper functions
  • Implement optional fixed-timestep stepping mechanism in the app

https://github.com/NoelFB/blah

Automatically mount base folder

This is a lot more beginner friendly than mounting nothing. Also some documentation page about mounting is necessary. This is a crucial first-step for everyone learning how to use CF and needs to be extremely streamlined.

Improve docs on how to use png_cache

The docs are unclear that in order to draw stuff using a png_cache, you must call make_batch(png_cache_get_pixels_fn(my_png_cache), my_png_cache) create a custom batch_t.

If you fail to create the custom batcher and just use sprite_get_batch() like I did, you'll get an error in the console when attempting to draw a sprite inside a png_cache_t. The error is "Aseprite cache -- unable to find id <img_id>"

Provide API for detecting and handling batches that will overflow the internal sg_buffer

8:43 PM] Limyc: How can I check if I'm going to overflow the sg_buffer with the current batch? I'm rendering circles using batch_circle_line and I assert when I hit around 171 circles using an iter count of 10. It asserts at lower circle counts if I draw  higher resolution circles.
sg_append_buffer: overall appended size is bigger than buffer size
[8:44 PM] Randy: https://github.com/RandyGaul/cute_framework/blob/master/src/cute_batch.cpp#L391
[8:44 PM] Randy: it's hard coded for now
[8:45 PM] Randy: Feel free to add a simple function to adjust or get the buffer size
[8:50 PM] Limyc: okay, so for now, there's no way to check if adding something to the batch will exceed the buffer size. I'll need to write that myself
[8:51 PM] Limyc: Would it make sense for CF to split batches up automatically if they are too big?
[8:51 PM] Randy: https://github.com/RandyGaul/cute_framework/blob/master/src/cute_gfx.cpp#L120-L141
[8:51 PM] Randy: Well sokol_gfx is supposed to be dropping draw calls silently if you overflow
[8:52 PM] Randy: But maybe sokol_gfx was changed
[8:52 PM] Randy: And added that nice error message you found
[8:54 PM] Limyc: looks like you can define SOKOL_VALIDATE_NON_FATAL to silently drop overflowed calls
[8:54 PM] Randy: ah that sounds new to me
[8:54 PM] Randy: the perks of using actively maintained software 🙂
[8:56 PM] Limyc: Validation starts here: https://github.com/RandyGaul/cute_framework/blob/master/libraries/sokol/sokol_gfx.h#L15465
And asserts here: https://github.com/RandyGaul/cute_framework/blob/master/libraries/sokol/sokol_gfx.h#L13690
[8:56 PM] Limyc: Should I make an issue for this? If so, what exactly?
[8:57 PM] Randy: Make a pull request
[8:57 PM] Randy: Unless you want me to try and change things
[8:58 PM] Randy: Then go ahead and make an issue, you can just screenshot our convo here, or post in the relevant details
[9:00 PM] Limyc: okay, I'll make an issue then. I think it's worth considering friendlier ways to detecting and handling overflows instead of dropping the draw calls silently.
[9:01 PM] Limyc: I'm not sure how I'd use triple_buffer_append as the public CF api currently stands, and maybe that's the solution and there's just missing docs or an example 
[9:02 PM] Randy: the triple_buffer_apped is lower level
[9:02 PM] Randy: you shouldn't have to deal with it directly when using the batch api
[9:02 PM] Randy: I think not silently dropping the calls is a good thing
[9:03 PM] Randy: Just need to expose a getter/setter for the buffer size
[9:04 PM] Limyc: yeah, I'd rather have the assert than not. What's missing is an easy way to detect the overflow at draw time and handle it 

Upgrade the mbedtls version to fix build error

Try to building cute_framework on my macOS 12.4,the 3.0 version mbedtls will make "parameter 'output_size' set but not used" error,upgrade to the newer 3.1 will fix it(set GIT_TAG to v3.1.0).

app_t* pointer

consider making it global

would solve some naming considerations for function prefixes

CF Coroutine Refactor

Higher level abstraction around CF coroutines is in the making. I have it sketched out but need to work on implementation at some point, but this requires proper dog-fooding and vetting first. Making this issue so it doesn't get lost. It will basically be the unrestricted and refined version of the routine macros referenced here #54 complete with a verb + adjective lego-style building blocks for more complex behaviors and finite state machines.

Dropping calls when sending too much drawable data to the GPU

Currently CF drops draw calls if too much data is requested to be sent to the GPU and issues a printed warning to stderr. This should work fairly well for development, but, an alternative may be much better.

Instead of dropping the draw call the vertices can be stored on the CPU in temporary memory, to be flushed to the GPU later. This would allow the entire system to handle temporary stalls in framerate, and simply render things a bit slower until the GPU catches up. The temporary overflow buffer can also fill up, at which point the entire CPU needs to hang and wait for the GPU, and a loud warning can be printed that to explain how the entire process is simply GPU bound.

C only option

ifdef out the C++ features

This is important for ABI stability and ease of language bindings

Scancodes

Use or expose scancodes as well so can pick physical layout — use case example: WASD for movement but user isn’t using QWERTY, needs to be a physical mapping.

Not sure how I want to do this. Need to think it through more.

ecs renames

in cute_ecs.h
param structs should have a consistent naming

params_t
config_t
or just _t

needs to be consistent

Implement optional cryptography

Right now the cmake options to turn off cryptography aren't implemented. This feature is a nice-to-have to simplify builds for non-networked games, or games that just don't want to deal with the cryptography dependency (even though it's not external).

online document

Hi RandyGaul
I created online documentation for cute_framework, using docsify.js, and customized the theme, and it looks pretty good,
The cute_framework doc online address is here, if you think it's ok, I'll be happy to pull request

MingW stuff

C:\Users\randy\Documents\projects\cute_framework\build>block_man
Assertion failed: !CUTE_STRCMP(buf, "Debug") || !CUTE_STRCMP(buf, "Release"), file C:/Users/randy/Documents/projects/cute_framework/block_man/world.cpp, line 473

and

All 72 tests ←[32mPASSED←[0m.

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.