Compare commits

...

2 Commits

7 changed files with 36 additions and 6 deletions

View File

@ -1,5 +1,5 @@
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
# 2D_Engine_C SDL2 Core
# 2D_Engine_C_SDL2_Core
## Description
The core made on SDL2 for the multi-platform 2D_Engine_C.

View File

@ -1,5 +1,6 @@
# Source files
CORE_SOURCES := \
asset_manager.c \
texture_manager.c \
event.c \
vector2d.c \
@ -8,7 +9,7 @@ CORE_SOURCES := \
# Compiler and flags
CORE_CC = gcc
CORE_CFLAGS = -Wall -Wextra -std=c17 -fPIC -g
CORE_CFLAGS = -Wall -Wextra -std=c17 -fPIC -g -DASSET_FILE=$(ASSET_OUTPUT)
CORE_INCLUDE_DIRS = $(CORE_DIR)/headers
CORE_LDFLAGS = $(shell sdl2-config --cflags --libs)
@ -26,7 +27,7 @@ core_setup:
@echo "Building libCore.so (1/3)"
$(Q)mkdir -p $(dir $(CORE_OBJECTS))
# Count files to build
# Count nb of files to build
count_core_build:
$(eval export TOTAL_CORE_FILES := $(shell echo $$(($$(make -n $(CORE_OBJECTS) 2>/dev/null | grep -c "Building") + 1))))

17
src/asset_manager.c Normal file
View File

@ -0,0 +1,17 @@
#include "asset_manager.h"
#include <SDL2/SDL_render.h>
#include "display.h"
#include "linked_list.h"
static void temporary_extract_asset(const char *path)
{
}
SDL_Texture load_image(const char *path)
{
IMG_LoadTexture(renderer, path);
}

View File

@ -1,6 +1,7 @@
#include "display.h"
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
@ -8,6 +9,8 @@ SDL_Renderer *renderer = NULL;
void display_init(void)
{
SDL_Init(SDL_INIT_EVERYTHING);
IMG_Init(IMG_INIT_PNG);
window = SDL_CreateWindow("2D_Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, DISPLAY_WIDTH * DISPLAY_SCALE, DISPLAY_HEIGHT * DISPLAY_SCALE, SDL_WINDOW_SHOWN);
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
}

View File

@ -0,0 +1,8 @@
#ifndef ASSET_MANAGER_H
#define ASSET_MANAGER_H
#include <SDL2/SDL_image.h>
SDL_Texture load_image(const char *path);
#endif // ASSET_MANAGER_H

View File

@ -1,6 +1,6 @@
#ifndef MALLOC_H
#define MALLOC_H
#ifndef MEMORY_ALLOC_H
#define MEMORY_ALLOC_H
#include <stdlib.h>
#endif // MALLOC_H
#endif // MEMORY_ALLOC_H

View File

@ -37,6 +37,7 @@ inline void texture_manager_init(texture_manager_t *texture_manager)
inline void texture_manager_load_texture(texture_manager_t *texture_manager, const char *name)
{
texture_t *texture;
linked_list_push_back(&texture_manager->textures, texture);
}