GithubHelp home page GithubHelp logo

evilpudding / candle Goto Github PK

View Code? Open in Web Editor NEW
368.0 22.0 14.0 3.37 MB

C Game Engine

License: MIT License

Makefile 0.41% C 99.05% HTML 0.20% Shell 0.06% Batchfile 0.28%
c game engine 3d-engine

candle's Introduction

banner

Candle

A Game Engine (C89 ANSI, early development stages)

External Dependencies

  • no

Setup

Firstly, clone the sample project:

git clone --recursive https://github.com/EvilPudding/twinpeaks

Note the use of the flag --recursive, this sample scene uses git submodules to include, compile and link candle statically. To update Candle to a newer version, just cd candle; git pull

In twinpeaks/main.c, we can see how entities are created.

Compiling

On linux, run make, additionally, you can run make run to compile and automatically run the result, or make gdb to compile a debug executable and run it through gdb.

On windows, you need Visual C++ build tools, you can compile by running the build.bat in the project directory.

On BSD systems, in order to be able to compile and run Candle, you have to install the GNU version of the Make program, because the BSD version usually doesn't implement many required extensions. Therefore, instead of executing make you should use gmake on BSDs.

Entities and Components

Candle loosely follows Entity Component System paradigm. Entities are a simple handle, which can be extended with the use of components.

entity_t entity = entity_new({ /* component0; component1; ... */ });

For example, to create a cube object, the following code may be used:

mat_t *material = mat_new("cube material");
mesh_t *mesh = mesh_new();
mesh_cube(mesh, 1, 1);
entity_t cube = entity_new({c_model_new(mesh, material, false, true);});
/* this creates a cube that does not cast shadows but is visible */

All components in Candle use c_ prefix, and references to the component types use the ct_ prefix.

As seen above, the entity requires a c_model component to specify which mesh and material to use. The c_model component depends on c_spatial component, which is used to determine an object's position, scale and rotation. If I wish to change the cube's position, I can simply:

c_spatial_t *sc = c_spatial(&cube); /* fetch the spatial component from the cube */
c_spatial_set_pos(sc, vec3(0, 1, 0)); /* move the cube upwards */
c_spatial_rotate_Y(sc, M_PI); /* rotate the cube around the Y axis by ~3.1415 radians */

If I wish to make cube the a light source, I can add to the entity a c_light component by:

entity_add_component(cube, c_light_new(30.0f, vec4(1.0, 0.0, 0.0, 1.0)));
/* this creates a red light component of radius 30 */

This makes the cube emit light.

Custom Components

Documentation on how to create custom components will be added in the repo's wiki, until then, to learn how to create custom components, look at the component directory in candle. Each component has it's own .h and .c file, the header specifies the structure and public methods, the source file implements the methods and registers listeners and signals for that component.

Custom Rendering

Further explanations on how to create custom render passes will be added in the wiki, until then, to learn how to create custom render passes, skim through the function renderer_default_pipeline in candle/utils/renderer.c, when I have the time, I will share example projects to demonstrate this functionality.

Resources

In order to have the engine manage texture, mesh, sound, material resources, they need to be indexed, to do so there are two ways:

  1. index a directory which will be available relative to the executable:
c_sauces_index_dir(c_sauces(&SYS), "name_of_directory");
  1. embed the directory by passing a SAUCES variable when building the the engine:
make -C candle SAUCES=resauces

after this, a texture that is within that directory can be accessed by:

texture_t *texture = sauces("name_of_texture.png");

Plugins

Features that aren't requirements for all projects, are split into plugins, the ones I've developed so far are the following:

Each plugin may require specific external dependencies, and are added to a project through the use of git submodules, for example:

git submodule add https://github.com/EvilPudding/assimp.candle

The Makefile for the project will compile and link the plugin automatically.

Contributing

Anyone is welcome to contribute, there are many features missing:

  • Documentation is lacking.
  • Compilation on windows is a work in progress.
  • I don't use any modern engines, so feature suggestions are welcome.

Screenshots

Screenshot Screenshot Screenshot Screenshot Screenshot Screenshot Screenshot Screenshot Screenshot

candle's People

Contributors

evilpudding avatar leo3738 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

candle's Issues

Texture artifacts

Some texture artifacts appear in Shift3D and twinpeaks demos when ran on a Linux system with a GTX 980 GPU and proprietary NVidia drivers.
2019-09-19-203414_3440x1440_scrot
2019-09-19-202841_3440x1440_scrot
2019-09-19-202509_3440x1440_scrot
2019-09-19-201101_3440x1440_scrot

sample project not functioning windows

I compile the sample project using build.bat ,I then start it and it shows an editor briefly before crashing.Here is the console output

no loader plane
no loader round_quad
no loader sky
no loader venus
Window created
GL Vendor : NVIDIA Corporation
GL Renderer : GeForce GTX 1050 Ti/PCIe/SSE2
GL Version (string) : 4.3.0 NVIDIA 451.67
GLSL Version : 4.30 NVIDIA via Cg compiler
0
1
0
0
0
vs ready candle:quad
fetching candle:quad.glsl
fetching candle:gbuffer#0.glsl
fetching candle:query_mips#0.glsl
fetching candle:depth#0.glsl
fetching candle:select#0.glsl
fetching candle:transparent#0.glsl
fetching candle:gbuffer#1.glsl
fetching candle:query_mips#1.glsl
fetching candle:depth#1.glsl
fetching candle:select#1.glsl
fetching candle:transparent#1.glsl
fetching candle:gbuffer#2.glsl
fetching candle:query_mips#2.glsl
fetching candle:depth#2.glsl
fetching candle:select#2.glsl
fetching candle:transparent#2.glsl
fetching candle:gbuffer#3.glsl
fetching candle:query_mips#3.glsl
fetching candle:depth#3.glsl
fetching candle:select#3.glsl
fetching candle:transparent#3.glsl
floor.obj counts 0 0 0 0
end object floor.obj
loading tile.mat
cloth.obj counts 0 0 0 0
end object cloth.obj
'ailed to fetch texture 'tile_diffuse
vs ready model
shader 27 ready f:candle:query_mips#0 v:model 1
fetching candle:framebuffer_draw.glsl

Does not compile on linux

Tested on Arch and Void linux systems. Build fails at when packager tries to do something.
2020-12-21-210706-2129x334-scrot

Let me know if you need more info.

Missing -llua on ubuntu 18.04

Hello, when I try to make, the compilation ends up with an error which shows that -llua cannot be found. What library is needed exactly?

No indexed sauce named...

After compiling the example code, that is twin_peaks, I get an executable that after running says:


GL Vendor : NVIDIA Corporation
GL Renderer : GeForce GTX 980/PCIe/SSE2
GL Version (string) : 4.4.0 NVIDIA 410.73
GL Version (integer) : 4.4
GLSL Version : 4.40 NVIDIA via Cg compiler
loading resauces/models/floor.obj
loading resauces/models/cloth.obj
no indexed sauce named tile_diffuse
no indexed sauce named tile_normal
no indexed sauce named velvet_diffuse
no indexed sauce named velvet_normal
no indexed sauce named stone3_diffuse
loading resauces/models/venus.obj

Also, the render screen is simply black, though GUI elements are visible.
2018-11-08-151147_1920x1200_scrot

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.