浏览代码

Start working on the header-only part of the framework.

This implies creating a trimmed down branch that contains almost
nothing. It will then be usable by projects that do not need the
complex build system, and by the engine itself as a submodule from
the same repository.
wip/core-clipp
Sam Hocevar 4 年前
父节点
当前提交
155ae65a4e
共有 100 个文件被更改,包括 74 次插入14731 次删除
  1. +0
    -147
      .gitignore
  2. +2
    -21
      .gitmodules
  3. +0
    -35
      .travis.yml
  4. +0
    -28
      .vscode/c_cpp_properties.json
  5. +0
    -37
      .ycm_extra_conf.py
  6. +0
    -16
      Makefile.am
  7. +1
    -10
      README.md
  8. +0
    -38
      TODO
  9. +71
    -0
      TODO.md
  10. +0
    -3
      binaries/Makefile.am
  11. +0
    -136
      bootstrap
  12. +0
    -15
      build.config
  13. +0
    -21
      build/Makefile.am
  14. +0
    -22
      build/android/AndroidManifest.xml
  15. +0
    -68
      build/android/LolActivity.java
  16. 二进制
      build/android/icon.png
  17. +0
    -4
      build/android/strings.xml
  18. +0
    -124
      build/autotools/common.am
  19. +0
    -287
      build/autotools/m4/lol-conf.m4
  20. +0
    -63
      build/autotools/m4/lol-ffmpeg.m4
  21. +0
    -156
      build/autotools/m4/lol-gl.m4
  22. +0
    -59
      build/autotools/m4/lol-misc.m4
  23. +0
    -126
      build/autotools/m4/lol-sdl.m4
  24. +0
    -55
      build/autotools/m4/lol-subproject.m4
  25. +0
    -22
      build/bitten/config-trunk-private.xml
  26. +0
    -22
      build/bitten/config-trunk-public.xml
  27. +0
    -10
      build/build-android
  28. +0
    -10
      build/build-html
  29. +0
    -10
      build/build-js
  30. +0
    -11
      build/build-linux
  31. +0
    -10
      build/build-mingw
  32. +0
    -10
      build/build-mingw64
  33. +0
    -10
      build/build-raspi
  34. +0
    -209
      build/check-source.sh
  35. +0
    -344
      build/lol-build
  36. +0
    -10
      build/msbuild/lol-bullet.props
  37. +0
    -10
      build/msbuild/lol-core.props
  38. +0
    -10
      build/msbuild/lol-lua.props
  39. +0
    -61
      build/msbuild/lol.config.props
  40. +0
    -20
      build/msbuild/lol.props
  41. +0
    -123
      build/msbuild/lol.rules.props
  42. +0
    -176
      build/msbuild/lol.vars.props
  43. +0
    -37
      build/msbuild/lolfx.props
  44. +0
    -80
      build/msbuild/lolfx.targets
  45. +0
    -79
      build/msbuild/lolfx.xml
  46. +0
    -240
      build/run-bitten.sh
  47. +0
    -280
      configure.ac
  48. +0
    -68
      doc/Makefile.am
  49. +0
    -2469
      doc/doxygen.cfg.in
  50. +0
    -1180
      doc/doxygen.css
  51. +0
    -2
      doc/footer.html
  52. +0
    -1
      doc/grammar/README
  53. +0
    -328
      doc/grammar/easymesh-parser.y
  54. +0
    -208
      doc/grammar/easymesh-scanner.l
  55. +0
    -1311
      doc/grammar/lolfx-parser.y
  56. +0
    -799
      doc/grammar/lolfx-scanner.l
  57. +0
    -8
      doc/header.html
  58. +0
    -10
      doc/lolengine.1
  59. +0
    -18
      doc/lolengine.dox
  60. +0
    -48
      doc/samples/Makefile.am
  61. +0
    -127
      doc/samples/benchmark/half.cpp
  62. +0
    -82
      doc/samples/benchmark/real.cpp
  63. +0
    -91
      doc/samples/benchmark/vector.cpp
  64. +0
    -57
      doc/samples/benchsuite.cpp
  65. +0
    -69
      doc/samples/benchsuite.vcxproj
  66. +0
    -39
      doc/samples/bluenoise.cpp
  67. +0
    -754
      doc/samples/btphystest.cpp
  68. +0
    -115
      doc/samples/btphystest.h
  69. +0
    -88
      doc/samples/btphystest.vcxproj
  70. +0
    -54
      doc/samples/btphystest.vcxproj.filters
  71. 二进制
      doc/samples/data/CatsSheet.png
  72. 二进制
      doc/samples/data/CatsSheet.xcf
  73. +0
    -110
      doc/samples/data/mesh-buffer.txt
  74. +0
    -15
      doc/samples/data/meshviewer.easymesh.lua
  75. +0
    -19
      doc/samples/data/meshviewer.init.lua
  76. 二进制
      doc/samples/data/test-texture.png
  77. +0
    -115
      doc/samples/front_camera_sprite.lolfx
  78. +0
    -15
      doc/samples/math/Makefile.am
  79. +0
    -55
      doc/samples/math/pi.cpp
  80. +0
    -31
      doc/samples/math/poly.cpp
  81. +0
    -446
      doc/samples/physicobject.h
  82. +0
    -241
      doc/samples/physics/bulletcharactercontroller.cpp
  83. +0
    -285
      doc/samples/physics/bulletcharactercontroller.h
  84. +0
    -150
      doc/samples/physics/easycharactercontroller.cpp
  85. +0
    -108
      doc/samples/physics/easycharactercontroller.h
  86. +0
    -43
      doc/samples/physics/easyconstraint.cpp
  87. +0
    -184
      doc/samples/physics/easyconstraint.h
  88. +0
    -430
      doc/samples/physics/easyphysics.cpp
  89. +0
    -159
      doc/samples/physics/easyphysics.h
  90. +0
    -47
      doc/samples/physics/lolbtphysicsintegration.h
  91. +0
    -425
      doc/samples/physics/lolphysics.h
  92. +0
    -11
      doc/samples/sandbox/Makefile.am
  93. +0
    -44
      doc/samples/sandbox/sample.cpp
  94. +0
    -147
      doc/samples/simplex.cpp
  95. +0
    -46
      doc/shitlolbotsays.txt
  96. +0
    -88
      doc/tutorial/01_triangle.cpp
  97. +0
    -35
      doc/tutorial/01_triangle.lolfx
  98. +0
    -69
      doc/tutorial/01_triangle.vcxproj
  99. +0
    -190
      doc/tutorial/02_cube.cpp
  100. +0
    -32
      doc/tutorial/02_cube.lolfx

+ 0
- 147
.gitignore 查看文件

@@ -1,150 +1,3 @@
# Autotools cruft
*.o
*.lo
*.a
*.la
*.exe
*.so
*.elf
*.self
*.nexe
*.userprefs
*.usertasks
*.pidb
.auto
.libs
.deps
.dirstamp
.*.androiddir
.*.androidstamp
Makefile
Makefile.in
aclocal.m4
build/autotools/m4/libtool.m4
build/autotools/m4/ltoptions.m4
build/autotools/m4/ltsugar.m4
build/autotools/m4/ltversion.m4
build/autotools/m4/lt~obsolete.m4
autom4te.cache
config.h.in
config.h
config.log
config.status
configure
libtool
stamp-*
*-stamp
lolengine-*.tar.*
test-suite.log
# Personal stuff
patch-*.diff
# Debugging cruft
core
!core/
core.*
vgcore.*
callgrind.out.*
perf.data*
*.gcda
*.gcno
# Editor cruft
.*.swp
*~
.ycm_extra_conf.pyc
# Visual Studio cruft
.vs
*.vcxproj.user
*.csproj.user
binaries/*Debug
binaries/*Release
build/*.VC.VC.opendb
build/*.VC.db
build/*.sdf
build/*.suo
build/*.opensdf
build/visualstudio/ipch
build/visualstudio/*.log
build/visualstudio/*.XGD
# Emscripten cruft
a.out*
doc/samples/*.html
doc/samples/*.wasm
doc/samples/*.wasm.*
doc/samples/*.js
doc/samples/*/*.html
doc/samples/*/*.wasm
doc/samples/*/*.wasm.*
doc/samples/*/*.js
doc/tutorial/*.html
doc/tutorial/*.wasm
doc/tutorial/*.wasm.*
doc/tutorial/*.js
src/t/*.html
src/t/*.wasm
src/t/*.wasm.*
src/t/*.js
# ReSharper cruft
_ReSharper.*
# Do not exclude anything in external. There is no way to do this recursively
# but the nesting below is currently one level more than our current max.
!external/*
!external/*/*
!external/*/*/*
!external/*/*/*/*
!external/*/*/*/*/*
!external/*/*/*/*/*/*
!external/*/*/*/*/*/*/*
# Our private repositories
src/private
# Our binaries
demos/lol.js/lol.js
doc/samples/benchsuite
doc/samples/bluenoise
doc/samples/btphystest
doc/samples/sandbox/sample
doc/samples/math/pi
doc/samples/math/poly
doc/samples/simplex
doc/tutorial/01_triangle
doc/tutorial/02_cube
doc/tutorial/03_noise
doc/tutorial/04_texture
doc/tutorial/05_easymesh
doc/tutorial/06_sprite
doc/tutorial/07_input
doc/tutorial/08_fbo
doc/tutorial/09_sound
doc/tutorial/11_fractal
doc/tutorial/12_voronoi
doc/tutorial/13_shader_builder
doc/tutorial/14_lua
doc/tutorial/15_gui
doc/tutorial/16_movie
doc/tutorial/16_movie.gif
tools/make-font
# Our data
doc/doxygen.cfg
doc/doxygen.log
doc/html
doc/latex
doc/man
# Our test suites
build/check-*.log
build/check-*.trs
src/t/test-base
src/t/test-math
src/t/test-sys
src/t/test-image
src/t/test-entity
src/t/test-*.log
src/t/test-*.trs
# Our tools
tools/vslol/bin/*/*
tools/vslol/obj/*/*
tools/vslol/obj/*/*/*
tools/vslol/obj/*/*/*
tools/vslol/*.suo
# ImGui cruft
imgui.ini
# Built stuff
binaries/

+ 2
- 21
.gitmodules 查看文件

@@ -1,27 +1,8 @@
[submodule "external"]
path = external
url = ../../lolengine/ext-binaries.git
branch = master
[submodule "imgui"]
path = src/3rdparty/imgui
url = ../../lolengine/ext-imgui.git
branch = master
[submodule "bullet3"]
path = src/3rdparty/bullet3
url = ../../lolengine/ext-bullet3.git
branch = lol
[submodule "lua"]
path = src/3rdparty/lua
url = ../../lolengine/ext-lua.git
branch = lol
[submodule "pegtl"]
path = src/3rdparty/pegtl
path = include/lol/3rdparty/pegtl
url = ../../lolengine/ext-pegtl.git
branch = lol
[submodule "mingw-std-threads"]
path = src/3rdparty/mingw-std-threads
path = include/lol/3rdparty/mingw-std-threads
url = ../../lolengine/ext-mingw-std-threads.git
branch = master
[submodule "cpp-httplib"]
path = src/3rdparty/cpp-httplib
url = ../../lolengine/ext-cpp-httplib.git

+ 0
- 35
.travis.yml 查看文件

@@ -1,35 +0,0 @@
sudo: required
dist: trusty
language: c++
env: VERBOSE=1

addons:
apt:
packages:
- build-essential
- automake
- autoconf
- libtool
- pkg-config
- libsdl2-dev
- libsdl2-image-dev
- libsdl2-mixer-dev
- libglew-dev
# this can fix clang compilation
- clang-3.8
- libc++-dev

before_install:
# - .travis/before_install.sh
- if [ "$CC" = "clang" ]; then export CC="clang-3.8"; fi
- if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.8 -stdlib=libc++"; fi
- ./bootstrap

os:
- linux
# - osx

compiler:
- gcc
- clang


+ 0
- 28
.vscode/c_cpp_properties.json 查看文件

@@ -1,28 +0,0 @@
{
"configurations": [
{
"name": "Mac",
"includePath": ["/usr/include"],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
},
{
"name": "Linux",
"includePath": ["/usr/include"],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
},
{
"name": "Win32",
"includePath": ["c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include", "src"],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
}
]
}

+ 0
- 37
.ycm_extra_conf.py 查看文件

@@ -1,37 +0,0 @@

# The following line might come handy in ~/.vimrc:
# let g:ycm_extra_conf_globlist = ['~/lol/*','!~/*']

import os
import ycm_core

flags = [
'-xc++',
'-std=c++11',
# Engine includes
'-I.',
'-I..',
'-Isrc',
# System includes
'-I/usr/include/SDL2',
'-I/usr/include/GL',
'-I/usr/include/libdrm',
'-I/usr/include/libpng15',
# Macros
'-DHAVE_CONFIG_H',
'-D_REENTRANT',
]

def FlagsForFile(filename, **kwargs):

extension = os.path.splitext(filename)[1]
if extension not in [ '.c', '.cpp', '.h' ]:
return None

final_flags = flags

return {
'flags': final_flags,
'do_cache': True
}


+ 0
- 16
Makefile.am 查看文件

@@ -1,16 +0,0 @@

include $(top_srcdir)/build/autotools/common.am

# Put "people" at the end because they're more likely to break builds.
SUBDIRS = build src tools doc
DIST_SUBDIRS = $(SUBDIRS) binaries

EXTRA_DIST += bootstrap COPYING TODO \
.gitignore .gitattributes .gitmodules \
.travis.yml lol.sln build.config
AUTOMAKE_OPTIONS = dist-bzip2
ACLOCAL_AMFLAGS = -I build/autotools/m4

test: lolcheck
check: lolcheck


+ 1
- 10
README.md 查看文件

@@ -1,13 +1,4 @@

# About

A collection of scripts and C++ code to make games, demos and tools.

## Notes

### Nintendo Switch support

That code is private, it needs to be activated manually:

> `git clone https://github.com/samhocevar/lol-nx.git src/private/nx`

The header-only part of the Lol Engine framework.

+ 0
- 38
TODO 查看文件

@@ -1,38 +0,0 @@

Large projects
----------------

- Scripting support.
- Lua is supported, check if CPP -> LUA ticking/updating is supported
- Lua needs more than one-shot-script
- Lua classes may still be a little bit obfuscated, a class renaming/revamping may be needed
- Tiler and Forge are almost the same, try to refactor them.

Engine classes
----------------

Scene:
- Remove uses of g_scene
- Maybe make Camera a world object instead?

Image:
- Handle pitch in SDL codec (and all others, actually)
- Fix the Floyd-Steinberg code in pixels.cpp
- Add gamma handling in pixels.cpp
- Port remaining libpipi files from src/image/todo/:

Thread:
- Solidify "Threaded-update" objects support
- AsyncImageLoader: "File modified update" is supported by OS, it should use that instead of doing it by hand
- Thread usage may still be a little bit awkward

Debug:
- Add history support. And layer-like sub-section ? (with imGUI support ?)
- ::DrawSetup* is fricking awkward, even I (Touky) get confused by it
Shaders:
- Creation/Setup is still a bit complicated, should look into making it more readable (compatibility with lua ?)
Frame Buffer Object:
- They were working at some point , check if it's still the case, but are still very awkward to use

+ 71
- 0
TODO.md 查看文件

@@ -0,0 +1,71 @@

## `lol` headers to keep

src/lol/base/map.h (map utilities)
src/lol/base/types.h (vec_t shortcuts eg. vec2, ivec2, u8vec3 etc.)
src/lol/math/bigint.h
src/lol/math/constants.h
src/lol/math/functions.h
src/lol/math/half.h (needs half.cpp)
src/lol/math/matrix.h
src/lol/math/noise/*
src/lol/math/ops.h
src/lol/math/polynomial.h
src/lol/math/rand.h
src/lol/math/real.h (needs real.cpp)
src/lol/math/transform.h (needs matrix.cpp and transform.cpp)
src/lol/math/vector.h (needs vector.cpp)
src/lol/sys/thread.h
src/lol/sys/timer.h


## other headers to keep

tools/lolunit/lolunit.h

## headers we could clean up and keep

src/lol/algorithm/aabb_tree.h
src/lol/base/assert.h (could be useful)
src/lol/base/avl_tree.h
src/lol/base/string.h (string utilities)
src/lol/image/color.h
src/lol/image/pixel.h (but is it useful?)
src/lol/math/arraynd.h (but do we really want to keep it?)
src/lol/math/geometry.h
src/lol/math/interp.h (but what is it?)

src/numeric.h


## headers to keep in the engine

src/lol/algorithm/portal.h
src/lol/audio/*
src/lol/base/features.h (a bit dangerous to ship)
src/lol/base/log.h
src/lol/debug/*
src/lol/engine.h
src/lol/engine/*
src/lol/engine-internal.h
src/lol/extras.h
src/lol/gpu/*
src/lol/image/image.h
src/lol/image/movie.h
src/lol/image/resource.h
src/lol/legacy.h
src/lol/lua.h
src/lol/net/http.h
src/lol/public.h
src/lol/sys/file.h
src/lol/sys/getopt.h
src/lol/sys/init.h


## headers to remove one day

src/lol/algorithm/sort.h (there’s plenty of stuff in libc++)
src/lol/base/array.h (use std::vector)
src/lol/base/enum.h (can’t see the point)
src/lol/base/tuple.h (use std::tuple)


+ 0
- 3
binaries/Makefile.am 查看文件

@@ -1,3 +0,0 @@

# Everything in this directory is temporary.


+ 0
- 136
bootstrap 查看文件

@@ -1,136 +0,0 @@
#! /bin/sh

# bootstrap: generic bootstrap/autogen.sh script for autotools projects
#
# Copyright (c) 2002-2010 Sam Hocevar <sam@hocevar.net>
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://www.wtfpl.net/ for more details.
#
# The latest version of this script can be found at the following place:
# http://caca.zoy.org/wiki/build

# Die if an error occurs
set -e

# Guess whether we are using configure.ac or configure.in
if test -f configure.ac; then
conffile="configure.ac"
elif test -f configure.in; then
conffile="configure.in"
else
echo "$0: could not find configure.ac or configure.in"
exit 1
fi

# Check for needed features
auxdir="`sed -ne 's/^[ \t]*A._CONFIG_AUX_DIR *([[ ]*\([^] )]*\).*/\1/p' $conffile`"
pkgconfig="`grep '^[ \t]*PKG_PROG_PKG_CONFIG' $conffile >/dev/null 2>&1 && echo yes || echo no`"
libtool="`grep '^[ \t]*A._PROG_LIBTOOL' $conffile >/dev/null 2>&1 && echo yes || echo no`"
makefile="`[ -f Makefile.am ] && echo yes || echo no`"
aclocalflags="`sed -ne 's/^[ \t]*ACLOCAL_AMFLAGS[ \t]*=//p' Makefile.am 2>/dev/null || :`"

# Check for automake
amvers="no"
for v in "" "-1.15" "-1.14" "-1.13" "-1.12" "-1.11"; do
if automake${v} --version > /dev/null 2>&1; then
amvers=${v}
break
fi
done

if test "$amvers" = "no"; then
echo "$0: automake not found"
exit 1
fi

# Check for autoconf
acvers="no"
for v in "" "259" "253"; do
if autoconf${v} --version >/dev/null 2>&1; then
acvers="${v}"
break
fi
done

if test "$acvers" = "no"; then
echo "$0: autoconf not found"
exit 1
fi

# Check for libtool
if test "$libtool" = "yes"; then
libtoolize="no"
if glibtoolize --version >/dev/null 2>&1; then
libtoolize="glibtoolize"
else
for v in "16" "15" "" "14"; do
if libtoolize${v} --version >/dev/null 2>&1; then
libtoolize="libtoolize${v}"
break
fi
done
fi

if test "$libtoolize" = "no"; then
echo "$0: libtool not found"
exit 1
fi
fi

# Check for pkg-config
if test "$pkgconfig" = "yes"; then
if ! pkg-config --version >/dev/null 2>&1; then
echo "$0: pkg-config not found"
exit 1
fi
fi

# Remove old cruft
for x in aclocal.m4 configure config.guess config.log config.sub config.cache config.h.in config.h compile libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 ltmain.sh libtool ltconfig missing mkinstalldirs depcomp install-sh; do rm -f $x autotools/$x; if test -n "$auxdir"; then rm -f "$auxdir/$x"; fi; done
rm -Rf autom4te.cache
if test -n "$auxdir"; then
if test ! -d "$auxdir"; then
mkdir "$auxdir"
fi
aclocalflags="-I $auxdir -I . ${aclocalflags}"
fi

# Honour M4PATH because sometimes M4 doesn't
save_IFS=$IFS
IFS=:
tmp="$M4PATH"
for x in $tmp; do
if test -n "$x"; then
aclocalflags="-I $x ${aclocalflags}"
fi
done
IFS=$save_IFS

# Explain what we are doing from now
set -x

# Bootstrap package
if test "$libtool" = "yes"; then
${libtoolize} --copy --force
if test -n "$auxdir" -a ! "$auxdir" = "." -a -f "ltmain.sh"; then
echo "$0: working around a minor libtool issue"
mv ltmain.sh "$auxdir/"
fi
fi

aclocal${amvers} ${aclocalflags}
autoconf${acvers}
autoheader${acvers}
if test "$makefile" = "yes"; then
#add --include-deps if you want to bootstrap with any other compiler than gcc
#automake${amvers} --add-missing --copy --include-deps
automake${amvers} --foreign --add-missing --copy
fi

# Remove cruft that we no longer want
rm -Rf autom4te.cache


+ 0
- 15
build.config 查看文件

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Configuration">

<!-- yes/no values -->
<enable_bullet>yes</enable_bullet>
<enable_ffmpeg>yes</enable_ffmpeg>
<enable_gl>yes</enable_gl>
<enable_sdl>yes</enable_sdl>
<enable_imlib2>yes</enable_imlib2>
<!-- not available yet -->
<enable_png>no</enable_png>

</PropertyGroup>
</Project>

+ 0
- 21
build/Makefile.am 查看文件

@@ -1,21 +0,0 @@

include $(top_srcdir)/build/autotools/common.am

# FIXME: can't include "Lol (vs2015).sln" because of the spaces

EXTRA_DIST += lol-build \
check-source.sh run-bitten.sh \
build-linux build-mingw build-mingw64 \
build-android build-html \
\
msbuild/lolfx.targets \
msbuild/lolfx.xml \
msbuild/lolfx.props \
msbuild/lol.config.props \
msbuild/lol.vars.props \
msbuild/lol.rules.props \
\
autotools/common.am

TESTS = check-source.sh


+ 0
- 22
build/android/AndroidManifest.xml 查看文件

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.lolengine.lol_@PROGRAM@"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name"
android:icon="@drawable/icon">
<activity android:name="net.lolengine.LolActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"
android:label="@string/app_name"
android:launchMode="singleTask">
<meta-data android:name="android.app.lib_name"
android:value="@PROGRAM@" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="13" />
</manifest>

+ 0
- 68
build/android/LolActivity.java 查看文件

@@ -1,68 +0,0 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//

package net.lolengine;

import android.app.NativeActivity; /* NativeActivity */
import android.os.Bundle; /* Bundle */

import android.content.res.AssetManager; /* getAssets() */
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class LolActivity extends NativeActivity
{
static
{
/* Need to preload libstlport_shared.so somewhere; also need to
* preload lib@PROGRAM@.so otherwise nativeInit() can’t be found. */
System.loadLibrary("stlport_shared");
System.loadLibrary("@PROGRAM@");
}

@Override
protected void onCreate(Bundle saved_instance)
{
super.onCreate(saved_instance);
m_assets = getAssets();
}

private AssetManager m_assets;

/*
* Bitmap loading helpers
*/

public Bitmap openImage(String name)
{
try
{
return BitmapFactory.decodeStream(m_assets.open(name));
}
catch (Exception e) { }
return null;
}

public int getWidth(Bitmap bmp) { return bmp.getWidth(); }
public int getHeight(Bitmap bmp) { return bmp.getHeight(); }

public void getPixels(Bitmap bmp, int[] pixels)
{
int w = bmp.getWidth();
int h = bmp.getHeight();
bmp.getPixels(pixels, 0, w, 0, 0, w, h);
}

public void closeImage(Bitmap bmp)
{
bmp.recycle();
}
}


二进制
build/android/icon.png 查看文件

之前 之后
宽度: 48  |  高度: 48  |  大小: 1.2 KiB

+ 0
- 4
build/android/strings.xml 查看文件

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">@PROGRAM@</string>
</resources>

+ 0
- 124
build/autotools/common.am 查看文件

@@ -1,124 +0,0 @@
# -*- coding: utf-8 -*-
# vi:syntax=python

#
# Define these variables from the beginning
#

CLEANFILES =
SUFFIXES =
EXTRA_DIST =
NULL =


#
# Miscellaneous rules
#

lol_recursive_rule = \
@if test -n "$(SUBDIRS)"; then for subdir in $(SUBDIRS); do \
if test "$$subdir" != "."; then \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $(patsubst %-recursive, %, $@)) || exit 1; \
fi; done; fi

bench: bench-recursive
bench-recursive:
$(lol_recursive_rule)

lolcheck: lolcheck-recursive
lolcheck-recursive:
$(lol_recursive_rule)

#
# Make tests verbose
# FIXME: this does not seem to work as documented
#

AM_TESTS_FD_REDIRECT = 9>&2


#
# .lolfx build rule
#

lolfx_gen = $(lolfx_gen_$(V))
lolfx_gen_ = $(lolfx_gen_$(AM_DEFAULT_VERBOSITY))
lolfx_gen_0 = @echo " LOLFX " $@;

SUFFIXES += .lolfx
.lolfx.o:
$(lolfx_gen)
$(AM_V_at)(echo "char const *"; \
echo "lolfx_resource_$(basename $(filter %.lolfx, $^))" | $(SED) 's/[^a-zA-Z0-9_]/_/g'; \
echo "="; \
$(SED) 's/"/\\"/g' $(filter %.lolfx, $^) | $(SED) 's/\([^\r]*\).*/"\1\\n"/'; \
echo ";") \
> $@.lolfx.cpp && \
$(CXXCOMPILE) -xc++ -c $@.lolfx.cpp -o $@ && \
exit=0 || exit=1; rm -f $@.lolfx.cpp ; exit "$$exit"

# Disable on the fly compilation because emscripten doesn't support it
# | $(CXXCOMPILE) -xc++ -c - -o $@


#
# Win32 rules
#

# This is here in case we forget to make clean after a Windows build
CLEANFILES += $(PROGRAMS:%$(EXEEXT)=%.exe) \
$(noinst_PROGRAMS:%$(EXEEXT)=%.exe)


#
# Emscripten rules
#

CLEANFILES += $(PROGRAMS:%$(EXEEXT)=%.data) \
$(noinst_PROGRAMS:%$(EXEEXT)=%.data)

#
# Android rules
#

all-local: all-local-android
clean-local: clean-local-android

if LOL_USE_ANDROID
all-local-android: $(foreach p, $(PROGRAMS:%$(EXEEXT)=%), .$(p).androidstamp)
.%.androidstamp: %$(EXEEXT)
$(eval p := $(^:%$(EXEEXT)=%))
$(eval d := .$(p).androiddir)
rm -rf "$(d)"
$(MKDIR_P) "$(d)" $(sort $(foreach f, $($(p)_DATA), "$(d)/assets/$(dir $(f))"))
$(foreach f, $($(p)_DATA), $(LN_S) "$(abs_srcdir)/$(f)" "$(d)/assets/$(f)" &&) true
$(SED) -e 's,@PROGRAM@,$(subst -,_,$(p)),' "$(lol_srcdir)/build/android/AndroidManifest.xml" > "$(d)/AndroidManifest.xml"
$(MKDIR_P) "$(d)/src/net/lolengine"
$(SED) -e 's,@PROGRAM@,$(subst -,_,$(p)),' "$(lol_srcdir)/build/android/LolActivity.java" > "$(d)/src/net/lolengine/LolActivity.java"
$(MKDIR_P) "$(d)/res/values"
$(SED) -e 's,@PROGRAM@,$(subst -,_,$(p)),' "$(lol_srcdir)/build/android/strings.xml" > "$(d)/res/values/strings.xml"
$(MKDIR_P) "$(d)/res/drawable"
cp "$(lol_srcdir)/build/android/icon.png" "$(d)/res/drawable/"
$(MKDIR_P) "$(d)/libs/armeabi"
$(LN_S) "$(abs_builddir)/$(p)$(EXEEXT)" "$(d)/libs/armeabi/lib$(p).so"
android update project -t android-19 -n "$(p)" -p "$(d)"
ant debug -f "$(d)/build.xml"
touch $@
else
all-local-android:
endif

clean-local-android:
$(foreach p, $(PROGRAMS:%$(EXEEXT)=%), rm -rf ".$(p).androiddir";)
$(foreach p, $(PROGRAMS:%$(EXEEXT)=%), rm -f ".$(p).androidstamp";)


#
# Additional rules
#

EXTRA_DIST += $(foreach p, $(PROGRAMS), $($(p)_DATA))


.PHONY: bench lolcheck


+ 0
- 287
build/autotools/m4/lol-conf.m4 查看文件

@@ -1,287 +0,0 @@
dnl
dnl Lol Engine
dnl
dnl Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net>
dnl
dnl Lol Engine is free software. It comes without any warranty, to
dnl the extent permitted by applicable law. You can redistribute it
dnl and/or modify it under the terms of the Do What the Fuck You Want
dnl to Public License, Version 2, as published by the WTFPL Task Force.
dnl See http://www.wtfpl.net/ for more details.
dnl


# LOL_AC_INIT()
# ---------------------
AC_DEFUN([LOL_AC_INIT], [

dnl Silent rules by default
AM_SILENT_RULES([yes])

dnl C++11 and later mode. Checked early so that we don't run into surprises.
version_flag=''
LOL_TRY_CXXFLAGS(-std=c++0x, [version_flag='-std=c++0x'])
LOL_TRY_CXXFLAGS(-std=c++11, [version_flag='-std=c++11'])
LOL_TRY_CXXFLAGS(-std=c++14, [version_flag='-std=c++14'])
LOL_TRY_CXXFLAGS(-std=c++17, [version_flag='-std=c++17'])
AM_CXXFLAGS="${AM_CXXFLAGS} ${version_flag}"
CXXFLAGS="${CXXFLAGS} ${version_flag}"

AC_LANG_PUSH(C++)
AC_MSG_CHECKING(for C++11 enum class support)
AC_TRY_LINK([], [enum class Foo : int { Bar, Baz };],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
AC_MSG_ERROR([[C++ compiler does not support C++11 enum classes]])])
AC_LANG_POP(C++)

]) # LOL_AC_INIT


# LOL_AC_CHECK()
# ---------------------
AC_DEFUN([LOL_AC_CHECK], [

dnl Check that the C++ compiler really works
AC_LANG_PUSH(C++)
AC_MSG_CHECKING(for a fully working C++ compiler)
AC_TRY_LINK([], [],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
AC_MSG_ERROR([[C++ compiler cannot link executables]])])
AC_LANG_POP(C++)


AC_C_CONST
AC_C_INLINE

dnl
dnl Common libraries
dnl

AC_CHECK_LIB(m, sin, LIBS="${LIBS} -lm")
AC_CHECK_LIB(pthread, main, LIBS="${LIBS} -lpthread")


dnl
dnl Activate some header-only libraries
dnl

LOL_CFLAGS="$LOL_CFLAGS -I\$(lol_srcdir)/src/3rdparty/cpp-httplib"
LOL_CFLAGS="$LOL_CFLAGS -I\$(lol_srcdir)/src/3rdparty/pegtl/include"
LOL_CFLAGS="$LOL_CFLAGS -I\$(lol_srcdir)/src/3rdparty/imgui"

dnl Use system-provided getopt_long?
ac_cv_have_getopt_long="no"
AC_CHECK_HEADERS(getopt.h unistd.h)
AC_CHECK_FUNCS(getopt_long,
[ac_cv_have_getopt_long="yes"],
[AC_CHECK_LIB(gnugetopt, getopt_long,
[ac_cv_have_getopt_long="yes"
LIBS="${LIBS} -lgnugetopt"])])
if test "$ac_cv_have_getopt_long" != "no"; then
AC_DEFINE(HAVE_GETOPT_LONG, 1, Define to 1 if you have the ‘getopt_long’ function.)
fi


dnl Use OpenSSL?
ac_cv_have_openssl=no
AC_CHECK_LIB(ssl, OPENSSL_init_ssl,
[ac_cv_have_openssl=yes
AC_DEFINE(LOL_USE_OPENSSL, 1, Define to 1 to use OpenSSL)
LOL_LIBS="${LOL_LIBS} -lssl -lcrypto"])
AM_CONDITIONAL(LOL_USE_OPENSSL, test "${ac_cv_have_openssl}" = "yes")


dnl Use Bullet Physics?
ac_cv_my_have_bullet="no"
if test "${enable_bullet}" != "no"; then
PKG_CHECK_MODULES(BULLET, bullet, [ac_cv_my_have_bullet="yes"], [:])
if test "${ac_cv_my_have_bullet}" != "no"; then
AC_DEFINE(LOL_USE_BULLET, 1, Define to 1 to use Bullet Physics)
LOL_CFLAGS="${LOL_CFLAGS} ${BULLET_CFLAGS}"
LOL_LIBS="${LOL_LIBS} ${BULLET_LIBS}"
fi
fi
AM_CONDITIONAL(LOL_USE_BULLET, test "${ac_cv_my_have_bullet}" = "yes")


dnl Use Android? FIXME: super hacks!
ac_cv_my_have_android="no"
AC_CHECK_LIB(log, __android_log_vprint,
[ac_cv_my_have_android="yes"
LOL_LIBS="${LOL_LIBS} -llog -landroid -module -lEGL -lGLESv2"])
AM_CONDITIONAL(LOL_USE_ANDROID, test "${ac_cv_my_have_android}" != "no")


dnl Use EGL? (autodetect unless GL is disabled)
ac_cv_my_have_egl="no"
if test "${enable_gl}" != "no"; then
PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
if test "${ac_cv_my_have_egl}" != "no"; then
AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl)
EGL_LIBS="${EGL_LIBS} -lX11"
fi
AC_CHECK_HEADERS(EGL/egl.h,
[AC_CHECK_LIB(EGL, eglInitialize,
[ac_cv_my_have_egl="yes"
AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl)
EGL_LIBS="-lEGL"])
dnl Raspberry Pi is different, check for it with extra libs; also we
dnl look for a different function to bypass autoconf caching
AC_CHECK_LIB(EGL, eglGetDisplay,
[ac_cv_my_have_egl="yes"
AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl)
EGL_LIBS="-lEGL -lvcos -lvchiq_arm -lbcm_host -lGLESv2"],
[:],
[-lvcos -lvchiq_arm -lbcm_host -lGLESv2])])
fi
AM_CONDITIONAL(LOL_USE_EGL, test "${ac_cv_my_have_egl}" != "no")


dnl Use libpng? (replacement for SDL_image)
ac_cv_my_have_libpng="no"
if test "${enable_png}" != "no"; then
PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
if test "${ac_cv_my_have_libpng}" != "no"; then
AC_DEFINE(LOL_USE_LIBPNG, 1, Define to 1 to use libpng)
fi
fi
AM_CONDITIONAL(LOL_USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")


dnl Use Imlib2?
ac_cv_my_have_imlib2="no"
if test "${enable_imlib2}" != "no"; then
PKG_CHECK_MODULES(IMLIB2, imlib2, [ac_cv_my_have_imlib2="yes"], [:])
if test "${ac_cv_my_have_imlib2}" != "no"; then
AC_DEFINE(LOL_USE_IMLIB2, 1, Define to 1 to use Imlib2)
LOL_CFLAGS="${LOL_CFLAGS} ${IMLIB2_CFLAGS}"
LOL_LIBS="${LOL_LIBS} ${IMLIB2_LIBS}"
fi
fi
AM_CONDITIONAL(LOL_USE_IMLIB2, test "${ac_cv_my_have_imlib2}" = "yes")


dnl Use Windows GDI+?
ac_cv_my_have_gdiplus="no"
AC_LANG_PUSH(C++)
AC_CHECK_HEADERS(gdiplus.h,
[ac_cv_my_have_gdiplus="yes"
LOL_LIBS="${LOL_LIBS} -lgdiplus"],
[ac_cv_my_have_gdiplus="no"],
[#include <algorithm>
using std::min;
using std::max;
#include <windows.h>])
AC_LANG_POP(C++)
if test "${ac_cv_my_have_gdiplus}" != "no"; then
AC_DEFINE(LOL_USE_GDIPLUS, 1, Define to 1 to use GDI+)
fi
AM_CONDITIONAL(LOL_USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")


dnl Are we building using MinGW?
LOL_TRY_CXXFLAGS(-mwindows -mwin32,
[AM_CXXFLAGS="${AM_CXXFLAGS} -mwindows -mwin32"
LOL_CFLAGS="${LOL_CFLAGS} -I\$(lol_srcdir)/src/3rdparty/mingw-std-threads"
LOL_CFLAGS="${LOL_CFLAGS} -D__STDC_FORMAT_MACROS"
LOL_LIBS="${LOL_LIBS} -uWinMain -u_WinMain@16"])


dnl Are we building using Emscripten?
ac_cv_my_have_emscripten="no"
AC_CHECK_HEADERS(emscripten.h,
[ac_cv_my_have_emscripten="yes"
AC_CHECK_HEADERS(emscripten/html5.h)
dnl XXX: activate this if memory heap is too small
#AM_CXXFLAGS="${AM_CXXFLAGS} -s ALLOW_MEMORY_GROWTH=1"
dnl See https://github.com/emscripten-core/emscripten/pull/7977 for more details
CPPFLAGS="${CPPFLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1"
dnl HACK: until emcc properly adds these to EMSDK_OPTS
CPPFLAGS="${CPPFLAGS} -U__i386__ -U__x86_64__ -U__i386 -U__x86_64 -Ui386 -Ux86_64"
CPPFLAGS="${CPPFLAGS} -U__SSE__ -U__SSE2__ -U__MMX__ -UX87_DOUBLE_ROUNDING"
CPPFLAGS="${CPPFLAGS} -UHAVE_GCC_ASM_FOR_X87 -U__STRICT_ANSI__ -U__CYGWIN__"])
AM_CONDITIONAL(LOL_USE_EMSCRIPTEN, test "${ac_cv_my_have_emscripten}" != "no")


dnl Are we on an OS X or iOS platform?
LOL_TRY_LDFLAGS(-framework Foundation,
[LOL_LIBS="${LOL_LIBS} -framework Foundation"])
LOL_TRY_LDFLAGS(-framework CoreGraphics,
[LOL_LIBS="${LOL_LIBS} -framework CoreGraphics"])
LOL_TRY_LDFLAGS(-framework CoreData,
[LOL_LIBS="${LOL_LIBS} -framework CoreData"])
LOL_TRY_LDFLAGS(-framework UIKit,
[LOL_LIBS="${LOL_LIBS} -framework UIKit"])


dnl Other complex checks
LOL_AC_CHECK_OPENGL()
LOL_AC_CHECK_SDL()
LOL_AC_CHECK_FFMPEG()


dnl Debug symbols
dnl We use --export-dynamic instead of -rdynamic because the latter causes
dnl emscripten to emit wasm even when html is asked…
LOL_TRY_LDFLAGS(--export-dynamic, [AM_LDFLAGS="${AM_LDFLAGS} --export-dynamic"])


dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
LOL_TRY_CXXFLAGS(-Wall, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wall"])
LOL_TRY_CXXFLAGS(-Wextra, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wextra"])
LOL_TRY_CXXFLAGS(-Wpointer-arith, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wpointer-arith"])
LOL_TRY_CXXFLAGS(-Wcast-align, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-align"])
LOL_TRY_CXXFLAGS(-Wcast-qual, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-qual"])
LOL_TRY_CXXFLAGS(-Wshadow, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wshadow"])
LOL_TRY_CXXFLAGS(-Wsign-compare, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wsign-compare"])
LOL_TRY_CXXFLAGS(-Wstrict-overflow=1, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wstrict-overflow=1"])

dnl Add these even though they're implicitly set, so that we can safely
dnl remove them from within a Makefile.
LOL_TRY_CXXFLAGS(-Wuninitialized, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wuninitialized"])
LOL_TRY_CXXFLAGS(-Wnarrowing, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wnarrowing"])
LOL_TRY_CXXFLAGS(-Wunused, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wunused"])
LOL_TRY_CXXFLAGS(-Wcast-align, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wcast-align"])
LOL_TRY_CXXFLAGS(-Wunused-parameter, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wunused-parameter"])
LOL_TRY_CXXFLAGS(-Wstrict-aliasing, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wstrict-aliasing"])
LOL_TRY_CXXFLAGS(-Wparentheses, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wparentheses"])
LOL_TRY_CXXFLAGS(-Wreorder, [AM_CXXFLAGS="${AM_CXXFLAGS} -Wreorder"])

dnl Disable these warnings because they're annoyingly verbose
LOL_TRY_CXXFLAGS(-Wno-psabi, [AM_CPPFLAGS="${AM_CPPFLAGS} -Wno-psabi"])

]) # LOL_AC_CHECK


# LOL_AC_FINI()
# ---------------------
AC_DEFUN([LOL_AC_FINI], [

dnl How to use the Lol Engine outside this tree
LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS $D3D_LIBS"
LOL_DEPS="${LOL_DEPS} \$(lol_builddir)/src/liblol-core.a"
LOL_LUA_DEPS="${LOL_LUA_DEPS} \$(lol_builddir)/src/3rdparty/liblol-lua.a"

dnl How to use the Lol Engine inside this tree
AM_CPPFLAGS="${AM_CPPFLAGS} -I\$(lol_srcdir)/src"
AM_CPPFLAGS="${AM_CPPFLAGS} -DLOL_CONFIG_SOURCESUBDIR=\\\"\$(subdir)\\\""
AM_CPPFLAGS="${AM_CPPFLAGS} ${LOL_CFLAGS}"
AM_LDFLAGS="${AM_LDFLAGS} ${LOL_DEPS}"
AM_LDFLAGS="${AM_LDFLAGS} ${LOL_LIBS}"

dnl Extra flags
AC_SUBST(LOL_CFLAGS)
AC_SUBST(LOL_LIBS)
AC_SUBST(LOL_DEPS)
AC_SUBST(LOL_LUA_DEPS)

AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_CPPFLAGS)
AC_SUBST(AM_CXXFLAGS)
AC_SUBST(AM_LDFLAGS)

]) # LOL_AC_FINI


+ 0
- 63
build/autotools/m4/lol-ffmpeg.m4 查看文件

@@ -1,63 +0,0 @@
dnl
dnl Lol Engine
dnl
dnl Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net>
dnl
dnl Lol Engine is free software. It comes without any warranty, to
dnl the extent permitted by applicable law. You can redistribute it
dnl and/or modify it under the terms of the Do What the Fuck You Want
dnl to Public License, Version 2, as published by the WTFPL Task Force.
dnl See http://www.wtfpl.net/ for more details.
dnl


# LOL_AC_CHECK_FFMPEG()
# ---------------------
AC_DEFUN([LOL_AC_CHECK_FFMPEG],
[
ac_cv_my_have_ffmpeg="no"
if test "${enable_ffmpeg}" != "no"; then
LOL_AC_CHECK_FFMPEG_INNER()
fi
AM_CONDITIONAL(LOL_USE_FFMPEG, test "${ac_cv_my_have_ffmpeg}" != "no")
])

# LOL_AC_CHECK_FFMPEG_INNER()
# ---------------------------
AC_DEFUN([LOL_AC_CHECK_FFMPEG_INNER],
[
ac_cv_my_have_ffmpeg="yes"
PKG_CHECK_MODULES([LIBAVCODEC], [libavcodec], [:], [ac_cv_my_have_ffmpeg=no])
PKG_CHECK_MODULES([LIBAVUTIL], [libavutil], [:], [ac_cv_my_have_ffmpeg=no])
PKG_CHECK_MODULES([LIBAVFORMAT], [libavformat], [:], [ac_cv_my_have_ffmpeg=no])
PKG_CHECK_MODULES([LIBSWSCALE], [libswscale], [:], [ac_cv_my_have_ffmpeg=no])
LOL_FFMPEG_EXTRA_LIBS=""
if test "${ac_cv_my_have_ffmpeg}" != "yes"; then
ac_cv_my_have_ffmpeg="yes"
AC_CHECK_HEADERS(libavcodec/avcodec.h, [:], [ac_cv_my_have_ffmpeg=no])
AC_CHECK_HEADERS(libavformat/avformat.h, [:], [ac_cv_my_have_ffmpeg=no])
AC_CHECK_HEADERS(libswscale/swscale.h, [:], [ac_cv_my_have_ffmpeg=no])
if test "${ac_cv_my_have_ffmpeg}" = "yes"; then
LIBAVCODEC_LIBS="-lavcodec"
LIBAVUTIL_LIBS="-lavutil"
LIBAVFORMAT_LIBS="-lavformat"
LIBSWSCALE_LIBS="-lswscale"
LIBSWRESAMPLE_LIBS="-lswresample"
dnl Required by avformat/network.c
AC_CHECK_LIB(ws2_32, main, LOL_FFMPEG_EXTRA_LIBS="${LOL_FFMPEG_EXTRA_LIBS} -lws2_32")
dnl Required by avformat/tls_schannel.c
AC_CHECK_LIB(secur32, main, LOL_FFMPEG_EXTRA_LIBS="${LOL_FFMPEG_EXTRA_LIBS} -lsecur32")
dnl Required by avutil/random_seed.c
AC_CHECK_LIB(bcrypt, main, LOL_FFMPEG_EXTRA_LIBS="${LOL_FFMPEG_EXTRA_LIBS} -lbcrypt")
dnl Required by avcodec/dxva2.c
AC_CHECK_LIB(ole32, main, LOL_FFMPEG_EXTRA_LIBS="${LOL_FFMPEG_EXTRA_LIBS} -lole32")
fi
fi
if test "${ac_cv_my_have_ffmpeg}" = "yes"; then
AC_DEFINE(LOL_USE_FFMPEG, 1, Define to 1 to use FFmpeg)
LOL_CFLAGS="${LOL_CFLAGS} ${LIBAVFORMAT_CFLAGS} ${LIBAVUTIL_CFLAGS} ${LIBAVCODEC_CFLAGS} ${LIBSWSCALE_CFLAGS}"
LOL_LIBS="${LOL_LIBS} ${LIBAVFORMAT_LIBS} ${LIBAVCODEC_LIBS} ${LIBAVUTIL_LIBS} ${LIBSWSCALE_LIBS} ${LIBSWRESAMPLE_LIBS} ${LOL_FFMPEG_EXTRA_LIBS}"
fi

]) # LOL_AC_CHECK_FFMPEG_INNER


+ 0
- 156
build/autotools/m4/lol-gl.m4 查看文件

@@ -1,156 +0,0 @@
dnl
dnl Lol Engine
dnl
dnl Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net>
dnl
dnl Lol Engine is free software. It comes without any warranty, to
dnl the extent permitted by applicable law. You can redistribute it
dnl and/or modify it under the terms of the Do What the Fuck You Want
dnl to Public License, Version 2, as published by the WTFPL Task Force.
dnl See http://www.wtfpl.net/ for more details.
dnl


# LOL_AC_CHECK_OPENGL()
# ---------------------
AC_DEFUN([LOL_AC_CHECK_OPENGL],
[
ac_cv_my_have_gl="no"
ac_cv_my_have_glew="no"
if test "${enable_gl}" != "no"; then
LOL_AC_CHECK_OPENGL_INNER()
fi
AM_CONDITIONAL(LOL_USE_GL, test "${ac_cv_my_have_gl}" != "no")
AM_CONDITIONAL(LOL_USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
])

# LOL_AC_CHECK_OPENGL_INNER()
# ---------------------------
AC_DEFUN([LOL_AC_CHECK_OPENGL_INNER],
[
dnl Find which version of OpenGL to use
ac_cv_my_have_gl="no"
ac_cv_my_stop_looking_for_gl="no"

if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
LIBS_save="$LIBS"
LIBS="$LIBS -Wl,-framework -Wl,OpenGL"
AC_MSG_CHECKING(for -framework OpenGL)
AC_TRY_LINK([], [],
[AC_MSG_RESULT(yes)
ac_cv_my_have_gl="yes"
GL_LIBS="${GL_LIBS} -framework OpenGL"
LOL_TRY_CXXFLAGS(-ObjC++, [CXXFLAGS="${CXXFLAGS} -ObjC++"])
AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
[AC_MSG_RESULT(no)])
LIBS="$LIBS_save"
fi

if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
LIBS_save="$LIBS"
LIBS="$LIBS -Wl,-framework -Wl,OpenGLES"
AC_MSG_CHECKING(for -framework OpenGLES)
AC_TRY_LINK([], [],
[AC_MSG_RESULT(yes)
ac_cv_my_have_gl="yes"
GL_LIBS="${GL_LIBS} -framework OpenGLES"
LOL_TRY_CXXFLAGS(-ObjC++, [CXXFLAGS="${CXXFLAGS} -ObjC++"])
AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)],
[AC_MSG_RESULT(no)])
LIBS="$LIBS_save"
fi

dnl Use the Raspberry Pi libraries?
if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
AC_CHECK_HEADERS(bcm_host.h,
[AC_CHECK_LIB(vcos, main,
[ac_cv_my_have_gl="yes"
ac_cv_my_stop_looking_for_gl="yes"
AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
dnl FIXME: -lEGL does not belong here but the configure test fails
dnl when cross-compiling, so we add it manually here.
GL_LIBS="${GL_LIBS} -lGLESv2 -lEGL -lvcos -lvchiq_arm -lbcm_host"])])
fi

if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
PKG_CHECK_MODULES(GLES2, glesv2,
[ac_cv_my_have_gl="yes"
AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
[:])
fi

if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
AC_CHECK_HEADER(GLES2/gl2.h,
[ac_cv_my_have_gl="yes"
AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
AC_CHECK_LIB(GLESv2, glEnable,
[GL_LIBS="${GL_LIBS} -lGLESv2"])])
fi

if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
PKG_CHECK_MODULES(GL, gl,
[ac_cv_my_have_gl="yes"
AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
[:])
fi

if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
AC_CHECK_LIB(GL, glEnable,
[ac_cv_my_have_gl="yes"
AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
GL_LIBS="-lGL"])
fi

if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
AC_CHECK_HEADER(GL/gl.h,
[LIBS_save="$LIBS"
LIBS="$LIBS -lopengl32"
AC_MSG_CHECKING(for glLoadIdentity in -lopengl32)
AC_TRY_LINK([#include <GL/gl.h>],
[glLoadIdentity();],
[ac_cv_my_have_gl="yes"
AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack
AC_MSG_RESULT(yes)
GL_LIBS="-lopengl32"],
[AC_MSG_RESULT(no)])
LIBS="$LIBS_save"])
fi

dnl Use Glew?
PKG_CHECK_MODULES(GLEW, glew,
[ac_cv_my_have_glew="yes"
GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}"
GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"],
[:])
AC_CHECK_HEADER(GL/glew.h,
[LIBS_save="${LIBS}"
LIBS="${LIBS} -lglew32s ${GL_LIBS}"
AC_MSG_CHECKING(for glewInit in -lglew32s)
AC_TRY_LINK(
[#include <GL/glew.h>],
[glewInit();],
[ac_cv_my_have_glew="yes"
GL_LIBS="-lglew32s ${GL_LIBS}"
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
LIBS="${LIBS_save}"])
if test "${ac_cv_my_have_glew}" != "no"; then
AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
AC_DEFINE(LOL_USE_GLEW, 1, Define to 1 to use libglew)
fi

dnl Poor man's GL feature detection if all else failed.
save_LIBS="${LIBS}"
LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
AC_CHECK_FUNCS(glBegin)
LIBS="${save_LIBS}"

dnl Warn if we couldn't find an OpenGL-like API
if test "${ac_cv_my_have_gl}" = "no"; then
AC_MSG_WARN([[No OpenGL or OpenGL ES implementation found]])
fi

]) # LOL_AC_CHECK_OPENGL_INNER


+ 0
- 59
build/autotools/m4/lol-misc.m4 查看文件

@@ -1,59 +0,0 @@
dnl
dnl Lol Engine
dnl
dnl Copyright © 2010—2016 Sam Hocevar <sam@hocevar.net>
dnl
dnl Lol Engine is free software. It comes without any warranty, to
dnl the extent permitted by applicable law. You can redistribute it
dnl and/or modify it under the terms of the Do What the Fuck You Want
dnl to Public License, Version 2, as published by the WTFPL Task Force.
dnl See http://www.wtfpl.net/ for more details.
dnl


dnl LOL_TRY_CFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS])
dnl check if $CC supports a given set of cflags
AC_DEFUN([LOL_TRY_CFLAGS],
[AC_MSG_CHECKING([if $CC supports $1 flags])
save_CFLAGS="$CFLAGS"
CFLAGS="$1 -Werror"
AC_TRY_COMPILE([],[],[ac_cv_try_cflags_ok=yes],[ac_cv_try_cflags_ok=no])
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT([$ac_cv_try_cflags_ok])
if test x"$ac_cv_try_cflags_ok" = x"yes"; then
ifelse([$2],[],[:],[$2])
else
ifelse([$3],[],[:],[$3])
fi])

dnl LOL_TRY_CXXFLAGS (CXXFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS])
dnl check if $CXX supports a given set of cxxflags
AC_DEFUN([LOL_TRY_CXXFLAGS],
[AC_MSG_CHECKING([if $CXX supports $1 flags])
AC_LANG_PUSH(C++)
save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$1 -Werror"
AC_TRY_COMPILE([],[],[ac_cv_try_cxxflags_ok=yes],[ac_cv_try_cxxflags_ok=no])
CXXFLAGS="$save_CXXFLAGS"
AC_MSG_RESULT([$ac_cv_try_cxxflags_ok])
if test x"$ac_cv_try_cxxflags_ok" = x"yes"; then
ifelse([$2],[],[:],[$2])
else
ifelse([$3],[],[:],[$3])
fi
AC_LANG_POP(C++)])

dnl LOL_TRY_LDFLAGS (LDFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS])
dnl check if $CC supports a given set of ldflags
AC_DEFUN([LOL_TRY_LDFLAGS],
[AC_MSG_CHECKING([if $CC supports $1 flags])
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$1 -Werror"
AC_TRY_LINK([],[],[ac_cv_try_ldflags_ok=yes],[ac_cv_try_ldflags_ok=no])
LDFLAGS="$save_LDFLAGS"
AC_MSG_RESULT([$ac_cv_try_ldflags_ok])
if test x"$ac_cv_try_ldflags_ok" = x"yes"; then
ifelse([$2],[],[:],[$2])
else
ifelse([$3],[],[:],[$3])
fi])

+ 0
- 126
build/autotools/m4/lol-sdl.m4 查看文件

@@ -1,126 +0,0 @@
dnl
dnl Lol Engine
dnl
dnl Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net>
dnl
dnl Lol Engine is free software. It comes without any warranty, to
dnl the extent permitted by applicable law. You can redistribute it
dnl and/or modify it under the terms of the Do What the Fuck You Want
dnl to Public License, Version 2, as published by the WTFPL Task Force.
dnl See http://www.wtfpl.net/ for more details.
dnl


# LOL_AC_CHECK_SDL()
# ------------------
AC_DEFUN([LOL_AC_CHECK_SDL],
[
ac_cv_my_have_sdl="no"
ac_cv_my_have_sdl_image="no"
ac_cv_my_have_sdl_mixer="no"
if test "${enable_sdl}" != "no"; then
LOL_AC_CHECK_SDL_INNER()
fi
AM_CONDITIONAL(LOL_USE_SDL, test "${ac_cv_my_have_sdl}" != "no")
AM_CONDITIONAL(LOL_USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" != "no")
AM_CONDITIONAL(LOL_USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" != "no")
])

# LOL_AC_CHECK_SDL_INNER()
# ------------------------
AC_DEFUN([LOL_AC_CHECK_SDL_INNER],
[
dnl Find which version of SDL to use (always required on Linux or Win32)
dnl
dnl Defined C/C++ macros:
dnl LOL_USE_SDL -- whether SDL v2 was found
dnl LOL_USE_SDL_IMAGE -- whether SDL_image was found
dnl LOL_USE_SDL_MIXER -- whether SDL_mixer was found
dnl HAVE_SDL_H -- whether to include <SDL.h>
dnl HAVE_SDL2_SDL_H -- whether to include <SDL2/SDL.h>
dnl Generated automake conditionals:
dnl LOL_USE_SDL -- whether SDL v2 was found
dnl LOL_USE_SDL_IMAGE -- whether SDL_image was found
dnl LOL_USE_SDL_MIXER -- whether SDL_mixer was found
dnl Generated shell variables:
dnl SDL_CFLAGS -- flags for SDL compilation
dnl SDL_LIBS -- flags for SDL linking


dnl First, try the proper pkg-config check for SDL2

if test "x${ac_cv_my_have_sdl}" = xno; then
PKG_CHECK_MODULES(SDL2, sdl2,
[ac_cv_my_have_sdl="yes"
PKG_CHECK_MODULES(SDL2MIXER, SDL2_mixer,
[ac_cv_my_have_sdl_mixer="yes"
AC_DEFINE(HAVE_SDL_MIXER_H, 1, Define to 1 to use SDL_mixer.h)],
[:])
PKG_CHECK_MODULES(SDL2IMAGE, SDL2_image,
[ac_cv_my_have_sdl_image="yes"
AC_DEFINE(HAVE_SDL_IMAGE_H, 1, Define to 1 to use SDL_image.h)],
[:])
SDL_CFLAGS="${SDL2_CFLAGS} ${SDL2MIXER_CFLAGS} ${SDL2IMAGE_CFLAGS}"
SDL_LIBS="${SDL2_LIBS} ${SDL2MIXER_LIBS} ${SDL2IMAGE_LIBS}"
AC_DEFINE(HAVE_SDL_H, 1, Define to 1 to use SDL.h)],
[:])
fi


dnl Maybe all this has failed, try direct inclusion instead

if test "x${ac_cv_my_have_sdl}" = xno; then
save_CPPFLAGS="${CPPFLAGS}"
save_LIBS="${LIBS}"
CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
LIBS="${LIBS} ${SDL_LIBS}"
AC_CHECK_HEADERS(SDL.h SDL2/SDL.h,
[ac_cv_my_have_sdl="yes"])
if test "x${ac_cv_my_have_sdl}" != xno; then
AC_CHECK_HEADERS(SDL_mixer.h SDL2/SDL_mixer.h,
[ac_cv_my_have_sdl_mixer="yes"])
AC_CHECK_HEADERS(SDL_image.h SDL2/SDL_image.h,
[ac_cv_my_have_sdl_image="yes"])
AC_CHECK_LIB(SDL2, main,
[SDL_LIBS="${SDL_LIBS} -lSDL2"],
[ac_cv_my_have_sdl="no"])
AC_CHECK_LIB(SDL2main, main,
[SDL_LIBS="${SDL_LIBS} -lSDL2main -lSDL2"])
AC_CHECK_LIB(SDL2_mixer, main,
[SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL2_mixer"],
[ac_cv_my_have_sdl_mixer="no"])
AC_CHECK_LIB(SDL2_image, main,
[SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL2_image"],
[AC_CHECK_LIB(SDL2_image_bmp-jpg-png, main,
[SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL2_image_bmp-jpg-png"],
[ac_cv_my_have_sdl_image="no"])])
SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
fi
CPPFLAGS="${save_CPPFLAGS}"
LIBS="${save_LIBS}"
fi


dnl Convert all this into conditionals

if test "x${ac_cv_my_have_sdl}" = xno; then
AC_MSG_WARN([SDL v2 not found])
else
AC_DEFINE(LOL_USE_SDL, 1, Define to 1 to use SDL)
fi

if test "x${ac_cv_my_have_sdl_mixer}" = xno; then
AC_MSG_WARN([SDL_mixer not found])
else
AC_DEFINE(LOL_USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
fi

if test "x${ac_cv_my_have_sdl_image}" = xno; then
AC_MSG_WARN([SDL_image not found])
else
AC_DEFINE(LOL_USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
fi

]) # LOL_AC_CHECK_SDL_INNER


+ 0
- 55
build/autotools/m4/lol-subproject.m4 查看文件

@@ -1,55 +0,0 @@
dnl
dnl Lol Engine
dnl
dnl Copyright © 2010—2016 Sam Hocevar <sam@hocevar.net>
dnl
dnl Lol Engine is free software. It comes without any warranty, to
dnl the extent permitted by applicable law. You can redistribute it
dnl and/or modify it under the terms of the Do What the Fuck You Want
dnl to Public License, Version 2, as published by the WTFPL Task Force.
dnl See http://www.wtfpl.net/ for more details.
dnl


# LOL_AC_SUBPROJECT()
# ---------------------
AC_DEFUN([LOL_AC_SUBPROJECT], [

dnl
dnl Parse build.config if present
dnl

AC_MSG_WARN([${srcdir}])
ac_lol_configure_args=""
if test -f ${srcdir}/build.config; then
for x in `sed -ne 's,.*<enable_\(@<:@^>@:>@*\)>\(@<:@^<@:>@*\)</enable_@<:@^>@:>@*>.*,\1=\2,p' ${srcdir}/build.config`; do
eval "enable_${x}"
case ${x} in
*=no) arg="--disable-${x%=no}" ;;
*=yes) arg="--enable-${x%=yes}" ;;
*) arg="" ;;
esac
ac_lol_configure_args="${ac_lol_configure_args} ${arg}"
done
fi

dnl
dnl Build and configure Lol Engine before our repository
dnl Ensure $lol_srcdir and $lol_builddir are properly set
dnl

ac_configure_args="${ac_configure_args} --enable-subproject ${ac_lol_configure_args} $1"
AC_CONFIG_SUBDIRS([lol])
AC_SUBST(lol_srcdir, '${top_srcdir}/lol')
AC_SUBST(lol_builddir, '${top_builddir}/lol')

dnl
dnl Subprojects use the same macros as us
dnl

LOL_AC_INIT()
LOL_AC_CHECK()
LOL_AC_FINI()

]) # LOL_AC_SUBPROJECT


+ 0
- 22
build/bitten/config-trunk-private.xml 查看文件

@@ -1,22 +0,0 @@
<build xmlns:sh="http://bitten.edgewall.org/tools/sh"
xmlns:svn="http://bitten.edgewall.org/tools/svn"
xmlns:c="http://bitten.edgewall.org/tools/c">
<step id="checkout" description="Checkout source from repository">
<svn:checkout url="svn://svn.zoy.org/lolengine/" path="${path}" revision="${revision}" />
</step>
<step id="bootstrap" description="Bootstrap build system">
<sh:exec file="./build/lol-build" args="bootstrap ${platform}"/>
</step>
<step id="configure" description="Configure tree">
<sh:exec file="./build/lol-build" args="configure ${platform}"/>
</step>
<step id="build" description="Build tree">
<sh:exec file="./build/lol-build" args="build ${platform}"/>
</step>
<step id="check" description="Run tests">
<sh:exec file="./build/lol-build" args="check ${platform}"/>
</step>
<step id="clean" description="Clean tree">
<sh:exec file="./build/lol-build" args="clean ${platform}"/>
</step>
</build>

+ 0
- 22
build/bitten/config-trunk-public.xml 查看文件

@@ -1,22 +0,0 @@
<build xmlns:sh="http://bitten.edgewall.org/tools/sh"
xmlns:svn="http://bitten.edgewall.org/tools/svn"
xmlns:c="http://bitten.edgewall.org/tools/c">
<step id="checkout" description="Checkout source from repository">
<svn:checkout url="svn://svn.zoy.org/lolengine/" path="${path}" revision="${revision}" username="anonymous" password="" no_auth_cache="true" />
</step>
<step id="bootstrap" description="Bootstrap build system">
<sh:exec file="./build/lol-build" args="bootstrap ${platform}"/>
</step>
<step id="configure" description="Configure tree">
<sh:exec file="./build/lol-build" args="configure ${platform}"/>
</step>
<step id="build" description="Build tree">
<sh:exec file="./build/lol-build" args="build ${platform}"/>
</step>
<step id="check" description="Run tests">
<sh:exec file="./build/lol-build" args="check ${platform}"/>
</step>
<step id="clean" description="Clean tree">
<sh:exec file="./build/lol-build" args="clean ${platform}"/>
</step>
</build>

+ 0
- 10
build/build-android 查看文件

@@ -1,10 +0,0 @@
#!/bin/sh

# This can't hurt
make distclean

set -e
./build/lol-build "$@" bootstrap android-arm
./build/lol-build "$@" configure android-arm
./build/lol-build "$@" build android-arm


+ 0
- 10
build/build-html 查看文件

@@ -1,10 +0,0 @@
#!/bin/sh

# This can't hurt
make distclean

set -e
"$(dirname "$0")/lol-build" "$@" bootstrap web-html
"$(dirname "$0")/lol-build" "$@" configure web-html
"$(dirname "$0")/lol-build" "$@" build web-html


+ 0
- 10
build/build-js 查看文件

@@ -1,10 +0,0 @@
#!/bin/sh

# This can't hurt
make distclean

set -e
./build/lol-build "$@" bootstrap web-js
./build/lol-build "$@" configure web-js
./build/lol-build "$@" build web-js


+ 0
- 11
build/build-linux 查看文件

@@ -1,11 +0,0 @@
#!/bin/sh

## Native Linux compilation for Lol Engine -- Sam Hocevar <sam@hocevar.net>

set -ex

./bootstrap
./configure
make clean
make -j6


+ 0
- 10
build/build-mingw 查看文件

@@ -1,10 +0,0 @@
#!/bin/sh

# This can't hurt
make distclean

set -e
./build/lol-build "$@" bootstrap windows-i386
./build/lol-build "$@" configure windows-i386
./build/lol-build "$@" build windows-i386


+ 0
- 10
build/build-mingw64 查看文件

@@ -1,10 +0,0 @@
#!/bin/sh

# This can't hurt
make distclean

set -e
./build/lol-build "$@" bootstrap windows-amd64
./build/lol-build "$@" configure windows-amd64
./build/lol-build "$@" build windows-amd64


+ 0
- 10
build/build-raspi 查看文件

@@ -1,10 +0,0 @@
#!/bin/sh

# This can't hurt
make distclean

set -e
./build/lol-build "$@" bootstrap raspi-arm
./build/lol-build "$@" configure raspi-arm
./build/lol-build "$@" build raspi-arm


+ 0
- 209
build/check-source.sh 查看文件

@@ -1,209 +0,0 @@
#!/bin/sh

set -e

fix=false
quiet=false
while [ "$#" -gt 0 ]; do
case "$1" in
-q)
quiet=true
;;
-w)
fix=true
;;
-c)
commit=true
fix=true
quiet=true
;;
*)
echo "E: invalid argument $1" >&2
exit 1
;;
esac
shift
done

error() { if [ "$quiet" != true ]; then echo "E: $1" >&2; fi }
info() { if [ "$quiet" != true ]; then echo "I: $1" >&2; fi }

# Ensure the system tools do not attempt to perform multibyte conversions
export LANG=C

# Find out where the top directory is and go there
top_srcdir="$(cd "$(dirname $0)"; cd ..; pwd)"
cd "$top_srcdir"

# Check for working tools
if [ "$(echo foo | grep -c foo)" != 1 ]; then
error "grep -c does not appear to work, cancelling"
exit 0
fi

SED=sed
if gsed --version >/dev/null 2>&1; then
SED=gsed
fi
if [ "$(echo 'x\x' | $SED 's/.*[^x\t]//')" != x ]; then
error "sed does not appear to work, cancelling"
exit 0
fi

if d2u -h >/dev/null 2>&1; then
d2u=d2u
elif dos2unix -h >/dev/null 2>&1; then
d2u=dos2unix
else
error "d2u or dos2unix not found, cancelling"
exit 0
fi

# Find out whether we need to care about CRLF
case "$(uname 2>/dev/null)" in
MINGW*|MSYS*)
can_check_crlf=false
;;
*)
can_check_crlf=true
;;
esac

# Find out what kind of Vcs directory this is
if [ -f "$top_srcdir/.git/index" ]; then
info "detected Git repository"
repo=git
else
info "not in a Git directory, nothing to do"
exit 0
fi

total_crlfs=0
total_spaces=0
total_tabs=0

OIFS="$IFS"
IFS='
'
FILES="`git ls-files`"

total_files=0
for file in $FILES; do
if [ -f "$file" ]; then
total_files="$(($total_files + 1))"
fi
done

total_errors=0
for file in $FILES; do
should_check_crlf=false
should_check_spaces=false
should_check_props=false

case "$file" in
# These files we know how to handle
*.c|*.cpp|*.m|*.mm|*.h|*.hh|*.lolfx|*.lua|*.l|*.y|*.sh|*.py)
should_check_crlf=true
should_check_spaces=true
should_check_props=true
;;
*)
continue
;;
esac

case "$file" in
# Don't harass these people, but fix their line endings
people/peeweek/*|\
people/touky/*|\
people/benlitz/*|\
people/sam/lua-*)
should_check_spaces=false
;;
esac

clean=true

# Check for CR LF
if [ "$can_check_crlf" = true -a "$should_check_crlf" = true ]; then
ncrlfs="$(od -tx1 "$file" | cut -b8- | tr ' ' '\n' | grep -c 0d || true)"
total_crlfs="$(($total_crlfs + $ncrlfs))"
if [ "$ncrlfs" -gt 0 ]; then
clean=false
if [ "$fix" = true ]; then
$d2u -q "$file"
info "$file has $ncrlfs CR characters"
else
error "$file has $ncrlfs CR characters"
fi
fi
fi

# Check for trailing spaces
if [ "$should_check_spaces" = true ]; then
nspaces="$($SED 's/.*[^ \t]//' "$file" | tr -cd '\t ' | wc -c)"
total_spaces="$(($total_spaces + $nspaces))"
if [ "$nspaces" -gt 0 ]; then
clean=false
if [ "$fix" = true ]; then
$SED -i 's/[[:space:]][[:space:]]*$//g' "$file"
info "$file has $nspaces trailing spaces"
else
error "$file has $nspaces trailing spaces"
fi
fi
fi

# Check for tabs
if [ "$should_check_spaces" = true ]; then
ntabs="$(tr -cd '\t' < "$file" | wc -c)"
total_tabs="$(($total_tabs + $ntabs))"
if [ "$ntabs" -gt 0 ]; then
clean=false
if [ "$fix" = true ]; then
$SED -i 's/\t/ /g' "$file"
info "$file has $ntabs tabs"
else
error "$file has $ntabs tabs"
fi
fi
fi

if [ "$clean" != true ]; then
total_errors="$(($total_errors + 1))"
fi
done
IFS="$OIFS"

if [ "$total_errors" -gt 0 ]; then
if [ "$commit" = "true" ]; then
# EITHER: commit all modified files
git commit --author 'Lolbot <lolbot@zoy.org>' -a -F - << EOF
fixed $total_errors files out of $total_files:
- removed $total_crlfs CR characters
- removed $total_spaces trailing whitespaces
- replaced $total_tabs tabs with spaces
EOF
elif [ "$fix" = "true" ]; then
# OR: report in stdout
info "fixed $total_errors files out of $total_files:"
if [ "$total_crlfs" -gt 0 ]; then
info " - fixed $total_crlfs CR characters"
fi
if [ "$total_spaces" -gt 0 ]; then
info " - fixed $total_spaces trailing spaces"
fi
if [ "$total_tabs" -gt 0 ]; then
info " - fixed $total_tabs tabs"
fi
info "re-run with -c to commit fixes"
else
# OR: warn about how to fix errors
info "re-run with -w to fix errors"
exit 1
fi
else
info "all $total_files source files appear to be OK, congratulations"
fi



+ 0
- 344
build/lol-build 查看文件

@@ -1,344 +0,0 @@
#!/bin/sh

#
# Lol Engine build script
# Usage:
# lol-build [<flags>...] <action> [<platform>]
#
# Supported flags:
# --enable-debug
# --enable-devel
# --enable-release
#
# Where <action> is one of:
# - bootstrap
# - configure
# - build
# - check
# - clean
#
# And <platform> is one of:
# - linux-i386
# - linux-amd64
# - ios-arm
# - osx-amd64
# - android-arm
# - win*-i386
# - win*-amd64
# - raspi-arm
# - web-html
# - web-js
#

set -e

###############################################################################
# Commandline parsing
#
action=""
platform=""
configure_flags=""
while [ "$#" -gt 0 ]; do
case "$1" in
--enable-debug|--enable-devel|--enable-release)
configure_flags="${configure_flags} $1"
;;
--*)
echo "E: invalid flag $1"
exit 1
;;
*)
if [ -z "$action" ]; then
action="$1"
else
platform="$1"
fi
;;
esac
shift
done

###############################################################################
# Initialisation code
#
# - sets the top_srcdir variable
# - sets the LOL_PARALLEL variable
# - fix PATH and MKPATH if necessary
#
__init__()
{
top_srcdir="$(dirname "$0")/.."
cd "$top_srcdir"
top_srcdir="`pwd`"

# Try to count CPU cores. First obvious try: /proc/cpuinfo on Linux
case "$cpu_count" in
[1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
*) if [ -r "/proc/cpuinfo" ]; then
cpu_count="$(grep -c '^processor\>' /proc/cpuinfo 2>/dev/null || true)"
fi ;;
esac
# If that didn't work, try sysctl (for OS X machines)
case "$cpu_count" in
[1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
*) cpu_count="$(sysctl -n hw.ncpu 2>/dev/null || true)" ;;
esac
# Otherwise, CPUInfo.exe (from Xoreax's XGE) may help on Windows
case "$cpu_count" in
[1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
*) cpu_count="$(CPUInfo.exe | sed -ne 's/CPU Cores.* \([0-9][0-9]*\)/\1/p')" ;;
esac
# Otherwise, Windows may define NUMBER_OF_PROCESSORS
case "$cpu_count" in
[1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
*) cpu_count="$NUMBER_OF_PROCESSORS" ;;
esac
# Otherwise, be conservative and assume 1 CPU core
case "$cpu_count" in
[1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
*) cpu_count=1 ;;
esac
# Now decide how many parallel threads to launch
case "$cpu_count" in
1) LOL_PARALLEL=1 ;;
2) LOL_PARALLEL=3 ;;
*) LOL_PARALLEL="$(expr $cpu_count '*' 3 / 2)" ;;
esac

case "${MSYSTEM}" in
MINGW32|MINGW64)
PATH="$PATH:./external/gtk-2.22.1/bin"
M4PATH="$M4PATH:./external/gtk-2.22.1/share/aclocal"
;;
esac

# Ensure we don’t launch weird Windows binaries when cross-compiling
WINEDLLOVERRIDES="winemenubuilder.exe,wineboot.exe,explorer.exe,winedbg.exe=d"
export WINEDLLOVERRIDES

# Ensure SDL does not redirect stdout/stderr to local files
SDL_STDIO_REDIRECT=0
export SDL_STDIO_REDIRECT
}

bootstrap()
{
cd "$top_srcdir"
case "$platform" in
*)
PATH="$PATH" M4PATH="$M4PATH" ./bootstrap
;;
esac
}

do_configure()
{
./configure ${configure_flags} "$@"
}

configure()
{
cd "$top_srcdir"
case "$platform" in
android-arm)
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/libcaca-0.99.beta18/lib/pkgconfig"
LDFLAGS="$LDFLAGS -L$PWD/external/libcaca-0.99.beta18/lib/arm-linux-androideabi -lz"
CPPFLAGS="$CPPFLAGS -I$PWD/external/libcaca-0.99.beta18/include -DCACA_STATIC"
;;
win*-i386)
if test "x${MSYSTEM}" = xMINGW32; then
:
elif i586-mingw32msvc-g++ --version >/dev/null 2>&1; then
HOSTFLAGS=--host=i586-mingw32msvc
BUILDFLAGS=--build=none
elif i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
HOSTFLAGS=--host=i686-w64-mingw32
BUILDFLAGS=--build=none
else
echo "Error: could not find win32 compiler" >&2
false
fi
if test "x${MSYSTEM}" = xMINGW64; then
# If using mingw64, we're not really cross-compiling
BUILDFLAGS=
fi
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/gtkglarea-2.0.1/lib/pkgconfig"
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/libcaca-0.99.beta18/lib/pkgconfig"
LDFLAGS="$LDFLAGS -L$PWD/external/ffmpeg-20190130/lib/i686-w64-mingw32"
LDFLAGS="$LDFLAGS -L$PWD/external/glew-2.1.0/lib/i686-w64-mingw32"
LDFLAGS="$LDFLAGS -L$PWD/external/sdl-2.0.9/lib/i686-w64-mingw32"
LDFLAGS="$LDFLAGS -L$PWD/external/sdl-image-2.0.4/lib/i686-w64-mingw32"
LDFLAGS="$LDFLAGS -L$PWD/external/sdl-mixer-2.0.4/lib/i686-w64-mingw32"
LDFLAGS="$LDFLAGS -L$PWD/external/gtk-2.22.1/lib"
LDFLAGS="$LDFLAGS -L$PWD/external/gtk-2.22.1/bin"
LDFLAGS="$LDFLAGS -L$PWD/external/gtkglarea-2.0.1/lib"
LDFLAGS="$LDFLAGS -L$PWD/external/libcaca-0.99.beta18/lib/i686-w64-mingw32"
;;
win*-amd64)
if test "x${MSYSTEM}" = xMINGW64; then
:
elif x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
HOSTFLAGS=--host=x86_64-w64-mingw32
BUILDFLAGS=--build=none
else
echo "Error: could not find win64 compiler" >&2
false
fi
if test "x${MSYSTEM}" = xMINGW32; then
# If using mingw32, we're not really cross-compiling
BUILDFLAGS=
fi
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/gtkglarea-2.0.1/lib/pkgconfig"
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PWD/external/libcaca-0.99.beta18/lib/pkgconfig"
LDFLAGS="$LDFLAGS -L$PWD/external/ffmpeg-20190130/lib/x86_64-w64-mingw32"
LDFLAGS="$LDFLAGS -L$PWD/external/glew-2.1.0/lib/x86_64-w64-mingw32"
LDFLAGS="$LDFLAGS -L$PWD/external/sdl-2.0.9/lib/x86_64-w64-mingw32"
LDFLAGS="$LDFLAGS -L$PWD/external/sdl-image-2.0.4/lib/x86_64-w64-mingw32"
LDFLAGS="$LDFLAGS -L$PWD/external/sdl-mixer-2.0.4/lib/x86_64-w64-mingw32"
LDFLAGS="$LDFLAGS -L$PWD/external/libcaca-0.99.beta18/lib/x86_64-w64-mingw32"
;;
*-i386)
# Ensure we're _really_ on i386
CXXFLAGS="$CXXFLAGS -m32"
;;
*-amd64)
# Ensure we're _really_ on amd64
CXXFLAGS="$CXXFLAGS -m64"
;;
web-*)
# Force cross-compilation because AC_TRY_LINK is going to check
# whether our binaries have the executable bit set.
HOSTFLAGS=--host=none
BUILDFLAGS=--build=`$top_srcdir/.auto/config.guess`
;;
esac
case "$platform" in
ios-arm)
XCODE="/Applications/Xcode.app/Contents/Developer"
SDKVER="6.1"
DEVROOT="$XCODE/Platforms/iPhoneOS.platform/Developer"
SDKROOT="$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk"
CC="$XCODE/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
CXX="$XCODE/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
do_configure --host=armv7-apple-darwin10 CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" CC="$CC" CXX="$CXX"
;;
android-arm)
CPPFLAGS="$CPPFLAGS -I$ANDROID_NDK_ROOT/sources/android/native_app_glue -fpic -fomit-frame-pointer -fno-strict-aliasing"
CFLAGS="$CFLAGS"
CXXFLAGS="$CXXFLAGS"
LOL_LIBS="$LOL_LIBS -lm -fpic -XCClinker -shared -u ANativeActivity_onCreate"
HOST=armv7a-linux-androideabi27
PKG_CONFIG_PATH="$PKG_CONFIG_PATH" do_configure --host="$HOST" CC="$HOST-clang" CXX="$HOST-clang++" ac_cv_exeext=.so CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" LOL_LIBS="$LOL_LIBS"
# FIXME: is this needed?
# ant debug
# ant debug install
# ant clean
;;
raspi-arm)
do_configure --host=arm-bcm2708hardfp-linux-gnueabi CPPFLAGS="-I$RASPI_SDK_ROOT/firmware/opt/vc/include -I$RASPI_SDK_ROOT/firmware/opt/vc/include/interface/vmcs_host/linux -I$RASPI_SDK_ROOT/chroot/usr/include -I$RASPI_SDK_ROOT/chroot/usr/include/arm-linux-gnueabihf" LDFLAGS="-L$RASPI_SDK_ROOT/firmware/opt/vc/lib -L$RASPI_SDK_ROOT/chroot/lib/arm-linux-gnueabihf -Wl,-rpath-link -Wl,$RASPI_SDK_ROOT/chroot/lib/arm-linux-gnueabihf -L$RASPI_SDK_ROOT/chroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link -Wl,$RASPI_SDK_ROOT/chroot/usr/lib/arm-linux-gnueabihf -Wl,--unresolved-symbols=ignore-in-shared-libs"
;;
osx-amd64)
# HACK: use clang++ because of a memory leak in llvm-g++.
do_configure CXX=clang++ CC=clang
;;
win*-i386|win*-amd64)
CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-2.0.9/include"
CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-image-2.0.4/include"
CPPFLAGS="$CPPFLAGS -I$PWD/external/sdl-mixer-2.0.4/include"
CPPFLAGS="$CPPFLAGS -I$PWD/external/ffmpeg-20190130/include"
CPPFLAGS="$CPPFLAGS -I$PWD/external/glew-2.1.0/include -DGLEW_STATIC"
CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/lib/glib-2.0/include"
CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/lib/gtk-2.0/include"
CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/glib-2.0"
CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/gtk-2.0"
CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/cairo"
CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/pango-1.0"
CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/gdk-pixbuf-2.0"
CPPFLAGS="$CPPFLAGS -I$PWD/external/gtk-2.22.1/include/atk-1.0"
CPPFLAGS="$CPPFLAGS -I$PWD/external/gtkglarea-2.0.1/include"
CPPFLAGS="$CPPFLAGS -I$PWD/src/3rdparty/imgui/include"
CPPFLAGS="$CPPFLAGS -mms-bitfields"
LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
GTK_LIBS="$GTK_LIBS -lgtkgl-2.0 -lopengl32 -lglew32 -lgdi32"
GTK_LIBS="$GTK_LIBS -lgtk-win32-2.0 -lgdk-win32-2.0"
GTK_LIBS="$GTK_LIBS -lglib-2.0 -lgthread-2.0 -lgobject-2.0"

CPPFLAGS="$CPPFLAGS -I$PWD/external/libcaca-0.99.beta18/include -DCACA_STATIC"

PATH="$PATH" PKG_CONFIG_PATH="$PKG_CONFIG_PATH" do_configure $HOSTFLAGS $BUILDFLAGS CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" GTK_LIBS="$GTK_LIBS"
;;
web-*)
# First do an emcc run so that dependent libraries are generated
emflags="-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2"
touch conftest.c ; emcc $(echo $emflags) conftest.c -c -o conftest.o ; rm -f conftest.c conftest.o
# We use --enable-release otherwise builds are really too slow
do_configure --enable-release $HOSTFLAGS $BUILDFLAGS CC=emcc CXX=em++ AR=emar RANLIB=emranlib PKG_CONFIG=/bin/false SDL_CONFIG=/bin/false ac_cv_exeext=".${platform##web-}" CPPFLAGS="$emflags" CXXFLAGS="$emflags" CFLAGS="$emflags"
;;
*)
PATH="$PATH" do_configure CFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS"
;;
esac
}

build()
{
cd "$top_srcdir"
case "$platform" in
win*-i386)
# Because of locking issues in Wine’s winepath.exe, we only
# build the static libraries in parallel.
make -j$LOL_PARALLEL -C src/3rdparty liblol-lua.a
make -j$LOL_PARALLEL -C src/ liblol-core.a
make
;;
*)
make -j$LOL_PARALLEL
;;
esac
}

check()
{
cd "$top_srcdir"
case "$platform" in
ios-arm)
;;
android-arm)
;;
raspi-arm)
;;
web-*)
;;
win*-i386)
# If neither $MSYSTEM or $DISPLAY are set, and xvfb-run
# exists, use it to run the test suite.
if test "x${MSYSTEM}${DISPLAY}" = x \
&& xvfb-run --help 2>&1 >/dev/null; then
xvfb-run -a make check VERBOSE=1
else
make check VERBOSE=1
fi
;;
win*-amd64)
# No support for Wine64 yet
;;
*)
make check VERBOSE=1
;;
esac
}

clean()
{
cd "$top_srcdir"
case "$platform" in
*)
make distclean
;;
esac
}

__init__
echo "lol-build: executing action '$action' on platform '$platform'" >&2
eval "$action"


+ 0
- 10
build/msbuild/lol-bullet.props 查看文件

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup>
<ProjectReference Condition="'$(enable_bullet)'!='no'" Include="$(LolDir)\src\3rdparty\lol-bullet.vcxproj">
<Project>{83d3b207-c601-4025-8f41-01dedc354661}</Project>
</ProjectReference>
</ItemGroup>

</Project>

+ 0
- 10
build/msbuild/lol-core.props 查看文件

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup>
<ProjectReference Include="$(LolDir)\src\lol-core.vcxproj">
<Project>{9e62f2fe-3408-4eae-8238-fd84238ceeda}</Project>
</ProjectReference>
</ItemGroup>

</Project>

+ 0
- 10
build/msbuild/lol-lua.props 查看文件

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup>
<ProjectReference Include="$(LolDir)\src\3rdparty\lol-lua.vcxproj">
<Project>{d84021ca-b233-4e0f-8a52-071b83bbccc4}</Project>
</ProjectReference>
</ItemGroup>

</Project>

+ 0
- 61
build/msbuild/lol.config.props 查看文件

@@ -1,61 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!--
- Import settings that can be overridden by the user
-->
<Import Condition="Exists('$(SolutionDir)\lol\build.config')" Project="$(SolutionDir)\lol\build.config" />
<Import Condition="Exists('$(SolutionDir)\build.config')" Project="$(SolutionDir)\build.config" />

<!--
- Import defaults settings from Visual Studio
-->
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

<!--
- Default settings for Debug configurations
-->
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>

<!--
- Default settings for Release configurations
-->
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>

<!--
- Default settings for any configuration
-->
<PropertyGroup Label="Configuration">
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>false</UseOfMfc>
<ExceptionHandling>false</ExceptionHandling>
<FloatingPointModel>Fast</FloatingPointModel>
</PropertyGroup>

<!--
- Select the platform toolset depending on the platform
-->
<PropertyGroup Condition="'$(Platform)'=='Win32'" Label="Configuration">
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)'=='x64'" Label="Configuration">
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>

<!--
- Secret stuff for platforms under NDA
-->
<Import Condition="Exists('$(LolDir)\src\private\nx\msbuild\nx.config.props')"
Project="$(LolDir)\src\private\nx\msbuild\nx.config.props" />

<!--
- Import final settings from Visual Studio
-->
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

</Project>

+ 0
- 20
build/msbuild/lol.props 查看文件

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<Import Project="$(LolDir)\build\msbuild\lol.config.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(LolDir)\build\msbuild\lolfx.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(LolDir)\build\msbuild\lol.vars.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<Import Project="$(LolDir)\build\msbuild\lol.rules.props" />
<ItemDefinitionGroup />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(LolDir)\build\msbuild\lolfx.targets" />
</ImportGroup>

</Project>

+ 0
- 123
build/msbuild/lol.rules.props 查看文件

@@ -1,123 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LinkIncremental Condition="'$(Configuration)'=='Debug'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)'=='Release'">false</LinkIncremental>
</PropertyGroup>

<!--
- Secret stuff for platforms under NDA
-->
<Import Condition="Exists('$(LolDir)\src\private\nx\msbuild\nx.rules.props')"
Project="$(LolDir)\src\private\nx\msbuild\nx.rules.props" />

<ItemDefinitionGroup>
<ClCompile>
<WarningLevel>Level3</WarningLevel>

<!-- Use latest version of the C++ draft -->
<LanguageStandard>stdcpplatest</LanguageStandard>

<!-- Always multiprocessor, never minimal rebuild -->
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>

<!-- We should use %(RelativeDir) here but for some reason it's an _absolute_ dir. WTF. -->
<ObjectFileName>$(IntDir)/%(Directory)/</ObjectFileName>

<AdditionalIncludeDirectories>
$(LolDir)\src;
$(LolDir)\src\3rdparty\bullet3\src;
$(LolDir)\tools\lolunit;
$(PegtlIncludes);
$(ImguiIncludes);
$(BtPhysIncludes);
$(GlIncludes);
%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>

<AdditionalIncludeDirectories Condition="'$(Platform)'=='Win32' Or '$(Platform)'=='x64'">
$(SdlIncludes);
$(CppHttpIncludes);
$(FfmpegIncludes);
$(AssimpIncludes);
$(XinputIncludes);
%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>

<AdditionalPreprocessorDefinitions>
NOMINMAX;
_CRT_SECURE_NO_WARNINGS;
B3_USE_CLEW;
LUA_ANSI;
</AdditionalPreprocessorDefinitions>

<PreprocessorDefinitions>$(AdditionalPreprocessorDefinitions.Replace('\n',''));%(PreprocessorDefinitions)</PreprocessorDefinitions>

<!-- Trim trailing backslashes and escape them for C++ -->
<PreprocessorDefinitions>LOL_CONFIG_PROJECTDIR="$(ProjectDir.Trim('\').Replace('\','/'))";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LOL_CONFIG_SOLUTIONDIR="$(SolutionDir.Trim('\').Replace('\','/'))";%(PreprocessorDefinitions)</PreprocessorDefinitions>

<PreprocessorDefinitions Condition="'$(Platform)'=='Win32'">WIN32;$(Win32Defines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">WIN32;$(Win32Defines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)'=='Orbis'">$(OrbisDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
<Optimization>Disabled</Optimization>
<RuntimeLibrary Condition="'$(Platform)'=='Win32' Or '$(Platform)'=='x64'">MultiThreadedDebugDLL</RuntimeLibrary>
<PreprocessorDefinitions>_DEBUG;LOL_BUILD_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Release'">
<GenerateDebugInformation>true</GenerateDebugInformation>
<!-- For Microsoft tools -->
<Optimization>MaxSpeed</Optimization>
<!-- For PlayStation tools -->
<OptimizationLevel>Level2</OptimizationLevel>

<RuntimeLibrary Condition="'$(Platform)'=='Win32' Or '$(Platform)'=='x64'">MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<PreprocessorDefinitions>NDEBUG;LOL_BUILD_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>

<Link Condition="'$(Platform)'=='Win32' Or '$(Platform)'=='x64'">
<!-- FIXME: not for the static library! -->
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;$(SdlDeps);$(FfmpegDeps);$(AssimpDeps);$(LibGccDeps);$(GdiDeps);$(XinputDeps);$(GlDeps);$(CppHttpDeps);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(LibGccLibs);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SdlLibs);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(CppHttpLibs);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(FfmpegLibs);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(AssimpLibs);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(GlLibs);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(XinputLibs);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem Condition="'$(enable_sdl)'!='no'">Windows</SubSystem>
<SubSystem Condition="'$(enable_sdl)'=='no'">Console</SubSystem>
</Link>
<Link Condition="'$(Platform)'=='Orbis'">
<AdditionalLibraryDirectories>$(OrbisLibs);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(OrbisDeps);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Link Condition="'$(Configuration)'=='Release'">
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>

<!-- Post-build hook to run commands -->
<PostBuildEvent Condition="'$(Platform)'=='Win32' Or '$(Platform)'=='x64'">
<Command Condition="'$(enable_sdl)'!='no'">
rem do nothing
</Command>
</PostBuildEvent>

</ItemDefinitionGroup>
</Project>

+ 0
- 176
build/msbuild/lol.vars.props 查看文件

@@ -1,176 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />

<PropertyGroup Label="UserMacros">
<ExternalDir>$(LolDir)\external</ExternalDir>

<PlatformCode Condition="'$(Platform)'=='Win32'">i686</PlatformCode>
<PlatformCode Condition="'$(Platform)'=='x64'">x86_64</PlatformCode>

<!-- PEGTL -->
<PegtlDir>$(LolDir)\src/3rdparty\pegtl\include</PegtlDir>
<PegtlIncludes>$(PegtlDir)</PegtlIncludes>

<!-- imgui -->
<ImguiDir>$(LolDir)\src\3rdparty\imgui</ImguiDir>
<ImguiIncludes>$(ImguiDir)</ImguiIncludes>

<!-- OpenSSL -->
<OpenSslDir>$(ExternalDir)\openssl-1.1.1d</OpenSslDir>

<!-- cpp-httplib (depends on OpenSSL) -->
<CppHttpDir>$(LolDir)\src/3rdparty\cpp-httplib</CppHttpDir>
<CppHttpIncludes>$(CppHttpDir);$(OpenSslDir)\include</CppHttpIncludes>
<CppHttpLibs>$(OpenSslDir)\lib\$(PlatformCode)-msvc</CppHttpLibs>
<CppHttpDeps>libssl.lib;libcrypto.lib;crypt32.lib</CppHttpDeps>
<Win32Defines>CPPHTTPLIB_OPENSSL_SUPPORT;$(Win32Defines)</Win32Defines>

<!-- GTK+ & GtkGl -->
<GtkDir>$(ExternalDir)\gtk-2.22.1</GtkDir>
<GtkGlDir>$(ExternalDir)\gtkglarea-2.0.1</GtkGlDir>
<GtkIncludes>$(GtkDir)\lib\glib-2.0\include;$(GtkDir)\lib\gtk-2.0\include;$(GtkDir)\include\glib-2.0;$(GtkDir)\include\gtk-2.0;$(GtkDir)\include\cairo;$(GtkDir)\include\pango-1.0;$(GtkDir)\include\gdk-pixbuf-2.0;$(GtkDir)\include\atk-1.0;$(GtkGlDir)\include</GtkIncludes>
<GtkLibs>$(GtkDir)\lib;$(GtkDir)\bin;$(GtkGlDir)\lib</GtkLibs>
<GtkDeps>gobject-2.0.lib;gthread-2.0.lib;glib-2.0.lib;gdk-win32-2.0.lib;gtk-win32-2.0.lib;gtkgl-2.0.lib</GtkDeps>

<!-- Assimp -->
<!--
<AssimpDir>$(ExternalDir)\assimp-3.1.1</AssimpDir>
<AssimpIncludes>$(AssimpDir)\include</AssimpIncludes>
<AssimpLibs Condition="'$(Platform)'=='Win32'">$(AssimpDir)\lib\win32</AssimpLibs>
<AssimpLibs Condition="'$(Platform)'=='x64'">$(AssimpDir)\lib\x64</AssimpLibs>
<AssimpDeps Condition="'$(Configuration)'=='Release'">zlibstatic.lib;assimp.lib</AssimpDeps>
<AssimpDeps Condition="'$(Configuration)'=='Debug'">zlibstatic.lib;assimp.lib</AssimpDeps>
<Win32Defines>LOL_USE_ASSIMP;$(Win32Defines)</Win32Defines>
-->

<!-- libcaca -->
<CacaDir>$(ExternalDir)\libcaca-0.99.beta18</CacaDir>
<CacaIncludes>$(CacaDir)\include</CacaIncludes>
<CacaLibs>$(CacaDir)\lib\$(PlatformCode)-w64-mingw32</CacaLibs>
<CacaDeps>caca.lib</CacaDeps>
<Win32Defines>CACA_STATIC;$(Win32Defines)</Win32Defines>

<!-- GDI+ -->
<GdiDeps>Gdiplus.lib</GdiDeps>
<Win32Defines>LOL_USE_GDIPLUS;$(Win32Defines)</Win32Defines>

<!-- Xinput -->
<XinputIncludes>$(DXSDK_DIR)\Include</XinputIncludes>
<XinputLibs Condition="'$(Platform)'=='Win32'">$(DXSDK_DIR)\Lib\x86</XinputLibs>
<XinputLibs Condition="'$(Platform)'=='x64'">$(DXSDK_DIR)\Lib\x64</XinputLibs>
<XinputDeps>xinput.lib</XinputDeps>
<Win32Defines>LOL_USE_XINPUT;$(Win32Defines)</Win32Defines>

<!-- Windows-specific -->
<Win32Defines>HAVE_STDIO_H;$(Win32Defines)</Win32Defines>

<!-- PS4-specific -->
<OrbisDefines>HAVE_STDIO_H;
$(OrbisDefines)</OrbisDefines>
</PropertyGroup>

<!-- OpenGL & GLEW -->
<PropertyGroup Condition="'$(enable_gl)'!='no'" Label="UserMacros">
<GlewDir>$(ExternalDir)\glew-2.1.0</GlewDir>
<GlIncludes>$(GlewDir)\include</GlIncludes>
<GlLibs>$(GlewDir)\lib\$(PlatformCode)-w64-mingw32</GlLibs>
<GlDeps>opengl32.lib;glew32s.lib</GlDeps>
<Win32Defines>HAVE_GL_2X;LOL_USE_GLEW;GLEW_STATIC;$(Win32Defines)</Win32Defines>
</PropertyGroup>

<!-- SDL -->
<PropertyGroup Condition="'$(enable_sdl)'!='no'" Label="UserMacros">
<SdlDir>$(ExternalDir)\sdl-2.0.9</SdlDir>
<SdlImageDir>$(ExternalDir)\sdl-image-2.0.4</SdlImageDir>
<SdlMixerDir>$(ExternalDir)\sdl-mixer-2.0.4</SdlMixerDir>
<SdlLibDir>$(SdlDir)\lib\$(PlatformCode)-msvc</SdlLibDir>
<SdlImageLibDir>$(SdlImageDir)\lib\$(PlatformCode)-msvc</SdlImageLibDir>
<SdlMixerLibDir>$(SdlMixerDir)\lib\$(PlatformCode)-msvc</SdlMixerLibDir>
<SdlIncludes>$(SdlDir)\include;$(SdlImageDir)\include;$(SdlMixerDir)\include</SdlIncludes>
<SdlLibs>$(SdlLibDir);$(SdlImageLibDir);$(SdlMixerLibDir)</SdlLibs>
<SdlDeps>SDL2.lib;SDL2main.lib;SDL2_image.lib;SDL2_mixer.lib</SdlDeps>
<Win32Defines>HAVE_SDL_H;LOL_USE_SDL;$(Win32Defines)</Win32Defines>
<Win32Defines>LOL_USE_SDL_MIXER;LOL_USE_SDL_IMAGE;$(Win32Defines)</Win32Defines>
</PropertyGroup>

<!-- FFmpeg -->
<PropertyGroup Condition="'$(enable_ffmpeg)'!='no'" Label="UserMacros">
<FfmpegDir>$(ExternalDir)\ffmpeg-20190130</FfmpegDir>
<FfmpegIncludes>$(FfmpegDir)\include</FfmpegIncludes>
<FfmpegLibs>$(FfmpegDir)\lib\$(PlatformCode)-msvc</FfmpegLibs>
<FfmpegDeps>swscale.lib;avformat.lib;avcodec.lib;swresample.lib;avutil.lib;ws2_32.lib;secur32.lib;bcrypt.lib</FfmpegDeps>
<Win32Defines>LOL_USE_FFMPEG;$(Win32Defines)</Win32Defines>
</PropertyGroup>

<PropertyGroup />

<ItemDefinitionGroup />

<ItemGroup>
<BuildMacro Include="ExternalDir"><Value>$(ExternalDir)</Value></BuildMacro>
<BuildMacro Include="PlatformCode"><Value>$(PlatformCode)</Value></BuildMacro>
</ItemGroup>
<ItemGroup>
<BuildMacro Include="PegtlDir"><Value>$(PegtlDir)</Value></BuildMacro>
<BuildMacro Include="PegtlIncludes"><Value>$(PegtlIncludes)</Value></BuildMacro>
<BuildMacro Include="CppHttpDir"><Value>$(CppHttpDir)</Value></BuildMacro>
<BuildMacro Include="CppHttpIncludes"><Value>$(CppHttpIncludes)</Value></BuildMacro>
<BuildMacro Include="ImguiDir"><Value>$(ImguiDir)</Value></BuildMacro>
<BuildMacro Include="ImguiIncludes"><Value>$(ImguiIncludes)</Value></BuildMacro>
<BuildMacro Include="LibGccDir"><Value>$(LibGccDir)</Value></BuildMacro>
<BuildMacro Include="LibGccLibs"><Value>$(LibGccLibs)</Value></BuildMacro>
<BuildMacro Include="LibGccDeps"><Value>$(LibGccDeps)</Value></BuildMacro>
<BuildMacro Include="SdlDir"><Value>$(SdlDir)</Value></BuildMacro>
<BuildMacro Include="SdlImageDir"><Value>$(SdlImageDir)</Value></BuildMacro>
<BuildMacro Include="SdlMixerDir"><Value>$(SdlMixerDir)</Value></BuildMacro>
<BuildMacro Include="SdlIncludes"><Value>$(SdlIncludes)</Value></BuildMacro>
<BuildMacro Include="SdlLibs"><Value>$(SdlLibs)</Value></BuildMacro>
<BuildMacro Include="SdlDeps"><Value>$(SdlDeps)</Value></BuildMacro>
<BuildMacro Include="BtPhysDir"><Value>$(BtPhysDir)</Value></BuildMacro>
<BuildMacro Include="BtPhysIncludes"><Value>$(BtPhysIncludes)</Value></BuildMacro>
<BuildMacro Include="GtkDir"><Value>$(GtkDir)</Value></BuildMacro>
<BuildMacro Include="GtkGlDir"><Value>$(GtkGlDir)</Value></BuildMacro>
<BuildMacro Include="GtkIncludes"><Value>$(GtkIncludes)</Value></BuildMacro>
<BuildMacro Include="GtkLibs"><Value>$(GtkLibs)</Value></BuildMacro>
<BuildMacro Include="GtkDeps"><Value>$(GtkDeps)</Value></BuildMacro>
<BuildMacro Include="FfmpegDir"><Value>$(FfmpegDir)</Value></BuildMacro>
<BuildMacro Include="FfmpegIncludes"><Value>$(FfmpegIncludes)</Value></BuildMacro>
<BuildMacro Include="FfmpegLibs"><Value>$(FfmpegLibs)</Value></BuildMacro>
<BuildMacro Include="FfmpegDeps"><Value>$(FfmpegDeps)</Value></BuildMacro>
<BuildMacro Include="AssimpDir"><Value>$(AssimpDir)</Value></BuildMacro>
<BuildMacro Include="AssimpIncludes"><Value>$(AssimpIncludes)</Value></BuildMacro>
<BuildMacro Include="AssimpLibs"><Value>$(AssimpLibs)</Value></BuildMacro>
<BuildMacro Include="AssimpDeps"><Value>$(AssimpDeps)</Value></BuildMacro>
<BuildMacro Include="CacaDir"><Value>$(CacaDir)</Value></BuildMacro>
<BuildMacro Include="CacaIncludes"><Value>$(CacaIncludes)</Value></BuildMacro>
<BuildMacro Include="CacaLibs"><Value>$(CacaLibs)</Value></BuildMacro>
<BuildMacro Include="CacaDeps"><Value>$(CacaDeps)</Value></BuildMacro>
<BuildMacro Include="GdiDeps"><Value>$(GdiDeps)</Value></BuildMacro>
<BuildMacro Include="GlewDir"><Value>$(GlewDir)</Value></BuildMacro>
<BuildMacro Include="GlIncludes"><Value>$(GlIncludes)</Value></BuildMacro>
<BuildMacro Include="GlLibs"><Value>$(GlLibs)</Value></BuildMacro>
<BuildMacro Include="GlDeps"><Value>$(GlDeps)</Value></BuildMacro>
<BuildMacro Include="XinputIncludes"><Value>$(XinputIncludes)</Value></BuildMacro>
<BuildMacro Include="XinputLibs"><Value>$(XinputLibs)</Value></BuildMacro>
<BuildMacro Include="XinputDeps"><Value>$(XinputDeps)</Value></BuildMacro>
<BuildMacro Include="Win32Defines"><Value>$(Win32Defines)</Value></BuildMacro>
<BuildMacro Include="OrbisDeps"><Value>$(OrbisDeps)</Value></BuildMacro>
<BuildMacro Include="OrbisLibs"><Value>$(OrbisLibs)</Value></BuildMacro>
<BuildMacro Include="OrbisDefines"><Value>$(OrbisDefines)</Value></BuildMacro>
</ItemGroup>

<!--
- Secret stuff for platforms under NDA
-->
<Import Condition="Exists('$(LolDir)\src\private\nx\msbuild\nx.vars.props')"
Project="$(LolDir)\src\private\nx\msbuild\nx.vars.props" />

<PropertyGroup>
<BinDir Condition="Exists('$(SolutionDir)\lol')">$(SolutionDir)\binaries</BinDir>
<BinDir Condition="!Exists('$(SolutionDir)\lol')">$(LolDir)\binaries</BinDir>
<OutDir>$(BinDir)\$(Platform) $(PlatformToolset) $(Configuration)\</OutDir>
<IntDir>$(BinDir)\$(Platform) $(PlatformToolset) $(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>

</Project>

+ 0
- 37
build/msbuild/lolfx.props 查看文件

@@ -1,37 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup
Condition="'$(LolFxCompileBeforeTargets)' == '' and '$(LolFxCompileAfterTargets)' == '' and '$(ConfigurationType)' != 'Makefile'">
<LolFxCompileBeforeTargets>Midl</LolFxCompileBeforeTargets>
<LolFxCompileAfterTargets>CustomBuild</LolFxCompileAfterTargets>
</PropertyGroup>
<PropertyGroup>
<LolFxCompileDependsOn
Condition="'$(ConfigurationType)' != 'Makefile'">_SelectedFiles;$(LolFxCompileDependsOn)</LolFxCompileDependsOn>
</PropertyGroup>
<ItemDefinitionGroup>
<LolFxCompile>
<CommandLineTemplate>@echo off
set D=$(IntDir)%(Filename)%(Extension).cpp

set "name=lolfx_resource_%(RelativeDir)%(Filename)"
set "name=%name:\=_%"
set "name=%name:-=_%"
set "name=%name:.=_%"

echo /* This file was autogenerated. DO NOT MODIFY IT. */ &gt; "%D%"
echo extern "C" { char const *%name% = &gt;&gt; "%D%"
setlocal disabledelayedexpansion
for /F "tokens=1,* delims=`" %%L in ('type "%(Fullpath)"') do (
set "line=%%L"
setlocal enabledelayedexpansion
echo "!line:"=\"!\n" &gt;&gt; "%D%"
endlocal
)
endlocal
echo ;} &gt;&gt; "%D%"</CommandLineTemplate>
<Outputs>$(IntDir)%(FileName)%(Extension).cpp</Outputs>
<ExecutionDescription>%(FileName)%(Extension)</ExecutionDescription>
</LolFxCompile>
</ItemDefinitionGroup>
</Project>

+ 0
- 80
build/msbuild/lolfx.targets 查看文件

@@ -1,80 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml" />
<AvailableItemName Include="LolFxCompile">
<Targets>LolFxCompile</Targets>
</AvailableItemName>
</ItemGroup>

<PropertyGroup>
<ComputeCompileInputsTargets>
$(ComputeCompileInputsTargets);
ComputeLolFxCompileOutput;
</ComputeCompileInputsTargets>
</PropertyGroup>

<UsingTask
TaskName="LolFxCompile"
TaskFactory="XamlTaskFactory"
AssemblyName="Microsoft.Build.Tasks.v4.0">
<Task>$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml</Task>
</UsingTask>

<Target
Name="LolFxCompile"
BeforeTargets="$(LolFxCompileBeforeTargets)"
AfterTargets="$(LolFxCompileAfterTargets)"
Condition="'@(LolFxCompile)' != ''"
DependsOnTargets="$(LolFxCompileDependsOn);ComputeLolFxCompileOutput"
Outputs="@(LolFxCompile-&gt;Metadata('CompileOut')-&gt;Distinct())"
Inputs="@(LolFxCompile);%(LolFxCompile.AdditionalDependencies);$(MSBuildProjectFile)">
<ItemGroup
Condition="'@(SelectedFiles)' != ''">
<LolFxCompile
Remove="@(LolFxCompile)"
Condition="'%(Identity)' != '@(SelectedFiles)'" />
</ItemGroup>
<ItemGroup>
<LolFxCompile_tlog
Include="%(LolFxCompile.Outputs)"
Condition="'%(LolFxCompile.Outputs)' != '' and '%(LolFxCompile.ExcludedFromBuild)' != 'true'">
<Source>@(LolFxCompile, '|')</Source>
</LolFxCompile_tlog>
</ItemGroup>
<Message
Importance="High"
Text="%(LolFxCompile.ExecutionDescription)" />
<WriteLinesToFile
Condition="'@(LolFxCompile_tlog)' != '' and '%(LolFxCompile_tlog.ExcludedFromBuild)' != 'true'"
File="$(IntDir)$(ProjectName).write.1.tlog"
Lines="^%(LolFxCompile_tlog.Source);@(LolFxCompile_tlog-&gt;'%(Fullpath)')" />
<ItemGroup>
<LolFxCompile>
</LolFxCompile>
</ItemGroup>
<LolFxCompile
Condition="'@(LolFxCompile)' != '' and '%(LolFxCompile.ExcludedFromBuild)' != 'true'"
CommandLineTemplate="%(LolFxCompile.CommandLineTemplate)"
Outputs="%(LolFxCompile.Outputs)"
IntDir="$(IntDir)"
FileName="%(FileName)"
Inputs="@(LolFxCompile)" />
</Target>


<Target Name="ComputeLolFxCompileOutput" Condition="'@(LolFxCompile)' != ''">
<ItemGroup>
<ClCompile Include="@(LolFxCompile->Metadata('CompileOut')->Distinct()->ClearMetadata())" Condition="'%(LolFxCompile.ExcludedFromBuild)' != 'true'">
<CompileAs>CompileAsC</CompileAs>
</ClCompile>
<ClCompile Include="%(LolFxCompile.Outputs)" />
</ItemGroup>
<ItemGroup>
<LolFxCompile>
<CompileOut>$(IntDir)\%(FileName).lolfx.cpp</CompileOut>
</LolFxCompile>
</ItemGroup>
</Target>

</Project>

+ 0
- 79
build/msbuild/lolfx.xml 查看文件

@@ -1,79 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ProjectSchemaDefinitions xmlns="clr-namespace:Microsoft.Build.Framework.XamlTypes;assembly=Microsoft.Build.Framework" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:transformCallback="Microsoft.Cpp.Dev10.ConvertPropertyCallback">
<Rule
Name="LolFxCompile"
PageTemplate="tool"
DisplayName="Lol Fx Build Rule v0.0"
Order="200">
<Rule.DataSource>
<DataSource
Persistence="ProjectFile"
ItemType="LolFxCompile" />
</Rule.DataSource>
<Rule.Categories>
<Category
Name="General">
<Category.DisplayName>
<sys:String>General</sys:String>
</Category.DisplayName>
</Category>
<Category
Name="Command Line"
Subtype="CommandLine">
<Category.DisplayName>
<sys:String>Command Line</sys:String>
</Category.DisplayName>
</Category>
</Rule.Categories>
<StringListProperty
Name="Inputs"
Category="Command Line"
IsRequired="true"
Switch=" ">
<StringListProperty.DataSource>
<DataSource
Persistence="ProjectFile"
ItemType="LolFxCompile"
SourceType="Item" />
</StringListProperty.DataSource>
</StringListProperty>
<StringListProperty
Name="IntDir"
Category="Command Line"
IsRequired="true"
Switch=" ">
<StringListProperty.DataSource>
<DataSource
Persistence="ProjectFile"
ItemType="LolFxCompile"
SourceType="Item" />
</StringListProperty.DataSource>
</StringListProperty>
<StringListProperty
Name="FileName"
Category="Command Line"
IsRequired="true"
Switch=" ">
</StringListProperty>
<StringProperty
Name="Outputs"
Category="Command Line"
IsRequired="true"
Switch=" " />
<StringProperty
Name="CommandLineTemplate"
DisplayName="Command Line"
Visible="False"
IncludeInCommandLine="False" />
</Rule>
<ItemType
Name="LolFxCompile"
DisplayName="Lol Fx Build Rule v0.0" />
<FileExtension
Name="*.lolfx"
ContentType="LolFxCompile" />
<ContentType
Name="LolFxCompile"
DisplayName="Lol Fx Build Rule v0.0"
ItemType="LolFxCompile" />
</ProjectSchemaDefinitions>

+ 0
- 240
build/run-bitten.sh 查看文件

@@ -1,240 +0,0 @@
#!/bin/sh

tmpdir="$TMPDIR"
if [ -z "${tmpdir}" ]; then tmpdir="$TEMP"; fi
if [ -z "${tmpdir}" ]; then tmpdir="$TEMPDIR"; fi
if [ -z "${tmpdir}" ]; then tmpdir="$TMP"; fi
if [ -z "${tmpdir}" ]; then tmpdir="/tmp"; fi

conffile="`mktemp -q "${tmpdir}/lol-bitten-XXXXXXXX" 2>/dev/null`"
if [ "${conffile}" = "" ]; then
conffile="`mktemp 2>/dev/null`"
fi
scriptfile=""
builddir="${tmpdir}/lol-bitten-`whoami`"
url="http://lolengine.net/builds"

#
# Utility functions
#

append() {
echo "$*" >> "${conffile}"
}

cleanup() {
rm -f "${conffile}" "${scriptfile}"
rm -rf "${builddir}"
}

bailout() {
cleanup
# Exit gracefully
exit 0
}

trap bailout EXIT HUP INT QUIT ABRT KILL ALRM TERM

#
# Fork if necessary
#

if [ "$1" = "--forked" ]; then
shift
scriptfile="$1"
shift
else
cp "$0" "${conffile}"
chmod +x "${conffile}"
exec "${conffile}" --forked "${conffile}" "$@"
exit 0
fi

#
# Check for command line
#

if [ "$#" != 2 ]; then
echo "Usage: run-bitten.sh <username> <password>"
exit 1
fi

#
# Clean up working directory
#
cleanup
if [ -e "${builddir}" ]; then
echo "Error: cannot get rid of ${builddir}"
exit 1
fi

#
# Operating system information
#

append "[os]"
append "name = `uname -srmo 2>/dev/null || uname -srm`"
append "version = 0"
family="`uname -s | tr A-Z a-z`"
case "$family" in
mingw*) family="windows" ;;
darwin*) family="osx" ;;
esac
append "family = $family"
# This random token prevents HTTP conflicts when several instances
# are run from the same machine.
append "token = $$$RANDOM"
append ""

#
# Hardware information
#

append "[machine]"
name="`uname -n | tr A-Z a-z | sed 's/[.].*//'`"
case "$name" in
d*e*s*o*v*) name="putois" ;;
esac
append "name = $name"
processor="`uname -m`"
case "$processor" in
x86_64) processor="amd64"
if test "`getconf LONG_BIT 2>/dev/null`" = 32; then
processor="i386"
fi ;;
i*86) processor="i386" ;;
esac
# Windows defines a lot of crazy shit, try to make sense of it
case "$PROCESSOR_ARCHITECTURE" in
amd64|AMD64) processor="amd64" ;;
x86|X86) processor="i386" ;;
esac
case "$PROCESSOR_ARCHITEW6432" in
amd64|AMD64) processor="amd64" ;;
x86|X86) processor="i386" ;;
esac
append "processor = $processor"
append ""

#
# Authentication information
#

append "[authentication]"
append "username = $1"
append "password = $2"
append ""

#
# Visual Studio configuration
#

# FIXME: we also need to check for the Visual Studio SDK
append "[msvc]"
if [ -n "$VS100COMNTOOLS" ]; then
append "version = 10"
elif [ -n "$VS110COMNTOOLS" ]; then
append "version = 11"
elif [ -n "$VS90COMNTOOLS" ]; then
append "version = 9"
fi
append ""

#
# iOS development kit
#

append "[ios]"
if [ -d "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk" ]; then
append "version = 6.1"
fi
append ""

#
# mingw32 / mingw-w64
#

append "[mingw64]"
if x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
append "version = $(x86_64-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
fi
append ""

append "[mingw32]"
if i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
append "version = $(i686-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
fi
append ""

#
# Emscripten
#

append "[emscripten]"
if em++ --version >/dev/null 2>&1; then
append "version = $(em++ --version | sed -ne 's/.*emcc.* \([0-9.]\{1,\}\).*/\1/p')"
fi
append ""

#
# Android NDK
#

append "[ndk]"
if [ "$family" != "windows" ]; then
if [ -f "$ANDROID_NDK_ROOT/RELEASE.TXT" ]; then
append "version = $(cat "$ANDROID_NDK_ROOT/RELEASE.TXT")"
fi
fi
append ""

#
# Raspberry Pi cross-compiler
#

append "[raspi]"
if [ "$family" != "windows" ]; then
if [ -d "$RASPI_SDK_ROOT/tools" ]; then
append "version = 0"
fi
fi
append ""

#
# Show what we just did here
#

cat "${conffile}"

#
# Fix system
#

if [ "$family" = "osx" ]; then
# The version of Subversion shipped by Apple is antique; try to
# use the one in /usr/local/bin instead.
PATH="/usr/local/bin:$PATH"
export PATH
# HACK: the version of llvm-g++ shipped by Apple has an insane
# memory leak; use clang++ instead.
CC="clang"
export CC
CXX="clang++"
export CXX
fi

#
# Launch everything
#

while : ; do
bitten-slave "$url" \
-f "${conffile}" \
--name "$name" \
--work-dir="${builddir}"
rm -rf "${builddir}"
sleep 10
done

exit 0


+ 0
- 280
configure.ac 查看文件

@@ -1,280 +0,0 @@
dnl
dnl Lol Engine
dnl
dnl Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net>
dnl
dnl Lol Engine is free software. It comes without any warranty, to
dnl the extent permitted by applicable law. You can redistribute it
dnl and/or modify it under the terms of the Do What the Fuck You Want
dnl to Public License, Version 2, as published by the WTFPL Task Force.
dnl See http://www.wtfpl.net/ for more details.
dnl

AC_INIT(lolengine, 0.0)
AC_PREREQ(2.50)
AC_CONFIG_AUX_DIR(.auto)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([subdir-objects no-define tar-ustar silent-rules])
dnl AM_MAINTAINER_MODE

dnl Versioning of the separate software we ship
LOLUNIT_VERSION=0.1
AC_SUBST(LOLUNIT_VERSION)

AC_SUBST(lol_srcdir, '${top_srcdir}')
AC_SUBST(lol_builddir, '${top_builddir}')

AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_RANLIB

LOL_AC_INIT()

AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL
AC_LIBTOOL_CXX

dnl Ensure an error is thrown if pkg-config M4 files are not found.
m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
m4_pattern_forbid([^PKG_CHECK_MODULES$])
m4_pattern_forbid([^PKG_PROG_PKG_CONFIG$])

dnl Same for Lol Engine M4 files.
m4_pattern_forbid([^LOL_AC_])


dnl Do not use PKG_CONFIG_LIBDIR when cross-compiling.
if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
export PKG_CONFIG_LIBDIR=/dev/null
fi

dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
dnl now otherwise it might be set in an obscure if statement. Same thing for
dnl PKG_PROG_PKG_CONFIG which needs to be called first.
AC_EGREP_CPP(yes, foo)
PKG_PROG_PKG_CONFIG()


dnl Check for a working implementation of sed
AC_PROG_SED
AC_MSG_CHECKING(for a sed that understands \t)
if test "$(echo 'x\x' | "${SED}" 's/.*@<:@^x\t@:>@//')" != x; then
AC_MSG_RESULT(no)
AC_MSG_ERROR([[consider installing GNU sed]])
else
AC_MSG_RESULT(yes)
fi


dnl conditional builds
AC_ARG_ENABLE(debug,
[ --enable-debug build debug versions of the game (default no)])
AC_ARG_ENABLE(release,
[ --enable-release build final release of the game (default no)])
AC_ARG_ENABLE(experimental,
[ --enable-experimental experimental build (default no)])

AC_ARG_ENABLE(subproject,
[ --enable-subproject build as a subproject (default no)])

AC_ARG_ENABLE(gl,
[ --enable-gl build using OpenGL or OpenGL ES (default autodetected)])
AC_ARG_ENABLE(ffmpeg,
[ --enable-ffmpeg build using FFmpeg (default autodetected)])
AC_ARG_ENABLE(sdl,
[ --enable-sdl build using SDL (default autodetected)])
AC_ARG_ENABLE(imlib2,
[ --enable-imlib2 build using Imlib2 (default autodetected)])
AC_ARG_ENABLE(png,
[ --enable-png build using libpng (default autodetected)])
AC_ARG_ENABLE(bullet,
[ --enable-bullet build using Bullet Physics (default yes)])

AC_ARG_ENABLE(test,
[ --enable-test build test suite (default yes)])
AC_ARG_ENABLE(tools,
[ --enable-tools build miscellaneous tools (default yes)])
AC_ARG_ENABLE(tutorial,
[ --enable-tutorial build tutorial applications (default yes)])
AC_ARG_ENABLE(samples,
[ --enable-samples build sample applications (default yes)])
AC_ARG_ENABLE(doc,
[ --enable-doc build documentation (needs doxygen and LaTeX)])


dnl Subproject builds
if test "${enable_subproject}" = "yes"; then
AC_MSG_CHECKING(for a config-lol.h file in the parent project)
if test -f "../config-lol.h"; then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_CONFIG_LOL_H, 1, Define to if parent project provides config-lol.h)
AH_BOTTOM([
#if HAVE_CONFIG_LOL_H
#include "../config-lol.h"
#endif
])
else
AC_MSG_RESULT(no)
fi
fi


dnl Common C headers
AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h stdint.h math.h)
AC_CHECK_HEADERS(fastmath.h unistd.h io.h)
AC_CHECK_HEADERS(execinfo.h)
AC_CHECK_HEADERS(sys/ioctl.h sys/ptrace.h sys/stat.h sys/syscall.h sys/user.h)
AC_CHECK_HEADERS(sys/wait.h sys/time.h sys/types.h)


dnl Common C++ headers
AC_LANG_PUSH(C++)
AC_CHECK_HEADERS(cxxabi.h)
AC_LANG_POP(C++)

dnl Common C functions
AC_CHECK_FUNCS(getenv system tmpfile tmpnam getcwd _getcwd)
AC_CHECK_FUNCS(backtrace_symbols)
AC_CHECK_FUNCS(gettimeofday usleep)


dnl Build mode
ac_cv_my_build_mode="devel"
if test "x${enable_release}" = "xyes"; then
ac_cv_my_build_mode="release"
fi
if test "x${enable_devel}" = "xyes"; then
ac_cv_my_build_mode="devel"
fi
if test "x${enable_debug}" = "xyes"; then
ac_cv_my_build_mode="debug"
fi

if test "x${ac_cv_my_build_mode}" = "xdebug"; then
AC_DEFINE(LOL_BUILD_DEBUG, 1, Define to 1 to activate debug build)
LOL_TRY_CXXFLAGS(-O, [AM_CXXFLAGS="${AM_CXXFLAGS} -O"])
LOL_TRY_CXXFLAGS(-g, [AM_CXXFLAGS="${AM_CXXFLAGS} -g"])
elif test "x${ac_cv_my_build_mode}" = "xdevel"; then
AC_DEFINE(LOL_BUILD_DEVEL, 1, Define to 1 to activate development build)
LOL_TRY_CXXFLAGS(-Os, [AM_CXXFLAGS="${AM_CXXFLAGS} -Os"])
LOL_TRY_CXXFLAGS(-g, [AM_CXXFLAGS="${AM_CXXFLAGS} -g"])
LOL_TRY_CXXFLAGS(-ffast-math, [AM_CXXFLAGS="${AM_CXXFLAGS} -ffast-math"])
else
AC_DEFINE(LOL_BUILD_RELEASE, 1, Define to 1 to activate final release)
LOL_TRY_CXXFLAGS(-Os, [AM_CXXFLAGS="${AM_CXXFLAGS} -Os"])
LOL_TRY_CXXFLAGS(-ffast-math, [AM_CXXFLAGS="${AM_CXXFLAGS} -ffast-math"])
LOL_TRY_CXXFLAGS(-fomit-frame-pointer, [AM_CXXFLAGS="${AM_CXXFLAGS} -fomit-frame-pointer"])
LOL_TRY_CXXFLAGS(-fno-strength-reduce, [AM_CXXFLAGS="${AM_CXXFLAGS} -fno-strength-reduce"])
fi


dnl Build documentation?
DOXYGEN="no"
LATEX="no"
if test "${enable_doc}" != "no" -a "${enable_subproject}" != "yes"; then
AC_PATH_PROG(DOXYGEN, doxygen, no)
if test "${DOXYGEN}" != "no"; then
# Build LaTeX documentation?
AC_PATH_PROG(LATEX, pdflatex, no)
AC_PATH_PROG(KPSEWHICH, kpsewhich, no)
AC_PATH_PROG(DVIPS, dvips, no)
if test "${DVIPS}" = "no" -o "${KPSEWHICH}" = "no"; then
LATEX="no"
fi
if test "${LATEX}" != "no"; then
AC_MSG_CHECKING(for a4.sty and a4wide.sty)
if "${KPSEWHICH}" a4.sty >/dev/null 2>&1; then
if "${KPSEWHICH}" a4wide.sty >/dev/null 2>&1; then
AC_MSG_RESULT(yes)
else
LATEX="no"
AC_MSG_RESULT(no)
fi
else
LATEX="no"
AC_MSG_RESULT(no)
fi
fi
AC_PATH_PROG(DOT, dot, no)
if test "${DOT}" != "no"; then
LOL_USE_DOT="YES"
else
LOL_USE_DOT="NO"
fi
fi
fi
dnl XXX: disable LaTeX because we use too much memory
LATEX=no
AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
AM_CONDITIONAL(LOL_USE_LATEX, test "${LATEX}" != "no")
AM_CONDITIONAL(LOL_USE_DOT, test "${DOT}" != "no")
AC_SUBST(LOL_USE_DOT)


dnl GCC-specific symbol demangling
AC_LANG_PUSH(C++)
AC_TRY_LINK(
[#include <cxxabi.h>],
[abi::__cxa_demangle(NULL, 0, 0, NULL);],
[AC_DEFINE(HAVE_CXA_DEMANGLE, 1, Define to 1 if abi::__cxa_demangle is available)])
AC_LANG_POP(C++)


LOL_AC_CHECK()


dnl Use libcaca? (required for font generation)
ac_cv_my_have_caca="no"
PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
if test "${ac_cv_my_have_caca}" != "no"; then
AC_DEFINE(LOL_USE_CACA, 1, Define to 1 to use libcaca)
fi
AM_CONDITIONAL(LOL_USE_CACA, test "${ac_cv_my_have_caca}" != "no")


dnl Use GTK+? (required for the deushax editor)
ac_cv_my_have_gtkgl="no"
PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
if test "${ac_cv_my_have_gtkgl}" != "no"; then
AC_DEFINE(LOL_USE_GTKGL, 1, Define to 1 to use GtkGl)
fi
AM_CONDITIONAL(LOL_USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")


dnl Optional features
AM_CONDITIONAL(BUILD_TEST, test "${enable_test}" != "no" -a "${enable_subproject}" != "yes")
AM_CONDITIONAL(BUILD_TOOLS, test "${enable_tools}" != "no" -a "${enable_subproject}" != "yes")
AM_CONDITIONAL(BUILD_TUTORIAL, test "${enable_tutorial}" != "no" -a "${enable_subproject}" != "yes")
AM_CONDITIONAL(BUILD_SAMPLES, test "${enable_samples}" != "no" -a "${enable_subproject}" != "yes")


LOL_AC_FINI()

AC_CONFIG_HEADER(config.h)

AC_CONFIG_FILES(
[Makefile
src/Makefile
src/3rdparty/Makefile
src/data/Makefile
src/data/font/Makefile
src/t/Makefile
build/Makefile
binaries/Makefile
doc/Makefile
doc/doxygen.cfg
doc/samples/Makefile
doc/samples/math/Makefile
doc/samples/sandbox/Makefile
doc/tutorial/Makefile
tools/Makefile
tools/lolunit/Makefile
tools/vimlol/Makefile
tools/vslol/Makefile
])

AC_OUTPUT


+ 0
- 68
doc/Makefile.am 查看文件

@@ -1,68 +0,0 @@
include $(top_srcdir)/build/autotools/common.am

SUBDIRS =
SUBDIRS += tutorial
SUBDIRS += samples

EXTRA_DIST += doxygen.cfg.in doxygen.css footer.html header.html \
$(man_MANS) $(doxygen_DOX)
CLEANFILES += doxygen.log stamp-latex stamp-doxygen

doxygen_DOX = lolengine.dox
if BUILD_DOCUMENTATION
man_MANS = lolengine.1
endif

if BUILD_DOCUMENTATION
htmldoc_DATA = html/doxygen.css
htmldocdir = $(datadir)/doc/lolengine-dev/html
if LOL_USE_LATEX
pdfdoc_DATA = latex/lolengine.pdf
pdfdocdir = $(datadir)/doc/lolengine-dev/pdf
endif
endif

html/doxygen.css html/doxygen.png: stamp-doxygen
latex/lolengine.pdf: stamp-latex

stamp-doxygen: $(doxygen_DOX)
if BUILD_DOCUMENTATION
doxygen doxygen.cfg 2>&1 | tee doxygen.log
touch stamp-doxygen
endif

stamp-latex: stamp-doxygen
if BUILD_DOCUMENTATION
if LOL_USE_LATEX
rm -f latex/lolengine.tex latex/lolengine.pdf
$(SED) -i -e 's/setlength{/renewcommand{/' latex/refman.tex
$(SED) -i -e 's/.*usepackage.*times.*//' latex/refman.tex
$(SED) -i -e 's/latex refman/latex -file-line-error -halt-on-error refman/' latex/Makefile
cd latex && $(MAKE) $(AM_CFLAGS) refman.pdf || (cat refman.log; exit 1)
mv latex/refman.pdf latex/lolengine.pdf
touch stamp-latex
endif
endif

clean-local:
-rm -Rf html latex man

install-data-local:
if BUILD_DOCUMENTATION
mkdir -p $(DESTDIR)$(datadir)/doc
$(mkinstalldirs) $(DESTDIR)$(datadir)/doc/lolengine-dev/html
cp `find html -name '*.html' -o -name '*.gif' -o -name '*.png'` \
$(DESTDIR)$(datadir)/doc/lolengine-dev/html
$(mkinstalldirs) $(DESTDIR)$(mandir)/man3
for man in $$(find man -name '*.3lol'); do \
sed -e 's/man3lol/man3/g' -e "s/fC'\([a-zA-Z0-9]*\)'/fC\"\1\"/g" \
$$man >$(DESTDIR)$(mandir)/man3/$${man##*/}; \
done
$(mkinstalldirs) $(DESTDIR)$(mandir)/man1
endif

uninstall-local:
rmdir $(DESTDIR)$(datadir)/doc/lolengine-dev/html 2>/dev/null || true
rmdir $(DESTDIR)$(datadir)/doc/lolengine-dev 2>/dev/null || true
rmdir $(DESTDIR)$(datadir)/doc 2>/dev/null || true


+ 0
- 2469
doc/doxygen.cfg.in
文件差异内容过多而无法显示
查看文件


+ 0
- 1180
doc/doxygen.css
文件差异内容过多而无法显示
查看文件


+ 0
- 2
doc/footer.html 查看文件

@@ -1,2 +0,0 @@
</body>
</html>

+ 0
- 1
doc/grammar/README 查看文件

@@ -1 +0,0 @@
This directory contains old grammars for languages we used to parse.

+ 0
- 328
doc/grammar/easymesh-parser.y 查看文件

@@ -1,328 +0,0 @@
%{
//
// Lol Engine
//
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// (c) 2009-2013 Cédric Lecacheur <jordx@free.fr>
// (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include "core.h"
#include "easymesh/easymesh.h"

#include <string>
%}

%require "2.3"
%debug
%defines
%skeleton "lalr1.cc"
%name-prefix="lol"
%define parser_class_name "EasyMeshParser"
%locations
%parse-param { class EasyMeshCompiler& mc }
%error-verbose

%union
{
float fval;
int ival;
bool bval;
float vval[4];
int ivval[4];
char* lval;
/* Can't use uin32_t here for some reason */
unsigned u32val;
}

%start mesh_description

%token T_LOOP T_COLOR T_ACOLOR T_BCOLOR T_VCOLOR
%token T_TOGGLESCALEWINDING T_TOGGLEQUADWEIGHTING T_TOGGLEPOSTBUILDNORMAL T_TOGGLEVERTNOCLEANUP
%token T_VERTMERGE T_VERTSEPARATE

%token T_TRANSLATEX T_ROTATEX T_TAPERX T_TWISTX T_SHEARX T_STRETCHX T_BENDXY T_BENDXZ T_SCALEX T_MIRRORX
%token T_TRANSLATEY T_ROTATEY T_TAPERY T_TWISTY T_SHEARY T_STRETCHY T_BENDYX T_BENDYZ T_SCALEY T_MIRRORY
%token T_TRANSLATEZ T_ROTATEZ T_TAPERZ T_TWISTZ T_SHEARZ T_STRETCHZ T_BENDZX T_BENDZY T_SCALEZ T_MIRRORZ
%token T_TRANSLATE T_ROTATE T_SCALE T_RADIALJITTER T_SPLITTRIANGLE T_SMOOTHMESH
%token T_DUPLICATE
%token T_CSGUNION T_CSGSUBSTRACT T_CSGSUBSTRACTLOSS T_CSGAND T_CSGXOR
%token T_CHAMFER

%token T_CYLINDER T_BOX T_SMOOTHCHAMFBOX T_FLATCHAMFBOX T_SPHERE T_CAPSULE
%token T_STAR T_EXPANDEDSTAR T_DISC T_TRIANGLE T_QUAD T_COG T_TORUS

%token T_END 0
%token T_ERROR

%token <fval> F_NUMBER
%token <ival> I_NUMBER
%token <bval> BOOLEAN
%token <u32val> COLOR

/* Base Number types */
%type <fval> fv
%type <ival> iv
/* Vector types */
%type <vval> v2
%type <vval> v3
%type <vval> v4
/* Special types */
%type <bval> bv

%{
#include "easymesh/easymesh-compiler.h"

#undef yylex
#define yylex mc.m_lexer->lex

/* HACK: workaround for Bison who insists on using exceptions */
#define try if (true)
#define catch(...) if (false)
#define throw (void)0
%}

%%

mesh_description:
mesh_expression_list T_END
;

mesh_expression_list:
mesh_expression
| mesh_expression mesh_expression_list
;

mesh_expression:
mesh_command_list
| mesh_open mesh_expression_list mesh_close
;

mesh_command_list:
mesh_command
| mesh_command mesh_command_list
;

mesh_command:
color_command
| transform_command
| primitive_command
| post_brace_command
| pre_brace_command '[' mesh_expression_list mesh_close
| doloop '[' mesh_expression_list ']' { mc.m_mesh.LoopEnd(); }
;

post_brace_command:
T_CSGUNION mesh_open mesh_expression_list ']' { mc.m_mesh.CsgUnion(); mc.m_mesh.CloseBrace(); }
| T_CSGSUBSTRACT mesh_open mesh_expression_list ']' { mc.m_mesh.CsgSub(); mc.m_mesh.CloseBrace(); }
| T_CSGSUBSTRACTLOSS mesh_open mesh_expression_list ']' { mc.m_mesh.CsgSubL(); mc.m_mesh.CloseBrace(); }
| T_CSGAND mesh_open mesh_expression_list ']' { mc.m_mesh.CsgAnd(); mc.m_mesh.CloseBrace(); }
| T_CSGXOR mesh_open mesh_expression_list ']' { mc.m_mesh.CsgXor(); mc.m_mesh.CloseBrace(); }
;

doloop:
T_LOOP iv { mc.m_mesh.LoopStart($2); }
;

pre_brace_command:
T_DUPLICATE { mc.m_mesh.DupAndScale(vec3(1.f), true); }
;

mesh_open:
'[' { mc.m_mesh.OpenBrace(); }
;

mesh_close:
']' { mc.m_mesh.CloseBrace(); }
;

color_command:
T_COLOR fv fv fv fv { mc.m_mesh.SetCurColor(vec4($2, $3, $4, $5)); }
| T_COLOR v4 { mc.m_mesh.SetCurColor(vec4($2[0], $2[1], $2[2], $2[3])); }
| T_COLOR COLOR { uint32_t x = $2;
ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
mc.m_mesh.SetCurColor(vec4(v) * (1.f / 255.f)); }
| T_ACOLOR fv fv fv fv { mc.m_mesh.SetCurColorA(vec4($2, $3, $4, $5)); }
| T_ACOLOR v4 { mc.m_mesh.SetCurColorA(vec4($2[0], $2[1], $2[2], $2[3])); }
| T_ACOLOR COLOR { uint32_t x = $2;
ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
mc.m_mesh.SetCurColorA(vec4(v) * (1.f / 255.f)); }
| T_BCOLOR fv fv fv fv { mc.m_mesh.SetCurColorB(vec4($2, $3, $4, $5)); }
| T_BCOLOR v4 { mc.m_mesh.SetCurColorB(vec4($2[0], $2[1], $2[2], $2[3])); }
| T_BCOLOR COLOR { uint32_t x = $2;
ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
mc.m_mesh.SetCurColorB(vec4(v) * (1.f / 255.f)); }
| T_VCOLOR fv fv fv fv { mc.m_mesh.SetVertColor(vec4($2, $3, $4, $5)); }
| T_VCOLOR v4 { mc.m_mesh.SetVertColor(vec4($2[0], $2[1], $2[2], $2[3])); }
| T_VCOLOR COLOR { uint32_t x = $2;
ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
mc.m_mesh.SetVertColor(vec4(v) * (1.f / 255.f)); }
;

transform_command:
T_TRANSLATEX fv { mc.m_mesh.Translate(vec3($2, 0.f, 0.f)); }
| T_TRANSLATEY fv { mc.m_mesh.Translate(vec3(0.f, $2, 0.f)); }
| T_TRANSLATEZ fv { mc.m_mesh.Translate(vec3(0.f, 0.f, $2)); }
| T_TRANSLATE fv fv fv { mc.m_mesh.Translate(vec3($2, $3, $4)); }
| T_TRANSLATE v3 { mc.m_mesh.Translate(vec3($2[0], $2[1], $2[2])); }
| T_ROTATEX fv { mc.m_mesh.RotateX($2); }
| T_ROTATEY fv { mc.m_mesh.RotateY($2); }
| T_ROTATEZ fv { mc.m_mesh.RotateZ($2); }
| T_ROTATE fv fv fv fv { mc.m_mesh.Rotate($2, vec3($3, $4, $5)); }
| T_ROTATE fv v3 { mc.m_mesh.Rotate($2, vec3($3[0], $3[1], $3[2])); }
| T_RADIALJITTER fv { mc.m_mesh.RadialJitter($2); }
| T_TAPERX fv fv fv bv { mc.m_mesh.TaperX($2, $3, $4, $5); }
| T_TAPERX fv fv fv { mc.m_mesh.TaperX($2, $3, $4); }
| T_TAPERX fv fv { mc.m_mesh.TaperX($2, $3); }
| T_TAPERY fv fv fv bv { mc.m_mesh.TaperY($2, $3, $4, $5); }
| T_TAPERY fv fv fv { mc.m_mesh.TaperY($2, $3, $4); }
| T_TAPERY fv fv { mc.m_mesh.TaperY($2, $3); }
| T_TAPERZ fv fv fv bv { mc.m_mesh.TaperZ($2, $3, $4, $5); }
| T_TAPERZ fv fv fv { mc.m_mesh.TaperZ($2, $3, $4); }
| T_TAPERZ fv fv { mc.m_mesh.TaperZ($2, $3); }
| T_TWISTX fv fv { mc.m_mesh.TwistX($2, $3); }
| T_TWISTX fv { mc.m_mesh.TwistX($2); }
| T_TWISTY fv fv { mc.m_mesh.TwistY($2, $3); }
| T_TWISTY fv { mc.m_mesh.TwistY($2); }
| T_TWISTZ fv fv { mc.m_mesh.TwistZ($2, $3); }
| T_TWISTZ fv { mc.m_mesh.TwistZ($2); }
| T_SHEARX fv fv fv bv { mc.m_mesh.ShearX($2, $3, $4, $5); }
| T_SHEARX fv fv fv { mc.m_mesh.ShearX($2, $3, $4); }
| T_SHEARX fv fv { mc.m_mesh.ShearX($2, $3); }
| T_SHEARY fv fv fv bv { mc.m_mesh.ShearY($2, $3, $4, $5); }
| T_SHEARY fv fv fv { mc.m_mesh.ShearY($2, $3, $4); }
| T_SHEARY fv fv { mc.m_mesh.ShearY($2, $3); }
| T_SHEARZ fv fv fv bv { mc.m_mesh.ShearZ($2, $3, $4, $5); }
| T_SHEARZ fv fv fv { mc.m_mesh.ShearZ($2, $3, $4); }
| T_SHEARZ fv fv { mc.m_mesh.ShearZ($2, $3); }
| T_STRETCHX fv fv fv { mc.m_mesh.StretchX($2, $3, $4); }
| T_STRETCHX fv fv { mc.m_mesh.StretchX($2, $3); }
| T_STRETCHY fv fv fv { mc.m_mesh.StretchY($2, $3, $4); }
| T_STRETCHY fv fv { mc.m_mesh.StretchY($2, $3); }
| T_STRETCHZ fv fv fv { mc.m_mesh.StretchZ($2, $3, $4); }
| T_STRETCHZ fv fv { mc.m_mesh.StretchZ($2, $3); }
| T_BENDXY fv fv { mc.m_mesh.BendXY($2, $3); }
| T_BENDXY fv { mc.m_mesh.BendXY($2); }
| T_BENDXZ fv fv { mc.m_mesh.BendXZ($2, $3); }
| T_BENDXZ fv { mc.m_mesh.BendXZ($2); }
| T_BENDYX fv fv { mc.m_mesh.BendYX($2, $3); }
| T_BENDYX fv { mc.m_mesh.BendYX($2); }
| T_BENDYZ fv fv { mc.m_mesh.BendYZ($2, $3); }
| T_BENDYZ fv { mc.m_mesh.BendYZ($2); }
| T_BENDZX fv fv { mc.m_mesh.BendZX($2, $3); }
| T_BENDZX fv { mc.m_mesh.BendZX($2); }
| T_BENDZY fv fv { mc.m_mesh.BendZY($2, $3); }
| T_BENDZY fv { mc.m_mesh.BendZY($2); }
| T_SCALEX fv { mc.m_mesh.Scale(vec3($2, 1.f, 1.f)); }
| T_SCALEY fv { mc.m_mesh.Scale(vec3(1.f, $2, 1.f)); }
| T_SCALEZ fv { mc.m_mesh.Scale(vec3(1.f, 1.f, $2)); }
| T_SCALE fv fv fv { mc.m_mesh.Scale(vec3($2, $3, $4)); }
| T_SCALE v3 { mc.m_mesh.Scale(vec3($2[0], $2[1], $2[2])); }
| T_SCALE fv { mc.m_mesh.Scale(vec3($2, $2, $2)); }
| T_MIRRORX { mc.m_mesh.MirrorX(); }
| T_MIRRORY { mc.m_mesh.MirrorY(); }
| T_MIRRORZ { mc.m_mesh.MirrorZ(); }
| T_CHAMFER fv { mc.m_mesh.Chamfer($2); }
| T_SPLITTRIANGLE iv { mc.m_mesh.SplitTriangles($2); }
| T_SMOOTHMESH iv iv iv { mc.m_mesh.SmoothMesh($2, $3, $4); }
| T_TOGGLESCALEWINDING { mc.m_mesh.ToggleScaleWinding(); }
| T_TOGGLEQUADWEIGHTING { mc.m_mesh.ToggleQuadWeighting(); }
| T_TOGGLEPOSTBUILDNORMAL { mc.m_mesh.TogglePostBuildNormal(); }
| T_TOGGLEVERTNOCLEANUP { mc.m_mesh.ToggleVerticeNoCleanup(); }
| T_VERTMERGE { mc.m_mesh.VerticesMerge(); }
| T_VERTSEPARATE { mc.m_mesh.VerticesSeparate(); }
;

primitive_command:
T_CYLINDER iv fv fv fv bv bv bv { mc.m_mesh.AppendCylinder($2, $3, $4, $5, $6, $7, $8); }
| T_CYLINDER iv fv fv fv bv bv { mc.m_mesh.AppendCylinder($2, $3, $4, $5, $6, $7); }
| T_CYLINDER iv fv fv fv bv { mc.m_mesh.AppendCylinder($2, $3, $4, $5, $6); }
| T_CYLINDER iv fv fv fv { mc.m_mesh.AppendCylinder($2, $3, $4, $5); }
| T_CYLINDER iv fv fv { mc.m_mesh.AppendCylinder($2, $3, $4, $4); }
| T_SPHERE iv fv { mc.m_mesh.AppendSphere($2, $3); }
| T_CAPSULE iv fv fv { mc.m_mesh.AppendCapsule($2, $3, $4); }
| T_TORUS iv fv fv { mc.m_mesh.AppendTorus($2, $3, $4); }
| T_BOX fv fv fv fv { mc.m_mesh.AppendBox(vec3($2, $3, $4), $5); }
| T_BOX fv fv fv { mc.m_mesh.AppendBox(vec3($2, $3, $4)); }
| T_BOX fv { mc.m_mesh.AppendBox(vec3($2, $2, $2)); }
| T_BOX v3 fv { mc.m_mesh.AppendBox(vec3($2[0], $2[1], $2[2]), $3); }
| T_BOX v3 { mc.m_mesh.AppendBox(vec3($2[0], $2[1], $2[2])); }
| T_SMOOTHCHAMFBOX fv fv fv fv { mc.m_mesh.AppendSmoothChamfBox(vec3($2, $3, $4), $5); }
| T_SMOOTHCHAMFBOX fv fv { mc.m_mesh.AppendSmoothChamfBox(vec3($2, $2, $2), $3); }
| T_SMOOTHCHAMFBOX v3 fv { mc.m_mesh.AppendSmoothChamfBox(vec3($2[0], $2[1], $2[2]), $3); }
| T_FLATCHAMFBOX fv fv fv fv { mc.m_mesh.AppendFlatChamfBox(vec3($2, $3, $4), $5); }
| T_FLATCHAMFBOX fv fv { mc.m_mesh.AppendFlatChamfBox(vec3($2, $2, $2), $3); }
| T_FLATCHAMFBOX v3 fv { mc.m_mesh.AppendFlatChamfBox(vec3($2[0], $2[1], $2[2]), $3); }
| T_STAR iv fv fv bv bv { mc.m_mesh.AppendStar($2, $3, $4, $5, $6); }
| T_STAR iv fv fv bv { mc.m_mesh.AppendStar($2, $3, $4, $5); }
| T_STAR iv fv fv { mc.m_mesh.AppendStar($2, $3, $4); }
| T_EXPANDEDSTAR iv fv fv fv { mc.m_mesh.AppendExpandedStar($2, $3, $4, $5); }
| T_EXPANDEDSTAR iv fv fv { mc.m_mesh.AppendExpandedStar($2, $3, $4); }
| T_DISC iv fv bv { mc.m_mesh.AppendDisc($2, $3, $4); }
| T_DISC iv fv { mc.m_mesh.AppendDisc($2, $3); }
| T_TRIANGLE fv bv { mc.m_mesh.AppendSimpleTriangle($2, $3); }
| T_TRIANGLE fv { mc.m_mesh.AppendSimpleTriangle($2); }
| T_QUAD fv bv { mc.m_mesh.AppendSimpleQuad($2, $3); }
| T_QUAD fv { mc.m_mesh.AppendSimpleQuad($2); }
| T_COG iv fv fv fv fv fv fv fv fv bv { mc.m_mesh.AppendCog($2, $3, $4, $5, $6, $7, $8, $9, $10, $11); }
| T_COG iv fv fv fv fv fv fv fv fv { mc.m_mesh.AppendCog($2, $3, $4, $5, $6, $7, $8, $9, $10); }
| T_COG iv fv fv fv fv fv fv fv { mc.m_mesh.AppendCog($2, $3, $4, $5, $6, $7, $8, $9); }
| T_COG iv fv v2 v2 v2 fv bv { mc.m_mesh.AppendCog($2, $3, $4[0], $4[1], $5[0], $5[1], $6[0], $6[1], $7, $8); }
| T_COG iv fv v2 v2 v2 fv { mc.m_mesh.AppendCog($2, $3, $4[0], $4[1], $5[0], $5[1], $6[0], $6[1], $7); }
| T_COG iv fv v2 v2 v2 { mc.m_mesh.AppendCog($2, $3, $4[0], $4[1], $5[0], $5[1], $6[0], $6[1]); }
;

/* Base Number types */
fv:
F_NUMBER { $$ = $1; }
| '-' fv { $$ = -$2; }
| I_NUMBER { $$ = (float)$1; }
| '-' iv { $$ = -(float)$2; }
;

iv:
I_NUMBER { $$ = $1; }
| '-' iv { $$ = -$2; }
| F_NUMBER { $$ = (int)$1; }
| '-' fv { $$ = -(int)$2; }
;

/* Vector types */
v2:
'('fv')' { $$[0] = $2; $$[1] = $2; }
| '('fv fv')' { $$[0] = $2; $$[1] = $3; }
;

v3:
'('fv')' { $$[0] = $2; $$[1] = $2; $$[2] = $2; }
| '('fv fv fv')' { $$[0] = $2; $$[1] = $3; $$[2] = $4; }
;

v4:
'('fv')' { $$[0] = $2; $$[1] = $2; $$[2] = $2; $$[3] = $2; }
| '('fv fv fv fv')' { $$[0] = $2; $$[1] = $3; $$[2] = $4; $$[3] = $5; }
;

/* Special types */
bv:
BOOLEAN { $$ = $1; }
| I_NUMBER { $$ = !!$1; }
| F_NUMBER { $$ = !!$1; }
;

%%

void lol::EasyMeshParser::error(const EasyMeshParser::location_type& l,
const std::string& m)
{
mc.Error(l, m);
}


+ 0
- 208
doc/grammar/easymesh-scanner.l 查看文件

@@ -1,208 +0,0 @@
%{
//
// Lol Engine
//
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// (c) 2009-2013 Cédric Lecacheur <jordx@free.fr>
// (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdlib>
using std::exit;
using std::malloc;
using std::realloc;
using std::free;

#include "core.h"
#include "easymesh/easymesh-compiler.h"

typedef lol::EasyMeshParser::token token;
typedef lol::EasyMeshParser::token_type token_type;

#ifndef YY_DECL
# define YY_DECL lol::EasyMeshParser::token_type \
lol::EasyMeshScanner::lex(lol::EasyMeshParser::semantic_type* yylval, \
lol::EasyMeshParser::location_type* yylloc)
#endif

#define yyterminate() return token::T_END
#define YY_NO_UNISTD_H
#define YY_USER_ACTION yylloc->columns(yyleng);
%}

%option c++ prefix="EasyMesh"
%option batch yywrap nounput stack

%%

%{ /* reset location at the beginning of yylex() */
yylloc->step();
%}

(csgu|csgunion) { return token::T_CSGUNION; }
(csgs|CsgSub) { return token::T_CSGSUBSTRACT; }
(csgsl|CsgSubL) { return token::T_CSGSUBSTRACTLOSS; }
(csga|csgand) { return token::T_CSGAND; }
(csgx|csgxor) { return token::T_CSGXOR; }

(lp|loop) { return token::T_LOOP; }
(sc|setcolor) { return token::T_COLOR; }
(sca|setcolora) { return token::T_ACOLOR; }
(scb|setcolorb) { return token::T_BCOLOR; }
(scv|setcolorv) { return token::T_VCOLOR; }

(tsw|tglscalewind) { return token::T_TOGGLESCALEWINDING; }
(tqw|tglquadweight) { return token::T_TOGGLEQUADWEIGHTING; }
(tpbn|tglpstbuildnormal) { return token::T_TOGGLEPOSTBUILDNORMAL; }
(tvnc|tglvertnocleanup) { return token::T_TOGGLEVERTNOCLEANUP; }

(vm|vertmerge) { return token::T_VERTMERGE; }
(vs|vertseparate) { return token::T_VERTSEPARATE; }

(tx|translatex) { return token::T_TRANSLATEX; }
(ty|translatey) { return token::T_TRANSLATEY; }
(tz|translatez) { return token::T_TRANSLATEZ; }
(t|translate) { return token::T_TRANSLATE; }
(rx|rotatex) { return token::T_ROTATEX; }
(ry|rotatey) { return token::T_ROTATEY; }
(rz|rotatez) { return token::T_ROTATEZ; }
(r|rotate) { return token::T_ROTATE; }
(rj|radialjitter) { return token::T_RADIALJITTER; }
(tax|taperx) { return token::T_TAPERX; }
(tay|tapery) { return token::T_TAPERY; }
(taz|taperz) { return token::T_TAPERZ; }
(twx|twistx) { return token::T_TWISTX; }
(twy|twisty) { return token::T_TWISTY; }
(twz|twistz) { return token::T_TWISTZ; }
(shx|shearx) { return token::T_SHEARX; }
(shy|sheary) { return token::T_SHEARY; }
(shz|shearz) { return token::T_SHEARZ; }
(stx|stretchx) { return token::T_STRETCHX; }
(sty|stretchy) { return token::T_STRETCHY; }
(stz|stretchz) { return token::T_STRETCHZ; }
(bdxy|bendxy) { return token::T_BENDXY; }
(bdxz|bendxz) { return token::T_BENDXZ; }
(bdyx|bendyx) { return token::T_BENDYX; }
(bdyz|bendyz) { return token::T_BENDYZ; }
(bdzx|bendzx) { return token::T_BENDZX; }
(bdzy|bendzy) { return token::T_BENDZY; }
(sx|scalex) { return token::T_SCALEX; }
(sy|scaley) { return token::T_SCALEY; }
(sz|scalez) { return token::T_SCALEZ; }
(s|scale) { return token::T_SCALE; }
(mx|mirrorx) { return token::T_MIRRORX; }
(my|mirrory) { return token::T_MIRRORY; }
(mz|mirrorz) { return token::T_MIRRORZ; }
(ch|chamfer) { return token::T_CHAMFER; }
(splt|splittriangle) { return token::T_SPLITTRIANGLE; }
(smth|smooth) { return token::T_SMOOTHMESH; }
(dup|duplicate) { return token::T_DUPLICATE; }

(ac|addcylinder) { return token::T_CYLINDER; }
(asph|addsphere) { return token::T_SPHERE; }
(acap|addcapsule) { return token::T_CAPSULE; }
(ato|addtorus) { return token::T_TORUS; }
(ab|addbox) { return token::T_BOX; }
(ascb|addsmoothchamfbox) { return token::T_SMOOTHCHAMFBOX; }
(afcb|addflatchamfbox) { return token::T_FLATCHAMFBOX; }
(as|addstar) { return token::T_STAR; }
(aes|addexpandedstar) { return token::T_EXPANDEDSTAR; }
(ad|adddisc) { return token::T_DISC; }
(at|addtriangle) { return token::T_TRIANGLE; }
(aq|addquad) { return token::T_QUAD; }
(acg|addcog) { return token::T_COG; }

%{ /* ======= BASE COLOR TYPES ========================================= */ %}
%{ /* COLOR */ %}
#[0-9a-fA-F]{3} {
uint32_t tmp = std::strtol(yytext + 1, nullptr, 16);
yylval->u32val = 0x11000000u * (tmp >> 8)
| 0x00110000u * ((tmp >> 4) & 0xf)
| 0x00001100u * (tmp & 0xf)
| 0x000000ffu;
return token::COLOR; }
#[0-9a-fA-F]{4} {
uint32_t tmp = std::strtol(yytext + 1, nullptr, 16);
yylval->u32val = 0x11000000u * (tmp >> 12)
| 0x00110000u * ((tmp >> 8) & 0xf)
| 0x00001100u * ((tmp >> 4) & 0xf)
| 0x00000011u * (tmp & 0xf);
return token::COLOR; }
#[0-9a-fA-F]{6} {
yylval->u32val = 0xffu
| 0x100u * (uint32_t)std::strtol(yytext + 1, nullptr, 16);
return token::COLOR; }
#[0-9a-fA-F]{8} {
yylval->u32val = (uint32_t)std::strtol(yytext + 1, nullptr, 16);
return token::COLOR; }

%{ /* ======= BASE DATA TYPES ========================================= */ %}
%{ /* BOOL */ %}
true { yylval->bval = true; return token::BOOLEAN; }
false { yylval->bval = false; return token::BOOLEAN; }
%{ /* FLOAT */ %}
[-+]?[0-9]*\.[0-9]+([eE][-+]?[0-9]+)? {
yylval->fval = (float)std::atof(yytext); return token::F_NUMBER; }
%{ /* INT */ %}
[-+]?[0-9]+ {
yylval->ival = std::atoi(yytext); return token::I_NUMBER; }

%{ /* ======= COMMENTS ======= */ %}
"//".* { /* ignore this */ }

%{ /* Semantics tokens */ %}
"-" { return token_type('-'); }
"(" { return token_type('('); }
")" { return token_type(')'); }
"{" { return token_type('{'); }
"}" { return token_type('}'); }
[\[] { return token_type('['); }
[\]] { return token_type(']'); }
[ ,] { /* ignore this */ }
[\n] { /* ignore this */ }
. { return token::T_ERROR; }

%%

lol::EasyMeshScanner::EasyMeshScanner(char const *command)
: EasyMeshFlexLexer(0, 0),
m_input(command)
{
}

lol::EasyMeshScanner::~EasyMeshScanner()
{
}

int lol::EasyMeshScanner::LexerInput(char* buf, int max_size)
{
(void)max_size; /* unused for now */

buf[0] = m_input[0];
if (buf[0])
++m_input;
return buf[0] ? 1 : 0;
}

#ifdef yylex
#undef yylex
#endif
int EasyMeshFlexLexer::yylex()
{
std::cerr << "in EasyMeshFlexLexer::yylex() !" << std::endl;
return 0;
}

int EasyMeshFlexLexer::yywrap()
{
return 1;
}


+ 0
- 1311
doc/grammar/lolfx-parser.y
文件差异内容过多而无法显示
查看文件


+ 0
- 799
doc/grammar/lolfx-scanner.l 查看文件

@@ -1,799 +0,0 @@
%{
//
// Lol Engine
//
// Copyright © 2012—2018 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdlib>
using std::exit;
using std::malloc;
using std::realloc;
using std::free;
#include <iostream>
#include <map>

#include "core.h"
#include "gpu/lolfx-compiler.h"

typedef lol::LolFxParser::token token;
typedef lol::LolFxParser::token_type token_type;

#ifndef YY_DECL
# define YY_DECL lol::LolFxParser::token_type \
lol::LolFxScanner::lex(lol::LolFxParser::semantic_type* yylval, \
lol::LolFxParser::location_type* yylloc)
#endif

#define yyterminate() return token::T_END
#define YY_NO_UNISTD_H
#define YY_USER_ACTION yylloc->columns(yyleng);
%}

%option c++ prefix="LolFx"
%option batch yywrap nounput stack

%x C_COMMENT
%x CPP_COMMENT
%x PREPROCESSOR_COMMENT

%%

%{
/* reset location at the beginning of yylex() */
yylloc->step();

int language_guess = INITIAL;
m_pp_stack.Push(BlockIsTrue);
%}

/*
* GLSL keywords
*/

"subroutine" { return token::GT_SUBROUTINE; }
"patch" { return token::GT_PATCH; }
"sample" { return token::GT_SAMPLE; }
"flat" { return token::GT_FLAT; }
"smooth" { return token::GT_SMOOTH; }
"layout" { return token::GT_LAYOUT; }
"sampler1dshadow" { return token::GT_SAMPLER1DSHADOW; }
"sampler2dshadow" { return token::GT_SAMPLER2DSHADOW; }
"samplercubeshadow" { return token::GT_SAMPLERCUBESHADOW; }
"sampler1darray" { return token::GT_SAMPLER1DARRAY; }
"sampler2darray" { return token::GT_SAMPLER2DARRAY; }
"sampler1darrayshadow" { return token::GT_SAMPLER1DARRAYSHADOW; }
"sampler2darrayshadow" { return token::GT_SAMPLER2DARRAYSHADOW; }
"isampler1d" { return token::GT_ISAMPLER1D; }
"isampler2d" { return token::GT_ISAMPLER2D; }
"isampler3d" { return token::GT_ISAMPLER3D; }
"isamplercube" { return token::GT_ISAMPLERCUBE; }
"isampler1darray" { return token::GT_ISAMPLER1DARRAY; }
"isampler2darray" { return token::GT_ISAMPLER2DARRAY; }
"usampler1d" { return token::GT_USAMPLER1D; }
"usampler2d" { return token::GT_USAMPLER2D; }
"usampler3d" { return token::GT_USAMPLER3D; }
"usamplercube" { return token::GT_USAMPLERCUBE; }
"usampler1darray" { return token::GT_USAMPLER1DARRAY; }
"usampler2darray" { return token::GT_USAMPLER2DARRAY; }
"sampler2drect" { return token::GT_SAMPLER2DRECT; }
"sampler2drectshadow" { return token::GT_SAMPLER2DRECTSHADOW; }
"isampler2drect" { return token::GT_ISAMPLER2DRECT; }
"usampler2drect" { return token::GT_USAMPLER2DRECT; }
"samplerbuffer" { return token::GT_SAMPLERBUFFER; }
"isamplerbuffer" { return token::GT_ISAMPLERBUFFER; }
"usamplerbuffer" { return token::GT_USAMPLERBUFFER; }
"samplercubearray" { return token::GT_SAMPLERCUBEARRAY; }
"samplercubearrayshadow" { return token::GT_SAMPLERCUBEARRAYSHADOW; }
"isamplercubearray" { return token::GT_ISAMPLERCUBEARRAY; }
"usamplercubearray" { return token::GT_USAMPLERCUBEARRAY; }
"sampler2dms" { return token::GT_SAMPLER2DMS; }
"isampler2dms" { return token::GT_ISAMPLER2DMS; }
"usampler2dms" { return token::GT_USAMPLER2DMS; }
"sampler2dmsarray" { return token::GT_SAMPLER2DMSARRAY; }
"isampler2dmsarray" { return token::GT_ISAMPLER2DMSARRAY; }
"usampler2dmsarray" { return token::GT_USAMPLER2DMSARRAY; }

"highp" { return token::GT_HIGHP; }
"mediump" { return token::GT_MEDIUMP; }
"lowp" { return token::GT_LOWP; }
"precision" { return token::GT_PRECISION; }
"invariant" { return token::GT_INVARIANT; }

/*
* Deprecated GLSL keywords
*/

"attribute" { return token::GT_ATTRIBUTE; }
"varying" { return token::GT_VARYING; }

/*
* GLSL vector types
*/

"bvec2" { return token::GT_BVEC2; }
"bvec3" { return token::GT_BVEC3; }
"bvec4" { return token::GT_BVEC4; }

"ivec2" { return token::GT_IVEC2; }
"ivec3" { return token::GT_IVEC3; }
"ivec4" { return token::GT_IVEC4; }

"uvec2" { return token::GT_UVEC2; }
"uvec3" { return token::GT_UVEC3; }
"uvec4" { return token::GT_UVEC4; }

"vec2" { return token::GT_VEC2; }
"vec3" { return token::GT_VEC3; }
"vec4" { return token::GT_VEC4; }
"mat2" { return token::GT_MAT2; }
"mat2x2" { return token::GT_MAT2X2; }
"mat2x3" { return token::GT_MAT2X3; }
"mat2x4" { return token::GT_MAT2X4; }
"mat3" { return token::GT_MAT3; }
"mat3x2" { return token::GT_MAT3X2; }
"mat3x3" { return token::GT_MAT3X3; }
"mat3x4" { return token::GT_MAT3X4; }
"mat4" { return token::GT_MAT4; }
"mat4x2" { return token::GT_MAT4X2; }
"mat4x3" { return token::GT_MAT4X3; }
"mat4x4" { return token::GT_MAT4X4; }

"dvec2" { return token::GT_DVEC2; }
"dvec3" { return token::GT_DVEC3; }
"dvec4" { return token::GT_DVEC4; }
"dmat2" { return token::GT_DMAT2; }
"dmat2x2" { return token::GT_DMAT2X2; }
"dmat2x3" { return token::GT_DMAT2X3; }
"dmat2x4" { return token::GT_DMAT2X4; }
"dmat3" { return token::GT_DMAT3; }
"dmat3x2" { return token::GT_DMAT3X2; }
"dmat3x3" { return token::GT_DMAT3X3; }
"dmat3x4" { return token::GT_DMAT3X4; }
"dmat4" { return token::GT_DMAT4; }
"dmat4x2" { return token::GT_DMAT4X2; }
"dmat4x3" { return token::GT_DMAT4X3; }
"dmat4x4" { return token::GT_DMAT4X4; }

/*
* GLSL constant values
*/

"true" { yylval->ival = 1; return token::BOOLCONSTANT; }
"false" { yylval->ival = 0; return token::BOOLCONSTANT; }

/*
* GLSL keywords that are also valid or reserved in HLSL
* and HLSL keywords that are also valid or reserved in GLSL.
*/

"bool" { return token::GHT_BOOL; }
"break" { return token::GHT_BREAK; }
"case" { return token::GHT_CASE; }
"centroid" { return token::GHT_CENTROID; }
"const" { return token::GHT_CONST; }
"continue" { return token::GHT_CONTINUE; }
"default" { return token::GHT_DEFAULT; }
"discard" { return token::GHT_DISCARD; }
"do" { return token::GHT_DO; }
"double" { return token::GHT_DOUBLE; }
"else" { return token::GHT_ELSE; }
"float" { return token::GHT_FLOAT; }
"for" { return token::GHT_FOR; }
"if" { return token::GHT_IF; }
"in" { return token::GHT_IN; }
"inout" { return token::GHT_INOUT; }
"int" { return token::GHT_INT; }
"noperspective" { return token::GHT_NOPERSPECTIVE; }
"out" { return token::GHT_OUT; }
"return" { return token::GHT_RETURN; }
"sampler1d" { return token::GHT_SAMPLER1D; }
"sampler2d" { return token::GHT_SAMPLER2D; }
"sampler3d" { return token::GHT_SAMPLER3D; }
"samplercube" { return token::GHT_SAMPLERCUBE; }
"struct" { return token::GHT_STRUCT; }
"switch" { return token::GHT_SWITCH; }
"uint" { return token::GHT_UINT; }
"uniform" { return token::GHT_UNIFORM; }
"void" { return token::GHT_VOID; }
"while" { return token::GHT_WHILE; }

(?i:bool) { return token::HGT_BOOL; }
(?i:break) { return token::HGT_BREAK; }
(?i:case) { return token::HGT_CASE; }
(?i:centroid) { return token::HGT_CENTROID; }
(?i:const) { return token::HGT_CONST; }
(?i:continue) { return token::HGT_CONTINUE; }
(?i:default) { return token::HGT_DEFAULT; }
(?i:discard) { return token::HGT_DISCARD; }
(?i:do) { return token::HGT_DO; }
(?i:double) { return token::HGT_DOUBLE; }
(?i:else) { return token::HGT_ELSE; }
(?i:float) { return token::HGT_FLOAT; }
(?i:for) { return token::HGT_FOR; }
(?i:if) { return token::HGT_IF; }
(?i:in) { return token::HGT_IN; }
(?i:inout) { return token::HGT_INOUT; }
(?i:int) { return token::HGT_INT; }
(?i:noperspective) { return token::HGT_NOPERSPECTIVE; }
(?i:out) { return token::HGT_OUT; }
(?i:return) { return token::HGT_RETURN; }
(?i:sampler1d) { return token::HGT_SAMPLER1D; }
(?i:sampler2d) { return token::HGT_SAMPLER2D; }
(?i:sampler3d) { return token::HGT_SAMPLER3D; }
(?i:samplercube) { return token::HGT_SAMPLERCUBE; }
(?i:struct) { return token::HGT_STRUCT; }
(?i:switch) { return token::HGT_SWITCH; }
(?i:uint) { return token::HGT_UINT; }
(?i:uniform) { return token::HGT_UNIFORM; }
(?i:void) { return token::HGT_VOID; }
(?i:while) { return token::HGT_WHILE; }

/*
* HLSL keywords
* Gathered from http://msdn.microsoft.com/en-us/library/windows/desktop/bb509568%28v=vs.85%29.aspx
*/

(?i:appendstructuredbuffer) { return token::HT_APPENDSTRUCTUREDBUFFER; }
(?i:asm) { return token::HT_ASM; }
(?i:asm_fragment) { return token::HT_ASM_FRAGMENT; }
(?i:blendstate) { return token::HT_BLENDSTATE; }
(?i:buffer) { return token::HT_BUFFER; }
(?i:byteaddressbuffer) { return token::HT_BYTEADDRESSBUFFER; }
(?i:cbuffer) { return token::HT_CBUFFER; }
(?i:column_major) { return token::HT_COLUMN_MAJOR; }
(?i:compile) { return token::HT_COMPILE; }
(?i:compile_fragment) { return token::HT_COMPILE_FRAGMENT; }
(?i:compileshader) { return token::HT_COMPILESHADER; }
(?i:computeshader) { return token::HT_COMPUTESHADER; }
(?i:consumestructuredbuffer) { return token::HT_CONSUMESTRUCTUREDBUFFER; }
(?i:depthstencilstate) { return token::HT_DEPTHSTENCILSTATE; }
(?i:depthstencilview) { return token::HT_DEPTHSTENCILVIEW; }
(?i:domainshader) { return token::HT_DOMAINSHADER; }
(?i:dword) { return token::HT_DWORD; }
(?i:extern) { return token::HT_EXTERN; }
(?i:false) { return token::HT_FALSE; }
(?i:fxgroup) { return token::HT_FXGROUP; }
(?i:geometryshader) { return token::HT_GEOMETRYSHADER; }
(?i:groupshared) { return token::HT_GROUPSHARED; }
(?i:half) { return token::HT_HALF; }
(?i:hullshader) { return token::HT_HULLSHADER; }
(?i:inline) { return token::HT_INLINE; }
(?i:inputpatch) { return token::HT_INPUTPATCH; }
(?i:interface) { return token::HT_INTERFACE; }
(?i:line) { return token::HT_LINE; }
(?i:lineadj) { return token::HT_LINEADJ; }
(?i:linear) { return token::HT_LINEAR; }
(?i:linestream) { return token::HT_LINESTREAM; }
(?i:matrix) { return token::HT_MATRIX; }
(?i:namespace) { return token::HT_NAMESPACE; }
(?i:nointerpolation) { return token::HT_NOINTERPOLATION; }
(?i:null) { return token::HT_NULL; }
(?i:outputpatch) { return token::HT_OUTPUTPATCH; }
(?i:packoffset) { return token::HT_PACKOFFSET; }
(?i:pass) { return token::HT_PASS; }
(?i:pixelfragment) { return token::HT_PIXELFRAGMENT; }
(?i:pixelshader) { return token::HT_PIXELSHADER; }
(?i:point) { return token::HT_POINT; }
(?i:pointstream) { return token::HT_POINTSTREAM; }
(?i:precise) { return token::HT_PRECISE; }
(?i:rasterizerstate) { return token::HT_RASTERIZERSTATE; }
(?i:rendertargetview) { return token::HT_RENDERTARGETVIEW; }
(?i:register) { return token::HT_REGISTER; }
(?i:row_major) { return token::HT_ROW_MAJOR; }
(?i:rwbuffer) { return token::HT_RWBUFFER; }
(?i:rwbyteaddressbuffer) { return token::HT_RWBYTEADDRESSBUFFER; }
(?i:rwstructuredbuffer) { return token::HT_RWSTRUCTUREDBUFFER; }
(?i:rwtexture1d) { return token::HT_RWTEXTURE1D; }
(?i:rwtexture1darray) { return token::HT_RWTEXTURE1DARRAY; }
(?i:rwtexture2d) { return token::HT_RWTEXTURE2D; }
(?i:rwtexture2darray) { return token::HT_RWTEXTURE2DARRAY; }
(?i:rwtexture3d) { return token::HT_RWTEXTURE3D; }
(?i:sampler) { return token::HT_SAMPLER; }
(?i:sampler_state) { return token::HT_SAMPLER_STATE; }
(?i:samplerstate) { return token::HT_SAMPLERSTATE; }
(?i:samplercomparisonstate) { return token::HT_SAMPLERCOMPARISONSTATE; }
(?i:shared) { return token::HT_SHARED; }
(?i:snorm) { return token::HT_SNORM; }
(?i:stateblock) { return token::HT_STATEBLOCK; }
(?i:stateblock_state) { return token::HT_STATEBLOCK_STATE; }
(?i:static) { return token::HT_STATIC; }
(?i:string) { return token::HT_STRING; }
(?i:structuredbuffer) { return token::HT_STRUCTUREDBUFFER; }
(?i:tbuffer) { return token::HT_TBUFFER; }
(?i:technique) { return token::HT_TECHNIQUE; }
(?i:technique10) { return token::HT_TECHNIQUE10; }
(?i:technique11xz) { return token::HT_TECHNIQUE11XZ; }
"texture" { return token::HT_TEXTURE; }
(?i:texture1d) { return token::HT_TEXTURE1D; }
(?i:texture1darray) { return token::HT_TEXTURE1DARRAY; }
(?i:texture2d) { return token::HT_TEXTURE2D; }
(?i:texture2darray) { return token::HT_TEXTURE2DARRAY; }
(?i:texture2dms) { return token::HT_TEXTURE2DMS; }
(?i:texture2dmsarray) { return token::HT_TEXTURE2DMSARRAY; }
(?i:texture3d) { return token::HT_TEXTURE3D; }
(?i:texturecube) { return token::HT_TEXTURECUBE; }
(?i:texturecubearray) { return token::HT_TEXTURECUBEARRAY; }
(?i:true) { return token::HT_TRUE; }
(?i:typedef) { return token::HT_TYPEDEF; }
(?i:triangle) { return token::HT_TRIANGLE; }
(?i:triangleadj) { return token::HT_TRIANGLEADJ; }
(?i:trianglestream) { return token::HT_TRIANGLESTREAM; }
(?i:unorm) { return token::HT_UNORM; }
(?i:vector) { return token::HT_VECTOR; }
(?i:vertexfragment) { return token::HT_VERTEXFRAGMENT; }
(?i:vertexshader) { return token::HT_VERTEXSHADER; }
(?i:volatile) { return token::HT_VOLATILE; }

/*
* HLSL vector types
* TODO: this can probably be factored somehow
*/

(?i:bool1) { return token::HT_BOOL1; }
(?i:bool1x1) { return token::HT_BOOL1x1; }
(?i:bool2x1) { return token::HT_BOOL2x1; }
(?i:bool3x1) { return token::HT_BOOL3x1; }
(?i:bool4x1) { return token::HT_BOOL4x1; }
(?i:bool2) { return token::HT_BOOL2; }
(?i:bool1x2) { return token::HT_BOOL1x2; }
(?i:bool2x2) { return token::HT_BOOL2x2; }
(?i:bool3x2) { return token::HT_BOOL3x2; }
(?i:bool4x2) { return token::HT_BOOL4x2; }
(?i:bool3) { return token::HT_BOOL3; }
(?i:bool1x3) { return token::HT_BOOL1x3; }
(?i:bool2x3) { return token::HT_BOOL2x3; }
(?i:bool3x3) { return token::HT_BOOL3x3; }
(?i:bool4x3) { return token::HT_BOOL4x3; }
(?i:bool4) { return token::HT_BOOL4; }
(?i:bool1x4) { return token::HT_BOOL1x4; }
(?i:bool2x4) { return token::HT_BOOL2x4; }
(?i:bool3x4) { return token::HT_BOOL3x4; }
(?i:bool4x4) { return token::HT_BOOL4x4; }

(?i:float1) { return token::HT_FLOAT1; }
(?i:float1x1) { return token::HT_FLOAT1x1; }
(?i:float2x1) { return token::HT_FLOAT2x1; }
(?i:float3x1) { return token::HT_FLOAT3x1; }
(?i:float4x1) { return token::HT_FLOAT4x1; }
(?i:float2) { return token::HT_FLOAT2; }
(?i:float1x2) { return token::HT_FLOAT1x2; }
(?i:float2x2) { return token::HT_FLOAT2x2; }
(?i:float3x2) { return token::HT_FLOAT3x2; }
(?i:float4x2) { return token::HT_FLOAT4x2; }
(?i:float3) { return token::HT_FLOAT3; }
(?i:float1x3) { return token::HT_FLOAT1x3; }
(?i:float2x3) { return token::HT_FLOAT2x3; }
(?i:float3x3) { return token::HT_FLOAT3x3; }
(?i:float4x3) { return token::HT_FLOAT4x3; }
(?i:float4) { return token::HT_FLOAT4; }
(?i:float1x4) { return token::HT_FLOAT1x4; }
(?i:float2x4) { return token::HT_FLOAT2x4; }
(?i:float3x4) { return token::HT_FLOAT3x4; }
(?i:float4x4) { return token::HT_FLOAT4x4; }

(?i:double1) { return token::HT_DOUBLE1; }
(?i:double1x1) { return token::HT_DOUBLE1x1; }
(?i:double2x1) { return token::HT_DOUBLE2x1; }
(?i:double3x1) { return token::HT_DOUBLE3x1; }
(?i:double4x1) { return token::HT_DOUBLE4x1; }
(?i:double2) { return token::HT_DOUBLE2; }
(?i:double1x2) { return token::HT_DOUBLE1x2; }
(?i:double2x2) { return token::HT_DOUBLE2x2; }
(?i:double3x2) { return token::HT_DOUBLE3x2; }
(?i:double4x2) { return token::HT_DOUBLE4x2; }
(?i:double3) { return token::HT_DOUBLE3; }
(?i:double1x3) { return token::HT_DOUBLE1x3; }
(?i:double2x3) { return token::HT_DOUBLE2x3; }
(?i:double3x3) { return token::HT_DOUBLE3x3; }
(?i:double4x3) { return token::HT_DOUBLE4x3; }
(?i:double4) { return token::HT_DOUBLE4; }
(?i:double1x4) { return token::HT_DOUBLE1x4; }
(?i:double2x4) { return token::HT_DOUBLE2x4; }
(?i:double3x4) { return token::HT_DOUBLE3x4; }
(?i:double4x4) { return token::HT_DOUBLE4x4; }

(?i:dword1) { return token::HT_DWORD1; }
(?i:dword1x1) { return token::HT_DWORD1x1; }
(?i:dword2x1) { return token::HT_DWORD2x1; }
(?i:dword3x1) { return token::HT_DWORD3x1; }
(?i:dword4x1) { return token::HT_DWORD4x1; }
(?i:dword2) { return token::HT_DWORD2; }
(?i:dword1x2) { return token::HT_DWORD1x2; }
(?i:dword2x2) { return token::HT_DWORD2x2; }
(?i:dword3x2) { return token::HT_DWORD3x2; }
(?i:dword4x2) { return token::HT_DWORD4x2; }
(?i:dword3) { return token::HT_DWORD3; }
(?i:dword1x3) { return token::HT_DWORD1x3; }
(?i:dword2x3) { return token::HT_DWORD2x3; }
(?i:dword3x3) { return token::HT_DWORD3x3; }
(?i:dword4x3) { return token::HT_DWORD4x3; }
(?i:dword4) { return token::HT_DWORD4; }
(?i:dword1x4) { return token::HT_DWORD1x4; }
(?i:dword2x4) { return token::HT_DWORD2x4; }
(?i:dword3x4) { return token::HT_DWORD3x4; }
(?i:dword4x4) { return token::HT_DWORD4x4; }

(?i:int1) { return token::HT_INT1; }
(?i:int1x1) { return token::HT_INT1x1; }
(?i:int2x1) { return token::HT_INT2x1; }
(?i:int3x1) { return token::HT_INT3x1; }
(?i:int4x1) { return token::HT_INT4x1; }
(?i:int2) { return token::HT_INT2; }
(?i:int1x2) { return token::HT_INT1x2; }
(?i:int2x2) { return token::HT_INT2x2; }
(?i:int3x2) { return token::HT_INT3x2; }
(?i:int4x2) { return token::HT_INT4x2; }
(?i:int3) { return token::HT_INT3; }
(?i:int1x3) { return token::HT_INT1x3; }
(?i:int2x3) { return token::HT_INT2x3; }
(?i:int3x3) { return token::HT_INT3x3; }
(?i:int4x3) { return token::HT_INT4x3; }
(?i:int4) { return token::HT_INT4; }
(?i:int1x4) { return token::HT_INT1x4; }
(?i:int2x4) { return token::HT_INT2x4; }
(?i:int3x4) { return token::HT_INT3x4; }
(?i:int4x4) { return token::HT_INT4x4; }

(?i:uint1) { return token::HT_UINT1; }
(?i:uint1x1) { return token::HT_UINT1x1; }
(?i:uint2x1) { return token::HT_UINT2x1; }
(?i:uint3x1) { return token::HT_UINT3x1; }
(?i:uint4x1) { return token::HT_UINT4x1; }
(?i:uint2) { return token::HT_UINT2; }
(?i:uint1x2) { return token::HT_UINT1x2; }
(?i:uint2x2) { return token::HT_UINT2x2; }
(?i:uint3x2) { return token::HT_UINT3x2; }
(?i:uint4x2) { return token::HT_UINT4x2; }
(?i:uint3) { return token::HT_UINT3; }
(?i:uint1x3) { return token::HT_UINT1x3; }
(?i:uint2x3) { return token::HT_UINT2x3; }
(?i:uint3x3) { return token::HT_UINT3x3; }
(?i:uint4x3) { return token::HT_UINT4x3; }
(?i:uint4) { return token::HT_UINT4; }
(?i:uint1x4) { return token::HT_UINT1x4; }
(?i:uint2x4) { return token::HT_UINT2x4; }
(?i:uint3x4) { return token::HT_UINT3x4; }
(?i:uint4x4) { return token::HT_UINT4x4; }

/*
* HLSL preprocessor directives
* Gathered from http://msdn.microsoft.com/en-us/library/windows/desktop/bb943993%28v=vs.85%29.aspx
*/

^[ \t]*"#"[ \t]*"define".* {
/* FIXME: this is very, very limited */
char const *tmp = strstr(yytext, "define") + 6;
while (*tmp == ' ' || *tmp == '\n')
tmp++;
if (*tmp == '\0')
return token::PREPROCESSOR_DEFINE;
char const *tmp2 = tmp;
while (*tmp != ' ' && *tmp != '\n' && *tmp != '\0')
tmp++;
String key(tmp2, (int)(tmp - tmp2));
while (*tmp == ' ' || *tmp == '\n')
tmp++;
String val(*tmp ? tmp : "1");

Log::Debug("new macro: ‘%s’ = ‘%s’\n", key.C(), val.C());
m_pp_defines[key] = val;
}

^[ \t]*"#"[ \t]*"elif" {
if (m_pp_stack.Count() <= 1)
return token::PREPROCESSOR_ELIF;
m_pp_stack.Last() = BlockIsForeverFalse;
BEGIN(PREPROCESSOR_COMMENT);
}

^[ \t]*"#"[ \t]*"else" {
if (m_pp_stack.Count() <= 1)
return token::PREPROCESSOR_ELSE;
m_pp_stack.Last() = BlockIsForeverFalse;
BEGIN(PREPROCESSOR_COMMENT);
}

^[ \t]*"#"[ \t]*"endif" {
if (m_pp_stack.Count() <= 1)
return token::PREPROCESSOR_ENDIF;
m_pp_stack.Pop();
}

^[ \t]*"#"[ \t]*"error".* { return token::PREPROCESSOR_ERROR; }

^[ \t]*"#"[ \t]*"if".* {
if (IsExpressionTrue(strstr(yytext, "if") + 2))
{
m_pp_stack.Push(BlockIsTrue);
}
else
{
m_pp_stack.Push(BlockIsFalse);
BEGIN(PREPROCESSOR_COMMENT);
}
}

^[ \t]*"#"[ \t]*"ifdef" {
/* FIXME: this is very, very limited */
char const *tmp = strstr(yytext, "ifdef") + 5;
while (*tmp == ' ' || *tmp == '\n')
tmp++;
if (*tmp == '\0')
return token::PREPROCESSOR_IFDEF;
char const *tmp2 = tmp;
while (*tmp != ' ' && *tmp != '\n' && *tmp != '\0')
tmp++;
String key(tmp2, (int)(tmp - tmp2));
if (has_key(m_pp_defines, key))
{
m_pp_stack.Push(BlockIsTrue);
}
else
{
m_pp_stack.Push(BlockIsFalse);
BEGIN(PREPROCESSOR_COMMENT);
}
}

^[ \t]*"#"[ \t]*"ifndef" {
/* FIXME: this is very, very limited */
char const *tmp = strstr(yytext, "ifndef") + 6;
while (*tmp == ' ' || *tmp == '\n')
tmp++;
if (*tmp == '\0')
return token::PREPROCESSOR_IFDEF;
char const *tmp2 = tmp;
while (*tmp != ' ' && *tmp != '\n' && *tmp != '\0')
tmp++;
String key(tmp2, (int)(tmp - tmp2));
if (has_key(m_pp_defines, key))
{
m_pp_stack.Push(BlockIsFalse);
BEGIN(PREPROCESSOR_COMMENT);
}
else
{
m_pp_stack.Push(BlockIsTrue);
}
}

^[ \t]*"#"[ \t]*"include" { return token::PREPROCESSOR_INCLUDE; }

^[ \t]*"#"[ \t]*"line".* { /* ignore for now */ }

^[ \t]*"#"[ \t]*"pragma".* { /* ignore for now */ }

^[ \t]*"#"[ \t]*"undef" {
/* FIXME: this is very, very limited */
char const *tmp = strstr(yytext, "undef") + 5;
while (*tmp == ' ' || *tmp == '\n')
tmp++;
if (*tmp == '\0')
return token::PREPROCESSOR_UNDEF;
char const *tmp2 = tmp;
while (*tmp != ' ' && *tmp != '\n' && *tmp != '\0')
tmp++;
String key(tmp2, (int)(tmp - tmp2));

Log::Debug("undef macro: ‘%s’\n", key.C());
m_pp_defines.remove(key);
}

<PREPROCESSOR_COMMENT>^[ \t]*"#"[ \t]*(if|ifdef|ifndef)[ \t]+.*$ {
m_pp_stack.Push(BlockIsForeverFalse);
}
<PREPROCESSOR_COMMENT>^[ \t]*"#"[ \t]*"else" {
switch (m_pp_stack.Last())
{
case BlockIsFalse:
m_pp_stack.Last() = BlockIsTrue;
BEGIN(INITIAL);
break;
case BlockIsForeverFalse:
break;
case BlockIsTrue:
m_pp_stack.Last() = BlockIsForeverFalse;
break;
}
}
<PREPROCESSOR_COMMENT>^[ \t]*"#"[ \t]*"elif" {
switch (m_pp_stack.Last())
{
case BlockIsFalse:
if (IsExpressionTrue(strstr(yytext, "elif") + 4))
{
m_pp_stack.Last() = BlockIsTrue;
BEGIN(INITIAL);
}
break;
case BlockIsForeverFalse:
break;
case BlockIsTrue:
m_pp_stack.Last() = BlockIsForeverFalse;
break;
}
}
<PREPROCESSOR_COMMENT>^[ \t]*"#"[ \t]*"endif" {
m_pp_stack.Pop();
if (m_pp_stack.Last() == BlockIsTrue)
BEGIN(INITIAL);
}
<PREPROCESSOR_COMMENT>\n { yylloc->lines(1); }
<PREPROCESSOR_COMMENT>[^/#]* { }
<PREPROCESSOR_COMMENT>"/*" { BEGIN(C_COMMENT); }
<PREPROCESSOR_COMMENT>[/#] { }

/*
* GLSL preprocessor directives
*/

^[ \t]*"#"[ \t]*"version"[^\n]* { /* ignore for now */ }

/*
* HLSL reserved keywords
* Gathered from http://msdn.microsoft.com/en-us/library/windows/desktop/bb509569%28v=vs.85%29.aspx
*/

(?i:auto) { return token::HT_AUTO; }
(?i:catch) { return token::HT_CATCH; }
(?i:char) { return token::HT_CHAR; }
(?i:class) { return token::HT_CLASS; }
(?i:const_cast) { return token::HT_CONST_CAST; }
(?i:delete) { return token::HT_DELETE; }
(?i:dynamic_cast) { return token::HT_DYNAMIC_CAST; }
(?i:enum) { return token::HT_ENUM; }
(?i:explicit) { return token::HT_EXPLICIT; }
(?i:friend) { return token::HT_FRIEND; }
(?i:goto) { return token::HT_GOTO; }
(?i:long) { return token::HT_LONG; }
(?i:mutable) { return token::HT_MUTABLE; }
(?i:new) { return token::HT_NEW; }
(?i:operator) { return token::HT_OPERATOR; }
(?i:private) { return token::HT_PRIVATE; }
(?i:protected) { return token::HT_PROTECTED; }
(?i:public) { return token::HT_PUBLIC; }
(?i:reinterpret_cast) { return token::HT_REINTERPRET_CAST; }
(?i:short) { return token::HT_SHORT; }
(?i:signed) { return token::HT_SIGNED; }
(?i:sizeof) { return token::HT_SIZEOF; }
(?i:static_cast) { return token::HT_STATIC_CAST; }
(?i:template) { return token::HT_TEMPLATE; }
(?i:this) { return token::HT_THIS; }
(?i:throw) { return token::HT_THROW; }
(?i:try) { return token::HT_TRY; }
(?i:typename) { return token::HT_TYPENAME; }
(?i:union) { return token::HT_UNION; }
(?i:unsigned) { return token::HT_UNSIGNED; }
(?i:using) { return token::HT_USING; }
(?i:virtual) { return token::HT_VIRTUAL; }

/*
* Various tokens
*/

"++" { return token::T_INC; }
"--" { return token::T_DEC; }
"<=" { return token::T_LE; }
">=" { return token::T_GE; }
"==" { return token::T_EQ; }
"!=" { return token::T_NE; }
"<<" { return token::T_LEFT; }
">>" { return token::T_RIGHT; }
"&&" { return token::T_AND; }
"||" { return token::T_OR; }
"^^" { return token::T_XOR; }

"*=" { return token::T_MULEQ; }
"/=" { return token::T_DIVEQ; }
"%=" { return token::T_MODEQ; }
"+=" { return token::T_ADDEQ; }
"-=" { return token::T_SUBEQ; }
"<<=" { return token::T_LEFTEQ; }
">>=" { return token::T_RIGHTEQ; }
"&=" { return token::T_ANDEQ; }
"^=" { return token::T_XOREQ; }
"|=" { return token::T_OREQ; }

(0|[1-9][0-9]*)\.[0-9]+ {
yylval->fval = std::atof(yytext);
return token::FLOATCONSTANT;
}
(0|[1-9][0-9]*)[uU] {
yylval->uval = std::atoi(yytext);
return token::UINTCONSTANT;
}
(0|[1-9][0-9]*) {
yylval->ival = std::atoi(yytext);
return token::INTCONSTANT;
}

([xyzw]{1,4}|[rgba]{1,4}|[stpq]{1,4}) {
/* Copy token for now */
yylval->sval = strdup(yytext);
return token::FIELDSELECTION;
}

[a-zA-Z_][a-zA-Z0-9_]* {
/* Copy token for now */
yylval->sval = strdup(yytext);
return token::IDENTIFIER;
}

[ \t\r]+ { /* ignore whitespace */ }
[\n] { yylloc->lines(1); }
. { return (token_type)*yytext; /* accept all characters */ }

/*
* Ignore C comments
*/

"/*" { BEGIN(C_COMMENT); }
<C_COMMENT>[^*\n]* { }
<C_COMMENT>\n { yylloc->lines(1); }
<C_COMMENT>. { }
<C_COMMENT>"*/" {
if (m_pp_stack.Last() == BlockIsTrue)
BEGIN(INITIAL);
else
BEGIN(PREPROCESSOR_COMMENT);
}

/*
* Ignore C++ comments
*/

"//" { BEGIN(CPP_COMMENT); }
<CPP_COMMENT>\n { yylloc->lines(1); BEGIN(INITIAL); }
<CPP_COMMENT>.* { }

%%

lol::LolFxScanner::LolFxScanner(char const *command)
: LolFxFlexLexer(0, 0),
m_input(command)
{
}

lol::LolFxScanner::~LolFxScanner()
{
}

int lol::LolFxScanner::LexerInput(char* buf, int max_size)
{
buf[0] = m_input[0];
if (buf[0])
++m_input;
return buf[0] ? 1 : 0;
}

bool lol::LolFxScanner::IsExpressionTrue(char const *buf)
{
/* FIXME: this is really too limited */
return std::atoi(buf) != 0;
}

#ifdef yylex
#undef yylex
#endif
int LolFxFlexLexer::yylex()
{
std::cerr << "in LolFxFlexLexer::yylex() !" << std::endl;
return 0;
}

int LolFxFlexLexer::yywrap()
{
return 1;
}


+ 0
- 8
doc/header.html 查看文件

@@ -1,8 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>lolengine documentation</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head>
<body>

+ 0
- 10
doc/lolengine.1 查看文件

@@ -1,10 +0,0 @@
.TH lolengine 1 "2012-01-01" "lolengine"
.SH NAME
lolengine\- foo bar
.SH SYNOPSIS
.B lolengine
[
.B \--crash
.I activated by default
]


+ 0
- 18
doc/lolengine.dox 查看文件

@@ -1,18 +0,0 @@
/** \mainpage lolengine Documentation

\section intro Introduction

\e lolengine

\e lolengine is free software, released under the Do What The Fuck You
Want To Public License. This ensures that no one, not even \e lolengine
developers, will ever have anything to say about what you do with the
software.

\section license License

Permission is granted to copy, distribute and/or modify this document
under the terms of the Do What The Fuck You Want To Public License, version
2 as published by Sam Hocevar. For details see http://www.wtfpl.net/ .

*/

+ 0
- 48
doc/samples/Makefile.am 查看文件

@@ -1,48 +0,0 @@

include $(top_srcdir)/build/autotools/common.am

SUBDIRS = math sandbox

bench: benchsuite$(EXEEXT)
./benchsuite$(EXEEXT)

if BUILD_SAMPLES
noinst_PROGRAMS = bluenoise benchsuite simplex
if LOL_USE_GL
if LOL_USE_BULLET
noinst_PROGRAMS += btphystest
endif
endif
endif

bluenoise_SOURCES = bluenoise.cpp
bluenoise_CPPFLAGS = $(AM_CPPFLAGS)
bluenoise_DEPENDENCIES = @LOL_DEPS@

benchsuite_SOURCES = benchsuite.cpp \
benchmark/vector.cpp benchmark/half.cpp benchmark/real.cpp
benchsuite_CPPFLAGS = $(AM_CPPFLAGS)
benchsuite_DEPENDENCIES = @LOL_DEPS@

btphystest_SOURCES = \
btphystest.cpp btphystest.h physicobject.h \
physics/easyphysics.cpp physics/easyphysics.h \
physics/lolbtphysicsintegration.h physics/lolphysics.h \
physics/easycharactercontroller.cpp physics/easycharactercontroller.h \
physics/easyconstraint.cpp physics/easyconstraint.h \
physics/bulletcharactercontroller.cpp physics/bulletcharactercontroller.h \
\
front_camera_sprite.lolfx
btphystest_CPPFLAGS = $(AM_CPPFLAGS)
btphystest_DEPENDENCIES = @LOL_DEPS@
btphystest_LDFLAGS = $(AM_LDFLAGS)
if LOL_USE_EMSCRIPTEN
btphystest_LDFLAGS += \
--preload-file data/CatsSheet.png \
-s TOTAL_MEMORY=$(shell expr 32 '*' 1024 '*' 1024)
endif

simplex_SOURCES = simplex.cpp
simplex_CPPFLAGS = $(AM_CPPFLAGS)
simplex_DEPENDENCIES = @LOL_DEPS@


+ 0
- 127
doc/samples/benchmark/half.cpp 查看文件

@@ -1,127 +0,0 @@
//
// Lol Engine — Benchmark program
//
// Copyright © 2005—2018 Sam Hocevar <sam@hocevar.net>
//
// This program is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdio>

#include <lol/engine.h>

using namespace lol;

static size_t const HALF_TABLE_SIZE = 1024 * 1024;
static size_t const HALF_RUNS = 50;

void bench_half(int mode)
{
float result[10] = { 0.0f };
lol::timer timer;

/* Set up tables */
float *pf = new float[HALF_TABLE_SIZE + 1];
half *ph = new half[HALF_TABLE_SIZE + 1];

for (size_t run = 0; run < HALF_RUNS; run++)
{
switch (mode)
{
case 1:
for (size_t i = 0; i < HALF_TABLE_SIZE + 1; i++)
ph[i] = half::makebits(rand<uint16_t>());
break;
case 2:
default:
for (size_t i = 0; i < HALF_TABLE_SIZE + 1; i++)
ph[i] = rand(-2.0f, 2.0f);
break;
}

/* Convert half to float (array) */
timer.get();
half::convert(pf, ph, HALF_TABLE_SIZE);
result[0] += timer.get();

/* Convert half to float (fast) */
timer.get();
for (size_t i = 0; i < HALF_TABLE_SIZE; i++)
pf[i] = (float)ph[i];
result[1] += timer.get();

/* Copy float */
timer.get();
for (size_t i = 0; i < HALF_TABLE_SIZE; i++)
pf[i] = pf[i + 1];
result[2] += timer.get();

/* Add a half to every float */
timer.get();
for (size_t i = 0; i < HALF_TABLE_SIZE; i++)
pf[i] += ph[i];
result[3] += timer.get();

/* Copy half */
timer.get();
for (size_t i = 0; i < HALF_TABLE_SIZE; i++)
ph[i] = ph[i + 1];
result[4] += timer.get();

/* Change sign of every half */
timer.get();
for (size_t i = 0; i < HALF_TABLE_SIZE; i++)
ph[i] = -ph[i];
result[5] += timer.get();

/* Convert float to half (array) */
timer.get();
half::convert(ph, pf, HALF_TABLE_SIZE);
result[6] += timer.get();

/* Convert float to half (fast) */
timer.get();
for (size_t i = 0; i < HALF_TABLE_SIZE; i++)
ph[i] = (half)pf[i];
result[7] += timer.get();

/* Convert float to half (accurate) */
timer.get();
for (size_t i = 0; i < HALF_TABLE_SIZE; i++)
ph[i] = half::makeaccurate(pf[i]);
result[8] += timer.get();

/* Add a float to every half */
timer.get();
for (size_t i = 0; i < HALF_TABLE_SIZE; i++)
ph[i] += pf[i];
result[9] += timer.get();
}

delete[] pf;
delete[] ph;

for (size_t i = 0; i < sizeof(result) / sizeof(*result); i++)
result[i] *= 1e9f / (HALF_TABLE_SIZE * HALF_RUNS);

msg::info(" ns/elem\n");
msg::info("float = half (array) %7.3f\n", result[0]);
msg::info("float = half (fast) %7.3f\n", result[1]);
msg::info("float = float %7.3f\n", result[2]);
msg::info("float += half %7.3f\n", result[3]);
msg::info("half = half %7.3f\n", result[4]);
msg::info("half = -half %7.3f\n", result[5]);
msg::info("half = float (array) %7.3f\n", result[6]);
msg::info("half = float (fast) %7.3f\n", result[7]);
msg::info("half = float (accurate) %7.3f\n", result[8]);
msg::info("half += float %7.3f\n", result[9]);
}


+ 0
- 82
doc/samples/benchmark/real.cpp 查看文件

@@ -1,82 +0,0 @@
//
// Lol Engine — Benchmark program
//
// Copyright © 2005—2018 Sam Hocevar <sam@hocevar.net>
//
// This program is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdio>

#include <lol/engine.h>

using namespace lol;

static size_t const REAL_TABLE_SIZE = 10000;
static size_t const REAL_RUNS = 50;

void bench_real(int mode)
{
float result[12] = { 0.0f };
lol::timer timer;

for (size_t run = 0; run < REAL_RUNS; run++)
{
switch (mode)
{
case 1:
break;
}

real fib1 = 1.0, fib2 = 1.0;
timer.get();
for (size_t i = 0; i < REAL_TABLE_SIZE; i++)
{
real tmp = fib1 + fib2;
fib1 = fib2;
fib2 = tmp;
}
result[0] += timer.get();

real fact = 1.0;
timer.get();
for (size_t i = 0; i < REAL_TABLE_SIZE; i++)
fact = fact * real(1.0 + i);
result[1] += timer.get();

real invfact = 1.0;
timer.get();
for (size_t i = 0; i < REAL_TABLE_SIZE; i++)
invfact = invfact / real(1.0 + i);
result[2] += timer.get();

timer.get();
for (size_t i = 0; i < REAL_TABLE_SIZE / 128; i++)
(void)sin(real(0.01 * i));
result[3] += timer.get() * 128;

timer.get();
for (size_t i = 0; i < REAL_TABLE_SIZE / 128; i++)
(void)exp((real)(int)(i - REAL_TABLE_SIZE / 256));
result[4] += timer.get() * 128;
}

for (size_t i = 0; i < sizeof(result) / sizeof(*result); i++)
result[i] *= 1e9f / (REAL_TABLE_SIZE * REAL_RUNS);

msg::info(" ns/elem\n");
msg::info("real = real + real %7.3f\n", result[0]);
msg::info("real = real * real %7.3f\n", result[1]);
msg::info("real = real / real %7.3f\n", result[2]);
msg::info("real = sin(real) %7.3f\n", result[3]);
msg::info("real = exp(real) %7.3f\n", result[4]);
}


+ 0
- 91
doc/samples/benchmark/vector.cpp 查看文件

@@ -1,91 +0,0 @@
//
// Lol Engine — Benchmark program
//
// Copyright © 2005—2018 Sam Hocevar <sam@hocevar.net>
//
// This program is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdio>

#include <lol/engine.h>

using namespace lol;

static size_t const MATRIX_TABLE_SIZE = 64 * 1024;
static size_t const MATRIX_RUNS = 100;

void bench_matrix(int mode)
{
float result[5] = { 0.0f };
lol::timer timer;

/* Set up tables */
mat4 *pm = new mat4[MATRIX_TABLE_SIZE + 1];
float *pf = new float[MATRIX_TABLE_SIZE];

for (size_t run = 0; run < MATRIX_RUNS; run++)
{
switch (mode)
{
case 1:
for (size_t i = 0; i < MATRIX_TABLE_SIZE; i++)
for (int j = 0; j < 4; j++)
for (int k = 0; k < 4; k++)
pm[i][j][k] = rand(-2.0f, 2.0f);
break;
}

/* Copy matrices */
timer.get();
for (size_t i = 0; i < MATRIX_TABLE_SIZE; i++)
pm[i] = pm[i + 1];
result[0] += timer.get();

/* Determinant */
timer.get();
for (size_t i = 0; i < MATRIX_TABLE_SIZE; i++)
pf[i] = determinant(pm[i]);
result[1] += timer.get();

/* Multiply matrices */
timer.get();
for (size_t i = 0; i < MATRIX_TABLE_SIZE; i++)
pm[i] *= pm[i + 1];
result[2] += timer.get();

/* Add matrices */
timer.get();
for (size_t i = 0; i < MATRIX_TABLE_SIZE; i++)
pm[i] += pm[i + 1];
result[3] += timer.get();

/* Invert matrix */
timer.get();
for (size_t i = 0; i < MATRIX_TABLE_SIZE; i++)
pm[i] = inverse(pm[i]);
result[4] += timer.get();
}

delete[] pm;
delete[] pf;

for (size_t i = 0; i < sizeof(result) / sizeof(*result); i++)
result[i] *= 1e9f / (MATRIX_TABLE_SIZE * MATRIX_RUNS);

msg::info(" ns/elem\n");
msg::info("mat4 = mat4 %7.3f\n", result[0]);
msg::info("float = mat4.det() %7.3f\n", result[1]);
msg::info("mat4 *= mat4 %7.3f\n", result[2]);
msg::info("mat4 += mat4 %7.3f\n", result[3]);
msg::info("mat4 = mat4.invert() %7.3f\n", result[4]);
}


+ 0
- 57
doc/samples/benchsuite.cpp 查看文件

@@ -1,57 +0,0 @@
//
// Lol Engine — Benchmark program
//
// Copyright © 2005—2015 Sam Hocevar <sam@hocevar.net>
//
// This program is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdio>

#include <lol/engine.h>

using namespace lol;

void bench_real(int mode);
void bench_matrix(int mode);
void bench_half(int mode);

int main(int argc, char **argv)
{
UNUSED(argc, argv);

msg::info("-----------------------\n");
msg::info(" High precision floats\n");
msg::info("-----------------------\n");
bench_real(1);

msg::info("----------------------------\n");
msg::info(" Float matrices [-2.0, 2.0]\n");
msg::info("----------------------------\n");
bench_matrix(1);

msg::info("-------------------------------------\n");
msg::info(" Half precision floats (random bits)\n");
msg::info("-------------------------------------\n");
bench_half(1);

msg::info("-----------------------------------\n");
msg::info(" Half precision floats [-2.0, 2.0]\n");
msg::info("-----------------------------------\n");
bench_half(2);

#if defined _WIN32
getchar();
#endif

return EXIT_SUCCESS;
}


+ 0
- 69
doc/samples/benchsuite.vcxproj 查看文件

@@ -1,69 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="LolMacros">
<LolDir Condition="Exists('$(SolutionDir)\lol')">$(SolutionDir)\lol</LolDir>
<LolDir Condition="!Exists('$(SolutionDir)\lol')">$(SolutionDir)</LolDir>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|NX64">
<Configuration>Debug</Configuration>
<Platform>NX64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ORBIS">
<Configuration>Debug</Configuration>
<Platform>ORBIS</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|NX64">
<Configuration>Release</Configuration>
<Platform>NX64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ORBIS">
<Configuration>Release</Configuration>
<Platform>ORBIS</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="benchmark\half.cpp" />
<ClCompile Include="benchmark\real.cpp" />
<ClCompile Include="benchmark\vector.cpp" />
<ClCompile Include="benchsuite.cpp" />
</ItemGroup>
<Import Project="$(LolDir)\build\msbuild\lol-core.props" />
<Import Project="$(LolDir)\build\msbuild\lol-bullet.props" />
<PropertyGroup Label="Globals">
<ProjectGuid>{B1E10086-A1DA-401A-834D-969C9DBB5CC1}</ProjectGuid>
<ConfigurationType>Application</ConfigurationType>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(LolDir)\build\msbuild\lol.config.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(LolDir)\build\msbuild\lolfx.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(LolDir)\build\msbuild\lol.vars.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<Import Project="$(LolDir)\build\msbuild\lol.rules.props" />
<ItemDefinitionGroup />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(LolDir)\build\msbuild\lolfx.targets" />
</ImportGroup>
</Project>

+ 0
- 39
doc/samples/bluenoise.cpp 查看文件

@@ -1,39 +0,0 @@
//
// bluenoise — create a N×N blue noise kernel
//
// Copyright © 2016—2017 Sam Hocevar <sam@hocevar.net>
//
// This program is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/engine.h>

using namespace lol;

int main(int argc, char **argv)
{
UNUSED(argc, argv);

ivec2 const size(64);
auto const &kernel = image::kernel::blue_noise(size, ivec2(8));

image im(size.xy);
array2d<vec4> &data = im.lock2d<PixelFormat::RGBA_F32>();

for (int j = 0; j < size.y; ++j)
for (int i = 0; i < size.x; ++i)
data[i][j] = vec4(vec3(kernel[i][j]), 1.0f);
im.unlock2d(data);
im.save("bluenoise.png");

return 0;
}


+ 0
- 754
doc/samples/btphystest.cpp 查看文件

@@ -1,754 +0,0 @@
//
// Lol Engine — BtPhys tutorial
//
// Copyright © 2012—2019 Sam Hocevar <sam@hocevar.net>
// © 2009—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/engine.h>
#include "loldebug.h"

using namespace lol;

#include "physics/lolphysics.h"
#include "physics/easyphysics.h"

#define CAT_MODE 0
#define OBJ_SIZE 2.f
#define NB_SPRITE 4
#define PARTICLE_SIZE 4
#include "physicobject.h"

#include "btphystest.h"

using namespace lol::phys;

#define CUBE_HALF_EXTENTS .5f
#define EXTRA_HEIGHT 1.f
#define BASE_TIME 2.f
#define ZERO_TIME (BASE_TIME + rand(-BASE_TIME * .4f, BASE_TIME * .4f))
#define ZERO_SPEED 3.5f
#define JUMP_HEIGHT 30.f
#define JUMP_STRAFE .5f
#define TARGET_TIMER 10.f + (rand(4.f) - 2.f)

int gNumObjects = 16;

#if CAT_MODE
#define USE_WALL 1
#define USE_BODIES 1
#else
#define USE_WALL 1
#define USE_PLATFORM 0
#define USE_ROPE 0
#define USE_BODIES 1
#define USE_ROTATION 1
#define USE_CHARACTER 0
#define USE_STAIRS 0
#endif

LOLFX_RESOURCE_DECLARE(front_camera_sprite);

BtPhysTest::BtPhysTest(bool editor)
{
m_init_status = 0;
}

void BtPhysTest::InitApp()
{
m_init_status = 1;

m_loop_value = .0f;

#if CAT_MODE
/* cat datas setup */
m_cat_texture = Tiler::Register("data/CatsSheet.png", ivec2::zero, ivec2(0,1));
m_fov_dp = .0f;
m_loc_dp = .0f;
#endif //CAT_MODE

/* Create a camera that matches the settings of XNA BtPhysTest */
m_camera = new Camera();

#if CAT_MODE
m_camera->SetView(vec3(70.f, 50.f, 0.f),
vec3(0.f, 0.f, 0.f),
vec3(0, 1, 0));
m_camera->SetProjection(radians(60.f), .1f, 1000.f, (float)Video::GetSize().x, (float)Video::GetSize().y / (float)Video::GetSize().x);
m_target_timer = TARGET_TIMER;
m_cam_target = -1;
#else
m_camera->SetView(vec3(50.f, 50.f, 0.f),
vec3(0.f, 0.f, 0.f),
vec3(0, 1, 0));
m_camera->SetProjection(radians(45.f), .1f, 1000.f, (float)Video::GetSize().x, (float)Video::GetSize().y / (float)Video::GetSize().x);
#endif
Scene& scene = Scene::GetScene();
scene.PushCamera(m_camera);

m_ready = false;

m_simulation = new Simulation();
m_simulation->SetWorldLimit(vec3(-1000.0f, -1000.0f, -1000.0f), vec3(1000.0f, 1000.0f, 1000.0f));
m_simulation->Init();
vec3 NewGravity = vec3(.0f, -10.0f, .0f);
m_simulation->SetGravity(NewGravity);
m_simulation->SetContinuousDetection(true);
m_simulation->SetTimestep(1.f / 120.f);
Ticker::Ref(m_simulation);

/* Add a white directional light */
m_light1 = new Light();
m_light1->SetPosition(vec3(0.2f, 0.2f, 0.f));
m_light1->SetColor(vec4(0.5f, 0.5f, 0.5f, 1.f));
m_light1->SetType(LightType::Directional);
Ticker::Ref(m_light1);

/* Add an orangeish point light */
m_light2 = new Light();
m_light2->SetPosition(vec3(-15.f, 15.f, 15.f));
m_light2->SetColor(vec4(0.4f, 0.3f, 0.2f, 1.f));
m_light2->SetType(LightType::Point);
Ticker::Ref(m_light2);

float offset = 29.5f;
vec3 pos_offset = vec3(.0f, 30.f, .0f);
#if USE_STAIRS
{
vec3 new_offset = vec3(1.0f, .125f, .0f);
quat NewRotation = quat::fromeuler_xyz(0.f, 0.f, 0.f);
vec3 NewPosition = pos_offset + vec3(5.0f, -29.f, 15.0f);
{
NewRotation = quat::fromeuler_xyz(0.f, 0.f, radians(30.f));
NewPosition += vec3(4.0f, .0f, -4.0f);

PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 3);
Ticker::Ref(NewPhyobj);
m_stairs_list << NewPhyobj;
}
{
NewRotation = quat::fromeuler_xyz(0.f, 0.f, radians(40.f));
NewPosition += vec3(4.0f, .0f, -4.0f);

PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 3);
Ticker::Ref(NewPhyobj);
m_stairs_list << NewPhyobj;
}
NewPosition = pos_offset + vec3(5.0f, -29.5f, 15.0f);
NewRotation = quat::fromeuler_xyz(0.f, 0.f, 0.f);
for (int i=0; i < 15; i++)
{
NewPosition += new_offset;

PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 3);
Ticker::Ref(NewPhyobj);
m_stairs_list << NewPhyobj;
}
}
#endif //USE_STAIRS

#if USE_WALL
{
for (int i=0; i < 6; i++)
{
vec3 NewPosition = vec3(.0f);
quat NewRotation = quat(1.f);

PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation);

int idx = i/2;
NewPosition = pos_offset;
NewPosition[idx] += offset;
offset *= -1.f;

if (idx != 1)
{
vec3 NewAxis = vec3(.0f);
NewAxis[2 - idx] = 1;
NewRotation = quat::rotate(radians(90.f), NewAxis);
}

NewPhyobj->SetTransform(NewPosition, NewRotation);
Ticker::Ref(NewPhyobj);
m_ground_list << NewPhyobj;
}
}
#endif //USE_WALL

PhysicsObject* BasePhyobj = nullptr;
#if USE_PLATFORM
{
quat NewRotation = quat::fromeuler_xyz(0.f, 0.f, 0.f);
vec3 NewPosition = pos_offset + vec3(5.0f, -25.0f, -15.0f);

PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 1);

m_platform_list << NewPhyobj;
Ticker::Ref(NewPhyobj);

NewPosition = pos_offset + vec3(-15.0f, -25.0f, 5.0f);

NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 1);
BasePhyobj = NewPhyobj;

m_platform_list << NewPhyobj;
Ticker::Ref(NewPhyobj);

NewRotation = quat::fromeuler_xyz(0.f, 0.f, radians(90.f));
NewPosition = pos_offset + vec3(-20.0f, -25.0f, 5.0f);

NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 1);

NewPhyobj->GetPhysic()->AttachTo(BasePhyobj->GetPhysic(), true, true);
m_platform_list << NewPhyobj;
Ticker::Ref(NewPhyobj);

//NewPosition += vec3(-0.0f, .0f, .0f);
//NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 1);

//NewPhyobj->GetPhysic()->AttachTo(BasePhyobj->GetPhysic(), true, false);
//m_platform_list << NewPhyobj;
//Ticker::Ref(NewPhyobj);

//NewPosition += vec3(-2.0f, .0f, .0f);
//NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 1);

//NewPhyobj->GetPhysic()->AttachTo(BasePhyobj->GetPhysic(), false, false);
//m_platform_list << NewPhyobj;
//Ticker::Ref(NewPhyobj);
}
#endif //USE_PLATFORM

#if USE_CHARACTER
{
quat NewRotation = quat::fromeuler_xyz(0.f, 0.f, 0.f);
vec3 NewPosition = pos_offset + vec3(-5.0f, -10.0f, 15.0f);

PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 2);

m_character_list << NewPhyobj;
Ticker::Ref(NewPhyobj);

//NewPhyobj->GetCharacter()->AttachTo(BasePhyobj->GetPhysic(), true, true);
}
#endif //USE_CHARACTER

#if USE_BODIES
{
for (int x=0; x < 6; x++)
{
for (int y=0; y < 2; y++)
{
for (int z=0; z < 5; z++)
{
PhysicsObject* new_physobj = new PhysicsObject(m_simulation, 1000.f,
vec3(-20.f, 15.f, -20.f) +
#if CAT_MODE
vec3(rand(4.f), rand(2.f), rand(4.f)) -
vec3(2.f , 1.f , 2.f) +
#endif //CAT_MODE
vec3(8.f * (float)x, 8.f * (float)y, 8.f * (float)z));
m_physobj_list.push(new_physobj, ZERO_TIME);
Ticker::Ref(new_physobj);
}
}
}
}
#endif //USE_BODIES

#if USE_ROPE
{
array<PhysicsObject*> RopeElements;
for (int i = 0; i < 14; i++)
{
PhysicsObject* new_physobj = new PhysicsObject(m_simulation, 1000.f,
vec3(0.f, 15.f, -20.f) +
vec3(0.f, 0.f, 2.f * (float)i), 1);
RopeElements << new_physobj;
m_physobj_list.push(new_physobj, ZERO_TIME);
Ticker::Ref(new_physobj);
if (RopeElements.count() > 1)
{
EasyConstraint* new_constraint = new EasyConstraint();

vec3 A2B = .5f * (RopeElements[i]->GetPhysic()->GetTransform()[3].xyz -
RopeElements[i - 1]->GetPhysic()->GetTransform()[3].xyz);
new_constraint->SetPhysObjA(RopeElements[i - 1]->GetPhysic(), lol::mat4::translate(A2B));
new_constraint->SetPhysObjB(RopeElements[i]->GetPhysic(), lol::mat4::translate(-A2B));
new_constraint->InitConstraintToPoint2Point();
new_constraint->DisableCollisionBetweenObjs(true);
new_constraint->AddToSimulation(m_simulation);
m_constraint_list << new_constraint;
}
}
}
#endif //USE_ROPE
}

BtPhysTest::~BtPhysTest()
{
Scene& scene = Scene::GetScene();
scene.PopCamera(m_camera);
Ticker::Unref(m_light1);
Ticker::Unref(m_light2);

#if CAT_MODE
/* cat datas setup */
Shader::Destroy(m_cat_shader);
Tiler::Deregister(m_cat_texture);
#endif //CAT_MODE

while (m_constraint_list.count())
{
EasyConstraint* CurPop = m_constraint_list.last();
m_constraint_list.pop();
CurPop->RemoveFromSimulation(m_simulation);
delete CurPop;
}
array<PhysicsObject*> objects
= m_ground_list
+ m_stairs_list
+ m_character_list
+ m_platform_list;
while (m_physobj_list.count())
{
objects << m_physobj_list.last().m1;
m_physobj_list.pop();
}
m_ground_list.clear();
m_stairs_list.clear();
m_character_list.clear();
m_platform_list.clear();

while (objects.count())
{
PhysicsObject* CurPop = objects.pop();
CurPop->GetPhysic()->RemoveFromSimulation(m_simulation);
Ticker::Unref(CurPop);
}

//while (m_ground_list.count())
//{
// PhysicsObject* CurPop = m_ground_list.last();
// m_ground_list.pop();
// CurPop->GetPhysic()->RemoveFromSimulation(m_simulation);
// Ticker::Unref(CurPop);
//}
//while (m_stairs_list.count())
//{
// PhysicsObject* CurPop = m_stairs_list.last();
// m_stairs_list.pop();
// CurPop->GetPhysic()->RemoveFromSimulation(m_simulation);
// Ticker::Unref(CurPop);
//}
//while (m_character_list.count())
//{
// PhysicsObject* CurPop = m_character_list.last();
// m_character_list.pop();
// CurPop->GetCharacter()->RemoveFromSimulation(m_simulation);
// Ticker::Unref(CurPop);
//}
//while (m_platform_list.count())
//{
// PhysicsObject* CurPop = m_platform_list.last();
// m_platform_list.pop();
// CurPop->GetPhysic()->RemoveFromSimulation(m_simulation);
// Ticker::Unref(CurPop);
//}
//while (m_physobj_list.count())
//{
// PhysicsObject* CurPop = m_physobj_list.last().m1;
// m_physobj_list.pop();
// CurPop->GetPhysic()->RemoveFromSimulation(m_simulation);
// Ticker::Unref(CurPop);
//}
Ticker::Unref(m_simulation);

}

void BtPhysTest::tick_game(float seconds)
{
WorldEntity::tick_game(seconds);

if (!m_init_status)
{
if (Scene::GetCount())
InitApp();
return;
}
else if (m_init_status == 1)
{
m_init_status++;
return;
}

auto context = Debug::DrawContext::New(Color::white, 1.f);
Debug::DrawGrid(vec3::zero, vec3::axis_x, vec3::axis_y, vec3::axis_z, 10.f);

if (input::keyboard()->key_released(input::key::SC_Escape))
Ticker::Shutdown();

m_loop_value += seconds;
if (m_loop_value > F_PI * 2.0f)
m_loop_value -= F_PI * 2.0f;

vec3 GroundBarycenter = vec3(.0f);
vec3 PhysObjBarycenter = vec3(.0f);
float factor = .0f;
#if CAT_MODE
#if USE_BODIES
vec3 cam_center(0.f);
float cam_factor = .0f;
vec2 screen_min_max[2] = { vec2(FLT_MAX), vec2(-FLT_MAX) };
Scene& scene = Scene::GetScene();
mat4 world_cam = scene.GetCamera()->GetView();
mat4 cam_screen = scene.GetCamera()->GetProjection();

m_target_timer -= seconds;
if (m_target_timer < .0f)
{
m_target_timer = TARGET_TIMER;
if (m_cam_target == -1)
m_cam_target = rand(m_physobj_list.count());
else
m_cam_target = -1;
}

for (int i = 0; i < m_physobj_list.count(); i++)
{
PhysicsObject* PhysObj = m_physobj_list[i].m1;
float &obj_timer = m_physobj_list[i].m2;

vec3 obj_loc = PhysObj->GetPhysic()->GetTransform()[3].xyz;

if (m_cam_target == -1 || m_cam_target == i)
{
cam_center += obj_loc;
cam_factor += 1.f;

mat4 LocalPos = mat4::translate(obj_loc);
vec3 vpos;

LocalPos = world_cam * LocalPos;
mat4 LocalPos0 = LocalPos;

int j = 2;
while (j-- > 0)
{
if (j == 1)
LocalPos = mat4::translate(vec3(-4.f)) * LocalPos0;
else
LocalPos = mat4::translate(vec3(4.f)) * LocalPos0;

LocalPos = cam_screen * LocalPos;
vpos = (LocalPos[3] / LocalPos[3].w).xyz;
screen_min_max[0] = min(vpos.xy, screen_min_max[0]);
screen_min_max[1] = max(vpos.xy, screen_min_max[1]);
}
}

//Jump handling
//if (length(PhysObj->GetPhysic()->GetLinearVelocity()) < ZERO_SPEED)
if (lol::abs(PhysObj->GetPhysic()->GetLinearVelocity().y) < ZERO_SPEED)
obj_timer -= seconds;

if (obj_timer < .0f)
{
PhysObj->GetPhysic()->AddImpulse(JUMP_HEIGHT *
vec3(JUMP_STRAFE, 1.f, JUMP_STRAFE) *
vec3(rand(-1.f, 1.f), 1.0f, rand(-1.f, 1.f)) *
PhysObj->GetPhysic()->GetMass());
obj_timer = ZERO_TIME;
}
}

float fov_ratio = max(max(lol::abs(screen_min_max[0].x), lol::abs(screen_min_max[0].y)),
max(lol::abs(screen_min_max[1].x), lol::abs(screen_min_max[1].y)));

vec3 new_target = cam_center / cam_factor;
float fov_dp = .0f;
float loc_dp = .0f;

//ideally fov is on the target
if (lol::abs(fov_ratio - 1.f) < .2f)
fov_dp = ((m_cam_target == -1)?(.7f):(.2f));
else
fov_dp = ((m_cam_target == -1)?(1.7f):(.9f));

//ideally loc is on the target
if (length(new_target - m_camera->GetTarget()) < 6.f)
loc_dp = ((m_cam_target == -1)?(.5f):(.03f));
else
loc_dp = ((m_cam_target == -1)?(.9f):(.5f));

m_fov_dp = damp(m_fov_dp, fov_dp, 0.08f, seconds);
m_loc_dp = damp(m_loc_dp, loc_dp, 0.08f, seconds);
m_camera->SetFov(damp(m_camera->GetFov(), m_camera->GetFov() * fov_ratio * 1.1f, m_fov_dp, seconds));
vec3 tmp = damp(m_camera->GetTarget(), new_target, m_loc_dp, seconds);
m_camera->SetView((mat4::rotate(radians(10.f) * seconds, vec3(.0f, 1.f, .0f)) * vec4(m_camera->GetPosition(), 1.0f)).xyz,
tmp, vec3(0, 1, 0));
#endif //USE_BODIES
#endif //CAT_MODE

#if USE_WALL
{
for (int i = 0; i < m_ground_list.count(); i++)
{
PhysicsObject* PhysObj = m_ground_list[i];
mat4 GroundMat = PhysObj->GetTransform();

GroundBarycenter += GroundMat[3].xyz;
factor += 1.f;
}

GroundBarycenter /= factor;

for (int i = 0; i < m_ground_list.count(); i++)
{
PhysicsObject* PhysObj = m_ground_list[i];

mat4 GroundMat = PhysObj->GetTransform();
vec3 CenterToGround = GroundMat[3].xyz - GroundBarycenter;
vec3 CenterToCam = m_camera->GetPosition() - GroundBarycenter;

if (dot(normalize(CenterToCam - CenterToGround),
normalize(CenterToGround)) > 0.f)
PhysObj->SetRender(false);
else
PhysObj->SetRender(true);
}
}
#endif //USE_WALL

#if USE_ROTATION
{
for (int i = 0; i < m_ground_list.count(); i++)
{
PhysicsObject* PhysObj = m_ground_list[i];

mat4 GroundMat = PhysObj->GetTransform();
mat4 CenterMx = mat4::translate(GroundBarycenter);
GroundMat = inverse(CenterMx) * GroundMat;
GroundMat = CenterMx *
mat4(quat::fromeuler_xyz(vec3(.0f, radians(20.f), radians(20.0f)) * seconds))
* GroundMat;
PhysObj->SetTransform(GroundMat[3].xyz, quat(mat3(GroundMat)));
}
}
#endif //USE_ROTATION

#if USE_PLATFORM
{
for (int i = 0; i < m_platform_list.count(); i++)
{
PhysicsObject* PhysObj = m_platform_list[i];

mat4 GroundMat = PhysObj->GetTransform();
if (i == 0)
{
GroundMat = GroundMat * mat4(quat::fromeuler_xyz(vec3(radians(20.f), .0f, .0f) * seconds));
PhysObj->SetTransform(GroundMat[3].xyz, quat(mat3(GroundMat)));
}
else if (i == 1)
{
GroundMat =
mat4::translate(vec3(-15.0f, 5.0f, lol::cos(m_loop_value) * 8.f)) *
mat4(quat::fromeuler_xyz(vec3(.0f, lol::cos(m_loop_value) * radians(20.f), .0f)));
PhysObj->SetTransform(GroundMat[3].xyz, quat(mat3(GroundMat)));
}
}
}
#endif //USE_PLATFORM

#if USE_CHARACTER
{
auto keyboard = input::keyboard();

for (int i = 0; i < m_character_list.count(); i++)
{
PhysicsObject* PhysObj = m_character_list[i];
EasyCharacterController* Character = (EasyCharacterController*)PhysObj->GetCharacter();
mat4 CtlrMx = Character->GetTransform();

vec3 movement(0.f);
movement.z = (keyboard->key(input::key::SC_Right) ? 1.f : 0.f)
- (keyboard->key(input::key::SC_Left) ? 1.f : 0.f);
movement.x = (keyboard->key(input::key::SC_Up) ? 1.f : 0.f)
- (keyboard->key(input::key::SC_Down) ? 1.f : 0.f);
movement.y = (keyboard->key(input::key::SC_PageUp) ? 1.f : 0.f)
- (keyboard->key(input::key::SC_PageDown) ? 1.f : 0.f);
vec3 CharMove = movement * seconds * vec3(4.f, 10.f, 4.f);

if (input::keyboard()->key_released(input::key::SC_Space))
Character->Jump();
Character->SetMovementForFrame(CharMove);

RayCastResult HitResult;
if (m_simulation->RayHits(HitResult, ERT_Closest, Character->GetTransform()[3].xyz, (Character->GetTransform()[3].xyz + vec3(.0f, -1.f, .0f)), Character))
Character->AttachTo(HitResult.m_collider_list[0], true, true);
else
Character->AttachTo(nullptr);
}
}
#endif //USE_CHARACTER

#if USE_CHARACTER
{
PhysObjBarycenter = vec3(.0f);
factor = .0f;

for (int i = 0; i < m_character_list.count(); i++)
{
PhysicsObject* PhysObj = m_character_list[i];
mat4 GroundMat = PhysObj->GetTransform();

PhysObjBarycenter += GroundMat[3].xyz;
factor += 1.f;
}

PhysObjBarycenter /= factor;

#if 0
m_camera->SetTarget(m_camera->GetTarget() + (seconds / (seconds + 0.18f)) * (PhysObjBarycenter - m_camera->GetTarget()));
vec3 CamPosCenter = m_camera->GetTarget() + vec3(.0f, 5.0f, .0f);
m_camera->SetPosition(CamPosCenter + normalize(m_camera->GetPosition() - CamPosCenter) * 20.0f);
#endif
}
#else
{
PhysObjBarycenter = vec3(.0f);
for (int i = 0; i < m_physobj_list.count(); i++)
{
PhysicsObject* PhysObj = m_physobj_list[i].m1;
mat4 GroundMat = PhysObj->GetTransform();

PhysObjBarycenter += GroundMat[3].xyz;
factor += 1.f;
}

PhysObjBarycenter /= factor;

#if 0
m_camera->SetTarget(PhysObjBarycenter);
m_camera->SetPosition(GroundBarycenter + normalize(GroundBarycenter - PhysObjBarycenter) * 60.0f);
#endif
}
#endif //USE_CHARACTER
}

void BtPhysTest::tick_draw(float seconds, Scene &scene)
{
WorldEntity::tick_draw(seconds, scene);

if (m_init_status != 2)
return;

if (!m_ready)
{
#if CAT_MODE
/* cat datas setup */
m_cat_shader = Shader::Create(LOLFX_RESOURCE_NAME(front_camera_sprite));
#if USE_BODIES
for (int i = 0; i < m_physobj_list.count(); i++)
{
PhysicsObject* PhysObj = m_physobj_list[i].m1;
m_cat_sdata = new CatShaderData(((1 << VertexUsage::Position) |
(1 << VertexUsage::Color) |
(1 << VertexUsage::TexCoord) |
(1 << VertexUsage::TexCoordExt)),
m_cat_shader);
m_cat_sdata->m_tex_uniform = m_cat_texture->GetTexture()->GetTextureUniform();
m_cat_sdata->m_sprite_flip = ((rand(2) == 1)?(1.f):(0.f)) / (float)(NB_SPRITE * PARTICLE_SIZE);
PhysObj->SetCustomShaderData(m_cat_sdata);
m_cat_sdata = nullptr;
}
#endif //USE_BODIES
#endif //CAT_MODE

/* FIXME: this object never cleans up */
m_ready = true;
}
else
{
#if CAT_MODE
for (int i = 0; i < m_physobj_list.count(); i++)
{
PhysicsObject* PhysObj = m_physobj_list[i].m1;
CatShaderData* ShaderData = (CatShaderData*)PhysObj->GetCustomShaderData();

ShaderData->m_sprite_orientation = damp(ShaderData->m_sprite_orientation,
F_PI_4 * ((ShaderData->m_sprite_flip * 2.f * (float)(NB_SPRITE * PARTICLE_SIZE)) - 1.f) *
clamp(PhysObj->GetPhysic()->GetLinearVelocity().y / 20.0f, -1.f, 1.f),
0.1f, seconds);
}
#endif //CAT_MODE
}

//Video::set_clear_color(vec4(0.0f, 0.0f, 0.12f, 1.0f));

}

//-----------------------------------------------------------------------------
// CShaderData
//-----------------------------------------------------------------------------
CatShaderData::CatShaderData(uint32_t vert_decl_flags, std::shared_ptr<Shader> shader)
: GpuShaderData(vert_decl_flags, shader, DebugRenderMode::Default)
{
m_sprite_orientation = .0f;
m_sprite_flip = .0f;
SetupDefaultData();
}

//-----------------------------------------------------------------------------
void CatShaderData::SetupDefaultData()
{
AddUniform("u_model_view");
AddUniform("u_normal_mat");
AddUniform("u_proj");
AddUniform("u_texture");
AddUniform("u_sprite_orientation");
AddUniform("u_sprite_flip");
}

//-----------------------------------------------------------------------------
void CatShaderData::SetupShaderDatas(mat4 const &model)
{
Scene& scene = Scene::GetScene();
mat4 proj = scene.GetCamera()->GetProjection();
mat4 view = scene.GetCamera()->GetView();

mat4 modelview = view * model;
mat3 normalmat = transpose(inverse(mat3(view)));

m_shader->SetUniform(*GetUniform("u_model_view"), modelview);
m_shader->SetUniform(*GetUniform("u_normal_mat"), normalmat);
m_shader->SetUniform(*GetUniform("u_proj"), proj);
m_shader->SetUniform(*GetUniform("u_texture"), m_tex_uniform, 0);
m_shader->SetUniform(*GetUniform("u_sprite_orientation"), m_sprite_orientation);
m_shader->SetUniform(*GetUniform("u_sprite_flip"), m_sprite_flip);
}

int main(int argc, char **argv)
{
sys::init(argc, argv);

Application app("BtPhysTest", ivec2(1280, 960), 60.0f);

new BtPhysTest(argc > 1);
app.ShowPointer(false);

app.Run();

return EXIT_SUCCESS;
}


+ 0
- 115
doc/samples/btphystest.h 查看文件

@@ -1,115 +0,0 @@
//
// Lol Engine — Bullet physics test
//
// Copyright © 2012—2019 Sam Hocevar <sam@hocevar.net>
// © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#pragma once

#include <memory>
#include <string>
#include <map>

class CatShaderData : public GpuShaderData
{
friend class CRenderer;

public:
//---
CatShaderData(uint32_t vert_decl_flags, std::shared_ptr<Shader> shader);
//---
void SetupDefaultData();
virtual void SetupShaderDatas(mat4 const &model);
//--
virtual std::string GetInVertexName() { return "in_vertex"; }
virtual std::string GetInNormalName() { return "in_normal"; }
virtual std::string GetInColorName() { return "in_color"; }
virtual std::string GetInTexCoordName() { return "in_texcoord"; }

TextureUniform m_tex_uniform;
float m_sprite_orientation;
float m_sprite_flip;
};

class BtPhysTest : public WorldEntity
{
public:
BtPhysTest(bool editor = false);
virtual ~BtPhysTest();

std::string GetName() const { return "<BtPhysTest>"; }

protected:
virtual void tick_game(float seconds);
virtual void tick_draw(float seconds, Scene &scene);

void InitApp();

private:
//MeshViewerInput ---------------------------------------------------------
struct BtPhysTestKeyInputBase : public StructSafeEnum
{
enum Type
{
KEY_START = 0,

KEY_MOVE_FORWARD = KEY_START,
KEY_MOVE_BACK,
KEY_MOVE_LEFT,
KEY_MOVE_RIGHT,
KEY_MOVE_UP,
KEY_MOVE_DOWN,
KEY_MOVE_JUMP,
KEY_QUIT,

KEY_MAX
};
protected:
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map)
{
enum_map[KEY_MOVE_FORWARD] = input::key_to_name(input::key::SC_Up);
enum_map[KEY_MOVE_BACK] = input::key_to_name(input::key::SC_Down);
enum_map[KEY_MOVE_LEFT] = input::key_to_name(input::key::SC_Left);
enum_map[KEY_MOVE_RIGHT] = input::key_to_name(input::key::SC_Right);
enum_map[KEY_MOVE_UP] = input::key_to_name(input::key::SC_PageUp);
enum_map[KEY_MOVE_DOWN] = input::key_to_name(input::key::SC_PageDown);
enum_map[KEY_MOVE_JUMP] = input::key_to_name(input::key::SC_Space);
enum_map[KEY_QUIT] = input::key_to_name(input::key::SC_Escape);

return true;
}
};
typedef SafeEnum<BtPhysTestKeyInputBase> BtPhysTestKeyInput;


TileSet* m_cat_texture;
std::shared_ptr<Shader> m_cat_shader;
CatShaderData* m_cat_sdata;
Camera* m_camera;
Light* m_light1;
Light* m_light2;
int m_init_status;
bool m_ready;

lol::phys::Simulation* m_simulation;
array<EasyConstraint*> m_constraint_list;
array<PhysicsObject*, float> m_physobj_list;
array<PhysicsObject*> m_ground_list;
array<PhysicsObject*> m_platform_list;
array<PhysicsObject*> m_character_list;
array<PhysicsObject*> m_stairs_list;

float m_loop_value;
float m_target_timer;
int m_cam_target;
float m_fov_dp;
float m_loc_dp;
};


+ 0
- 88
doc/samples/btphystest.vcxproj 查看文件

@@ -1,88 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="LolMacros">
<LolDir Condition="Exists('$(SolutionDir)\lol')">$(SolutionDir)\lol</LolDir>
<LolDir Condition="!Exists('$(SolutionDir)\lol')">$(SolutionDir)</LolDir>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|NX64">
<Configuration>Debug</Configuration>
<Platform>NX64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ORBIS">
<Configuration>Debug</Configuration>
<Platform>ORBIS</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|NX64">
<Configuration>Release</Configuration>
<Platform>NX64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ORBIS">
<Configuration>Release</Configuration>
<Platform>ORBIS</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="btphystest.h" />
<ClInclude Include="physicobject.h" />
<ClInclude Include="physics\bulletcharactercontroller.h" />
<ClInclude Include="physics\easycharactercontroller.h" />
<ClInclude Include="physics\easyconstraint.h" />
<ClInclude Include="physics\easyphysics.h" />
<ClInclude Include="physics\lolbtphysicsintegration.h" />
<ClInclude Include="physics\lolphysics.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="btphystest.cpp" />
<ClCompile Include="physics\bulletcharactercontroller.cpp" />
<ClCompile Include="physics\easycharactercontroller.cpp" />
<ClCompile Include="physics\easyconstraint.cpp" />
<ClCompile Include="physics\easyphysics.cpp" />
</ItemGroup>
<Import Project="$(LolDir)\build\msbuild\lol-core.props" />
<Import Project="$(LolDir)\build\msbuild\lol-bullet.props" />
<ItemGroup>
<None Include="Makefile.am">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</None>
</ItemGroup>
<ItemGroup>
<LolFxCompile Include="front_camera_sprite.lolfx" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{ee203b88-44cf-4859-9d42-7a1f43fecb52}</ProjectGuid>
<ConfigurationType>Application</ConfigurationType>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(LolDir)\build\msbuild\lol.config.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(LolDir)\build\msbuild\lolfx.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(LolDir)\build\msbuild\lol.vars.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<Import Project="$(LolDir)\build\msbuild\lol.rules.props" />
<ItemDefinitionGroup />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(LolDir)\build\msbuild\lolfx.targets" />
</ImportGroup>
</Project>

+ 0
- 54
doc/samples/btphystest.vcxproj.filters 查看文件

@@ -1,54 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="btphystest.h" />
<ClInclude Include="physicobject.h" />
<ClInclude Include="physics\easycharactercontroller.h">
<filter>physics</filter>
</ClInclude>
<ClInclude Include="physics\lolphysics.h">
<filter>physics</filter>
</ClInclude>
<ClInclude Include="physics\easyconstraint.h">
<filter>physics</filter>
</ClInclude>
<ClInclude Include="physics\easyphysics.h">
<filter>physics</filter>
</ClInclude>
<ClInclude Include="physics\lolbtphysicsintegration.h">
<filter>physics</filter>
</ClInclude>
<ClInclude Include="physics\bulletcharactercontroller.h">
<filter>physics</filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="btphystest.cpp" />
<ClCompile Include="physics\easycharactercontroller.cpp">
<filter>physics</filter>
</ClCompile>
<ClCompile Include="physics\easyconstraint.cpp">
<filter>physics</filter>
</ClCompile>
<ClCompile Include="physics\easyphysics.cpp">
<filter>physics</filter>
</ClCompile>
<ClCompile Include="physics\bulletcharactercontroller.cpp">
<filter>physics</filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="generated">
<UniqueIdentifier>{4fc7662b-b17a-49b9-acd1-0cf767183b06}</UniqueIdentifier>
</Filter>
<Filter Include="physics">
<UniqueIdentifier>{ccecd634-9321-4c49-9471-e9da50dda6d3}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="Makefile.am" />
</ItemGroup>
<ItemGroup>
<LolFxCompile Include="front_camera_sprite.lolfx" />
</ItemGroup>
</Project>

二进制
doc/samples/data/CatsSheet.png 查看文件

之前 之后
宽度: 1024  |  高度: 1024  |  大小: 908 KiB

二进制
doc/samples/data/CatsSheet.xcf 查看文件


+ 0
- 110
doc/samples/data/mesh-buffer.txt 查看文件

@@ -1,110 +0,0 @@
addlight 0 position (0 0 15) color #bbb
addlight 1 position (0 0 15) color #bbb
//addlight 1 position (3 10 0) color #444
clearcolor #ddd
showgizmo true
showlight true
//SCENE SETUP END
//addlight 0.0 position (1 0 1) color #0ff
//addlight 0.0 position (-0.2 -1 -0.5) color (.0 .2 .5 1)
//custom setmesh "sc#f00 ab 2 ty 1.5 ab 2"
custom setmesh "
//tqw
//CMD TEST
//sc#0f0 asph 1 10
//sc#0f0 ab 10
//sc#0f0 afcb 1 -.2
//sc#0f0 acg 8 1 1 1 2 2 1.5 1.5 -.4
//sc#0f0 as 6 1 2
//sc#0f0 scb#f00 aes 6 1 2 2
//sc#0f0 ac 6 5 2 2 false true true
//sc#0f0 aq 1
//splt 2 smth 4 0 1
//[sc#0f0 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 dup [ rz 90 ry 90 scv#00f dup [ ry 90 scv#f00 ] ] ]
//[sc#fff ab .1]
//[sc#0f0 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 dup[rz 90 ry 90 scv#00f dup[ry 90 scv#f00]]][sc#fff ab .1]
//[sc#fff ab 1 tx .5 ty .5]
//[sc#fff ab 1 tx -.5 ty -.5]
//[sc#fff ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 [ad 3 .1 sy -1] ty 1]
//smth 3 1 1 smth 8 0 1
//[sc#fff loop 4 [ [loop 4 [ab 1 tx 2]] tz 2]]
//[sc#f00 scb#f00 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 .1 ty .5 rz -90]
//[sc#00f scb#00f ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 .1 ty .5 rx 90]
//[sc#f00 ab .2 tx 1]
//[sc#0f0 ab .2 ty 1]
//[sc#00f ab .2 tz 1]
//sc#0f0 ab 2 ty 1.5 ab 2
//sc#00f ab 2 ty 1.5 ab 2
//sc#00f tqw lp 5[tz 11 [lp 6 [tx 5 ty 5 afcb 10 -1 ]]] tz -22
// tqw
sc#f00 ab 10
//tz 5
//vm
// splt 1
// rj .2
// splt 1
// rj .2
// smth 1 0 1
//[sc#66f afcb(10) .25tx0]csgs[sc#fff afcb(10).25t(2)][[sc#6f6 afcb(7).25]csgs[sc#fff afcb(7).25t(1.5)]][[sc#f44 asph4 12t(-2.5)]csga[sc#fff afcb(7).25t(1.4)]csgs[sc#fff afcb(7).25t(2.5)]][[sc#ff0 ato6 2.5 1.2rx90tz-1.25tx-.9][sc#ff0 ab.5 2.1 .5dup[rz90sx.5ty-.8tx-.28]ty.55tx.25tz-.4taz1 1sy.8sx.8ty-.55tx-.25tz.4tz-1.2tx1.2]tz1.25tx1.25dup[sx-1ry90]tz-1.25tx-1.25]
"
//splt 0
//test
//[sc#f8f ab 1 splt 4 twy 90]
// splt 5 twy 90 0
//[sc#f8f afcb 10 10 10 .25 tx 0 splt 4 twy 1.6 0 ]
//sc#fff
//[afcb 1 1 1 -.1 tx 1]
//[afcb 1 1 1 -.1 tx 0]
//[afcb 1 1 1 -.1 tx -1]
//[[afcb 1 1 1 -.1 tx 1]
//[afcb 1 1 1 -.1 tx 0]
//[afcb 1 1 1 -.1 tx -1]tz 1]
//[[afcb 1 1 1 -.1 tx 1]
//[afcb 1 1 1 -.1 tx 0]
//[afcb 1 1 1 -.1 tx -1]tz -1]
//[afcb 3 .2 3 -.05 ty -.6]
//[sc#fff scb#fff ato 20 8 12 rx0]
//[sc#fff scb#fff acg 8 2 5 1 6 8 4 2 .1 1]
//[sc#fff ab 4 4 4 ]//twy 45 0 bdxy 90 0 splt 5 tz 2
//[sc#88f ab 4 4 4 tx 4 ab 4 4 4 tx -2 tax .4 .4 0]
//[sc#88f ab .25 1 1 tx .25 ab .25 1 1 tx .25 ab .25 1 1 tx .25 ab .25 1 1 tx .125 stx 10 0 0]
// tax -2 0 0 0
//[sc#88f ab 4 4 4 tx 4 ab 4 4 4 tx -2 shz 1 0 0 0]
//[sc#fff asph 4 4]
//[sc#ff2 asph 4 4 tax .4 .4 0]
//[sc#ff2 asph 2 4]
//[sc#fff acap 1 4 4]
//[sc#fff scb#fff ac 10 4 4 4 0 0 1]
//[sc#ff2 scb#ff2 ad 10 4 0]
//[sc#fff scb#fff at 4 1]
//[sc#fff scb#000 aq 4 1]
//[sc#fff scb#2ff aes 5 3 6 2]
//[sc#fff scb#2ff as 4 2 4 0 0]
//[sc#fff scb#fff acg 2 10 .1 .1 .4 .4 .1 .1 0 1]
//[sc#ff2 asph 2 10 10 10]
//[sc#400 asph 2 10 10 10 t 2 2 2 csgs]

+ 0
- 15
doc/samples/data/meshviewer.easymesh.lua 查看文件

@@ -1,17 +0,0 @@
em0 = EasyMesh.New("Mesh0");

em0:SetColor("#f00")
em0:AddBox(2)
em0:TranslateY(1.5)
em0:AddBox(2.5)

em1 = EasyMesh.New("Mesh1");

em1:SetColor("#0f0")
em1:AddBox(2.5)
em1:TranslateY(2)
em1:AddBox(2)



+ 0
- 19
doc/samples/data/meshviewer.init.lua 查看文件

@@ -1,19 +0,0 @@
s0 = SceneSetup.New("DefaultSetup")

s0:AddLight("Point")
s0:Position(0, 0, 15)
s0:Color("#bbb")
s0:AddLight("Directional")
s0:Position(0, 0, 15)
s0:Color("#bbb")
--addlight 1 position (3 10 0) color #444

s0:Setup()
s0:Color("#ddd")
s0:Show("Gizmo")
s0:Show("Light")

--SCENE SETUP END

--addlight 0.0 position (1 0 1) color #0ff
--addlight 0.0 position (-0.2 -1 -0.5) color (.0 .2 .5 1)

二进制
doc/samples/data/test-texture.png 查看文件

之前 之后
宽度: 256  |  高度: 256  |  大小: 2.5 KiB

+ 0
- 115
doc/samples/front_camera_sprite.lolfx 查看文件

@@ -1,115 +0,0 @@

[vert.glsl]
#version 130

in vec3 in_position;
in vec4 in_color;
in vec4 in_texcoord;

uniform mat4 u_model_view;
uniform mat3 u_normal_mat;
uniform mat4 u_proj;
uniform float u_sprite_orientation;

out vec4 pass_texcoord;
out vec4 pass_color;

void main(void)
{
vec4 vertex = u_model_view * vec4(in_position - vec3(0.0,0.5,0.0), 1.0);

vec3 v_offset = vec3(1.0 * in_texcoord.z, -1.0 * in_texcoord.w, 0.0);

float sinX = sin(u_sprite_orientation);
float cosX = cos(u_sprite_orientation);
float sinY = sinX;
mat2 rotationMatrix = mat2(cosX, -sinX, sinY, cosX);

v_offset.xy = rotationMatrix * v_offset.xy;

//Billboard calculations
vertex.xyz += v_offset;

//pass datas
pass_texcoord = in_texcoord;
pass_color = in_color;

gl_Position = u_proj * vertex;
}

[frag.glsl]
#version 130

#if defined GL_ES
precision highp float;
#endif

in vec4 pass_texcoord;
in vec4 pass_color;

uniform sampler2D u_texture;
uniform float u_sprite_flip;

const float cos_45 = 0.70710678118;
const float PI = 3.14159265358979323846264;

vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = c.g < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy);
vec4 q = c.r < p.x ? vec4(p.xyw, c.r) : vec4(c.r, p.yzx);

float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}

vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}

const int sample_nb = 2;

void main(void)
{
vec2 texcoord = pass_texcoord.xy - vec2(pass_texcoord.z * u_sprite_flip, 0.0);
vec4 color = texture2D(u_texture, texcoord) * pass_color;

//need 130 : ivec2 tex_size = textureSize(u_texture, 0);
if (color.a < 0.9)
{
bool break_loop = false;
for (int x = -sample_nb; x <= sample_nb; x++)
{
for (int y = -sample_nb; y <= sample_nb; y++)
{
if (x != 0 && y != 0)
{
vec2 new_tc = clamp(texcoord + (vec2(x, y) / 1024.0), vec2(0.0), vec2(1.0));
vec4 new_col = texture2D(u_texture, new_tc);
//need 130 : vec4 new_col = texelFetch(u_texture, ivec2(tex_size * texcoord) + ivec2(x, y), 0);
if (new_col.a > 0.9)
{
color = vec4(0.0, 0.0, 0.0, 1.0);
break_loop = true;
//x = sample_nb + 1;
//y = sample_nb + 1;
}
if (break_loop)
break;
}
}
if (break_loop)
break;
}
}
if (color.a < 0.01)
discard;
vec3 hsv = rgb2hsv(color.rgb);
hsv.x = fract(hsv.x + rgb2hsv(pass_color.rgb).x);
gl_FragColor = vec4(hsv2rgb(hsv), color.a);
}


+ 0
- 15
doc/samples/math/Makefile.am 查看文件

@@ -1,15 +0,0 @@

include $(top_srcdir)/build/autotools/common.am

if BUILD_SAMPLES
noinst_PROGRAMS = pi poly
endif

pi_SOURCES = pi.cpp
pi_CPPFLAGS = $(AM_CPPFLAGS)
pi_DEPENDENCIES = @LOL_DEPS@

poly_SOURCES = poly.cpp
poly_CPPFLAGS = $(AM_CPPFLAGS)
poly_DEPENDENCIES = @LOL_DEPS@


+ 0
- 55
doc/samples/math/pi.cpp 查看文件

@@ -1,55 +0,0 @@
//
// Lol Engine — Sample math program: compute Pi
//
// Copyright © 2005—2019 Sam Hocevar <sam@hocevar.net>
//
// This program is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <iostream>
#include <iomanip>

#include <lol/engine.h>

using lol::real;

int main(int argc, char **argv)
{
UNUSED(argc, argv);

std::cout << std::setprecision(150);
std::cout << " 0: " << real::R_0() << '\n';
std::cout << " 1: " << real::R_1() << '\n';
std::cout << "sqrt(2): " << real::R_SQRT2() << '\n';
std::cout << "sqrt(½): " << real::R_SQRT1_2() << '\n';
std::cout << " ln(2): " << real::R_LN2() << '\n';
std::cout << " e: " << real::R_E() << '\n';
std::cout << " π: " << real::R_PI() << '\n';

// Gauss-Legendre computation of Pi — six iterations are enough for 150 digits
real a = 1.0, b = real::R_SQRT1_2(), t = 0.25, p = 1.0;

for (int i = 0; i < 6; i++)
{
real tmp = (a - b) * (real)0.5;
b = sqrt(a * b);
a -= tmp;
t -= p * tmp * tmp;
p += p;
}

real sum = a + b;
sum = sum * sum / ((real)4 * t);
std::cout << " " << sum << '\n';

return EXIT_SUCCESS;
}


+ 0
- 31
doc/samples/math/poly.cpp 查看文件

@@ -1,31 +0,0 @@
//
// Lol Engine — Sample math program: polynomials
//
// Copyright © 2005—2017 Sam Hocevar <sam@hocevar.net>
//
// This program is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdio>

#include <lol/engine.h>

using namespace lol;

int main(int argc, char **argv)
{
UNUSED(argc, argv);

polynomial<polynomial<float>> p;

return EXIT_SUCCESS;
}


+ 0
- 446
doc/samples/physicobject.h 查看文件

@@ -1,446 +0,0 @@
//
// Lol Engine — Bullet physics test
//
// Copyright © 2009—2013 Cédric Lecacheur <jordx@free.fr>
// © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
// © 2012—2018 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#pragma once

/* FIXME: this file is pure crap; it's only a test. */

#include <lol/engine.h>

#include "easymesh/easymesh.h"
#include "physics/easyphysics.h"
#include "physics/easycharactercontroller.h"
#include "physics/easyconstraint.h"

using namespace lol;
using namespace lol::phys;

#if CAT_MODE
#define USE_SPHERE 1
#else
#define USE_BOX 1
#define USE_SPHERE 1
#define USE_CONE 1
#define USE_CYLINDER 1
#define USE_CAPSULE 1
#endif

class PhysicsObject : public WorldEntity
{
public:
PhysicsObject(Simulation* new_sim, const vec3 &base_location, const quat &base_rotation)
: m_custom_shader(0),
m_ready(false),
m_should_render(true),
m_is_character(false),
m_is_phys(false)
{
m_physics = new EasyPhysic(this);

//m_mesh.Compile("[sc#ddd afcb 60 1 60 -.1]");
m_mesh.SetCurColor(Color::white);
m_mesh.AppendFlatChamfBox(vec3(60.f, 1.f, 60.f), -.1f);

vec3 BoxSize = vec3(60.f, 1.f, 60.f);
m_physics->SetCollisionChannel(0, 0xFF);
m_physics->SetShapeToBox(BoxSize);
m_physics->SetMass(.0f);
m_physics->SetTransform(base_location, base_rotation);
m_physics->InitBodyToRigid(true);
m_physics->AddToSimulation(new_sim);
}

PhysicsObject(Simulation* new_sim, const vec3 &base_location, const quat &base_rotation, int dummy)
: m_custom_shader(0),
m_ready(false),
m_should_render(true),
m_is_character(false),
m_is_phys(false)
{
if (dummy == 1) //for platform purpose
{
m_physics = new EasyPhysic(this);

m_mesh.Compile("[sc#ddd afcb 20 1 20 -.1]");
vec3 BoxSize = vec3(20.f, 1.f, 20.f);
m_physics->SetCollisionChannel(0, 0xFF);
m_physics->SetShapeToBox(BoxSize);
m_physics->SetMass(.0f);
m_physics->SetTransform(base_location, base_rotation);
m_physics->InitBodyToRigid(true);
m_physics->AddToSimulation(new_sim);
}
else if (dummy == 2) //for character purpose
{
m_character = new EasyCharacterController(this);
m_is_character = true;
//m_mesh.Compile("[sc#f00 afcb10 10 10 -.1]");
m_mesh.Compile(
"[sc#000 scb#000"
//"[sc#aaa scb#aaa"
"[ad8 2 0 rx180 ty-1]"
"[asph8 .5 ty1]"
"[ac32 2 .5 .5 0 0]"
"[asph6 .1 ty.9 tx.5 tz.15]"
"[asph6 .1 ty.9 tx.5 tz-.15]"
"[asph8 .05 sy10 ty.6 tz.5]"
"[asph8 .05 sy10 ty.6 tz-.5]"
"]"
"[sc#fd0 scb#fd0"
"[ac8 .4 .1 0 0 0 ty.25 rz-90 ty.7 tx.5]"
"]"
"["
"[sc#fff scb#fff"
"[ad8 2 0 rx180 ty-1]"
"[asph8 .5 ty1]"
"[ac32 1.9 .5 .5 0 0]"
"]"
" ty-.1 tx.05]"
);
vec3 BoxSize = vec3(1.f, 2.f, 1.f);
m_character->SetCollisionChannel(0, 0xFF);
m_character->SetShapeToCapsule(BoxSize.x, BoxSize.y);
m_character->SetMass(.0f);
//m_character->SetStepHeight(1.f);
m_character->SetTransform(base_location, base_rotation);
m_character->InitBodyToGhost();
m_character->AddToSimulation(new_sim);
}
else if (dummy == 3) //for Stairs purpose
{
m_physics = new EasyPhysic(this);

m_mesh.Compile("[sc#aae afcb4 .25 4 -.01]");
vec3 BoxSize = vec3(4.f, .25f, 4.f);
m_physics->SetCollisionChannel(0, 0xFF);
m_physics->SetShapeToBox(BoxSize);
m_physics->SetMass(.0f);
m_physics->SetTransform(base_location, base_rotation);
m_physics->InitBodyToRigid(true);
m_physics->AddToSimulation(new_sim);
}
}

PhysicsObject(Simulation* new_sim, float base_mass, const vec3 &base_location, int RandValue = -1)
: m_custom_shader(0),
m_ready(false),
m_should_render(true),
m_is_character(false),
m_is_phys(false)
{
static array<EasyMesh> MeshRand;
static array<int> MeshLimit;
static array<int> MeshType;

if (!MeshRand.count())
{
array<std::string> colors_base = { "#add", "#dad", "#dda", "#daa", "#ada", "#aad" };

MeshLimit << 0;

#if USE_BOX
{
array<std::string> colors = colors_base;
while (colors.count())
{
EasyMesh m;
vec4 color = Color::C8BppHexString(colors.pop());
m.SetCurColor(color);
m.AppendFlatChamfBox(vec3(1.7f), .4f);
m.OpenBrace();
{
m.SetCurColor(Color::black);
m.ToggleScaleWinding();
m.AppendFlatChamfBox(vec3(1.9f), .4f);
m.ScaleX(-1.f);
m.ScaleY(-1.f);
m.ScaleZ(-1.f);
}
m.CloseBrace();
MeshRand << m;
}
}
//MeshRand << "[sc#add afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]";
//MeshRand << "[sc#dad afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]";
//MeshRand << "[sc#dda afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]";
//MeshRand << "[sc#daa afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]";
//MeshRand << "[sc#ada afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]";
//MeshRand << "[sc#aad afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]";

MeshLimit << MeshRand.count();
MeshType << 0;
#endif //USE_BOX


#if USE_SPHERE
#if CAT_MODE
int nb_sprite = NB_SPRITE;
//SPRITE
vec2 start_point = vec2((float)rand(nb_sprite), (float)rand(nb_sprite)) / vec2((float)nb_sprite);
//vec2(0.f, .0f) / vec2((float)nb_sprite);
vec2 size = vec2(1.f) / vec2((float)nb_sprite);
m_mesh.BD()->SetTexCoordCustomBuild(MeshType::Quad, MeshFaceType::QuadDefault,
start_point, start_point + size);
m_mesh.BD()->SetTexCoordCustomBuild2(MeshType::Quad, MeshFaceType::QuadDefault,
vec2(-PARTICLE_SIZE), vec2(PARTICLE_SIZE));
MeshRand << "[tpbn tvnc sc#ffff aq 0 0]";
MeshRand << "[tpbn tvnc sc#faaf aq 0 0]";
MeshRand << "[tpbn tvnc sc#afaf aq 0 0]";
MeshRand << "[tpbn tvnc sc#aaff aq 0 0]";
#else
{
array<std::string> colors = colors_base;
while (colors.count())
{
EasyMesh m;
vec4 color = Color::C8BppHexString(colors.pop());
m.SetCurColor(color);
m.AppendSphere(1, 2.f);
MeshRand << m;
}
}
//MeshRand << "[sc#add asph1 2]";
//MeshRand << "[sc#dad asph1 2]";
//MeshRand << "[sc#dda asph1 2]";
//MeshRand << "[sc#daa asph1 2]";
//MeshRand << "[sc#ada asph1 2]";
//MeshRand << "[sc#aad asph1 2]";
#endif

MeshLimit << MeshRand.count();
MeshType << 1;
#endif //USE_SPHERE

#if USE_CONE
{
array<std::string> colors = colors_base;
while (colors.count())
{
EasyMesh m;
vec4 color = Color::C8BppHexString(colors.pop());
m.SetCurColor(color);
m.SetCurColorB(color);
m.AppendDisc(8, 2.f);
m.RotateX(180.f);
m.TranslateY(-1.f);
m.AppendCylinder(8, 2.f, 2.f, 0.f);
MeshRand << m;
}
}
//MeshRand << "[sc#add scb#add ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]";
//MeshRand << "[sc#dad scb#dad ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]";
//MeshRand << "[sc#dda scb#dda ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]";
//MeshRand << "[sc#daa scb#daa ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]";
//MeshRand << "[sc#ada scb#ada ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]";
//MeshRand << "[sc#aad scb#aad ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]";

MeshLimit << MeshRand.count();
MeshType << 2;
#endif //USE_CONE

#if USE_CYLINDER
{
array<std::string> colors = colors_base;
while (colors.count())
{
EasyMesh m;
vec4 color = Color::C8BppHexString(colors.pop());
m.SetCurColor(color);
m.SetCurColorB(color);
m.AppendDisc(8, 2.f);
m.RotateX(180.f);
m.TranslateY(-1.f);
m.MirrorY();
m.AppendCylinder(8.f, 2.f, 2.f, 2.f);
MeshRand << m;
}
}
//MeshRand << "[sc#add scb#add ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]";
//MeshRand << "[sc#dad scb#dad ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]";
//MeshRand << "[sc#dda scb#dda ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]";
//MeshRand << "[sc#daa scb#daa ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]";
//MeshRand << "[sc#ada scb#ada ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]";
//MeshRand << "[sc#aad scb#aad ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]";

MeshLimit << MeshRand.count();
MeshType << 3;
#endif //USE_CYLINDER

#if USE_CAPSULE
{
array<std::string> colors = colors_base;
while (colors.count())
{
EasyMesh m;
vec4 color = Color::C8BppHexString(colors.pop());
m.SetCurColor(color);
m.SetCurColorB(color);
m.AppendCapsule(1, 2.f, 1.f);
MeshRand << m;
}
}
//MeshRand << "[sc#add scb#add acap1 2 1]";
//MeshRand << "[sc#dad scb#dad acap1 2 1]";
//MeshRand << "[sc#dda scb#dda acap1 2 1]";
//MeshRand << "[sc#daa scb#daa acap1 2 1]";
//MeshRand << "[sc#ada scb#ada acap1 2 1]";
//MeshRand << "[sc#aad scb#aad acap1 2 1]";

MeshLimit << MeshRand.count();
MeshType << 4;
#endif //USE_CAPSULE
}

int RandLimit = RandValue;
if (MeshLimit.count() <= RandValue || RandValue < 0)
RandLimit = rand((int)MeshLimit.count() - 1);
RandValue = rand(MeshLimit[RandLimit], MeshLimit[RandLimit + 1]);

m_physics = new EasyPhysic(this);

//m_mesh.Compile(MeshRand[RandValue]);
m_mesh = MeshRand[RandValue];
m_mesh.Scale(vec3(OBJ_SIZE));
vec3 BoxSize = vec3(2.0f) * OBJ_SIZE;
int ColGroup = 1;

switch (MeshType[RandLimit])
{
case 0:
{
m_physics->SetShapeToBox(BoxSize);
ColGroup += 0;
break;
}
case 1:
{
m_physics->SetShapeToSphere(BoxSize.x);
ColGroup += 1;
break;
}
case 2:
{
m_physics->SetShapeToCone(BoxSize.x, BoxSize.y);
ColGroup += 2;
break;
}
case 3:
{
m_physics->SetShapeToCylinder(BoxSize);
ColGroup += 3;
break;
}
case 4:
{
m_physics->SetShapeToCapsule(BoxSize.x, BoxSize.y);
ColGroup += 4;
break;
}
default:
{
}
}

m_physics->SetHitRestitution(1.0f);
m_physics->SetCollisionChannel(0, 0xFF);
//m_physics->SetCollisionChannel(ColGroup, (1 << ColGroup)|(1));
m_physics->SetMass(base_mass);
m_physics->SetTransform(base_location);
m_physics->InitBodyToRigid();
m_physics->AddToSimulation(new_sim);
}

void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation = lol::quat(lol::mat3(1.0f)))
{
if (m_is_character)
m_character->SetTransform(base_location, base_rotation);
else
m_physics->SetTransform(base_location, base_rotation);
}

lol::mat4 GetTransform()
{
if (m_is_character)
return m_character->GetTransform();
else
return m_physics->GetTransform();
}

void SetRender(bool should_render)
{
m_should_render = should_render;
}

void SetCustomShaderData(GpuShaderData* custom_shader)
{
m_custom_shader = custom_shader;
}
GpuShaderData* GetCustomShaderData()
{
return m_custom_shader;
}

EasyMesh *GetMesh() { return &m_mesh; }
EasyPhysic *GetPhysic() { return m_physics; }
EasyCharacterController *GetCharacter() { return m_character; }

~PhysicsObject()
{
}

std::string GetName() const { return "<PhysicsObject>"; }

protected:
virtual void tick_game(float seconds)
{
WorldEntity::tick_game(seconds);
}

virtual void tick_draw(float seconds, Scene &scene)
{
WorldEntity::tick_draw(seconds, scene);

#if CAT_MODE
if (!m_is_phys || m_custom_shader)
#endif //CAT_MODE
{
if (!m_ready)
{
m_mesh.MeshConvert();
/* FIXME: m_custom_shader is ignored */
m_ready = true;
}
else if (m_should_render)
{
if (m_is_character)
m_mesh.Render(scene, m_character->GetTransform());
else
m_mesh.Render(scene, m_physics->GetTransform());
}
}
}

private:
// Base data
EasyMesh m_mesh;
EasyPhysic* m_physics;
EasyCharacterController* m_character;
GpuShaderData* m_custom_shader;

bool m_ready;
bool m_should_render;
bool m_is_character;
bool m_is_phys; /* Only used in CAT_MODE */
};


+ 0
- 241
doc/samples/physics/bulletcharactercontroller.cpp 查看文件

@@ -1,241 +0,0 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// (c) 2009-2013 Cédric Lecacheur <jordx@free.fr>
// (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#define USE_LOL_CTRLR_CHARAC

#include <lol/engine.h>
#include <stdio.h>
#include "lolbtphysicsintegration.h"
#include "lolphysics.h"
#include "easycharactercontroller.h"
#include "bulletcharactercontroller.h"
//#include "LinearMath/btIDebugDraw.h"
//#include "BulletCollision/CollisionDispatch/btGhostObject.h"
//#include "BulletCollision/CollisionShapes/btMultiSphereShape.h"
//#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"
//#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
//#include "BulletCollision/CollisionDispatch/btCollisionWorld.h"
//#include "LinearMath/btDefaultMotionState.h"

namespace lol
{

namespace phys
{

#ifdef USE_LOL_CTRLR_CHARAC

//When called, will try to remove Character controller from its collision.
bool BulletKinematicCharacterController::RecoverFromPenetration(btCollisionWorld* CollisionWorld)
{
bool HasPenetration = false;

//Retrieve all pair with us colliding.
CollisionWorld->getDispatcher()->dispatchAllCollisionPairs(m_ghost_object->getOverlappingPairCache(), CollisionWorld->getDispatchInfo(), CollisionWorld->getDispatcher());
m_current_position = BT2LOLU_VEC3(m_ghost_object->getWorldTransform().getOrigin());

float MaxPen = .0f;
for (int i = 0; i < m_ghost_object->getOverlappingPairCache()->getNumOverlappingPairs(); i++)
{
m_manifold_array.resize(0);

//this is the equivalent of the "Touch algorithm". Maybe refactor ?
btBroadphasePair* CollisionPair = &m_ghost_object->getOverlappingPairCache()->getOverlappingPairArray()[i];
if (CollisionPair->m_algorithm)
CollisionPair->m_algorithm->getAllContactManifolds(m_manifold_array);

for (int j = 0; j < m_manifold_array.size(); ++j)
{
btPersistentManifold* CurMfold = m_manifold_array[j];
//Normal direction differs if we're Body0
float DirSign = CurMfold->getBody0() == m_ghost_object ? -1.f : 1.f;

for (int k = 0; k < CurMfold->getNumContacts(); k++)
{
const btManifoldPoint& MfPoint = CurMfold->getContactPoint(k);
float Dist = MfPoint.getDistance();
if (Dist < .0f)
{
if (Dist < MaxPen)
{
MaxPen = Dist;
m_touching_normal = BT2LOL_VEC3(MfPoint.m_normalWorldOnB) * DirSign;
}
m_current_position += BT2LOL_VEC3(MfPoint.m_normalWorldOnB) * DirSign * Dist * .2f;
HasPenetration = true;
}
}
}
}

btTransform GObjMx = m_ghost_object->getWorldTransform();
GObjMx.setOrigin(LOL2BTU_VEC3(m_current_position));
m_ghost_object->setWorldTransform(GObjMx);

return HasPenetration;
}

//When the Controller hits a wall, we modify the target so the controller will MoveStep along the wall.
void BulletKinematicCharacterController::UpdateTargetOnHit(const vec3& HitNormal, float TangentMag, float NormalMag)
{
vec3 Movedir = m_target_position - m_current_position;
float MoveLength = (float)length(Movedir);

if (MoveLength > SIMD_EPSILON)
{
Movedir = normalize(Movedir);

vec3 ReflectDir = normalize(GetReflectedDir(Movedir, HitNormal));
vec3 ParallelDir = ProjectDirOnNorm(ReflectDir, HitNormal);
vec3 PerpindicularDir = ProjectDirOnNormPerpindicular(ReflectDir, HitNormal);

m_target_position = m_current_position;

if (NormalMag != .0f)
m_target_position += PerpindicularDir * NormalMag * MoveLength;
}
}

//Handles the actual Movement. It actually moves in the 3 dimensions, function name is confusing.
void BulletKinematicCharacterController::DoMove(btCollisionWorld* CollisionWorld, const vec3& MoveStep, float DeltaTime)
{
// phase 2: forward and strafe
m_target_position = m_current_position + MoveStep;
btTransform SweepStart, SweepEnd;
SweepStart.setIdentity();
SweepEnd.setIdentity();

float Fraction = 1.f;
float SqDist = .0f;

if (m_touching_contact && dot(m_normalized_direction, m_touching_normal) > .0f)
UpdateTargetOnHit(m_touching_normal);

//Let's loop on movement, until Movement fraction if below 0.01, which means we've reached our destination.
//Or until we'tried 10 times.
int MaxMoveLoop = 10;
while (Fraction > .01f && MaxMoveLoop-- > 0)
{
SweepStart.setOrigin(LOL2BTU_VEC3(m_current_position));
SweepEnd.setOrigin(LOL2BTU_VEC3(m_target_position));
vec3 SweepDirNeg(m_current_position - m_target_position);

ClosestNotMeConvexResultCallback SweepCallback(m_ghost_object, SweepDirNeg, .0f);
SweepCallback.m_collisionFilterGroup = GetGhostObject()->getBroadphaseHandle()->m_collisionFilterGroup;
SweepCallback.m_collisionFilterMask = GetGhostObject()->getBroadphaseHandle()->m_collisionFilterMask;

//The sweep test is done with an added margin, so we use it and then discard it
float SavedMargin = m_convex_shape->getMargin();
m_convex_shape->setMargin(SavedMargin + m_added_margin); //Apply Added Margin
if (m_do_gobject_sweep_test)
m_ghost_object->convexSweepTest (m_convex_shape, SweepStart, SweepEnd, SweepCallback, CollisionWorld->getDispatchInfo().m_allowedCcdPenetration);
else
CollisionWorld->convexSweepTest (m_convex_shape, SweepStart, SweepEnd, SweepCallback, CollisionWorld->getDispatchInfo().m_allowedCcdPenetration);
m_convex_shape->setMargin(SavedMargin); //Restore saved margin

Fraction -= SweepCallback.m_closestHitFraction;

if (SweepCallback.hasHit())
{
//We moved only a Fraction
float HitDist = (float)length(BT2LOLU_VEC3(SweepCallback.m_hitPointWorld) - m_current_position);

UpdateTargetOnHit(BT2LOL_VEC3(SweepCallback.m_hitNormalWorld));
vec3 NewDir = m_target_position - m_current_position;
SqDist = sqlength(NewDir);
if (SqDist > SIMD_EPSILON)
{
NewDir = normalize(NewDir);
//See Quake2: "If velocity is against original velocity, stop ead to avoid tiny oscilations in sloping corners."
if (dot(NewDir, m_normalized_direction) <= .0f)
break;
}
else
break;
}
else //We moved whole way
m_current_position = m_target_position;
}
}

//The PreStep is done in order to recover from any HasPenetration.
void BulletKinematicCharacterController::PreStep(btCollisionWorld* CollisionWorld)
{
int MaxPenetrationLoop = 0;
m_touching_contact = false;

while (RecoverFromPenetration(CollisionWorld))
{
MaxPenetrationLoop++;
m_touching_contact = true;
if (MaxPenetrationLoop > 4)
break;
}

m_current_position = BT2LOLU_VEC3(m_ghost_object->getWorldTransform().getOrigin());
m_target_position = m_current_position;
}

//And so we step :
//StepUpfirst, then movement, then StepDownon the ground.
void BulletKinematicCharacterController::PlayerStep(btCollisionWorld* CollisionWorld, float DeltaTime)
{
// quick check...
if (!m_use_walk_direction && m_velocity_time_interval <= .0f)
return; // no motion

// Update fall velocity.
//m_velocity -= m_gravity * DeltaTime;

btTransform NewTransform;
NewTransform = m_ghost_object->getWorldTransform();

vec3 MoveStep(.0f);
if (m_use_walk_direction)
MoveStep = m_walk_direction;
else
{
//Still have some time left for moving!
float dtMoving = (DeltaTime < m_velocity_time_interval) ? DeltaTime : m_velocity_time_interval;
m_velocity_time_interval -= DeltaTime;

// how far will we MoveStep while we are moving?
MoveStep = m_walk_direction * dtMoving;
}

//Okay, step !
DoMove(CollisionWorld, MoveStep, DeltaTime);

//Movement finished, update World transform
NewTransform.setOrigin(LOL2BTU_VEC3(m_current_position));
m_ghost_object->setWorldTransform(NewTransform);
}

//should MoveStep Jump logic in EasyCC
void BulletKinematicCharacterController::Jump()
{
if (!CanJump())
return;

m_vertical_velocity = m_jump_speed;
m_was_jumping = true;
}

#endif // USE_LOL_CTRLR_CHARAC

} /* namespace phys */

} /* namespace lol */

+ 0
- 285
doc/samples/physics/bulletcharactercontroller.h 查看文件

@@ -1,285 +0,0 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
//

//
// The BulletCharacterController class
// ------------------
// This class is a equivalent of btKinematicCharacterController, but more useful for Lol.
//

#if !defined __BULLETCHARACTERCONTROLLER_BULLETCHARACTERCONTROLLER_H__
#define __BULLETCHARACTERCONTROLLER_BULLETCHARACTERCONTROLLER_H__

#include <lol/engine.h>
#include "easyphysics.h"
//#include "BulletDynamics\Character\btCharacterControllerInterface.h"

#define USE_LOL_CTRLR_CHARAC

namespace lol
{

namespace phys
{

#ifdef USE_LOL_CTRLR_CHARAC

//SweepCallback used for Swweep Tests.
class ClosestNotMeConvexResultCallback : public btCollisionWorld::ClosestConvexResultCallback
{
public:
ClosestNotMeConvexResultCallback(btCollisionObject* NewMe, const vec3& NewUp, float MinSlopeDot) :
btCollisionWorld::ClosestConvexResultCallback(LOL2BTU_VEC3(vec3(.0f)), LOL2BTU_VEC3(vec3(.0f))),
m_me(NewMe),
m_up(NewUp),
m_min_slope_dot(MinSlopeDot) { }

virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& ConvexResult, bool NormalInWorld)
{
//We hit ourselves, FAIL
if (ConvexResult.m_hitCollisionObject == m_me)
return btScalar(1.f);

vec3 WorldHitNomal(.0f);
if (NormalInWorld)
WorldHitNomal = BT2LOL_VEC3(ConvexResult.m_hitNormalLocal);
else //need to transform Normal into worldspace
{
btVector3 TmpWorldHitNormal = ConvexResult.m_hitCollisionObject->getWorldTransform().getBasis() * ConvexResult.m_hitNormalLocal;
WorldHitNomal = BT2LOL_VEC3(TmpWorldHitNormal);
}

float DotUp = dot(m_up, WorldHitNomal);
//We hit below the accepted slope_dot, FAIL
if (DotUp < m_min_slope_dot)
return btScalar(1.f);

//Continue to next.
return ClosestConvexResultCallback::addSingleResult(ConvexResult, NormalInWorld);
}
protected:
btCollisionObject* m_me;
const vec3 m_up;
float m_min_slope_dot;
};

///BulletKinematicCharacterController is an object that supports a sliding motion in a world.
///It uses a ghost object and convex sweep test to test for upcoming collisions. This is combined with discrete collision detection to recover from penetrations.
///Interaction between btKinematicCharacterController and dynamic rigid bodies needs to be explicity implemented by the user.
class BulletKinematicCharacterController : public btActionInterface
{
public:
BulletKinematicCharacterController(btPairCachingGhostObject* NewGhostObject, btConvexShape* NewConvexShape, float NewStepHeight, int NewUpAxis=1)
{
m_convex_shape = NewConvexShape;
m_i_up_axis = NewUpAxis;
m_ghost_object = NewGhostObject;
m_step_height = NewStepHeight;

m_added_margin = 0.02f;
m_walk_direction = vec3(.0f, .0f, .0f);
m_do_gobject_sweep_test = true;
m_turn_angle = .0f;
m_use_walk_direction = false; // Should remove walk direction, this doesn't work correctly.
m_velocity_time_interval = .0f;
m_vertical_velocity = .0f;
m_vertical_offset = .0f;
m_f_gravity = 9.8f * 3.f; // 3G acceleration.
m_fall_speed = 55.f; // Terminal velocity of a sky diver in m/s.
m_jump_speed = 10.f; // ?
m_was_on_ground = false;
m_was_jumping = false;
SetMaxSlope(45.f);
}
~BulletKinematicCharacterController() { }

protected:

static vec3* GetUpAxisDirections()
{
static vec3 sUpAxisDirection[3] = { vec3(1.0f, 0.0f, 0.0f), vec3(0.0f, 1.0f, 0.0f), vec3(0.0f, 0.0f, 1.0f) };

return sUpAxisDirection;
}

//--------------------------
//CONVENIENCE FUNCTIONS
//--

//Returns the reflection Direction of a ray going 'Direction' hitting a surface with Normal 'Normal' from: http://www-cs-students.stanford.edu/~adityagp/final/node3.html
vec3 GetReflectedDir(const vec3& Direction, const vec3& Normal)
{
return Direction - (2.f * dot(Direction, Normal) * Normal);
}
//Returns the portion of 'direction' that is parallel to 'normal'
vec3 ProjectDirOnNorm(const vec3& Direction, const vec3& Normal)
{
return Normal * dot(Direction, Normal);
}
//Returns the portion of 'Direction' that is perpindicular to 'Normal'
vec3 ProjectDirOnNormPerpindicular(const vec3& Direction, const vec3& Normal)
{
return Direction - ProjectDirOnNorm(Direction, Normal);
}
//Returns Ghost Object. -duh-
btPairCachingGhostObject* GetGhostObject()
{
return m_ghost_object;
}

//"Real" war functions
bool RecoverFromPenetration(btCollisionWorld* CollisionWorld);
void UpdateTargetOnHit(const vec3& hit_normal, float TangentMag = .0f, float NormalMag = 1.f);
void DoMove(btCollisionWorld* CollisionWorld, const vec3& MoveStep, float DeltaTime);

public:
///btActionInterface interface : KEEP IN camelCase
virtual void updateAction(btCollisionWorld* CollisionWorld, float deltaTime)
{
PreStep(CollisionWorld);
PlayerStep(CollisionWorld, deltaTime);
}

//not in the interface, but called above
void PreStep(btCollisionWorld* CollisionWorld);
void PlayerStep(btCollisionWorld* CollisionWorld, float DeltaTime);

///btActionInterface interface : KEEP IN camelCase
void debugDraw(btIDebugDraw* debugDrawer) { }

void SetUpAxis(int NewAxis)
{
if (NewAxis < 0)
NewAxis = 0;
if (NewAxis > 2)
NewAxis = 2;
m_i_up_axis = NewAxis;
}

//!!!!!! SHOULD DITCH THAT !!!!!!
//This should probably be called setPositionIncrementPerSimulatorStep.
//This is neither a Direction nor a velocity, but the amount to
//increment the position each simulation iteration, regardless
//of DeltaTime.
//This call will Reset any velocity set by SetVelocityForTimeInterval().
virtual void SetWalkDirection(const vec3& walkDirection)
{
m_use_walk_direction = true;
m_walk_direction = walkDirection;
m_normalized_direction = normalize(m_walk_direction);
}

//Caller provides a velocity with which the character should MoveStep for
//the given time period. After the time period, velocity is Reset
//to zero.
//This call will Reset any walk Direction set by SetWalkDirection().
//Negative time intervals will result in no motion.
virtual void SetVelocityForTimeInterval(const vec3& velocity, float timeInterval)
{
m_use_walk_direction = false;
m_walk_direction = velocity;
m_normalized_direction = normalize(m_walk_direction);
m_velocity_time_interval = timeInterval;
}

//Usefulness ?
void Reset() { }
void Warp(const vec3& NewOrigin)
{
btTransform NewTransform;
NewTransform.setIdentity();
NewTransform.setOrigin(LOL2BTU_VEC3(NewOrigin));
m_ghost_object->setWorldTransform(NewTransform);
}

//External Setup
//--

void SetFallSpeed(float NewFallSpeed) { m_fall_speed = NewFallSpeed; }
void SetJumpSpeed(float NewJumpSpeed) { m_jump_speed = NewJumpSpeed; }
void SetMaxJumpHeight(float NewMaxJumpHeight) { m_max_jump_height = NewMaxJumpHeight; }

//Jump logic will go in EasyCC
bool CanJump() const { return OnGround(); }
void Jump();

//NewGravity functions
void SetGravity(float NewGravity) { m_f_gravity = NewGravity; }
float GetGravity() const { return m_f_gravity; }

//The max slope determines the maximum angle that the controller can walk up.
//The slope angle is measured in radians.
void SetMaxSlope(float NewSlopeRadians) { m_max_slope_radians = NewSlopeRadians; m_max_slope_cosine = lol::cos(NewSlopeRadians); }
float GetMaxSlope() const { return m_max_slope_radians; }

void SetUseGhostSweepTest(bool UseGObjectSweepTest) { m_do_gobject_sweep_test = UseGObjectSweepTest; }

bool OnGround() const { return m_vertical_velocity == .0f && m_vertical_offset == .0f; }

private:

btPairCachingGhostObject* m_ghost_object;
btConvexShape* m_convex_shape; //is also in m_ghost_object, but it needs to be convex, so we store it here to avoid upcast

//keep track of the contact manifolds
btManifoldArray m_manifold_array;

float m_half_height;
float m_velocity_time_interval;
float m_vertical_velocity;
float m_vertical_offset;
float m_fall_speed;
float m_jump_speed;
float m_max_jump_height;
float m_max_slope_radians; // Slope angle that is set (used for returning the exact value)
float m_max_slope_cosine; // Cosine equivalent of m_max_slope_radians (calculated once when set, for optimization)
float m_f_gravity;
float m_turn_angle;
float m_step_height;
float m_added_margin;//@todo: remove this and fix the code

///this is the desired walk Direction, set by the user
vec3 m_walk_direction;
vec3 m_normalized_direction;

//some internal variables
vec3 m_current_position;
float m_current_step_offset;
vec3 m_target_position;

vec3 m_touching_normal;
bool m_touching_contact;

bool m_was_on_ground;
bool m_was_jumping;
bool m_do_gobject_sweep_test;
bool m_use_walk_direction;
int m_i_up_axis;

//---------------------------------------------------------------------
//NEW INTERNAL VARS
//---------------------------------------------------------------------

//Gravity in vec3
vec3 m_gravity;

//Current Velocity
vec3 m_velocity;
};

#endif // USE_LOL_CTRLR_CHARAC

} /* namespace phys */

} /* namespace lol */

#endif /* __BULLETCHARACTERCONTROLLER_BULLETCHARACTERCONTROLLER_H__ */


+ 0
- 150
doc/samples/physics/easycharactercontroller.cpp 查看文件

@@ -1,150 +0,0 @@
//
// Lol Engine — Bullet physics test
//
// Copyright © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
// © 2010—2019 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include "lolbtphysicsintegration.h"
#include "lolphysics.h"
#include "easycharactercontroller.h"

namespace lol
{

namespace phys
{

//-------------------------------------------------------------------------
//EASY_CHARACTER_CONTROLLER
//--

//Deactivated for Character controller
void EasyCharacterController::InitBodyToRigid(bool ZeroMassIsKinematic)
{
}

//Return correct Ghost Object
btGhostObject* EasyCharacterController::GetGhostObjectInstance()
{
return new btPairCachingGhostObject();
}

//Init to Pair caching ghost object, since Character uses that one.
void EasyCharacterController::InitBodyToGhost()
{
EasyPhysic::InitBodyToGhost();

m_pair_caching_object = (btPairCachingGhostObject*)m_ghost_object;
m_ghost_object->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT | m_ghost_object->getCollisionFlags());
}

//Add Physic object to the simulation
void EasyCharacterController::AddToSimulation(class Simulation* current_simulation)
{
EasyPhysic::AddToSimulation(current_simulation);

btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld();
if (dynamics_world)
{
if (m_character)
delete m_character;

//m_character = new btKinematicCharacterController(m_pair_caching_object, m_convex_shape, m_step_height, m_up_axis);
m_character = new BulletKinematicCharacterController(m_pair_caching_object, m_convex_shape, m_step_height, m_up_axis);

//Deactivate Character controller basic behaviour.
//m_character->setGravity(.0f);
//m_character->setFallSpeed(.0f);

dynamics_world->addAction(m_character);
current_simulation->ObjectRegistration(true, this, Simulation::EEPT_CharacterController);
Ticker::Ref(this);
}
}

//Remove Physic object to the simulation
void EasyCharacterController::RemoveFromSimulation(class Simulation* current_simulation)
{
EasyPhysic::RemoveFromSimulation(current_simulation);

btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld();
if (dynamics_world)
{
if (m_character)
{
dynamics_world->removeAction(m_character);
current_simulation->ObjectRegistration(false, this, Simulation::EEPT_CharacterController);
Ticker::Unref(this);
}
}
}

void EasyCharacterController::Jump()
{
m_character->Jump();
}

//Set movement for this frame
void EasyCharacterController::SetMovementForFrame(vec3 const &MoveQuantity)
{
m_frame_cached_movement = MoveQuantity;
}

//-------------------------------------------------------------------------
//Base Location/Rotation setup
//--
void EasyCharacterController::SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation)
{
if (m_base_is_updating)
{
m_base_cached_movement = base_location - m_local_to_world[3].xyz;
m_local_to_world = lol::mat4::translate(m_local_to_world[3].xyz) * lol::mat4(base_rotation);
if (m_ghost_object)
m_ghost_object->setWorldTransform(btTransform(LOL2BT_QUAT(base_rotation), LOL2BT_VEC3(LOL2BT_UNIT * m_local_to_world[3].xyz)));
}
else
EasyPhysic::SetTransform(base_location, base_rotation);
}

//Internal callback when Base transform has changed.
void EasyCharacterController::BaseTransformChanged(const lol::mat4& PreviousMatrix, const lol::mat4& NewMatrix)
{
m_base_is_updating = true;
EasyPhysic::BaseTransformChanged(PreviousMatrix, NewMatrix);
m_base_is_updating = false;
}

//---
std::string EasyCharacterController::GetName()
{
return "<EasyCharacterController>";
}

//Physic Tick
void EasyCharacterController::tick_game(float seconds)
{
entity::tick_game(seconds);

//Send final velocity in Bullet
{
int IterationsNb = (int)(seconds / m_owner_simulation->m_timestep);
float NewSeconds = IterationsNb * m_owner_simulation->m_timestep;
m_character->SetVelocityForTimeInterval((m_base_cached_movement + m_frame_cached_movement) / NewSeconds, NewSeconds);
m_base_cached_movement = vec3(.0f);
}
}

} /* namespace phys */

} /* namespace lol */

+ 0
- 108
doc/samples/physics/easycharactercontroller.h 查看文件

@@ -1,108 +0,0 @@
//
// Lol Engine — Bullet physics test
//
// Copyright © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
// © 2012—2019 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#pragma once

//
// The EasyCharacterController class
// ------------------
//

//Should try to to make a btKinematicCharacterController for real.
//

#include <lol/engine.h>
#include "easyphysics.h"
#include "bulletcharactercontroller.h"
#include <BulletDynamics/Character/btKinematicCharacterController.h>

namespace lol
{

namespace phys
{

class EasyCharacterController : public EasyPhysic,
public entity
{

friend class Simulation;
friend class EasyPhysic;

public:
EasyCharacterController(WorldEntity* NewOwnerEntity) :
EasyPhysic(NewOwnerEntity),
m_pair_caching_object(nullptr),
m_character(nullptr),
m_step_height(.0f),
m_base_is_updating(false),
m_base_cached_movement(vec3(0.f)),
m_frame_cached_movement(vec3(0.f)),
m_walk_velocity(vec3(0.f)),
m_current_velocity(vec3(0.f))
{
m_gamegroup = GAMEGROUP_EZP_CHAR_CTRLR;
m_up_axis = 1;
m_gravity = vec3(.0f, -9.81f, .0f);
m_walk_velocity_damping = 0.2f;
}
~EasyCharacterController()
{
delete m_character;
}

virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false);
virtual void InitBodyToGhost();
virtual void AddToSimulation(class Simulation* current_simulation);
virtual void RemoveFromSimulation(class Simulation* current_simulation);
virtual void SetMovementForFrame(vec3 const &MoveQuantity);
virtual void Jump();

virtual void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation);

protected:
virtual void BaseTransformChanged(const lol::mat4& PreviousMatrix, const lol::mat4& NewMatrix);
virtual std::string GetName();

public:
virtual void tick_game(float seconds);

protected:

virtual btGhostObject* GetGhostObjectInstance();

btPairCachingGhostObject* m_pair_caching_object;
//btKinematicCharacterController* m_character;
BulletKinematicCharacterController* m_character;

float m_step_height;
int m_up_axis;
bool m_base_is_updating;
vec3 m_base_cached_movement;
vec3 m_frame_cached_movement;

//----
float m_walk_velocity_damping;

//----
vec3 m_gravity;

//----
vec3 m_walk_velocity;
vec3 m_current_velocity;
};

} /* namespace phys */

} /* namespace lol */


+ 0
- 43
doc/samples/physics/easyconstraint.cpp 查看文件

@@ -1,43 +0,0 @@

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include "lolbtphysicsintegration.h"
#include "lolphysics.h"
#include "easyconstraint.h"

namespace lol
{

namespace phys
{

//-------------------------------------------------------------------------
//EASY_CONSTRAINT
//--

void EasyConstraint::AddToSimulation(class Simulation* current_simulation)
{
btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld();
if (dynamics_world && m_typed_constraint)
{
dynamics_world->addConstraint(m_typed_constraint, m_disable_a2b_collision);
current_simulation->ObjectRegistration(true, this);
}
}

void EasyConstraint::RemoveFromSimulation(class Simulation* current_simulation)
{
btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld();
if (dynamics_world && m_typed_constraint)
{
dynamics_world->removeConstraint(m_typed_constraint);
current_simulation->ObjectRegistration(false, this);
}
}

} /* namespace phys */

} /* namespace lol */


+ 0
- 184
doc/samples/physics/easyconstraint.h 查看文件

@@ -1,184 +0,0 @@
//
// Lol Engine
//
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net>
// © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
//
// This library is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#pragma once

//
// The EasyPhysic class
// ------------------
//

#include <lol/engine.h>

#include "easyphysics.h"

namespace lol
{

namespace phys
{

class EasyConstraint
{

friend class Simulation;
friend class EasyPhysic;

public:
EasyConstraint() :
m_typed_constraint(nullptr),
m_p2p_constraint(nullptr),
m_hinge_constraint(nullptr),
m_slider_constraint(nullptr),
m_cone_twist_constraint(nullptr),
m_6dof_constraint(nullptr),
m_owner_simulation(nullptr),
m_a_physobj(nullptr),
m_b_physobj(nullptr),
m_a_transform(lol::mat4(1.f)),
m_b_transform(lol::mat4(1.f)),
m_using_ref_a(false),
m_disable_a2b_collision(false)

{
}
~EasyConstraint()
{
delete m_typed_constraint;
m_p2p_constraint = nullptr;
m_hinge_constraint = nullptr;
m_slider_constraint = nullptr;
m_cone_twist_constraint = nullptr;
m_6dof_constraint = nullptr;
}

void AddToSimulation(class Simulation* current_simulation);
void RemoveFromSimulation(class Simulation* current_simulation);

private:

//check if Init can be done
bool CanProceedWithInit()
{
if (!m_a_physobj || !m_b_physobj)
return false;

if (!m_a_physobj->m_rigid_body || !m_b_physobj->m_rigid_body)
return false;

return true;
}

//-------------------------------------------------------------------------
//Init constraint functions
//--
void CustomInitConstraintToPoint2Point()
{
m_p2p_constraint = new btPoint2PointConstraint(*m_a_physobj->m_rigid_body, *m_b_physobj->m_rigid_body,
LOL2BT_VEC3(m_a_transform[3].xyz * LOL2BT_UNIT), LOL2BT_VEC3(m_b_transform[3].xyz * LOL2BT_UNIT));
m_typed_constraint = m_p2p_constraint;
}

void CustomInitConstraintToHinge()
{
m_hinge_constraint = new btHingeConstraint(*m_a_physobj->m_rigid_body, *m_b_physobj->m_rigid_body,
btTransform(LOL2BT_QUAT(quat(mat3(m_a_transform))), LOL2BT_VEC3(m_a_transform[3].xyz * LOL2BT_UNIT)),
btTransform(LOL2BT_QUAT(quat(mat3(m_b_transform))), LOL2BT_VEC3(m_b_transform[3].xyz * LOL2BT_UNIT)),
m_using_ref_a);
m_typed_constraint = m_hinge_constraint;
}

void CustomInitConstraintToSlider()
{
m_slider_constraint = new btSliderConstraint(*m_a_physobj->m_rigid_body, *m_b_physobj->m_rigid_body,
btTransform(LOL2BT_QUAT(quat(mat3(m_a_transform))), LOL2BT_VEC3(m_a_transform[3].xyz * LOL2BT_UNIT)),
btTransform(LOL2BT_QUAT(quat(mat3(m_b_transform))), LOL2BT_VEC3(m_b_transform[3].xyz * LOL2BT_UNIT)),
m_using_ref_a);
m_typed_constraint = m_slider_constraint;
}

void CustomInitConstraintToConeTwist()
{
m_cone_twist_constraint = new btConeTwistConstraint(*m_a_physobj->m_rigid_body, *m_b_physobj->m_rigid_body,
btTransform(LOL2BT_QUAT(quat(mat3(m_a_transform))), LOL2BT_VEC3(m_a_transform[3].xyz * LOL2BT_UNIT)),
btTransform(LOL2BT_QUAT(quat(mat3(m_b_transform))), LOL2BT_VEC3(m_b_transform[3].xyz * LOL2BT_UNIT)));
m_typed_constraint = m_cone_twist_constraint;
}

void CustomInitConstraintTo6Dof()
{
m_6dof_constraint = new btGeneric6DofConstraint(*m_a_physobj->m_rigid_body, *m_b_physobj->m_rigid_body,
btTransform(LOL2BT_QUAT(quat(mat3(m_a_transform))), LOL2BT_VEC3(m_a_transform[3].xyz * LOL2BT_UNIT)),
btTransform(LOL2BT_QUAT(quat(mat3(m_b_transform))), LOL2BT_VEC3(m_b_transform[3].xyz * LOL2BT_UNIT)),
m_using_ref_a);
m_typed_constraint = m_6dof_constraint;
}

btTypedConstraint* m_typed_constraint;
btPoint2PointConstraint* m_p2p_constraint;
btHingeConstraint* m_hinge_constraint;
btSliderConstraint* m_slider_constraint;
btConeTwistConstraint* m_cone_twist_constraint;
btGeneric6DofConstraint* m_6dof_constraint;

public:
void InitConstraintToPoint2Point() { if (CanProceedWithInit()) CustomInitConstraintToPoint2Point(); }
void InitConstraintToHinge() { if (CanProceedWithInit()) CustomInitConstraintToHinge(); }
void InitConstraintToSlider() { if (CanProceedWithInit()) CustomInitConstraintToSlider(); }
void InitConstraintToConeTwist() { if (CanProceedWithInit()) CustomInitConstraintToConeTwist(); }
void InitConstraintTo6Dof() { if (CanProceedWithInit()) CustomInitConstraintTo6Dof(); }

//Set given physic object to the proper slot.
void SetPhysObjA(EasyPhysic* NewPhysObj, lol::mat4 NewTransform) { SetPhysObj(false, NewPhysObj, NewTransform); }
void SetPhysObjB(EasyPhysic* NewPhysObj, lol::mat4 NewTransform) { SetPhysObj(true, NewPhysObj, NewTransform); }
void SetPhysObj(bool SetToB, EasyPhysic* NewPhysObj, lol::mat4 NewTransform)
{
if (SetToB)
{
m_b_physobj = NewPhysObj;
m_b_transform = NewTransform;
}
else
{
m_a_physobj = NewPhysObj;
m_a_transform = NewTransform;
}
}

//Set whether or not the physic engine should use the A object as the reference (most constraint transform are local).
void SetRefAsA(bool NewUseRefA)
{
m_using_ref_a = NewUseRefA;
}

//Set whether or not to disable the collision between the bodies
void DisableCollisionBetweenObjs(bool DisableCollision)
{
m_disable_a2b_collision = DisableCollision;
}

private:
Simulation* m_owner_simulation;
EasyPhysic* m_a_physobj;
EasyPhysic* m_b_physobj;
lol::mat4 m_a_transform;
lol::mat4 m_b_transform;
bool m_using_ref_a;
bool m_disable_a2b_collision;

};

} /* namespace phys */

} /* namespace lol */


+ 0
- 430
doc/samples/physics/easyphysics.cpp 查看文件

@@ -1,430 +0,0 @@
//
// Lol Engine
//
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net>
// © 2009—2013 Cédric Lecacheur <jordx@free.fr>
// © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
//
// This library is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include "lolbtphysicsintegration.h"
#include "lolphysics.h"

namespace lol
{

namespace phys
{

//-------------------------------------------------------------------------
//EASY_PHYSIC
//--

EasyPhysic::EasyPhysic(WorldEntity* NewOwnerEntity) :
m_collision_object(nullptr),
m_ghost_object(nullptr),
m_rigid_body(nullptr),
m_local_inertia(btVector3(.0f, .0f, .0f)),
m_collision_shape(nullptr),
m_convex_shape(nullptr),
m_motion_state(nullptr),
m_mass(.0f),
m_hit_restitution(.0f),
m_collision_group(1),
m_collision_mask(1),
m_owner_entity(NewOwnerEntity),
m_owner_simulation(nullptr),
m_base_physic(nullptr)
{
}

EasyPhysic::~EasyPhysic()
{
m_rigid_body = nullptr;
delete m_collision_object;
delete m_collision_shape;
delete m_motion_state;
}

//-------------------------------------------------------------------------
//Set Shape functions
//--

void EasyPhysic::SetShapeTo(btCollisionShape* collision_shape)
{
bool bReinitToRigidBody = false;
if (m_rigid_body)
{
bReinitToRigidBody = true;
delete m_rigid_body;
}
if (m_collision_shape)
delete m_collision_shape;

m_collision_shape = collision_shape;

if (bReinitToRigidBody)
InitBodyToRigid();
}

//Box Shape support
void EasyPhysic::SetShapeToBox(lol::vec3& box_size)
{
vec3 new_box_size = box_size * LOL2BT_UNIT * LOL2BT_SIZE;
m_convex_shape = new btBoxShape(LOL2BT_VEC3(new_box_size));
SetShapeTo(m_convex_shape);
}

void EasyPhysic::SetShapeToSphere(float radius)
{
m_convex_shape = new btSphereShape(radius * LOL2BT_UNIT * LOL2BT_SIZE);
SetShapeTo(m_convex_shape);
}

void EasyPhysic::SetShapeToCone(float radius, float height)
{
m_convex_shape = new btConeShape( radius * LOL2BT_UNIT,
height * LOL2BT_UNIT);
SetShapeTo(m_convex_shape);
}

void EasyPhysic::SetShapeToCylinder(lol::vec3& cyl_size)
{
vec3 new_cyl_size = cyl_size * LOL2BT_UNIT;
new_cyl_size.y *= LOL2BT_SIZE;
m_convex_shape = new btCylinderShape(LOL2BT_VEC3(new_cyl_size));
SetShapeTo(m_convex_shape);
}

void EasyPhysic::SetShapeToCapsule(float radius, float height)
{
m_convex_shape = new btCapsuleShape(radius * LOL2BT_UNIT * LOL2BT_SIZE,
height * LOL2BT_UNIT * LOL2BT_SIZE);
SetShapeTo(m_convex_shape);
}

//-------------------------------------------------------------------------
//Base Location/Rotation setup
//--

//Getter
mat4 EasyPhysic::GetTransform()
{
m_local_to_world = lol::mat4(1.0f);
if (m_rigid_body && m_motion_state)
{
btTransform CurTransform;
m_motion_state->getWorldTransform(CurTransform);
CurTransform.getOpenGLMatrix(&m_local_to_world[0][0]);
}
else if (m_collision_object)
m_collision_object->getWorldTransform().getOpenGLMatrix(&m_local_to_world[0][0]);
return m_local_to_world;
}

//Setter
void EasyPhysic::SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation)
{
lol::mat4 PreviousMatrix = m_local_to_world;
m_local_to_world = lol::mat4::translate(base_location) * lol::mat4(base_rotation);

if (m_ghost_object)
m_ghost_object->setWorldTransform(btTransform(LOL2BT_QUAT(base_rotation), LOL2BT_VEC3(LOL2BT_UNIT * base_location)));
else
{
if (m_motion_state)
m_motion_state->setWorldTransform(btTransform(LOL2BT_QUAT(base_rotation), LOL2BT_VEC3(LOL2BT_UNIT * base_location)));
else
m_motion_state = new btDefaultMotionState(btTransform(LOL2BT_QUAT(base_rotation), LOL2BT_VEC3(LOL2BT_UNIT * base_location)));
}

for (int i = 0; i < m_based_physic_list.count(); i++)
{
if (m_based_physic_list[i])
m_based_physic_list[i]->BaseTransformChanged(PreviousMatrix, m_local_to_world);
else
m_based_physic_list.remove(i--);
}
}

//Internal callback when Base transform has changed.
void EasyPhysic::BaseTransformChanged(const lol::mat4& PreviousMatrix, const lol::mat4& NewMatrix)
{
mat4 PreviousMatrixLoc = ((m_base_lock_location)?(PreviousMatrix):(lol::mat4::translate(PreviousMatrix[3].xyz)));
mat4 PreviousMatrixRot = ((m_base_lock_rotation)?(lol::mat4(lol::quat(lol::mat3(PreviousMatrix)))):(lol::mat4(1.f)));
mat4 NewMatrixLoc = ((m_base_lock_location)?(NewMatrix):(lol::mat4::translate(NewMatrix[3].xyz)));
mat4 NewMatrixRot = ((m_base_lock_rotation)?(lol::mat4(lol::quat(lol::mat3(NewMatrix)))):(lol::mat4(1.f)));

if (m_ghost_object || (m_rigid_body->getCollisionFlags() & btCollisionObject::CF_KINEMATIC_OBJECT))
{
mat4 ThisMatrixLoc = NewMatrixLoc * inverse(PreviousMatrixLoc) * lol::mat4::translate(m_local_to_world[3].xyz);
mat4 ThisMatrixRot = NewMatrixRot * inverse(PreviousMatrixRot) * lol::mat4(lol::quat(lol::mat3(m_local_to_world)));
SetTransform(ThisMatrixLoc[3].xyz, lol::quat(lol::mat3(ThisMatrixRot)));
}
}

//-------------------------------------------------------------------------
//Mass related functions
//--
//Set Mass functions
void EasyPhysic::SetMass(float mass)
{
m_mass = mass;

if (m_rigid_body)
{
SetLocalInertia(m_mass);
m_rigid_body->setMassProps(m_mass, m_local_inertia);
}
}

//-------------------------------------------------------------------------
//Hit restitution functions
//--
//Set Hit Restitution functions
void EasyPhysic::SetHitRestitution(float hit_restitution)
{
m_hit_restitution = hit_restitution;

if (m_rigid_body)
{
m_rigid_body->setRestitution(m_hit_restitution);
}
}

//-------------------------------------------------------------------------
//Final conversion pass functions : Body related
//--

//Init to rigid body
void EasyPhysic::InitBodyToRigid(bool SetToKinematic)
{
if (m_collision_object)
delete m_collision_object;

if (!m_motion_state)
SetTransform(vec3(.0f));

btRigidBody::btRigidBodyConstructionInfo NewInfos(m_mass, m_motion_state, m_collision_shape, m_local_inertia);
NewInfos.m_restitution = m_hit_restitution;
m_rigid_body = new btRigidBody(NewInfos);
m_collision_object = m_rigid_body;
m_collision_object->setUserPointer(this);

if (m_mass == .0f)
{
if (SetToKinematic)
{
m_rigid_body->setActivationState(DISABLE_DEACTIVATION);
m_rigid_body->setCollisionFlags(m_rigid_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
}
}
else
SetMass(m_mass);
}

//Return correct Ghost Object
btGhostObject* EasyPhysic::GetGhostObjectInstance()
{
return new btGhostObject();
}

//Init to Ghost object, for Overlap/Sweep Test/Touching logic
void EasyPhysic::InitBodyToGhost()
{
if (m_collision_object)
delete m_collision_object;

m_ghost_object = GetGhostObjectInstance();
m_ghost_object->setCollisionShape(m_collision_shape);
m_collision_object = m_ghost_object;
m_collision_object->setUserPointer(this);

SetTransform(m_local_to_world[3].xyz, lol::quat(lol::mat3(m_local_to_world)));

m_ghost_object->setCollisionFlags(m_ghost_object->getCollisionFlags());
}

//-------------
//Touch logic
//-------------
// btManifoldArray manifoldArray;
// btBroadphasePairArray& pairArray = ghostObject->getOverlappingPairCache()->getOverlappingPairArray();
// int numPairs = pairArray.size();

// for (int i=0;i<numPairs;i++)
// {
// manifoldArray.clear();

// const btBroadphasePair& pair = pairArray[i];
//
// //unless we manually perform collision detection on this pair, the contacts are in the dynamics world paircache:
// btBroadphasePair* collisionPair = dynamicsWorld->getPairCache()->findPair(pair.m_pProxy0,pair.m_pProxy1);
// if (!collisionPair)
// continue;

// if (collisionPair->m_algorithm)
// collisionPair->m_algorithm->getAllContactManifolds(manifoldArray);

// for (int j=0;j<manifoldArray.size();j++)
// {
// btPersistentManifold* manifold = manifoldArray[j];
// btScalar directionSign = manifold->getBody0() == m_ghostObject ? btScalar(-1.0) : btScalar(1.0);
// for (int p=0;p<manifold->getNumContacts();p++)
// {
// const btManifoldPoint&pt = manifold->getContactPoint(p);
// if (pt.getDistance()<0.f)
//{
// const btVector3& ptA = pt.getPositionWorldOnA();
// const btVector3& ptB = pt.getPositionWorldOnB();
// const btVector3& normalOnB = pt.m_normalWorldOnB;
// /// work here
//}
// }
// }
// }


//Add Physic object to the simulation
void EasyPhysic::AddToSimulation(class Simulation* current_simulation)
{
btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld();
if (dynamics_world)
{
if (m_ghost_object)
{
dynamics_world->addCollisionObject(m_ghost_object, m_collision_group, m_collision_mask);
current_simulation->ObjectRegistration(true, this, Simulation::EEPT_Ghost);
}
else if (m_rigid_body)
{
dynamics_world->addRigidBody(m_rigid_body, m_collision_group, m_collision_mask);
if (m_mass != .0f)
current_simulation->ObjectRegistration(true, this, Simulation::EEPT_Dynamic);
else
current_simulation->ObjectRegistration(true, this, Simulation::EEPT_Static);
}
else
{
dynamics_world->addCollisionObject(m_collision_object, m_collision_group, m_collision_mask);
current_simulation->ObjectRegistration(true, this, Simulation::EEPT_CollisionObject);
}
}
}

//Remove Physic object to the simulation
void EasyPhysic::RemoveFromSimulation(class Simulation* current_simulation)
{
btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld();
if (dynamics_world)
{
if (m_rigid_body)
{
dynamics_world->removeRigidBody(m_rigid_body);
if (m_mass != .0f)
current_simulation->ObjectRegistration(false, this, Simulation::EEPT_Dynamic);
else
current_simulation->ObjectRegistration(false, this, Simulation::EEPT_Static);
}
else
{
dynamics_world->removeCollisionObject(m_collision_object);
if (m_ghost_object)
current_simulation->ObjectRegistration(false, this, Simulation::EEPT_Ghost);
current_simulation->ObjectRegistration(false, this, Simulation::EEPT_CollisionObject);
}
}
}

//-------------------------------------------------------------------------
//Force/Impulse functions
//--
void EasyPhysic::AddImpulse(const lol::vec3& impulse)
{
if (m_rigid_body)
m_rigid_body->applyCentralImpulse(LOL2BT_VEC3(impulse));
}

void EasyPhysic::AddImpulse(const lol::vec3& impulse, const lol::vec3& rel_pos)
{
if (m_rigid_body)
m_rigid_body->applyImpulse(LOL2BT_VEC3(impulse), LOL2BTU_VEC3(rel_pos));
}

void EasyPhysic::AddImpulseTorque(const lol::vec3& torque)
{
if (m_rigid_body)
m_rigid_body->applyTorqueImpulse(LOL2BT_VEC3(torque));
}

//--
void EasyPhysic::AddForce(const lol::vec3& force)
{
if (m_rigid_body)
m_rigid_body->applyCentralForce(LOL2BT_VEC3(force));
}

void EasyPhysic::AddForce(const lol::vec3& force, const lol::vec3& rel_pos)
{
if (m_rigid_body)
m_rigid_body->applyForce(LOL2BT_VEC3(force), LOL2BTU_VEC3(rel_pos));
}

void EasyPhysic::AddForceTorque(const lol::vec3& torque)
{
if (m_rigid_body)
m_rigid_body->applyTorque(LOL2BT_VEC3(torque));
}

//-------------------------------------------------------------------------
//Movements getter
//--
lol::vec3 EasyPhysic::GetLinearVelocity() const
{
if (m_rigid_body)
return BT2LOL_VEC3(m_rigid_body->getLinearVelocity());
return lol::vec3(.0f);
}

lol::vec3 EasyPhysic::GetLinearForce() const
{
if (m_rigid_body)
return BT2LOL_VEC3(m_rigid_body->getTotalForce());
return lol::vec3(.0f);
}

lol::vec3 EasyPhysic::GetAngularVelocity() const
{
if (m_rigid_body)
return BT2LOL_VEC3(m_rigid_body->getAngularVelocity());
return lol::vec3(.0f);
}

lol::vec3 EasyPhysic::GetAngularForce() const
{
if (m_rigid_body)
return BT2LOL_VEC3(m_rigid_body->getTotalTorque());
return lol::vec3(.0f);
}

//Set Local Inertia
void EasyPhysic::SetLocalInertia(float mass)
{
if (mass != .0f)
m_collision_shape->calculateLocalInertia(mass, m_local_inertia);
else
m_local_inertia = btVector3(.0f, .0f, .0f);
}

} /* namespace phys */

} /* namespace lol */

+ 0
- 159
doc/samples/physics/easyphysics.h 查看文件

@@ -1,159 +0,0 @@
//
// Lol Engine
//
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net>
// © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
//
// This library is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#pragma once

//
// The EasyPhysic class
// ------------------
//

#include <lol/engine.h>

#include <btBulletDynamicsCommon.h>
#include <btBulletCollisionCommon.h>
#include <BulletCollision/CollisionDispatch/btGhostObject.h>

namespace lol
{

namespace phys
{

class EasyPhysic
{

friend class Simulation;
friend class EasyConstraint;

public:
EasyPhysic(WorldEntity* NewOwnerEntity);
~EasyPhysic();

virtual void SetShapeToBox(lol::vec3& box_size);
virtual void SetShapeToSphere(float radius);
virtual void SetShapeToCone(float radius, float height);
virtual void SetShapeToCylinder(lol::vec3& cyl_size);
virtual void SetShapeToCapsule(float radius, float height);

virtual bool CanChangeCollisionChannel() { return (m_rigid_body == nullptr); }
virtual mat4 GetTransform();
virtual void SetTransform(const vec3& base_location, const quat& base_rotation = quat(mat3(1.0f)));
protected:
virtual void BaseTransformChanged(const mat4& PreviousMatrix, const mat4& NewMatrix);
public:
virtual void SetMass(float mass);
virtual float GetMass() { return m_mass; }
virtual void SetHitRestitution(float hit_restitution);
virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false);
virtual void InitBodyToGhost();
virtual void AddToSimulation(class Simulation* current_simulation);
virtual void RemoveFromSimulation(class Simulation* current_simulation);

//Force/Impulse functions
virtual void AddImpulse(const lol::vec3& impulse);
virtual void AddImpulse(const lol::vec3& impulse, const lol::vec3& rel_pos);
virtual void AddImpulseTorque(const lol::vec3& torque);
virtual void AddForce(const lol::vec3& force);
virtual void AddForce(const lol::vec3& force, const lol::vec3& rel_pos);
virtual void AddForceTorque(const lol::vec3& torque);

//Movements getter
lol::vec3 GetLinearVelocity() const;
lol::vec3 GetLinearForce() const;
lol::vec3 GetAngularVelocity() const;
lol::vec3 GetAngularForce() const;

protected:
virtual void SetLocalInertia(float mass);
virtual void SetShapeTo(btCollisionShape* collision_shape);

virtual btGhostObject* GetGhostObjectInstance();

btCollisionObject* m_collision_object;

btGhostObject* m_ghost_object;

btRigidBody* m_rigid_body;
btVector3 m_local_inertia;

btCollisionShape* m_collision_shape;
btConvexShape* m_convex_shape;
btMotionState* m_motion_state;

public:
//Sets the collision Group & Mask.
//Mask can change at runtime, not group !
virtual bool SetCollisionChannel(int NewGroup, int NewMask)
{
if (CanChangeCollisionChannel())
{
m_collision_group = (1 << NewGroup);
m_collision_mask = NewMask;
return true;
}
return false;
}
int GetCollisionGroup() { return m_collision_group; }
int GetCollisionMask() { return m_collision_mask; }

//Base/Attachment logic
virtual void AttachTo(EasyPhysic* NewBase, bool NewBaseLockLocation = true, bool NewBaseLockRotation = true)
{
if (NewBase == this || (NewBase && NewBase->m_base_physic == this))
return;

if (NewBase)
{
bool bAlreadyExists = false;
for (int i = 0; i < NewBase->m_based_physic_list.count(); ++i)
if (NewBase->m_based_physic_list[i] == this)
bAlreadyExists = true;
if (!bAlreadyExists)
NewBase->m_based_physic_list << this;
m_base_physic = NewBase;
m_base_lock_location = NewBaseLockLocation;
m_base_lock_rotation = NewBaseLockRotation;
}
else if (m_base_physic)
{
for (int i = 0; i < m_base_physic->m_based_physic_list.count(); ++i)
if (m_base_physic->m_based_physic_list[i] == this)
m_base_physic->m_based_physic_list.remove(i--);
m_base_physic = nullptr;
}
}

protected:
lol::mat4 m_local_to_world;
float m_mass;
float m_hit_restitution;
int m_collision_group;
int m_collision_mask;
WorldEntity* m_owner_entity;
Simulation* m_owner_simulation;

//Base/Attachment logic
array<EasyPhysic*> m_based_physic_list; //List of objects based on this : this object moves, its based object MoveStep with it.
EasyPhysic* m_base_physic; //Base for this object : The base moves, the object moves with it.
bool m_base_lock_location; //when this is TRUE, location moves with rotation change.
bool m_base_lock_rotation; //when this is TRUE, rotation moves with rotation change.

//Touch logic
array<EasyPhysic*> m_touching_physic; //Maintained by ghost objects
};

} /* namespace phys */

} /* namespace lol */


+ 0
- 47
doc/samples/physics/lolbtphysicsintegration.h 查看文件

@@ -1,47 +0,0 @@
//
// Lol Engine
//
// Copyright © 2009—2019 Sam Hocevar <sam@hocevar.net>
// © 2010—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
//
// This library is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#pragma once

//
// Bullet Physics integration in Lol
// ---------------------------------
//

namespace lol
{

// Override Gamegroups names for Physic-usage
// "_ENT_" means that this is a group for Entities that use EasyPhysic primitives.
// "_EZP_" means that this is a group for EasyPhysic primitives.
#define GAMEGROUP_EZP_CHAR_CTRLR tickable::group::game::other_2
#define GAMEGROUP_SIMULATION tickable::group::game::other_3

#define LOL2BT_UNIT 1.0f
#define BT2LOL_UNIT 1.0f

#define LOL2BT_SIZE 0.5f
#define BT2LOL_SIZE 2.0f

#define LOL2BT_VEC3(v) btVector3((v).x, (v).y, (v).z)
#define BT2LOL_VEC3(v) lol::vec3(v.getX(), v.getY(), v.getZ())

// Same as above with Unit taken into account
#define LOL2BTU_VEC3(v) (LOL2BT_VEC3(v) * LOL2BT_UNIT)
#define BT2LOLU_VEC3(v) (BT2LOL_VEC3(v) * BT2LOL_UNIT)

#define LOL2BT_QUAT(q) btQuaternion((q).x, (q).y, (q).z, (q).w)
#define BT2LOL_QUAT(q) lol::quat((q).getW(), BT2LOL_VEC3((q).getAxis())

} /* namespace lol */


+ 0
- 425
doc/samples/physics/lolphysics.h 查看文件

@@ -1,425 +0,0 @@
//
// Lol Engine — Bullet physics test
//
// Copyright © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
// © 2012—2019 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#pragma once

#include <cstring>

#include <btBulletDynamicsCommon.h>
#include <btBulletCollisionCommon.h>
#include <BulletDynamics/Character/btKinematicCharacterController.h>

#include "lolbtphysicsintegration.h"
#include "easyphysics.h"
#include "easyconstraint.h"

namespace lol
{

namespace phys
{

enum eRaycastType
{
ERT_Closest,
ERT_AllHit,
ERT_AnyHit, //Will stop at the first hit. Hit data are supposed to be irrelevant

ERT_MAX
};

struct RayCastResult
{
RayCastResult(int CollisionFilterGroup=1, int CollisionFilterMask=(0xFF))
{
memset(this, 0, sizeof(RayCastResult));

m_collision_filter_group = CollisionFilterGroup;
m_collision_filter_mask = CollisionFilterMask;
}
void Reset()
{
m_collider_list.clear();
m_hit_normal_list.clear();
m_hit_point_list.clear();
m_hit_fraction_list.clear();
}

array<EasyPhysic*> m_collider_list;
array<vec3> m_hit_normal_list;
array<vec3> m_hit_point_list;
array<float> m_hit_fraction_list;

short int m_collision_filter_group;
short int m_collision_filter_mask;
unsigned int m_flags; //???
};

class Simulation : public entity
{
public:
Simulation() :
m_broadphase(0),
m_collision_configuration(0),
m_dispatcher(0),
m_solver(0),
m_dynamics_world(0),
m_timestep(1.f/60.f)
{
m_gamegroup = GAMEGROUP_SIMULATION;
}
~Simulation()
{
Exit();
}

std::string GetName() const { return "<Simulation>"; }

public:
void Init()
{
// Build the broadphase
if (1)
{
m_Sweep_broadphase = new btAxisSweep3(LOL2BT_VEC3(m_world_min), LOL2BT_VEC3(m_world_max));
m_Sweep_broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
m_broadphase = m_Sweep_broadphase;
}
else
m_broadphase = new btDbvtBroadphase();

// Set up the collision configuration and dispatcher
m_collision_configuration = new btDefaultCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collision_configuration);

// The actual physics solver
m_solver = new btSequentialImpulseConstraintSolver;

// The world.
m_dynamics_world = new btDiscreteDynamicsWorld(m_dispatcher, m_broadphase, m_solver, m_collision_configuration);
}

virtual void tick_game(float seconds)
{
entity::tick_game(seconds);

//step the simulation
if (m_dynamics_world)
{
//the "+1" is to have at least one Timestep and to ensure float to int .5f conversion.
int steps = (int)(seconds / m_timestep) + 1;
m_dynamics_world->stepSimulation(seconds, steps, m_timestep);
}
}

//Rip-Off of the btKinematicClosestNotMeRayResultCallback
class ClosestNotMeRayResultCallback : public btCollisionWorld::ClosestRayResultCallback
{
public:
ClosestNotMeRayResultCallback(btCollisionObject* Me, const btVector3& rayFromWorld, const btVector3& rayToWorld) :
btCollisionWorld::ClosestRayResultCallback(rayFromWorld, rayToWorld)
{
m_me = Me;
}

virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult,bool normalInWorldSpace)
{
if (rayResult.m_collisionObject == m_me)
return 1.0;

return ClosestRayResultCallback::addSingleResult(rayResult, normalInWorldSpace);
}
protected:
btCollisionObject* m_me;
};

//Will stop at the first hit. Hit data are supposed to be irrelevant
class AnyHitRayResultCallback : public btCollisionWorld::ClosestRayResultCallback
{
public:
AnyHitRayResultCallback(const btVector3& rayFromWorld, const btVector3& rayToWorld) :
btCollisionWorld::ClosestRayResultCallback(rayFromWorld, rayToWorld)
{
}

virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult,bool normalInWorldSpace)
{
UNUSED(rayResult);
UNUSED(normalInWorldSpace);
return .0f;
}
};

//Returns true when hitting something. If SourceCaster is set, it will be ignored by Raycast.
bool RayHits(RayCastResult& HitResult, eRaycastType RaycastType, const vec3& RayFrom, const vec3& RayTo, EasyPhysic* SourceCaster = nullptr)
{
bool bResult = false;

btCollisionWorld::RayResultCallback* BtRayResult = nullptr;
btCollisionWorld::ClosestRayResultCallback* BtRayResult_Closest;
btCollisionWorld::AllHitsRayResultCallback* BtRayResult_AllHits;

switch (RaycastType)
{
case ERT_Closest:
{
if (SourceCaster)
BtRayResult_Closest = new ClosestNotMeRayResultCallback(SourceCaster->m_collision_object, LOL2BTU_VEC3(RayFrom), LOL2BTU_VEC3(RayTo));
else
BtRayResult_Closest = new btCollisionWorld::ClosestRayResultCallback(LOL2BTU_VEC3(RayFrom), LOL2BTU_VEC3(RayTo));
BtRayResult = BtRayResult_Closest;
break;
}
case ERT_AllHit:
{
BtRayResult_AllHits = new btCollisionWorld::AllHitsRayResultCallback(LOL2BTU_VEC3(RayFrom), LOL2BTU_VEC3(RayTo));
BtRayResult = BtRayResult_AllHits;
break;
}
case ERT_AnyHit:
{
BtRayResult_Closest = new AnyHitRayResultCallback(LOL2BTU_VEC3(RayFrom), LOL2BTU_VEC3(RayTo));
BtRayResult = BtRayResult_Closest;
break;
}
default:
{
ASSERT(0, "Raycast not handled");
}
}

m_dynamics_world->rayTest(LOL2BTU_VEC3(RayFrom), LOL2BTU_VEC3(RayTo), *BtRayResult);
if (BtRayResult->hasHit())
{
bResult = true;

switch (RaycastType)
{
case ERT_Closest:
{
HitResult.m_collider_list << (EasyPhysic*)BtRayResult_Closest->m_collisionObject->getUserPointer();
HitResult.m_hit_normal_list << BT2LOLU_VEC3(BtRayResult_Closest->m_hitNormalWorld);
HitResult.m_hit_point_list << BT2LOLU_VEC3(BtRayResult_Closest->m_hitPointWorld);
HitResult.m_hit_fraction_list << BtRayResult_Closest->m_closestHitFraction;
break;
}
case ERT_AllHit:
{
for (int i = 0; i < BtRayResult_AllHits->m_collisionObjects.size(); i++)
{
HitResult.m_collider_list << (EasyPhysic*)BtRayResult_AllHits->m_collisionObjects[i]->getUserPointer();
HitResult.m_hit_normal_list << BT2LOLU_VEC3(BtRayResult_AllHits->m_hitNormalWorld[i]);
HitResult.m_hit_point_list << BT2LOLU_VEC3(BtRayResult_AllHits->m_hitPointWorld[i]);
HitResult.m_hit_fraction_list << BtRayResult_AllHits->m_hitFractions[i];
}
break;
}
default:
{
ASSERT(0, "Raycast not handled");
}
}
}

delete BtRayResult;

return bResult;
}


void Exit()
{
delete m_dynamics_world;
delete m_solver;
delete m_dispatcher;
delete m_collision_configuration;
delete m_broadphase;
}

btDiscreteDynamicsWorld* GetWorld()
{
return m_dynamics_world;
}

private:
void CustomSetContinuousDetection(bool ShouldUseCCD)
{
if (m_dynamics_world)
m_dynamics_world->getDispatchInfo().m_useContinuous = ShouldUseCCD;
}

void CustomSetGravity(vec3 &NewGravity)
{
if (m_dynamics_world)
m_dynamics_world->setGravity(LOL2BT_VEC3(NewGravity * LOL2BT_UNIT));
}

void CustomSetWorldLimit(vec3 const &NewWorldMin, vec3 const &NewWorldMax)
{
UNUSED(NewWorldMin);
UNUSED(NewWorldMax);
}

void CustomSetTimestep(float NewTimestep) { }

//broadphase
btBroadphaseInterface* m_broadphase;
btAxisSweep3* m_Sweep_broadphase;
// Set up the collision configuration and dispatc
btDefaultCollisionConfiguration* m_collision_configuration;
btCollisionDispatcher* m_dispatcher;
// The actual physics solver
btSequentialImpulseConstraintSolver* m_solver;
// The world.
btDiscreteDynamicsWorld* m_dynamics_world;

public:
//Main logic :
//The Set*() functions do the all-lib-independent data storage.
//And then it calls the CustomSet*() which are the specialized versions.

//Sets the continuous collision detection flag.
void SetContinuousDetection(bool ShouldUseCCD)
{
m_using_CCD = ShouldUseCCD;
CustomSetContinuousDetection(ShouldUseCCD);
}

//Sets the simulation gravity.
void SetGravity(vec3 &NewGravity)
{
m_gravity = NewGravity;
CustomSetGravity(NewGravity);
}

//Sets the simulation gravity.
void SetWorldLimit(vec3 const &NewWorldMin, vec3 const &NewWorldMax)
{
m_world_min = NewWorldMin;
m_world_max = NewWorldMax;
CustomSetWorldLimit(NewWorldMin, NewWorldMax);
}

//Sets the simulation fixed timestep.
void SetTimestep(float NewTimestep)
{
if (NewTimestep > .0f)
{
m_timestep = NewTimestep;
CustomSetTimestep(NewTimestep);
}
}

private:

friend class EasyPhysic;
friend class EasyCharacterController;
friend class EasyConstraint;

enum eEasyPhysicType
{
EEPT_Dynamic,
EEPT_Static,
EEPT_Ghost,
EEPT_CollisionObject,
EEPT_CharacterController,

EEPT_MAX
};

//m_owner_simulation
//Adds the given EasyPhysic to the correct list.
void ObjectRegistration(bool AddObject, EasyPhysic* NewEP, eEasyPhysicType CurType)
{
array<EasyPhysic*>* SearchList = nullptr;
switch(CurType)
{
case EEPT_Dynamic:
{
SearchList = &m_dynamic_list;
break;
}
case EEPT_Static:
{
SearchList = &m_static_list;
break;
}
case EEPT_Ghost:
{
SearchList = &m_ghost_list;
break;
}
case EEPT_CollisionObject:
{
SearchList = &m_collision_object_list;
break;
}
case EEPT_CharacterController:
{
SearchList = &m_character_controller_list;
break;
}
default:
{
ASSERT(0, "Physic type does not exist.");
}
}

if (AddObject)
{
NewEP->m_owner_simulation = this;
(*SearchList) << NewEP;
}
else
{
NewEP->m_owner_simulation = nullptr;
SearchList->remove_item(NewEP);
}
}
void ObjectRegistration(bool AddObject, EasyConstraint* NewEC)
{
array<EasyConstraint*>* SearchList = nullptr;
SearchList = &m_constraint_list;

if (AddObject)
{
NewEC->m_owner_simulation = this;
(*SearchList) << NewEC;
}
else
{
NewEC->m_owner_simulation = nullptr;
SearchList->remove_item(NewEC);
}
}

//Easy Physics body List
array<EasyPhysic*> m_dynamic_list;
array<EasyPhysic*> m_static_list;
array<EasyPhysic*> m_ghost_list;
array<EasyPhysic*> m_collision_object_list;
array<EasyPhysic*> m_character_controller_list;
array<EasyConstraint*> m_constraint_list;

//Easy Physics data storage
float m_timestep;
bool m_using_CCD;
vec3 m_gravity;
vec3 m_world_min;
vec3 m_world_max;
};

} /* namespace phys */

} /* namespace lol */


+ 0
- 11
doc/samples/sandbox/Makefile.am 查看文件

@@ -1,11 +0,0 @@

include $(top_srcdir)/build/autotools/common.am

if BUILD_SAMPLES
bin_PROGRAMS = sample
endif

sample_SOURCES = sample.cpp
sample_CPPFLAGS = $(AM_CPPFLAGS)
sample_DEPENDENCIES = @LOL_DEPS@


+ 0
- 44
doc/samples/sandbox/sample.cpp 查看文件

@@ -1,44 +0,0 @@
//
// Lol Engine — Sandbox program
//
// Copyright © 2005—2018 Sam Hocevar <sam@hocevar.net>
//
// This program is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/engine.h>

using namespace lol;

int main(int, char **)
{
timer t;

bigint<128> x(17), y(23);
x.print();
y.print();

auto z = x * y;
z.print();

for (int i = 0; i < 500000; ++i)
{
x = (bigint<128>)(x * x);
x ^= y;
}

printf("%d %d\n", (int)x, (int)y);

printf("Time: %f s\n", t.get());

return EXIT_SUCCESS;
}


+ 0
- 147
doc/samples/simplex.cpp 查看文件

@@ -1,147 +0,0 @@
//
// Lol Engine — Simplex Noise tutorial
//
// Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net>
// © 2013-2014 Guillaume Bittoun <guillaume.bittoun@gmail.com>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/engine.h>

using namespace lol;

/* Constants to tweak */
ivec2 const size(1280 * 1, 720 * 1);
float const zoom = 0.03f / 1;
int const octaves = 1;

int main(int argc, char **argv)
{
UNUSED(argc, argv);

srand(time(nullptr));

/* Create an image */
image img(size);
array2d<vec4> &data = img.lock2d<PixelFormat::RGBA_F32>();

/* Declare plenty of allocators */
simplex_noise<2> s2;
simplex_noise<3> s3;
simplex_noise<4> s4;
simplex_noise<5> s5;
simplex_noise<6> s6;
simplex_noise<7> s7;
simplex_noise<8> s8;
simplex_noise<9> s9;
simplex_noise<10> s10;
simplex_noise<11> s11;
simplex_noise<12> s12;

/* Fill image with simplex noise */
for (int j = 0; j < size.y; ++j)
for (int i = 0; i < size.x; ++i)
{
int cell = j / (size.y / 2) * 3 + i / (size.x / 3);

float x = (float)i, y = (float)j;
float sum = 0.f, coeff = 0.f;
int const max_k = 1 << octaves;
bool b_centre = false, b_sphere1 = false, b_sphere2 = false;

for (int k = 1; k < max_k; k *= 2)
{
float t = 0.f;

switch (cell)
{
case 0:
t = s2.eval(zoom * k * vec2(x, y));
break;
case 1:
t = s3.eval(zoom * k * vec3(x, 1.f, y));
break;
case 2:
t = s4.eval(zoom * k * vec4(x, 1.f, y, 2.f));
break;
case 3:
t = s6.eval(zoom * k * vec6(x, 1.f, 2.f, y, 3.f, 4.f));
break;
case 4:
t = s8.eval(zoom * k * vec8(x, 1.f, 2.f, 3.f,
y, 4.f, 5.f, 6.f));
break;
case 5:
//t = s12.eval(zoom * k * vec12(x / 2, -x / 2, y / 2, -y / 2,
// -x / 2, x / 2, -y / 2, y / 2,
// 7.f, 8.f, 9.f, 10.f));
t = s12.eval(zoom * k * vec12(x, 1.f, 2.f, 3.f, 4.f, 5.f,
y, 6.f, 7.f, 8.f, 9.f, 10.f));
break;
default:
break;
}

if (t == -2.f) b_centre = true;
if (t == -3.f) b_sphere1 = true;
if (t == -4.f) b_sphere2 = true;

sum += 1.f / k * t;
coeff += 1.f / k;
}

if (b_centre)
data[i][j] = vec4(1.f, 0.f, 1.f, 1.f);
else if (b_sphere1)
data[i][j] = vec4(0.f, 1.f, 0.f, 1.f);
else if (b_sphere2)
data[i][j] = vec4(0.f, 0.f, 1.f, 1.f);
else
{
float c = saturate(0.5f + 0.5f * sum / coeff);
data[i][j] = vec4(c, c, c, 1.f);
//data[i][j] = Color::HSVToRGB(vec4(c, 1.0f, 0.5f, 1.f));
}
}

#if 0
/* Mark simplex vertices */
vec2 diagonal = normalize(vec2(1.f));
vec2 dx = mat2::rotate(radians(60.f)) * diagonal;
vec2 dy = mat2::rotate(radians(-60.f)) * diagonal;
for (int j = -100; j < 100; ++j)
for (int i = -100; i < 100; ++i)
{
auto putpixel = [&](ivec2 p, vec4 c = vec4(1.f, 0.f, 1.f, 1.f))
{
if (p.x >= 0 && p.x < size.x - 1 && p.y >= 0 && p.y < size.y - 1)
data[p.x][p.y] = c;
};

ivec2 coord = ivec2(i / zoom * dx + j / zoom * dy);

vec2 g = s2.gradient((i + 0.1f) * dx + (j + 0.1f) * dy);
for (int t = 0; t < 40; ++t)
putpixel(coord + (ivec2)(g * (t / 2.f)), vec4(0.f, 1.f, 0.f, 1.f));

putpixel(coord);
putpixel(coord + ivec2(1, 0));
putpixel(coord + ivec2(0, 1));
putpixel(coord + ivec2(1, 1));
}
#endif

/* Save image */
img.unlock2d(data);
img.save("simplex.png");
}


+ 0
- 46
doc/shitlolbotsays.txt 查看文件

@@ -1,46 +0,0 @@
<lolbot> en france tfacon :)
%
<lolbot> Je crois qu'il est en AMerique mon ptit gars, je me lève tôt demain matin, je pars bosser
%
<lolbot> c'est ou ?
%
<lolbot> Touky bloque avec Guillaume devant des questions d'hygiène
%
<lolbot> oui c'est le kiff les nouveaux locaux omg
%
<lolbot> CPU à priori mon vc6.0 est dans le port, dans l'eau, probablement completement bourre, car les bars sont pas trompés http://files.sharenator.com/Kill_it_With_Fire_Aliens-s576x304-132453.jpg
%
<lolbot> j'ai recommencé le jeu est proche de FTL au final
%
<lolbot> au fait tu peux devenir chef-Producer, ils en sont capables de nous parler de l'hégémonie du grand gourou du groupe O+ et me l'étaler sur le site reçoit un prix acceptable
%
<rez_> ha ben
<rez_> ça va vite le net chez nous
<rez_> je récupère un torrent de 3Go à 12 Mo par secondes
<lolbot> c'est franchement pas grave je passe plus de 100 lolipop par secondes
%
<lolbot> Touky: (et faut attendre tout le middleware pendant ma pause de midi comme vous genre On aura saisi qu'il est pas censé être déja le HA. GAYYYYYY c'est mort
%
<sam> bon c'est rigolo mais ça va super nous gaver
<lolbot> ouais mais ça fait des frissons tout partout
%
<Jnat1> cocaine + lolbot = shitloads of fun
<lolbot> ouais avec theory of fun bien proéminent
%
<lolbot> RuTT: p'tain mais Gameblog, ce Gorafi du JV
%
<lolbot> wanadoo hahahaah la loooooooooooooooooooooooooooooooooooozzzeeee
%
<lolbot> rez_: nan les pédophiles abiment la marchandise
%
<lolbot> rez_: et ça sentait la prèz bidonnée, de tellement loin… et ces ptits pédés : ils se sont succédées
%
<lolbot> c'est .... hum .... "normal" ?
%
<lolbot> rez_: mais bon, suffit de mettre leur caca chez nous
%
<lolbot> rez_: c'est a eux alors qu'on est pas loin de chez toi de remplir les champs de vecteurs, comme dans diablo 3 en built-in, mais des bougnoules marrants
%
<lolbot> TypX: aucun signe de vie ridicule par rapport à la cuisine !!
%
<lolbot> voir ENCULER de rire

+ 0
- 88
doc/tutorial/01_triangle.cpp 查看文件

@@ -1,88 +0,0 @@
//
// Lol Engine — Triangle tutorial
//
// Copyright © 2012—2019 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <memory>

#include <lol/engine.h>
#include "loldebug.h"

using namespace lol;

LOLFX_RESOURCE_DECLARE(01_triangle);

class Triangle : public WorldEntity
{
public:
virtual bool init_draw() override
{
array<vec2> vertices
{
vec2( 0.0f, 0.8f),
vec2(-0.8f, -0.8f),
vec2( 0.8f, -0.8f),
};

m_shader = Shader::Create(LOLFX_RESOURCE_NAME(01_triangle));
m_coord = m_shader->GetAttribLocation(VertexUsage::Position, 0);

m_vdecl = std::make_shared<VertexDeclaration>(VertexStream<vec2>(VertexUsage::Position));

m_vbo = std::make_shared<VertexBuffer>(vertices.bytes());
m_vbo->set_data(vertices.data(), vertices.bytes());

return true;
}

virtual void tick_draw(float seconds, Scene &scene) override
{
WorldEntity::tick_draw(seconds, scene);

m_shader->Bind();
m_vdecl->Bind();
m_vdecl->SetStream(m_vbo, m_coord);
m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 3);
m_vdecl->Unbind();
}

virtual bool release_draw() override
{
m_shader.reset();
m_vdecl.reset();
m_vbo.reset();

return true;
}

private:
std::shared_ptr<Shader> m_shader;
ShaderAttrib m_coord;
std::shared_ptr<VertexDeclaration> m_vdecl;
std::shared_ptr<VertexBuffer> m_vbo;
};

int main(int argc, char **argv)
{
sys::init(argc, argv);

Application app("Tutorial 1: Triangle", ivec2(640, 480), 60.0f);

new DebugFps(5, 5);
new Triangle();

app.Run();
return EXIT_SUCCESS;
}


+ 0
- 35
doc/tutorial/01_triangle.lolfx 查看文件

@@ -1,35 +0,0 @@
/*
* Awesome triangle shader
*/

technique FlatColor
{
pass DefaultPass
{
vertexshader = vert;
pixelshader = frag;
}
}

[vert.glsl]
#version 130

in vec2 in_position;

void main(void)
{
gl_Position = vec4(in_position, 0.0, 1.0);
}

[frag.glsl]
#version 130

#if defined GL_ES
precision highp float;
#endif

void main(void)
{
gl_FragColor = vec4(0.7, 0.2, 0.5, 1.0);
}


+ 0
- 69
doc/tutorial/01_triangle.vcxproj 查看文件

@@ -1,69 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="LolMacros">
<LolDir Condition="Exists('$(SolutionDir)\lol')">$(SolutionDir)\lol</LolDir>
<LolDir Condition="!Exists('$(SolutionDir)\lol')">$(SolutionDir)</LolDir>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|NX64">
<Configuration>Debug</Configuration>
<Platform>NX64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ORBIS">
<Configuration>Debug</Configuration>
<Platform>ORBIS</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|NX64">
<Configuration>Release</Configuration>
<Platform>NX64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ORBIS">
<Configuration>Release</Configuration>
<Platform>ORBIS</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="01_triangle.cpp" />
</ItemGroup>
<ItemGroup>
<LolFxCompile Include="01_triangle.lolfx" />
</ItemGroup>
<Import Project="$(LolDir)\build\msbuild\lol-core.props" />
<Import Project="$(LolDir)\build\msbuild\lol-bullet.props" />
<PropertyGroup Label="Globals">
<ProjectGuid>{b92abadc-45be-4cc5-b724-9426053123a1}</ProjectGuid>
<ConfigurationType>Application</ConfigurationType>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(LolDir)\build\msbuild\lol.config.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(LolDir)\build\msbuild\lolfx.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(LolDir)\build\msbuild\lol.vars.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<Import Project="$(LolDir)\build\msbuild\lol.rules.props" />
<ItemDefinitionGroup />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(LolDir)\build\msbuild\lolfx.targets" />
</ImportGroup>
</Project>

+ 0
- 190
doc/tutorial/02_cube.cpp 查看文件

@@ -1,190 +0,0 @@
//
// Lol Engine — Cube tutorial
//
// Copyright © 2011—2019 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/engine.h>
#include "loldebug.h"

using namespace lol;

LOLFX_RESOURCE_DECLARE(02_cube);

class Cube : public WorldEntity
{
public:
Cube()
{
m_camera = new Camera();
m_camera->SetProjection(mat4::perspective(radians(30.f), 640.f, 480.f, .1f, 1000.f));
m_camera->SetView(mat4::lookat(vec3(-15.f, 5.f, 0.f),
vec3(0.f, -1.f, 0.f),
vec3(0.f, 1.f, 0.f)));
Scene& scene = Scene::GetScene();
scene.PushCamera(m_camera);
Ticker::Ref(m_camera);
}

~Cube()
{
Scene& scene = Scene::GetScene();
scene.PopCamera(m_camera);
Ticker::Unref(m_camera);
}

virtual bool init_draw() override
{
array<vec3, vec3> mesh
{
// Front vertices/colors
{ vec3(-1.0, -1.0, 1.0), vec3(1.0, 0.0, 1.0) },
{ vec3( 1.0, -1.0, 1.0), vec3(0.0, 1.0, 0.0) },
{ vec3( 1.0, 1.0, 1.0), vec3(1.0, 0.5, 0.0) },
{ vec3(-1.0, 1.0, 1.0), vec3(1.0, 1.0, 0.0) },
// Back
{ vec3(-1.0, -1.0, -1.0), vec3(1.0, 0.0, 0.0) },
{ vec3( 1.0, -1.0, -1.0), vec3(0.0, 0.5, 0.0) },
{ vec3( 1.0, 1.0, -1.0), vec3(0.0, 0.5, 1.0) },
{ vec3(-1.0, 1.0, -1.0), vec3(0.0, 0.0, 1.0) },
};

array<uint16_t> lines_indices
{
0, 1, 1, 2, 2, 3, 3, 0,
4, 5, 5, 6, 6, 7, 7, 4,
0, 4, 1, 5, 2, 6, 3, 7,
};

array<uint16_t> faces_indices
{
0, 1, 2, 2, 3, 0, 1, 5, 6, 6, 2, 1,
7, 6, 5, 5, 4, 7, 4, 0, 3, 3, 7, 4,
4, 5, 1, 1, 0, 4, 3, 2, 6, 6, 7, 3,
};

m_shader = Shader::Create(LOLFX_RESOURCE_NAME(02_cube));

m_mvp = m_shader->GetUniformLocation("u_matrix");
m_coord = m_shader->GetAttribLocation(VertexUsage::Position, 0);
m_color = m_shader->GetAttribLocation(VertexUsage::Color, 0);

m_vdecl = std::make_shared<VertexDeclaration>(
VertexStream<vec3,vec3>(VertexUsage::Position,
VertexUsage::Color));

m_vbo = std::make_shared<VertexBuffer>(mesh.bytes());
m_vbo->set_data(mesh.data(), mesh.bytes());

m_lines_ibo = std::make_shared<IndexBuffer>(lines_indices.bytes());
m_lines_ibo->set_data(lines_indices.data(), lines_indices.bytes());

m_faces_ibo = std::make_shared<IndexBuffer>(faces_indices.bytes());
m_faces_ibo->set_data(faces_indices.data(), faces_indices.bytes());

return true;
}

virtual void tick_game(float seconds) override
{
WorldEntity::tick_game(seconds);

m_angle += seconds * radians(45.0f);

mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0));
mat4 model = mat4::translate(vec3(0, 0, -4.5));
mat4 view = mat4::lookat(vec3(0, 2, 0), vec3(0, 0, -4), vec3(0, 1, 0));
mat4 proj = mat4::perspective(radians(45.0f), 640.0f, 480.0f, 0.1f, 10.0f);

m_matrix = proj * view * model * anim;

{
auto context0 = Debug::DrawContext::New(Color::red);
{
auto context1 = Debug::DrawContext::New(Color::blue);
Debug::DrawBox(box3(vec3(0.f), vec3(1.2f)));
Debug::DrawGrid(vec3(0.f), vec3::axis_x, vec3::axis_y, vec3::axis_z, 10.0f);
{
auto context2 = Debug::DrawContext::New(context0);
Debug::DrawBox(box3(vec3(0.f), vec3(1.3f)));
}
{
auto context2 = Debug::DrawContext::New(context0);
context2.SetColor(Color::yellow);
Debug::DrawBox(box3(vec3(-1.f), vec3(1.4f)));
}
}
Debug::DrawBox(box3(vec3(0.f), vec3(1.1f)));
}
}

virtual void tick_draw(float seconds, Scene &scene) override
{
WorldEntity::tick_draw(seconds, scene);

scene.get_renderer()->clear_color(vec4(0.0f, 0.0f, 0.0f, 1.0f));

m_shader->Bind();
m_vdecl->Bind();
m_vdecl->SetStream(m_vbo, m_coord, m_color);

m_shader->SetUniform(m_mvp, m_matrix);
m_lines_ibo->Bind();
m_vdecl->DrawIndexedElements(MeshPrimitive::Lines, m_lines_ibo->size() / sizeof(uint16_t));
m_lines_ibo->Unbind();

m_shader->SetUniform(m_mvp, m_matrix * mat4::scale(0.5f));
m_faces_ibo->Bind();
m_vdecl->DrawIndexedElements(MeshPrimitive::Triangles, m_faces_ibo->size() / sizeof(uint16_t));
m_faces_ibo->Unbind();

m_vdecl->Unbind();
}

virtual bool release_draw() override
{
m_shader.reset();
m_vdecl.reset();
m_vbo.reset();
m_lines_ibo.reset();
m_faces_ibo.reset();
return true;
}

private:
Camera* m_camera = nullptr;
float m_angle = 0.0f;
mat4 m_matrix;

std::shared_ptr<Shader> m_shader;
ShaderAttrib m_coord, m_color;
ShaderUniform m_mvp;
std::shared_ptr<VertexDeclaration> m_vdecl;
std::shared_ptr<VertexBuffer> m_vbo;
std::shared_ptr<IndexBuffer> m_lines_ibo, m_faces_ibo;
};

int main(int argc, char **argv)
{
sys::init(argc, argv);

Application app("Tutorial 2: Cube", ivec2(640, 480), 60.0f);

new DebugFps(5, 5);
new Cube();

app.Run();

return EXIT_SUCCESS;
}


+ 0
- 32
doc/tutorial/02_cube.lolfx 查看文件

@@ -1,32 +0,0 @@
[vert.glsl]

#version 130

attribute vec3 in_position;
attribute vec3 in_color;

uniform mat4 u_matrix;

out vec3 pass_color;

void main(void)
{
gl_Position = u_matrix * vec4(in_position, 1.0);
pass_color = in_color;
}

[frag.glsl]

#version 130

#if defined GL_ES
precision highp float;
#endif

in vec3 pass_color;

void main(void)
{
gl_FragColor = vec4(pass_color, 1.0);
}


部分文件因为文件数量过多而无法显示

正在加载...
取消
保存