Skip to content

Commit

Permalink
Merge pull request #12 from alsamitech/dev
Browse files Browse the repository at this point in the history
Improved logging, better documentation, and fixed nasty X Error
  • Loading branch information
alsamitech authored Dec 3, 2020
2 parents eac62db + fad67a9 commit 2df8244
Show file tree
Hide file tree
Showing 44 changed files with 113,764 additions and 12,881 deletions.
103,610 changes: 103,610 additions & 0 deletions .experimental/completesrc.c

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.cbp
*.replit
*.sln
*.pro

# Swap files
*.swp
Expand Down
14 changes: 5 additions & 9 deletions CONTRIBUTING
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
Contributing to alsgm

By Sami Alameddine
Contributing to AlsGM

So, you want to contribute to this game engine project? Please read this document before pull requesting.

Tips to make contributing easier:
Read the docs to get the general idea on how the engine works.
Go to the issues page on the GitHub repository ( https://github.com/alsamitech/alsgm ) to get ideas on what you might want to work on.
If the issues page is empty, check the TODO to get more ideas on what you might want to work on.

I intentionally ignored the .locl directory so you can put something like a TODO file in that dierectory. This makes it easier to keep track of what it is you need to work.

Example of what a .locl/TODO might look like

Fix the bug at src/ExampleHeader.h - DONE
I intentionally ignored the .locl directory so you can put something like another TODO file in that dierectory. This makes it easier to keep track of what it is you need to work on.

Add some better logging - IN PROGRESS

Guidelines:
Please be respectful on the Github page and the wiki.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# _AlsGM_ Game Engine

This is a game engine I am working on as a simple project. This game engine contains a few componetents that we will get into after this section about what makes this game engine different than most game engines
This is a game engine that I am working on as one of my projects. (TLDR: this is meant to be a simple game engine that still does a good job of abstracting away most of the complexity involved in low-level graphics!)

NOTE BEFORE READING:
This engine is likely to go through a ton of rewrites. I'm learning with every line of C++ and C I write. This engine will probably not be stable for a few months.
This engine is likely to go through a ton of rewrites. I'm learning with every line of C++ and C I write. This engine will probably not be stable for a few months (or longer!).
Also, while I plan to work on this as often as possible, for the first month or so, I would probably spend most of the time reading about how to pull off a project as large as this.

Premable:
Game Engines are not supposed to be one-size-fits-all engines. While this can be done efficiently with a lot of effort, I don't see the point in trying to use one engine for a ton of use cases.
Game Engines are supposed to assist with game rendering, but not abstract the APIs away. You should still be to use OpenGL functions.
Game Engines are also supposed to be open source. Why would you make a game on a engine which has source code that you dont even know or cant even modify to your needs?
Game Engines are supposed to be written as low-level as possible. While this isin't too much of a problem with engines like Unity or Unreal, smaller game engine projects are sometimes wirrtin in excessive C++
Game Engines are supposed to be written as low-level as possible. While this isin't too much of a problem with engines like Unity or Unreal, smaller game engine projects are sometimes wirrtin in excessive C++. While Class-Based game engines make life easier, they are often slower and harder to port to C.

ALSGM intends to fix all that.

Expand All @@ -34,9 +34,9 @@ Premable:
_alsgm_ does the low-level implementation work that would normally be have to be done on it's own if you were do design a game without a game engine. AlsGM also intends to standardize logging (both to console and to files). AlsGM is also responsible for utilizing multiple threads using pthreads. The game can spin off more threads from it's one thread. However, AlsGM does not abstract away pthead.h __(thankfully)__. AlsGM also can run on either a sprite model, or a function-based model. In the sprite model, everything (depending on the configuration). is a struct or object that has functions for handling the sprite.
Example (in C++):
```cpp
gm_sprite *foo = new Sprite(/*intial position*/100,130,/*states that the object would not be able to be dragged by a mouse*/STATIC,/*nmv states that this object is unchanging*/NMV);
foo->Hide();
// Hides the sprite
gm_sprite *foo = new gm_sprite(/*intial position*/100,130,/*states that the object would not be able to be dragged by a mouse*/STATIC,/*nmv states that this object is unchanging*/NMV);
foo->Show();
// Shows the sprite
```
The function model provides the fuctions to draw , move, and destroy objects. It also provides a comprehensive event system. However, it does take more code.

Expand Down
5 changes: 5 additions & 0 deletions Shaders/GLSL/frag.fsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#version 330 core
out vec4 FC;

uniform vec4 OC;

3 changes: 2 additions & 1 deletion Shaders/README
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
AlsGM Shader Componenent
This are primaraly for OpenGL and are written in GLSL
This are primaraly for OpenGL and the shaders are written in GLSL.

Basics of Shaders (For Developers)


Contributors:
Expand Down
13 changes: 7 additions & 6 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ DO THIS MONTH:

Things to work on:

Vulkan Support along with openGL support
The X window header
The win module
Communication between the processes (should be done with a 1000 byte buffer)
Rewrie the core of alsgm to remove the dependence on libc
Vulkan Support along with openGL support - implementation is far from complete.
The X window header - also far from complete
The win module - not started yet
Communication between the processes (pthreads) (should be done with a 1000 byte buffer)
Rewrie the core of alsgm to remove the dependence on libc - after a few rewrites, maybe
Implement colored logging - Almost compete


DO ANYTIME

Make an alsgm designer and IDE
Make an alsgm designer and IDE - not expected until 2021
3 changes: 3 additions & 0 deletions archive-src/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is a place where files that have either been replaced by better versions or are not finished go

No worries, all files that are in here will either be deleted or be finished and retruned to the AlsGM source folder
File renamed without changes.
Binary file added docs/Alsgm_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/Basics
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ int START() {

```

Global Set Options (GSO):
Global Set Options are options that are (optionally) able to be defined.
These defines tell the engine

Networking(check the networking documentation for more information):
Game engines are not supposed to just handle graphics, logging, and errors for you.
Let's say you wanted to design a multiplayer online game but you don't want to handle sockets and protocols manually.
Expand Down
18 changes: 5 additions & 13 deletions docs/events
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
ALSAMI CODENAME YIN
The AlsGM game engine Events System (v3)

GAME ENGINE
AlsGM uses it's own events system. This event system is queue-based.
While using the re-written events system is prefferred, you may also use the older, (less efficient and stable) event system. However, Documentation will not be provided for the older events systems and the headers will likely be removed soon

AlsGM uses a costoum events system, Desinged for the project by Sami Alameddine.
Whenever an event occurs, AlsGM would create a event structure element (event_T). which than can be parsed with gm_event_parse. AlsGM will than check the event type. After that, it will call a callback function and pass a uint32_t specifying what happend so the game can deal with it.

Author's Note:
Don't ask why I excessively use the word "Yin", it's a very, VERY long story. However, this is how the events module work.


Name of the events module: YEM (codename Yin Event Module)

When an event occurs inside the window, Our window class (wcls.h) will recive an event callback. After that, it constructs a ALS_GMEV (ALSami GaMe Event). which would be handled by our run function.

At the end of the Main loop in the window classs, the class will check to see if there are any events queued in the buffer. The buffer that it reads from is a heap allocated buffer, so a game/user can queue up as many actions as desired without causing an offerflow (provided that 1. the game developer does not make a queued event without giving the event length size 2. the operating system/machine will allow alsgm to acsess more RAM)
At the end of the Main loop in the window class, the class will check to see if there are any events queued in the buffer. The buffer that it reads from is a heap allocated buffer, so a game/user can queue up as many actions as desired without causing an offerflow (provided that 1. the game developer does not make a queued event without giving the event length size 2. the operating system/machine will allow alsgm to acsess more RAM)

Event Checker:
The Event checker checks if tehre is any events in the Queue.
Expand All @@ -25,4 +18,3 @@ if((strcmp(oldEventQueue,EventQueue)!=0)){
```
There are two ways AlsGM can handle events (configured in the config.h file)

The Event system.
24 changes: 24 additions & 0 deletions docs/implementation
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
AlsGM Documentation

AlsGM is a lib-style game engine.
As of now, you have to directly include the source for AlsGM in your project's directory.

The AlsGM repository is meant to house all of the major components of AlsGM, even if they archived and not included AlsGM at the moment. the src/ directory contains the engine itself. If you plan on just using the AlsGM engine itself and none of the other goodies in the repostitory, move the rename the src directory to alsgm and include it in your project.

AlsGM is written in C++, and is only certified to work with clang++ and g++.

Now that we have acsess to AlsGM in our project, lets set it up. In your main project file (assuming it is in the home directory), include "alsgm/core.h". Note that you must all the dependencies specified in the README set up. At this point, you can go along and start using AlsGM... but DONT

What good is AlsGM if you're not going to configure the library to your liking?
go to the config.h file and configure AlsGM according to your desires.

After that and reading the rest of the documentation, you're ready to go!

However, if you still want to check out some of the goodies AlsGM provides in it's central repository, here is a not-so-brief explinaton of what you can use in the repository

.experimental/ (formerly .yin/): Is where the AlsGM developers play around with new ideas.
Shaders/: is where the Alsgm GLSL shaders are stored. For now, they aren't filled with much, but I am planning to write more GLSL shaders in the future.
docs/: is where you are! this is the official AlsGM documentation, made to help people understand how AlsGM works without having to read through it's source code.
scripts/: is where implementation assistance scripts live. These scripts do everything from setting up AlsGM-Based projects to building an AlsGM-based soloution.
src/: Explained earlier.
buildopts: Scritps that build AlsGM soloutions, along with Makefiles
2 changes: 1 addition & 1 deletion docs/msgformat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
In (Codename Yin) Engine, Logs and messages are formatted like this
Example of a AlsGM-formatted message

--LOG--
INFO: ALSAMI LOGGER (CODENAME YIN RENDERING ENGINE EDITION)
Expand Down
25 changes: 25 additions & 0 deletions scripts/buildproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
# AlsGM Project Build Script

# I would make it g++, but this is fine for the sake of versatility
CC=c++

SOURCE=main.c
TARGET=game.out

# -g for debug code, -o so it can return a result. Keep -g until you do a final compile. After that, it is STRONGLY reccomded you remove the -g flag
PREFLAGS=-g -o

CFLAGS=
LFLAGS=-lvulkan -lpthread -lX11

if [ $# -eq 2 ] then

if (( $1 = 'REL' )) then
$CC -o $TARGET $SOURCE $CFLAGS $LFLAGS
fi


else
$CC $PREFLAGS $TARGET $SOURCE $CFLAGS $LFLAGS
fi
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CC=g++
CFlags= -o2 -lpthread -lX11 -lGL
CC=c++
CFlags= -o2 -lvulkan -lpthread -lGL -lX11
RESULTS=completesrc.c plain nodeadcode

# While yes, you can change the comiler, GCC is reccomended
Expand Down
52 changes: 52 additions & 0 deletions src/aar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#ifndef ALSGM_ARR
#define ALSGM_ARR

/*
* AlsGM Dyanmic Array of any type
*
* uses a void** pointer
* */

#define darray_del(x) free(x)

#ifdef __cplusplus
extern "C" {
#endif

typedef struct DYANMIC_ARR_STRUCT{

size_t size;
size_t item_size;
void** items;
}darray_T;

darray_T* darr_alloc(size_t init_size){
darray_T* darray_i=(darray_T*)calloc(1, sizeof(darray_T));
darray_i->item_size=init_size;
darray_i->size=0;

return darray_i;
}

void* darr_append(darray_T* darray_i, void* item){
darray_i->size++;
darray_i->items=(void**)realloc(darray_i->items, darray_i->size*darray_i->item_size);

darray_i->items[darray_i->size-1]=item;

return item;
}

void darr_shift_left(darray_T* darray_i, int index){}

// Ill make a remove function later

void darr_free(darray_T* darray_i, void (*free_method)(void* item)){

}

#ifdef __cplusplus
}
#endif

#endif // ALSGM_ARR
Loading

0 comments on commit 2df8244

Please sign in to comment.