Initial commit.
This commit is contained in:
commit
b701dde3db
12
.clang-format
Normal file
12
.clang-format
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
BasedOnStyle: LLVM
|
||||
AlignConsecutiveShortCaseStatements:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: true
|
||||
AcrossComments: true
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
IndentWidth: 4
|
||||
PointerAlignment: Left
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
build
|
||||
*.out
|
64
Makefile
Normal file
64
Makefile
Normal file
@ -0,0 +1,64 @@
|
||||
NAME = ln-frag
|
||||
|
||||
TARGET = $(NAME).out
|
||||
|
||||
SRC_DIR = src
|
||||
INC_DIR = $(SRC_DIR)/include
|
||||
SHADER_DIR = res/shaders
|
||||
BUILD_DIR = build
|
||||
OBJ_DIR = $(BUILD_DIR)/obj
|
||||
SPV_DIR = $(BUILD_DIR)/spv
|
||||
|
||||
CXX = clang++
|
||||
LINK = clang
|
||||
GLSLC = glslc
|
||||
CFLAGS = -Wall -DDBG -ggdb
|
||||
LDFLAGS =
|
||||
|
||||
SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp)
|
||||
OBJ_FILES = $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRC_FILES))
|
||||
OBJ_FILES_NOMAIN = $(filter-out $(OBJ_DIR)/main.o, $(OBJ_FILES)) # Object files without main.c.
|
||||
SHADER_FILES = $(wildcard $(SHADER_DIR)/*)
|
||||
|
||||
RESETCOLOR = \033[0m
|
||||
WHITE = $(RESETCOLOR)\033[37m
|
||||
WHITE_BOLD = $(RESETCOLOR)\033[37;1m
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
release: clean
|
||||
release: CFLAGS = -Wall -O2
|
||||
release: $(TARGET)
|
||||
|
||||
run: $(TARGET)
|
||||
@ echo -e "$(WHITE_BOLD)Running... $(RESETCOLOR)./$(TARGET)"
|
||||
@ ./$(TARGET)
|
||||
|
||||
# Compile project sources.
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(INC_DIR)/%.hpp
|
||||
@ mkdir -p $(OBJ_DIR)
|
||||
@ echo -e "$(WHITE_BOLD)Compiling $(WHITE)$<$(WHITE_BOLD)... $(RESETCOLOR)$(CXX) $(CFLAGS) -c $< -o $@"
|
||||
@ $(CXX) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# Compile vertex shaders.
|
||||
$(SPV_DIR)/%-vert.spv: $(SHADER_DIR)/%.vert
|
||||
@ mkdir -p $(SPV_DIR)
|
||||
@ echo -e "$(WHITE_BOLD)Compiling vertex shader $(WHITE)$<$(WHITE_BOLD)... $(RESETCOLOR)$(GLSLC) $< -o $@"
|
||||
@ $(GLSLC) $< -o $@
|
||||
|
||||
# Compile fragment shaders.
|
||||
$(SPV_DIR)/%-frag.spv: $(SHADER_DIR)/%.frag
|
||||
@ mkdir -p $(SPV_DIR)
|
||||
@ echo -e "$(WHITE_BOLD)Compiling fragment shader $(WHITE)$<$(WHITE_BOLD)... $(RESETCOLOR)$(GLSLC) $< -o $@"
|
||||
@ $(GLSLC) $< -o $@
|
||||
|
||||
# Link to final binary.
|
||||
$(TARGET): $(OBJ_FILES)
|
||||
@ echo -e "$(WHITE_BOLD)Linking $(WHITE)$(TARGET)$(WHITE_BOLD)...$(RESETCOLOR) $(LINK) -o $(TARGET) $(OBJ_FILES) $(LDFLAGS)"
|
||||
@ $(LINK) -o $(TARGET) $(OBJ_FILES) $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
@ echo -e "$(WHITE_BOLD)Cleaning up...$(WHITE) $(OBJ_DIR)/*.o $(TARGET) $(SPV_DIR)/*.spv $(RESETCOLOR)"
|
||||
@ rm -rf $(OBJ_DIR)/*.o $(TARGET) $(SPV_DIR)/*.spv
|
||||
|
||||
.PHONY: all clean nocolor release run
|
10
res/shaders/test.frag
Normal file
10
res/shaders/test.frag
Normal file
@ -0,0 +1,10 @@
|
||||
// Simple triangle fragment shader.
|
||||
#version 450
|
||||
|
||||
layout(location = 0) in vec3 fragColor;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
outColor = vec4(fragColor, 1.0);
|
||||
}
|
21
res/shaders/test.vert
Normal file
21
res/shaders/test.vert
Normal file
@ -0,0 +1,21 @@
|
||||
// Simple triangle vertex shader.
|
||||
#version 450
|
||||
|
||||
layout(location = 0) out vec3 fragColor;
|
||||
|
||||
vec2 positions[3] = vec2[](
|
||||
vec2(0.0, -0.5),
|
||||
vec2(0.5, 0.5),
|
||||
vec2(-0.5, 0.5)
|
||||
);
|
||||
|
||||
vec3 colors[3] = vec3[](
|
||||
vec3(1.0, 0.0, 0.0),
|
||||
vec3(0.0, 1.0, 0.0),
|
||||
vec3(0.0, 0.0, 1.0)
|
||||
);
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
|
||||
fragColor = colors[gl_VertexIndex];
|
||||
}
|
0
src/include/main.hpp
Normal file
0
src/include/main.hpp
Normal file
7
src/main.cpp
Normal file
7
src/main.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
printf("Hello, world!\n");
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user