Compare commits
3 commits
ae236efe2b
...
5bcb4cfdd3
Author | SHA1 | Date | |
---|---|---|---|
5bcb4cfdd3 | |||
5748e0a496 | |||
a88aa739b1 |
7 changed files with 97 additions and 29 deletions
48
.drone.yml
48
.drone.yml
|
@ -32,8 +32,43 @@ steps:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit ${has_fomatting_issues}
|
exit ${has_fomatting_issues}
|
||||||
---
|
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: unit tests
|
||||||
|
clone:
|
||||||
|
recursive: true
|
||||||
|
submodule_update_remote: true
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- main
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: unit tests
|
||||||
|
image: unit_tests:latest
|
||||||
|
pull: if-not-exists
|
||||||
|
commands:
|
||||||
|
- |
|
||||||
|
git submodule update --init --recursive
|
||||||
|
|
||||||
|
conan build . \
|
||||||
|
-c tools.system.package_manager:mode=install \
|
||||||
|
-s build_type=Release \
|
||||||
|
-o enable_static_analysis=False \
|
||||||
|
-o enable_tests=True \
|
||||||
|
--build=missing
|
||||||
|
|
||||||
|
find ./build \
|
||||||
|
-type f \
|
||||||
|
-name '*_tests' \
|
||||||
|
-executable \
|
||||||
|
-exec sh -c \
|
||||||
|
'{}' \
|
||||||
|
\;
|
||||||
|
|
||||||
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: static analysis
|
name: static analysis
|
||||||
|
@ -51,5 +86,12 @@ steps:
|
||||||
pull: if-not-exists
|
pull: if-not-exists
|
||||||
privileged: true
|
privileged: true
|
||||||
commands:
|
commands:
|
||||||
- git submodule update --init --recursive
|
- |
|
||||||
- conan build . -s build_type=Release -o enable_static_analysis=True --build=missing
|
git submodule update --init --recursive
|
||||||
|
|
||||||
|
conan build . \
|
||||||
|
-c tools.system.package_manager:mode=install \
|
||||||
|
-s build_type=Release \
|
||||||
|
-o enable_static_analysis=True \
|
||||||
|
-o enable_tests=True \
|
||||||
|
--build=missing
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace lt {
|
||||||
|
|
||||||
//==================== CONSTANT_BUFFER ====================//
|
//==================== CONSTANT_BUFFER ====================//
|
||||||
glConstantBuffer::glConstantBuffer(ConstantBufferIndex index, unsigned int size)
|
glConstantBuffer::glConstantBuffer(ConstantBufferIndex index, unsigned int size)
|
||||||
: m_buffer_id(NULL)
|
: m_buffer_id()
|
||||||
, m_index(static_cast<int>(index))
|
, m_index(static_cast<int>(index))
|
||||||
{
|
{
|
||||||
glCreateBuffers(1, &m_buffer_id);
|
glCreateBuffers(1, &m_buffer_id);
|
||||||
|
@ -40,7 +40,7 @@ void glConstantBuffer::un_map()
|
||||||
|
|
||||||
//==================== VERTEX_BUFFER ====================//
|
//==================== VERTEX_BUFFER ====================//
|
||||||
glVertexBuffer::glVertexBuffer(float *vertices, unsigned int stride, unsigned int count)
|
glVertexBuffer::glVertexBuffer(float *vertices, unsigned int stride, unsigned int count)
|
||||||
: m_buffer_id(NULL)
|
: m_buffer_id()
|
||||||
{
|
{
|
||||||
glCreateBuffers(1, &m_buffer_id);
|
glCreateBuffers(1, &m_buffer_id);
|
||||||
glNamedBufferData(
|
glNamedBufferData(
|
||||||
|
@ -63,7 +63,7 @@ void glVertexBuffer::bind()
|
||||||
|
|
||||||
void glVertexBuffer::un_bind()
|
void glVertexBuffer::un_bind()
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, NULL);
|
glBindBuffer(GL_ARRAY_BUFFER, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto glVertexBuffer::map() -> void *
|
auto glVertexBuffer::map() -> void *
|
||||||
|
@ -78,7 +78,7 @@ void glVertexBuffer::un_map()
|
||||||
//==================== VERTEX_BUFFER ====================//
|
//==================== VERTEX_BUFFER ====================//
|
||||||
|
|
||||||
//==================== INDEX_BUFFER ====================//
|
//==================== INDEX_BUFFER ====================//
|
||||||
glIndexBuffer::glIndexBuffer(unsigned int *indices, unsigned int count): m_buffer_id(NULL)
|
glIndexBuffer::glIndexBuffer(unsigned int *indices, unsigned int count): m_buffer_id()
|
||||||
{
|
{
|
||||||
// generate indices if not provided
|
// generate indices if not provided
|
||||||
auto hasIndices = !!indices;
|
auto hasIndices = !!indices;
|
||||||
|
@ -132,7 +132,7 @@ void glIndexBuffer::bind()
|
||||||
|
|
||||||
void glIndexBuffer::un_bind()
|
void glIndexBuffer::un_bind()
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, NULL);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, {});
|
||||||
}
|
}
|
||||||
//==================== INDEX_BUFFER ====================//
|
//==================== INDEX_BUFFER ====================//
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ namespace lt {
|
||||||
|
|
||||||
glFramebuffer::glFramebuffer(const FramebufferSpecification &specification)
|
glFramebuffer::glFramebuffer(const FramebufferSpecification &specification)
|
||||||
: m_specification(specification)
|
: m_specification(specification)
|
||||||
, m_buffer_id(NULL)
|
, m_buffer_id()
|
||||||
, m_color_attachment_id(NULL)
|
, m_color_attachment_id()
|
||||||
, m_depth_stencil_attachment_id(NULL)
|
, m_depth_stencil_attachment_id()
|
||||||
{
|
{
|
||||||
resize({ specification.width, specification.height });
|
resize({ specification.width, specification.height });
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ void glFramebuffer::resize(const glm::uvec2 &size)
|
||||||
GL_RGBA8,
|
GL_RGBA8,
|
||||||
m_specification.width,
|
m_specification.width,
|
||||||
m_specification.height,
|
m_specification.height,
|
||||||
NULL,
|
{},
|
||||||
GL_RGBA,
|
GL_RGBA,
|
||||||
GL_UNSIGNED_BYTE,
|
GL_UNSIGNED_BYTE,
|
||||||
nullptr
|
nullptr
|
||||||
|
@ -74,17 +74,6 @@ void glFramebuffer::resize(const glm::uvec2 &size)
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
// glTextureStorage2D(m_color_attachment_id, 0, GL_RGBA8, m_specification.width,
|
|
||||||
// m_specification.height);
|
|
||||||
|
|
||||||
// glCreateTextures(GL_TEXTURE_2D, 1, &m_depth_stencil_attachment_id);
|
|
||||||
// glBindTexture(GL_TEXTURE_2D, m_depth_stencil_attachment_id);
|
|
||||||
// glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, m_specification.width,
|
|
||||||
// m_specification.height, NULL, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr);
|
|
||||||
// // glTextureStorage2D(m_depth_stencil_attachment_id, 0, GL_DEPTH24_STENCIL8,
|
|
||||||
// m_specification.width, m_specification.height); glFramebufferTexture2D(GL_FRAMEBUFFER,
|
|
||||||
// GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_depth_stencil_attachment_id, 0);
|
|
||||||
|
|
||||||
ensure(
|
ensure(
|
||||||
(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE),
|
(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE),
|
||||||
"Framebuffer is incomplete"
|
"Framebuffer is incomplete"
|
||||||
|
|
|
@ -33,7 +33,7 @@ void glRenderCommand::draw_indexed(unsigned int count)
|
||||||
|
|
||||||
void glRenderCommand::default_target_framebuffer()
|
void glRenderCommand::default_target_framebuffer()
|
||||||
{
|
{
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, NULL);
|
glBindFramebuffer(GL_FRAMEBUFFER, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void glRenderCommand::set_viewport(
|
void glRenderCommand::set_viewport(
|
||||||
|
|
|
@ -56,7 +56,7 @@ void glShader::bind()
|
||||||
|
|
||||||
void glShader::un_bind()
|
void glShader::un_bind()
|
||||||
{
|
{
|
||||||
glUseProgram(NULL);
|
glUseProgram({});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto glShader::compile_shader(const std::string &source, Shader::Stage stage) -> unsigned int
|
auto glShader::compile_shader(const std::string &source, Shader::Stage stage) -> unsigned int
|
||||||
|
@ -67,7 +67,7 @@ auto glShader::compile_shader(const std::string &source, Shader::Stage stage) ->
|
||||||
stage == Shader::Stage::vertex ? GL_VERTEX_SHADER :
|
stage == Shader::Stage::vertex ? GL_VERTEX_SHADER :
|
||||||
stage == Shader::Stage::pixel ? GL_FRAGMENT_SHADER :
|
stage == Shader::Stage::pixel ? GL_FRAGMENT_SHADER :
|
||||||
stage == Shader::Stage::geometry ? GL_GEOMETRY_SHADER :
|
stage == Shader::Stage::geometry ? GL_GEOMETRY_SHADER :
|
||||||
NULL
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
// compile
|
// compile
|
||||||
|
@ -91,7 +91,7 @@ auto glShader::compile_shader(const std::string &source, Shader::Stage stage) ->
|
||||||
errorLog
|
errorLog
|
||||||
);
|
);
|
||||||
|
|
||||||
return NULL;
|
return {};
|
||||||
}
|
}
|
||||||
#define LIGHT_OPENGL_ENABLE_SHADER_INFO_LOG
|
#define LIGHT_OPENGL_ENABLE_SHADER_INFO_LOG
|
||||||
#ifdef LIGHT_OPENGL_ENABLE_SHADER_INFO_LOG
|
#ifdef LIGHT_OPENGL_ENABLE_SHADER_INFO_LOG
|
||||||
|
|
|
@ -9,7 +9,7 @@ glVertexLayout::glVertexLayout(
|
||||||
const Ref<VertexBuffer> &buffer,
|
const Ref<VertexBuffer> &buffer,
|
||||||
const std::vector<std::pair<std::string, VertexElementType>> &elements
|
const std::vector<std::pair<std::string, VertexElementType>> &elements
|
||||||
)
|
)
|
||||||
: m_array_id(NULL)
|
: m_array_id()
|
||||||
{
|
{
|
||||||
// check
|
// check
|
||||||
ensure(
|
ensure(
|
||||||
|
@ -65,7 +65,7 @@ void glVertexLayout::bind()
|
||||||
|
|
||||||
void glVertexLayout::un_bind()
|
void glVertexLayout::un_bind()
|
||||||
{
|
{
|
||||||
glBindVertexArray(NULL);
|
glBindVertexArray({});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto glVertexLayout::get_element_desc(VertexElementType type, unsigned int offset)
|
auto glVertexLayout::get_element_desc(VertexElementType type, unsigned int offset)
|
||||||
|
|
37
tools/ci/images/unit_tests/Dockerfile
Normal file
37
tools/ci/images/unit_tests/Dockerfile
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
bash \
|
||||||
|
clang \
|
||||||
|
llvm \
|
||||||
|
cmake \
|
||||||
|
git \
|
||||||
|
make \
|
||||||
|
g++ \
|
||||||
|
python3 \
|
||||||
|
py3-pip \
|
||||||
|
mesa-dev \
|
||||||
|
mesa-gl \
|
||||||
|
pkgconf
|
||||||
|
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir --break-system-packages conan gitpython \
|
||||||
|
&& conan profile detect
|
||||||
|
|
||||||
|
RUN clang --version \
|
||||||
|
&& conan --version \
|
||||||
|
&& pip --version \
|
||||||
|
&& cmake --version \
|
||||||
|
&& clang --version
|
||||||
|
|
||||||
|
|
||||||
|
RUN git clone 'https://git.light7734.com/light7734/light.git' --recursive \
|
||||||
|
&& cd light \
|
||||||
|
&& conan install . \
|
||||||
|
-s build_type=Debug \
|
||||||
|
-c tools.system.package_manager:mode=install \
|
||||||
|
--build=missing \
|
||||||
|
&& conan install . \
|
||||||
|
-s build_type=Release \
|
||||||
|
-c tools.system.package_manager:mode=install \
|
||||||
|
--build=missing
|
Loading…
Add table
Reference in a new issue