Giter Club home page Giter Club logo

gameenginefromscratch's Introduction

Game Engine From Scratch

CircleCI Build Status Build status GitHub license

配合我的知乎专栏当中的系列文章《从零开始手敲次世代游戏引擎》所写的项目。

This project is written by me as the sample of My articles Hand-made Next-Gen Game Engine From Scratch

このプロジェクトは私の連載中のゼロから始める手作り次世代ゲームエンジンのサンプルソースである

Platform Support Status

  • Windows 10 / 11
  • MacOS Catalina - Monterey
  • Linux (Build test on Ubuntu 20.04 - 22.04 and CentOS 7)
  • FreeBSD (Not tested recently, build might fail)
  • Android (Not tested recently, build might fail)
  • WebAssembly (Emscripten, not tested recently, build might fail)
  • PlayStation 4 (Not continued, related source code not disclosed due to NDA)
  • PlayStation Vita (Not continued, related source code not disclosed due to NDA)

Graphic API Support Status

  • OpenGL
  • OpenGL ES (Not tested recently)
  • Metal2
  • DirectX 12 (On going)
  • Vulkan (On going)
  • GNM (Not disclosed due to NDA)

Physics

  • Bullet
  • My Physics (on going)

Scene Graph

  • OpenGEX
  • Collada (On the roadmap, not implemented yet)

Shading Language

  • HLSL, auto convert to GLSL/Metal Performance Shader

Texture Format

  • JPEG
  • PNG
  • TGA
  • HDR
  • DDS
  • BMP
  • PVR (BC1 - 7)
  • ASTC

High Performance / Parallel Computing

  • ISPC

Dependencies

  • Windows -- Windows Platform SDK -- Visual Studio or Clang -- CMake

  • MacOS -- Xcode -- Xcode command line tools -- MacPorts -- CMake

  • Linux -- gcc/g++ or clang/clang++ -- uuid-dev libx11-dev libx11-xcb-dev libgl1-mesa-dev libnss3-dev libxss-dev libatk1.0-dev libatk-bridge2.0-dev libglib2.0-dev libpango1.0-dev libxi-dev libfontconfig1-dev libnspr4-dev libxcomposite-dev libxcursor-dev libxrender-dev libxtst-dev libxrandr-dev libgio2.0-cil-dev libdbus-1-dev libasound2-dev libcups2-dev libncurses5-dev

  • Android -- Android SDK -- Android NDK

Build Steps

Windows

scripts\build_crossguid
scripts\build_opengex
scripts\build_zlib
scripts\build_bullet
scripts\build_cef
scripts\build_glslangValidator
scripts\build_spirvcross
scripts\build_imgui
scripts\build_libispc-texcomp
scripts\build

MacOS & Linux

./scripts/build_crossguid.sh
./scripts/build_opengex.sh
./scripts/build_bullet.sh
./scripts/build_cef.sh
./scripts/build_glslangValidator.sh
./scripts/build_spirvcross.sh
./scripts/build_imgui
./scripts/build_libispc-texcomp
./scripts/build-ninja.sh

Cook Materials

Windows

scripts\cook_material

Mac)S & Linux

./scripts/cook_material

gameenginefromscratch's People

Contributors

netwarm007 avatar sijieshen avatar xzrunner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gameenginefromscratch's Issues

Would a Rust port for this project be possible at all?

Dear Team,
This is an amazing project.
Thanks for putting so much effort to make this tutorial a reality in the first place!

I like this project so I want to follow along and create my own game at the end but I am really afraid of using C++ as the dev language because I do think I can do memory management correctly.

In the mean time I am also aware that not all existing eco system is there for Rust so I wanted to know what is the most important support needed if I were to port this project from C++ to Rust?

I do not know either language well so my question is probably too much of an ask.
Can someone please with enough context either help me find the minimum set of work needs to be done or help me ask the right question?

Thanks in advance, really appreciate the work here, I am already grateful for what the project has been offering at the moment.

有个有疑问的地方

void* My::MemoryManager::Allocate(size_t size, size_t alignment)
{
uint8_t* p;
size += alignment;
Allocator* pAlloc = LookUpAllocator(size);
if (pAlloc)
p = reinterpret_cast<uint8_t*>(pAlloc->Allocate());
else
p = reinterpret_cast<uint8_t*>(malloc(size));

p = reinterpret_cast<uint8_t*>(ALIGN(reinterpret_cast<size_t>(p), alignment));

return static_cast<void*>(p);

}

您好,这里有个地方我有点疑问,不知道对不对。
p = reinterpret_cast<uint8_t*>(ALIGN(reinterpret_cast<size_t>(p), alignment));
这里对Allocator返回出来的指针可能会做对齐的移动操作,但是在free的时候没有看到移回之前的位置,不知道会不会有问题

Linux下直接编译失败,感觉是ispc没有编译,但是看您专栏好像也没提到

Scanning dependencies of target GeomMathLib
[ 1%] Building DivByElement
No such file or directory
Framework/GeomMath/ispc/CMakeFiles/GeomMathLib.dir/build.make:138: recipe for target 'Framework/GeomMath/ispc/DivByElement.o' failed
make[2]: *** [Framework/GeomMath/ispc/DivByElement.o] Error 1
CMakeFiles/Makefile2:1197: recipe for target 'Framework/GeomMath/ispc/CMakeFiles/GeomMathLib.dir/all' failed
make[1]: *** [Framework/GeomMath/ispc/CMakeFiles/GeomMathLib.dir/all] Error 2
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2

请问Xcode下如何构建?

把代码全部拉取下来后,执行./build-xcode.sh,每次都报错:

...
-- CMAKE_RANLIB: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib
-- CMAKE_CROSSCOMPILING: FALSE
-- TARGET_ARCH: x86_64
-- XG_LIBRARY: XG_LIBRARY-NOTFOUND
-- OPENDDL_LIBRARY: OPENDDL_LIBRARY-NOTFOUND
-- OPENGEX_LIBRARY: OPENGEX_LIBRARY-NOTFOUND
-- BULLET_COLLISION_LIBRARY: BULLET_COLLISION_LIBRARY-NOTFOUND
-- BULLET_DYNAMICS_LIBRARY: BULLET_DYNAMICS_LIBRARY-NOTFOUND
-- BULLET_LINEARMATH_LIBRARY: BULLET_LINEARMATH_LIBRARY-NOTFOUND
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
BULLET_COLLISION_LIBRARY
linked by target "BulletPhysics" in directory /Users/jackjhu/Project/Recent/GameEngineFromScratch/Physics/Bullet
BULLET_DYNAMICS_LIBRARY
linked by target "BulletPhysics" in directory /Users/jackjhu/Project/Recent/GameEngineFromScratch/Physics/Bullet
BULLET_LINEARMATH_LIBRARY
linked by target "BulletPhysics" in directory /Users/jackjhu/Project/Recent/GameEngineFromScratch/Physics/Bullet
OPENDDL_LIBRARY
linked by target "Common" in directory /Users/jackjhu/Project/Recent/GameEngineFromScratch/Framework/Common
OPENGEX_LIBRARY
linked by target "Common" in directory /Users/jackjhu/Project/Recent/GameEngineFromScratch/Framework/Common
XG_LIBRARY
linked by target "Common" in directory /Users/jackjhu/Project/Recent/GameEngineFromScratch/Framework/Common

-- Configuring incomplete, errors occurred!
See also "/Users/jackjhu/Project/Recent/GameEngineFromScratch/build/CMakeFiles/CMakeOutput.log".
See also "/Users/jackjhu/Project/Recent/GameEngineFromScratch/build/CMakeFiles/CMakeError.log".

关于知乎第12篇

只显示出了窗口,没有图案。
Log:
Matching fbconfig 0, visual ID 0x41: SAMPLE_BUFFERS = 0, SAMPLES = 0 Matching fbconfig 1, visual ID 0x124: SAMPLE_BUFFERS = 0, SAMPLES = 0 Matching fbconfig 2, visual ID 0x126: SAMPLE_BUFFERS = 0, SAMPLES = 0 Matching fbconfig 3, visual ID 0x12a: SAMPLE_BUFFERS = 0, SAMPLES = 0 Matching fbconfig 4, visual ID 0x12e: SAMPLE_BUFFERS = 1, SAMPLES = 4 Matching fbconfig 5, visual ID 0x136: SAMPLE_BUFFERS = 1, SAMPLES = 4 Matching fbconfig 6, visual ID 0x12f: SAMPLE_BUFFERS = 1, SAMPLES = 8 Matching fbconfig 7, visual ID 0x137: SAMPLE_BUFFERS = 1, SAMPLES = 8 Matching fbconfig 8, visual ID 0x127: SAMPLE_BUFFERS = 0, SAMPLES = 0 Matching fbconfig 9, visual ID 0x12b: SAMPLE_BUFFERS = 0, SAMPLES = 0 Matching fbconfig 10, visual ID 0xbc: SAMPLE_BUFFERS = 0, SAMPLES = 0 Matching fbconfig 11, visual ID 0x15a: SAMPLE_BUFFERS = 0, SAMPLES = 0 Matching fbconfig 12, visual ID 0x15c: SAMPLE_BUFFERS = 0, SAMPLES = 0 Matching fbconfig 13, visual ID 0x15d: SAMPLE_BUFFERS = 0, SAMPLES = 0 Chosen visual ID = 0x12f Creating context Created GL 3.0 context Direct GLX rendering context obtained

image

Hello大佬, git拉取项目报错了,麻烦有空的时候看一下

Cloning into 'GameEngineFromScratch'...
remote: Enumerating objects: 28327, done.
remote: Counting objects: 100% (361/361), done.
remote: Compressing objects: 100% (165/165), done.
remote: Total 28327 (delta 183), reused 354 (delta 177), pack-reused 27966
Receiving objects: 100% (28327/28327), 465.69 MiB | 24.15 MiB/s, done.
Resolving deltas: 100% (15410/15410), done.
Updating files: 100% (975/975), done.
Downloading Asset/Fonts/NotoSansCJKsc-VF.ttf (36 MB)
Error downloading object: Asset/Fonts/NotoSansCJKsc-VF.ttf (990c807): Smudge error: Error downloading Asset/Fonts/NotoSansCJKsc-VF.ttf (990c807e79c25662a5a9ecf7f971baeb2bf2eab9a559e5ecf15cdfdb8561d21f): batch response: This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access.

Errors logged to 'E:\source\GameEngineFromScratch.git\lfs\logs\20221128T193110.7088739.log'.
Use git lfs logs last to view the log.
error: external filter 'git-lfs filter-process' failed
fatal: Asset/Fonts/NotoSansCJKsc-VF.ttf: smudge filter lfs failed
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

Ubuntu部分编译失败和OpenGl运行崩溃

感谢您的代码,学习受教了。
1.我在windows平台编译通过了,也可以运行。
2.在Ubuntu 20下,也安装各种库后,只有最后的最后,Test/BulletTest.cpp 的25行
btCollisionShape* groundShape = **new btStaticPlaneShape(btVector3(0.0f, 1.0f, 0.0f), 1);**编译失败,提示:undefined reference to `btStaticPlaneShape::btStaticPlaneShape(btVector3 const&, double)'
collect2: error: ld returned 1 exit status
另外一个工程:Game/Billiard也是同样的错误。
我看了一下大约是部分内容引用float,部分引用了double,不知怎么修改。
3.我临时屏掉这两个工程,编译通过,我用Viewer工程进行测试,发现运行时Initialize崩溃,崩到:GameEngineFromScratch/Platform/Linux/OpenGLApplication.cpp的156行,int default_screen = DefaultScreen(m_pDisplay);,我也分析了一下,这个时间理论上m_pDisplay = nullptr,理论上强转到结构体,的确会崩。
下面是堆栈,刚启动,比较简单,我这边必现的。
My::OpenGLApplication::CreateMainWindow(My::OpenGLApplication * const this) (/GameEngineFromScratch/Platform/Linux/OpenGLApplication.cpp:156)
My::BaseApplication::Initialize(My::BaseApplication * const this) (/GameEngineFromScratch/Framework/Common/BaseApplication.cpp:20)
My::OpenGLApplication::Initialize(My::OpenGLApplication * const this) (/GameEngineFromScratch/Platform/Linux/OpenGLApplication.cpp:50)
main(int argc, char ** argv) (/GameEngineFromScratch/Framework/Common/main.cpp:52)

谢谢,祝好。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.