Открыть боковую панель
6yntar05
BebraCraft
Коммиты
102cd35d
Не подтверждена
Коммит
102cd35d
создал
Мар 08, 2023
по автору
6yntar05
Просмотр файлов
rpi staging commit
владелец
1175b68f
Изменения
6
Скрыть пробелы
Построчно
Рядом
README.md
Просмотр файла @
102cd35d
# BebraCraft
S
tudents laboratory work. OpenGL C++ Minecraft (not)clone
# BebraCraft
(RaspberryPI branch)
S
eems layout didnt work on opengl 2.1, but mesa still compilling this shader even with errors

## Installation
###
Archlinux
-
`sudo
pacman -S sdl2 glew glm stb
`
-
`
# and glfw-x11 or
gl
f
w-
wayland
`
###
Debian/Ubuntu/RpiOS/...
-
`sudo
apt update # && sudo apt upgrade
`
-
`
sudo apt install build-essential cmake extra-cmake-modules libopengl-dev libglx-dev libglu1-mesa-dev libglm-dev lib
gl
e
w-
dev glew-utils libsdl2-dev libstb-dev
`
## Building
-
`git clone https://github.com/6yntar05/BebraCraft`
-
`git clone https://github.com/6yntar05/BebraCraft
--branch raspberrypi
`
-
`mkdir build; cd build`
-
`cmake ..; cmake --build ./ -j${nproc}`
-
`./BebraEngine`
\ Нет новой строки в конце файла
Screenshot.png
Просмотр заменённого файла @
1175b68f
Просмотр файла @
102cd35d
536,0 КБ
|
W:
|
H:
356,2 КБ
|
W:
|
H:
2-up
Swipe
Onion skin
res/shaders/block.frag
Просмотр файла @
102cd35d
/*#version 330 core
#extension GL_ARB_explicit_attrib_location : require
// Textures
in vec2 TexCoord;
flat in int vertexID;
uniform sampler2D front;
uniform sampler2D back;
uniform sampler2D up;
uniform sampler2D down;
uniform sampler2D left;
uniform sampler2D right;
// Raw data
in vec3 Position;
in vec4 glPos;
// FX
float camShadEase = 5.0;
out vec4 color;
void main(void){
// Texture choosing (very cringe, i know)
if (vertexID < 6)
color = texture2D(front, TexCoord);
else if (vertexID < 12)
color = texture2D(back, TexCoord);
else if (vertexID < 18)
color = texture2D(up, TexCoord);
else if (vertexID < 24)
color = texture2D(down, TexCoord);
else if (vertexID < 30)
color = texture2D(left, TexCoord);
else if (vertexID < 36)
color = texture2D(right, TexCoord);
else // Out of range
color = vec4(1.0, 0.0, 1.0, 1.0);
// Camera shadow
if (color.w > 0.9)
color.xyz -= vec3(
( 1.0 - gl_FragCoord.z ) / camShadEase
);
}*/
#version 110
#extension GL_ARB_explicit_attrib_location : require
...
...
res/shaders/block.vs
Просмотр файла @
102cd35d
/*
#version 330 core
#extension GL_ARB_explicit_attrib_location : require
// VBO & Textures
layout (location = 0) in vec3 position;
layout (location = 1) in vec2 texCoord;
out vec3 Position;
out vec2 TexCoord;
flat out int vertexID;
// Positions
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
out vec4 glPos;
void main(void){
// Calculate position
gl_Position = projection * view * model * vec4(position, 1.0);
// Pass data to fragment shader
vertexID = gl_VertexID;
TexCoord = texCoord;
Position = position;
glPos = gl_Position;
}
*/
#version 110
#extension GL_ARB_explicit_attrib_location : require
...
...
src/engine/core.cpp
Просмотр файла @
102cd35d
...
...
@@ -19,10 +19,9 @@ namespace bebra {
}
SDL_GL_SetAttribute
(
SDL_GL_CONTEXT_PROFILE_MASK
,
SDL_GL_CONTEXT_PROFILE_CORE
);
SDL_GL_SetAttribute
(
SDL_GL_CONTEXT_MAJOR_VERSION
,
3
);
SDL_GL_SetAttribute
(
SDL_GL_CONTEXT_MINOR_VERSION
,
3
);
SDL_GL_SetAttribute
(
SDL_GL_CONTEXT_MAJOR_VERSION
,
2
);
SDL_GL_SetAttribute
(
SDL_GL_CONTEXT_MINOR_VERSION
,
1
);
/*
SDL_GL_SetAttribute
(
SDL_GL_RED_SIZE
,
8
);
SDL_GL_SetAttribute
(
SDL_GL_GREEN_SIZE
,
8
);
SDL_GL_SetAttribute
(
SDL_GL_BLUE_SIZE
,
8
);
...
...
@@ -30,7 +29,6 @@ namespace bebra {
SDL_GL_SetAttribute
(
SDL_GL_BUFFER_SIZE
,
32
);
SDL_GL_SetAttribute
(
SDL_GL_DOUBLEBUFFER
,
1
);
SDL_GL_SetAttribute
(
SDL_GL_DEPTH_SIZE
,
24
);
*/
SDL_GL_SetSwapInterval
(
0
);
...
...
@@ -38,16 +36,9 @@ namespace bebra {
}
SDL_Window
*
window
(
std
::
string
windowName
,
uint
windowWidth
,
uint
windowHeight
,
uint32_t
properties_graphic_api
)
{
SDL_GL_SetAttribute
(
SDL_GL_MULTISAMPLEBUFFERS
,
1
);
// It blows mesa zink
SDL_GL_SetAttribute
(
SDL_GL_MULTISAMPLESAMPLES
,
8
);
// It blows mesa zink
SDL_GL_SetAttribute
(
SDL_GL_ACCELERATED_VISUAL
,
1
);
SDL_SetHint
(
SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR
,
"1"
);
//Keep X11 compositor enable
SDL_SetHint
(
SDL_HINT_RENDER_SCALE_QUALITY
,
"1"
);
SDL_SetHint
(
SDL_HINT_RENDER_VSYNC
,
"0"
);
SDL_GL_SetSwapInterval
(
0
);
SDL_Window
*
window
=
SDL_CreateWindow
(
windowName
.
c_str
()
,
SDL_WINDOWPOS_CENTERED
,
SDL_WINDOWPOS_CENTERED
,
windowWidth
,
windowHeight
,
properties_graphic_api
|
SDL_RENDERER_ACCELERATED
);
windowWidth
,
windowHeight
,
properties_graphic_api
);
if
(
window
==
NULL
){
std
::
cout
<<
"ERROR::SDL::CREATE_WINDOW
\n
"
;
...
...
@@ -55,7 +46,6 @@ namespace bebra {
}
SDL_SetWindowGrab
(
window
,
SDL_TRUE
);
//SDL_SetWindowMouseGrab(window, SDL_TRUE);
SDL_SetRelativeMouseMode
(
SDL_TRUE
);
return
window
;
...
...
@@ -67,7 +57,7 @@ namespace bebra {
glewInit
();
glViewport
(
0
,
0
,
windowWidth
,
windowHeight
);
glEnable
(
GL_DEPTH_TEST
);
if
(
nicest
)
{
if
(
0
)
{
glEnable
(
GL_MULTISAMPLE
);
glHint
(
GL_LINE_SMOOTH_HINT
,
GL_NICEST
);
glHint
(
GL_POLYGON_SMOOTH_HINT
,
GL_NICEST
);
...
...
src/game/game.cpp
Просмотр файла @
102cd35d
...
...
@@ -46,17 +46,6 @@ int main() {
bebra
::
graphics
::
Shader
blockShader
(
"shaders/block.vs"
,
"shaders/block.frag"
);
bebra
::
graphics
::
Shader
skyboxShader
(
"shaders/skybox.vs"
,
"shaders/skybox.frag"
);
// Create skyBox (Keep it higher then other texture loadings, otherwise you get a flipped textures)
GLuint
VBOsky
,
VAOsky
;
bebra
::
graphics
::
loadObject
(
VBOsky
,
VAOsky
);
auto
skyBoxTexture
=
bebra
::
graphics
::
loadCubemap
(
{
"textures/skybox/ft.png"
,
"textures/skybox/bk.png"
,
"textures/skybox/up.png"
,
"textures/skybox/dn.png"
,
"textures/skybox/lf.png"
,
"textures/skybox/rt.png"
});
// Create blocks
GLuint
VBO
,
VAO
,
EBO
;
bebra
::
objects
::
block
::
loadObject
(
VBO
,
VAO
,
EBO
);
...
...
@@ -90,20 +79,6 @@ int main() {
// glClearColor(54.0/255.0, 58.0/255.0, 61.0/255.0, 1.0f);
glClearColor
(
15.0
/
255.0
,
15.0
/
255.0
,
15.0
/
255.0
,
1.0
f
);
{
// SkyBox render
glDepthMask
(
GL_FALSE
);
skyboxShader
.
Use
();
int
viewLocIdenpedent
=
glGetUniformLocation
(
skyboxShader
.
Program
,
"view"
);
glUniformMatrix4fv
(
viewLocIdenpedent
,
1
,
GL_FALSE
,
glm
::
value_ptr
(
viewIdenpedent
));
int
projectionLocIdenpedent
=
glGetUniformLocation
(
skyboxShader
.
Program
,
"projection"
);
glUniformMatrix4fv
(
projectionLocIdenpedent
,
1
,
GL_FALSE
,
glm
::
value_ptr
(
projection
));
glBindVertexArray
(
VAOsky
);
glBindTexture
(
GL_TEXTURE_CUBE_MAP
,
skyBoxTexture
);
glDrawArrays
(
GL_TRIANGLES
,
0
,
36
);
glDepthMask
(
GL_TRUE
);
}
{
// Chunks render
blockShader
.
Use
();
glBindVertexArray
(
VAO
);
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать