Kiss Engine » Forums » First version available
timothy.wright
Timothy Wright
72 posts
1 project
#11899 First version available
2 weeks, 3 days ago

https://github.com/ZenToad/kiss_engine

It's been a year since I started this thing. A lot of life stuff happened, but I finally found the time to dig in and get everything finished, uploaded, and documented (on the front page anyway).

If you have some time, head on over, try to build it, and let me know what is broken or confusing or anything else that might help make this easier to use.

The next example will be a 2D rogue-like similar to the Unity tutorial. This will add audio, animation, and drive all the new features.

Until next time...
Tim
mrmixer
Simon Anciaux
202 posts
#11901 First version available
2 weeks, 3 days ago

I didn't look at the code at all yet, but when I compile, I get lots of warnings and a few errors.

Does it require C99 ? I'm compiling with VS2012 so that's probably the problem.
timothy.wright
Timothy Wright
72 posts
1 project
#11902 First version available
2 weeks, 3 days ago

mrmixer:
I didn't look at the code at all yet, but when I compile, I get lots of warnings and a few errors.

Does it require C99 ? I'm compiling with VS2012 so that's probably the problem.


Lol - a "few" errors. It doesn't require C99, and in fact the Box2D is C++ so it should work. My Windows test uses vs2017.

I need to add some build instructions. The Box2D and glfw projects in the lib folder need to be built first, or linked to some already built static libs. glfw3.lib and Box2D.lib.

There is an example build.bat in the glfw that uses CMake, and the Box2d one uses premake. I wasn't able to compile the Box2D from the command line. I had to open the project in VS and convert it to my 10.0 SDK.

Thank you for trying to build it! The more stuff I can fix the better it will get.
mrmixer
Simon Anciaux
202 posts
#11910 First version available
2 weeks, 1 day ago

I added /wd4054 /wd4055 /wd4127 to the build options to remove void* to function pointers, function pointers to void*, conditional expression is constant warnings.

And those few changes:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// zen.h
typedef struct StaticArray {
    enum{ MAX=512 };
    int a[MAX];
    int n; // <- Removed the "= 0" Not working in C++ 03 (VS2012). StaticArray is never use in the code so it's not a problem.
    bool (*cmp)(int a, int b);
} StaticArray;

// zen_glfw.h
class ZenGlfw {

    ZenGlfw() {
        ZGLFW temp = { 0 }; // <-
        glfw = temp; // <- glfw = {0} Not working in C++ 03
        ptr = &glfw;
    }
    ...
}

// ufo_2d.cpp

int main(int, char **) {
    
    // glfw = {0}; Not working in C++ 03, already initialized to 0 in the global scope.
    ...
}


To compile box2d using only the command line:
1
2
3
4
5
6
7
8
9
@echo off
rem Batch file at the root of the box2d folder (same folder as premake5.lua).
rem You need to change the path for the xcopy at the end.
mkdir build
pushd build
cl /c /Tp ../Box2D/Box2D.h ../Box2D/Rope\b2Rope.cpp ../Box2D/Dynamics\b2Body.cpp ../Box2D/Dynamics\b2ContactManager.cpp ../Box2D/Dynamics\b2Fixture.cpp ../Box2D/Dynamics\b2Island.cpp ../Box2D/Dynamics\b2World.cpp ../Box2D/Dynamics\b2WorldCallbacks.cpp ../Box2D/Dynamics\Contacts\b2ChainAndCircleContact.cpp ../Box2D/Dynamics\Contacts\b2ChainAndPolygonContact.cpp ../Box2D/Dynamics\Contacts\b2CircleContact.cpp ../Box2D/Dynamics\Contacts\b2Contact.cpp ../Box2D/Dynamics\Contacts\b2ContactSolver.cpp ../Box2D/Dynamics\Contacts\b2EdgeAndCircleContact.cpp ../Box2D/Dynamics\Contacts\b2EdgeAndPolygonContact.cpp ../Box2D/Dynamics\Contacts\b2PolygonAndCircleContact.cpp ../Box2D/Dynamics\Contacts\b2PolygonContact.cpp ../Box2D/Dynamics\Joints\b2DistanceJoint.cpp ../Box2D/Dynamics\Joints\b2FrictionJoint.cpp ../Box2D/Dynamics\Joints\b2GearJoint.cpp ../Box2D/Dynamics\Joints\b2Joint.cpp ../Box2D/Dynamics\Joints\b2MotorJoint.cpp ../Box2D/Dynamics\Joints\b2MouseJoint.cpp ../Box2D/Dynamics\Joints\b2PrismaticJoint.cpp ../Box2D/Dynamics\Joints\b2PulleyJoint.cpp ../Box2D/Dynamics\Joints\b2RevoluteJoint.cpp ../Box2D/Dynamics\Joints\b2RopeJoint.cpp ../Box2D/Dynamics\Joints\b2WeldJoint.cpp ../Box2D/Dynamics\Joints\b2WheelJoint.cpp ../Box2D/Common\b2BlockAllocator.cpp ../Box2D/Common\b2Draw.cpp ../Box2D/Common\b2Math.cpp ../Box2D/Common\b2Settings.cpp ../Box2D/Common\b2StackAllocator.cpp ../Box2D/Common\b2Timer.cpp ../Box2D/Collision\b2BroadPhase.cpp ../Box2D/Collision\b2CollideCircle.cpp ../Box2D/Collision\b2CollideEdge.cpp ../Box2D/Collision\b2CollidePolygon.cpp ../Box2D/Collision\b2Collision.cpp ../Box2D/Collision\b2Distance.cpp ../Box2D/Collision\b2DynamicTree.cpp ../Box2D/Collision\b2TimeOfImpact.cpp ../Box2D/Collision\Shapes\b2ChainShape.cpp ../Box2D/Collision\Shapes\b2CircleShape.cpp ../Box2D/Collision\Shapes\b2EdgeShape.cpp ../Box2D/Collision\Shapes\b2PolygonShape.cpp /DNDEBUG /O2 /I../ /nologo /MD
lib *.obj /OUT:box2d.lib /NOLOGO
xcopy box2d.lib ..\..\bin /Y
popd


There was a glfw3.lib file in the repository so I tried to use it but I got this error (and I don't have the time now):
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
imgui_draw.cpp
Generating Code...
Compiling...
glad.c
Generating Code...
Skipping... (no relevant changes detected)
imgui_demo.cpp
imgui.cpp
ufo_2d.cpp
MSVCRT.lib(MSVCR110.dll) : error LNK2005: sscanf already defined in glfw3.lib(context.obj)
glfw3.lib(init.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsprintf referenced in function vsnprintf
glfw3.lib(context.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsscanf referenced in function _vsscanf_l
ufo_2d.exe : fatal error LNK1120: 2 unresolved externals


For an engine that is following the KISS principle there is a lot of overhead just to compile it.
timothy.wright
Timothy Wright
72 posts
1 project
#11911 First version available
2 weeks, 1 day ago

Thank you for the help. I knew that getting this to build would be the hard part. I am working on a premake build script that hopefully will fix a lot of these issues.

I will continue to fix stuff.
Thanks again.
timothy.wright
Timothy Wright
72 posts
1 project
#11914 First version available
2 weeks, 1 day ago

mrmixer:

For an engine that is following the KISS principle there is a lot of overhead just to compile it.


I look at this as a great chance to learn about portable C/C++ code. If building it is the only problem I'll have that would be amazing.

^-^
mrmixer
Simon Anciaux
202 posts
#11917 First version available
2 weeks, 1 day ago

The problem for me is more that I would prefer not to have to install separate build tools or build libraries. The cpp errors were simple and caused by me using an old-ish version of the compiler. A simple "Requirements" field on the download page would help though.

Anyway I made a batch file to compile glfw.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
@echo off

rem From src/glfw_config.h.in:
rem Define this to 1 if building GLFW for X11
rem _GLFW_X11
rem Define this to 1 if building GLFW for Win32
rem _GLFW_WIN32
rem Define this to 1 if building GLFW for Cocoa
rem _GLFW_COCOA
rem Define this to 1 if building GLFW for Wayland
rem _GLFW_WAYLAND
rem Define this to 1 if building GLFW for Mir
rem _GLFW_MIR

rem Define this to 1 if building as a shared library / dynamic library / DLL
rem _GLFW_BUILD_DLL
rem Define this to 1 to use Vulkan loader linked statically into application
rem _GLFW_VULKAN_STATIC

rem Define this to 1 to force use of high-performance GPU on hybrid systems
rem _GLFW_USE_HYBRID_HPG

rem Define this to 1 if the Xxf86vm X11 extension is available
rem _GLFW_HAS_XF86VM

rem Define this to 1 if glfwInit should change the current directory
rem _GLFW_USE_CHDIR
rem Define this to 1 if glfwCreateWindow should populate the menu bar
rem _GLFW_USE_MENUBAR
rem Define this to 1 if windows should use full resolution on Retina displays
rem _GLFW_USE_RETINA

mkdir build
pushd build
echo #define _GLFW_WIN32 1 > ../src/glfw_config.h
echo #define _GLFW_USE_HYBRID_HPG 1 >> ../src/glfw_config.h
echo #define _GLFW_USE_RETINA 1 >> ../src/glfw_config.h
cl /c /Tp ../src/internal.h /Tp ../src/glfw_config.h /Tp ../include/GLFW/glfw3.h /Tp../include/GLFW/glfw3native.h ../src/context.c ../src/init.c ../src/input.c ../src/monitor.c ../src/vulkan.c ../src/window.c ../src/win32_init.c ../src/win32_joystick.c ../src/win32_monitor.c ../src/win32_time.c ../src/win32_tls.c ../src/win32_window.c ../src/wgl_context.c ../src/egl_context.c /D_GLFW_USE_CONFIG_H /D_CRT_SECURE_NO_WARNINGS /O2 /nologo /Fm /MD
lib *.obj /OUT:glfw3.lib /NOLOGO
xcopy glfw3.lib ..\..\bin /Y
popd


Now ufo_2d is compiling. But an assert fires in imgui_draw.cpp at line 1282 (IM_ASSERT(font_offset >= 0); // font_offset is -1). To be continued...
timothy.wright
Timothy Wright
72 posts
1 project
#11918 First version available
2 weeks, 1 day ago

There is a custom font xamples/ufo_2d/res/PressStart2P.ttf

Pretty sure it's not in the right path. I haven't tackled resource bundling or anything like that yet. If you don't want another build tool (and I completely understand) then letting the user know this depends on GLFW and Box2D would be enough?

*note - Box2d just switched to premake5 from CMake, and I helped get the Linux version working, so I figured that might be a good way to go.

Does anyone know of any other HM projects that just work from source that I can study?
mrmixer
Simon Anciaux
202 posts
#11924 First version available
2 weeks ago

The problem was that the zip I downloaded from github had corrupted the font and texture files. It's now running, but the game freezes every few seconds. Here is a video (all freezes are from the game, not from the recording).

timothy.wright
Timothy Wright
72 posts
1 project
#11925 First version available
2 weeks ago

Thank you for getting this working.
Of course I've not seen any of those freezes. Time to add some more debugging output and log files. It isn't doing anything fancy, just plain OpenGL, a simple fixed time step, and a few Box2d calls.

What fun...

I wonder if it's some weird glfw thing?