Clean up TMS includes in Principia code

Always only `#include <tms/cpp.hh>` in C++ source files to make sure everything gets included with the correct declarations (i.e. `extern "C"` for TMS C stuff)
This commit is contained in:
ROllerozxa 2026-06-07 20:50:17 +02:00
commit a2b7870842
57 changed files with 394 additions and 594 deletions

View file

@ -107,8 +107,7 @@ include_directories(
file(GLOB SRCS
src/tms/core/*.c
src/tms/math/*.c
src/tms/util/*.c
src/tms/bindings/cpp/cpp.cc
src/tms/cpp.cc
src/tms/modules/3ds.c
src/*.c

View file

@ -1,10 +1,9 @@
#pragma once
#include <map>
#include <Box2D/Box2D.h>
#include <tms/math/vector.h>
#include "creature.hh"
#include <Box2D/Box2D.h>
#include <map>
#include <tms/cpp.hh>
class entity;
class creature;

View file

@ -1,21 +1,21 @@
#include "adventure.hh"
#include "game.hh"
#include <tms/bindings/cpp/cpp.hh>
#include "settings.hh"
#include "ui.hh"
#include "backpack.hh"
#include "checkpoint.hh"
#include "object_factory.hh"
#include "panel.hh"
#include "tpixel.hh"
#include "fxemitter.hh"
#include "robot.hh"
#include "widget_manager.hh"
#include "factory.hh"
#include "fxemitter.hh"
#include "game.hh"
#include "gui.hh"
#include "item.hh"
#include "misc.hh"
#include "object_factory.hh"
#include "panel.hh"
#include "plant.hh"
#include "gui.hh"
#include "robot.hh"
#include "settings.hh"
#include "tpixel.hh"
#include "ui.hh"
#include "widget_manager.hh"
#include <tms/cpp.hh>
#define MINING_INTERVAL 75000
#define MINING_DAMAGE 1.f

View file

@ -1,7 +1,7 @@
#pragma once
#include "entity.hh"
#include "tms/bindings/cpp/cpp.hh"
#include <tms/cpp.hh>
#include <set>
#define CABLE_BLACK 0

View file

@ -7,7 +7,7 @@
#include <unistd.h>
#ifndef _NO_TMS
#include "tms/backend/print.h"
#include <tms/backend/print.h>
#endif
uint32_t

View file

@ -1,7 +1,7 @@
#pragma once
#include <Box2D/Box2D.h>
#include <tms/bindings/cpp/cpp.hh>
#include <tms/cpp.hh>
class world;

View file

@ -4,10 +4,9 @@
#include "main.hh"
#include "network.hh"
#include "pkgman.hh"
#include "tms/backend/print.h"
#include "tms/core/err.h"
#include <cstdlib>
#include <emscripten/fetch.h>
#include <tms/cpp.hh>
/**
* Emscripten-based level downloader using emscripten_fetch (async callbacks).

View file

@ -1,6 +1,6 @@
#pragma once
#include <tms/bindings/cpp/cpp.hh>
#include <tms/cpp.hh>
#include <Box2D/Box2D.h>
#include "pkgman.hh"

View file

@ -1,9 +1,8 @@
#pragma once
#include "mood.hh"
#include <tms/math/vector.h>
#include <inttypes.h>
#include <tms/cpp.hh>
#define ENEMY 0
#define FRIENDLY 1

View file

@ -1,6 +1,6 @@
#pragma once
#include "tms/bindings/cpp/cpp.hh"
#include <tms/cpp.hh>
#define FLUIDBUFFER_MAX_1_5_1 4096 // Used in <= 1.5.1
#define FLUIDBUFFER_MAX 16384 // Used in >= 1.5.2

View file

@ -13,7 +13,7 @@
#define FT_FLOOR(X) ((X & -64) / 64)
#endif
#include <tms/math/vector.h>
#include <tms/cpp.hh>
#include <SDL_rwops.h>
#include <ft2build.h>
#include FT_FREETYPE_H

View file

@ -3,9 +3,7 @@
#include "pscreen.hh"
#include "settings.hh"
#include <tms/bindings/cpp/cpp.hh>
#include <tms/core/tms.h>
#include <tms/core/ddraw.h>
#include <tms/cpp.hh>
#include <limits>

View file

@ -2,7 +2,7 @@
#include "text.hh"
#include "pscreen.hh"
#include <tms/core/glob.h>
#include <tms/cpp.hh>
static double DEFAULT_ALPHA_MULTIPLIER = 4.0;

View file

@ -1,16 +1,15 @@
#pragma once
#include "misc.hh"
#include "pscreen.hh"
#include "entity.hh"
#include <tms/bindings/cpp/cpp.hh>
#include <set>
#include <map>
#include "misc.hh"
#include "panel.hh"
#include "types.hh"
#include "pscreen.hh"
#include "text.hh"
#include "types.hh"
#include "world.hh"
#include <map>
#include <set>
#include <tms/cpp.hh>
#define OFFS_REPAIR_STATION 0.f, 3.f

View file

@ -3,7 +3,7 @@
#include "font.hh"
#include "settings.hh"
#include "misc.hh"
#include <tms/bindings/cpp/cpp.hh>
#include <tms/cpp.hh>
#define FONT_CACHE_VERSION 34

View file

@ -1,6 +1,6 @@
#pragma once
#include <tms/bindings/cpp/cpp.hh>
#include <tms/cpp.hh>
#include "text.hh"
#include "const.hh"

View file

@ -1,6 +1,6 @@
#pragma once
#include "tms/bindings/cpp/cpp.hh"
#include <tms/cpp.hh>
#define LEDBUFFER_MAX 512

View file

@ -1,6 +1,6 @@
#pragma once
#include "tms/bindings/cpp/cpp.hh"
#include <tms/cpp.hh>
#define LINEBUFFER_MAX 512

View file

@ -2,6 +2,7 @@
#include "menu_main.hh"
#include "settings.hh"
#include "text.hh"
#include <tms/cpp.hh>
loading_screen::loading_screen()
{

View file

@ -1,7 +1,7 @@
#pragma once
#include <tms/bindings/cpp/cpp.hh>
#include "text.hh"
#include <tms/cpp.hh>
#define LOAD_CONT 0
#define LOAD_ERROR 1

View file

@ -1,6 +1,5 @@
#include "game.hh"
#include "main.hh"
#include "tms/core/err.h"
#include "loading_screen.hh"
#include "soundmanager.hh"
#include "ui.hh"
@ -45,11 +44,7 @@
#include <sys/stat.h>
#include <tms/core/tms.h>
#include <tms/core/framebuffer.h>
#include <tms/core/entity.h>
#include <tms/core/pipeline.h>
#include <tms/bindings/cpp/cpp.hh>
#include <tms/cpp.hh>
#include "network.hh"

View file

@ -1,9 +1,7 @@
#pragma once
#include "misc.hh"
#include <tms/bindings/cpp/cpp.hh>
#include <tms/cpp.hh>
#include <vector>
class pscreen;

View file

@ -1,6 +1,6 @@
#pragma once
#include <tms/bindings/cpp/cpp.hh>
#include <tms/cpp.hh>
#define M_DENSITY 1.f

View file

@ -1,8 +1,8 @@
#pragma once
#include <tms/bindings/cpp/cpp.hh>
#include "menu-base.hh"
#include "pkgman.hh"
#include <tms/cpp.hh>
class menu_pkg : public menu_base
{

View file

@ -1,7 +1,7 @@
#pragma once
#include <tms/bindings/cpp/cpp.hh>
#include "main.hh"
#include <tms/cpp.hh>
class p_text;

View file

@ -6,7 +6,7 @@
#include <cstdint>
#ifndef _NO_TMS
#include <tms/math/vector.h>
#include <tms/cpp.hh>
#endif
#if defined(TMS_BACKEND_ANDROID)

View file

@ -1,6 +1,6 @@
#pragma once
#include <tms/bindings/cpp/cpp.hh>
#include <tms/cpp.hh>
enum {
MODEL_PLANK1,

View file

@ -7,10 +7,9 @@
#include "object_factory.hh"
#include "progress.hh"
#include "text.hh"
#include "tms/backend/print.h"
#include "tms/core/err.h"
#include "ui.hh"
#include "version.hh"
#include <tms/cpp.hh>
/* Publish level variables */
uint32_t _publish_lvl_community_id;

View file

@ -1,11 +1,10 @@
#include "pkgman.hh"
#include "misc.hh"
#include "progress.hh"
#include <dirent.h>
#include <sys/stat.h>
#include <time.h>
#include <dirent.h>
#include "progress.hh"
#include "zlib.h"
#include "misc.hh"
#include <zlib.h>
#ifdef TMS_BACKEND_WINDOWS
#include <windows.h>
@ -25,7 +24,7 @@
static const char *tms_storage_path() { return "/tmp/"; }
static const char *tms_storage_cache_path() { return "/tmp/"; }
#else
#include <tms/bindings/cpp/cpp.hh>
#include <tms/cpp.hh>
#endif
static char _level_path[4][1024];

View file

@ -9,7 +9,7 @@
#define tms_infof(...)
#define tms_errorf(...)
#else
#include <tms/bindings/cpp/cpp.hh>
#include <tms/cpp.hh>
#endif
#define WARNING_STR "Warning: if you edit this file manually, you risk losing all your game data."

View file

@ -1,9 +1,9 @@
#pragma once
#include "font.hh"
#include <tms/bindings/cpp/cpp.hh>
#include <deque>
#include "game-graph.hh"
#include <deque>
#include <tms/cpp.hh>
class p_text;
class p_font;

View file

@ -1,7 +1,5 @@
#include <tms/core/tms.h>
#include "settings.hh"
#include <cmath>
#include "game.hh"
#include <tms/cpp.hh>
#ifdef BUILD_VALGRIND
#include <valgrind/valgrind.h>

View file

@ -1,9 +1,9 @@
#pragma once
#include <map>
#include <cstring>
#include <inttypes.h>
#include <tms/backend/print.h>
#include <map>
#include <tms/cpp.hh>
enum {
S_INT8,

View file

@ -1,7 +1,7 @@
#include "solver.hh"
#include "entity.hh"
#include "gear.hh"
#include <tms/bindings/cpp/cpp.hh>
#include <tms/cpp.hh>
#define NUM_HANDLERS 13

View file

@ -1,31 +1,29 @@
#include "solver_ingame.hh"
#include "entity.hh"
#include "plant.hh"
#include "robot_parts.hh"
#include "robot_base.hh"
#include "robot.hh"
#include "ball.hh"
#include "pipeline.hh"
#include "gear.hh"
#include "conveyor.hh"
#include "impact_sensor.hh"
#include "ragdoll.hh"
#include "game.hh"
#include "explosive.hh"
#include "pixel.hh"
#include "fxemitter.hh"
#include "button.hh"
#include "adventure.hh"
#include "robot_parts.hh"
#include "item.hh"
#include "ball.hh"
#include "button.hh"
#include "conveyor.hh"
#include "entity.hh"
#include "explosive.hh"
#include "factory.hh"
#include "fxemitter.hh"
#include "game.hh"
#include "gear.hh"
#include "impact_sensor.hh"
#include "item.hh"
#include "minibot.hh"
#include "pipeline.hh"
#include "pixel.hh"
#include "plant.hh"
#include "ragdoll.hh"
#include "resource.hh"
#include "robot.hh"
#include "robot_base.hh"
#include "robot_parts.hh"
#include "soundmanager.hh"
#include "ud2.hh"
#include "spikebot.hh"
#include <tms/bindings/cpp/cpp.hh>
#include "ud2.hh"
#include <tms/cpp.hh>
static void begincontact_creature(b2Contact *contact, entity *a, entity *b, int rev);
static void begincontact_plant(b2Contact *contact, entity *a, entity *b, int rev);

View file

@ -1,8 +1,8 @@
#include "soundmanager.hh"
#include "settings.hh"
#include "const.hh"
#include <tms/math/misc.h>
#include "settings.hh"
#include <Box2D/Box2D.h>
#include <tms/cpp.hh>
sm_sound*
sm::get_sound_by_id(uint32_t sound_id)

View file

@ -5,7 +5,7 @@
#endif
#include "const.hh"
#include <tms/core/tms.h>
#include <tms/cpp.hh>
#ifdef ENABLE_SOUND
#include "SDL_mixer.h"

View file

@ -1,7 +1,7 @@
#pragma once
#include "font.hh"
#include <tms/math/glob.h>
#include <tms/cpp.hh>
namespace tms
{

View file

@ -1,7 +1,7 @@
#pragma once
#include "text.hh"
#include "tms/bindings/cpp/cpp.hh"
#include <tms/cpp.hh>
#define TEXTBUFFER_MAX 512

View file

@ -1,9 +1,8 @@
#include "tiles.hh"
#include "object_factory.hh"
#include <stdio.h>
#include <tms/backend/print.h>
#include <string.h>
#include <tms/cpp.hh>
struct tile_load_data tile_factory::tiles[NUM_TILES] = {
{ "data/tiles/nomad_hideout_0.txt" },

View file

@ -1,9 +1,8 @@
#pragma once
#include <cstring>
#include <inttypes.h>
#include <deque>
#include <tms/math/vector.h>
#include <inttypes.h>
#include <tms/cpp.hh>
enum {
TILE_NOMAD_HIDEOUT_FULL,

View file

@ -1,7 +1,15 @@
TMS Game Engine
===============
# TMS Game Engine
Game engine for Principia, written in C.
Basically, it uses a concept of setting up different rendering pipelines and then rendering graphs of models in these. It supports everything in terms of graphics that was required for all versions of Principia.
## C++ bindings
While TMS itself is written in C, it contains C++ bindings which allow you to interface with the engine's structures in an object-oriented manner.
When including TMS from C++ code in Principia, you would want to just include this header, which will also include everything else within an `extern "C"` block:
```c++
#include <tms/cpp.hh>
```
Typically this is always just what you need.

View file

@ -1,23 +1,19 @@
#include "main.hh"
#include "pipe.hh"
#include "settings.hh"
#include "version.hh"
#include <SDL.h>
#include <glad/gl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <tms/cpp.hh>
#include <unistd.h>
#include <tms/core/project.h>
#include <tms/core/event.h>
#include <tms/core/tms.h>
#include <glad/gl.h>
#include "settings.hh"
#include "main.hh"
#include "version.hh"
#ifdef TMS_BACKEND_WINDOWS
#include <windows.h>
#include <windowsx.h>
@ -31,8 +27,6 @@
#include <emscripten.h>
#endif
#include "pipe.hh"
FILE *_f_out = stdout;
SDL_Window *_window;

View file

@ -1,30 +1,22 @@
// Linux screenshot build backend
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <pwd.h>
#include <libgen.h>
#include <tms/core/project.h>
#include <tms/core/event.h>
#include <tms/core/tms.h>
#include <glad/gl.h>
#include "settings.hh"
#include "game.hh"
#include "main.hh"
#include "pkgman.hh"
#include "screenshot_marker.hh"
#include "settings.hh"
#include <errno.h>
#include <fcntl.h>
#include <glad/gl.h>
#include <libgen.h>
#include <png.h>
#include "tms/bindings/cpp/cpp.hh"
#include <pwd.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <tms/cpp.hh>
#include <unistd.h>
#define STEP_QUIT -1

View file

@ -1,18 +1,8 @@
#include <math.h>
#include <stdlib.h>
#include <tms/core/tms.h>
#include <tms/core/ddraw.h>
#include <tms/core/shader.h>
#include <tms/core/program.h>
#include <tms/core/pipeline.h>
#include <tms/core/gbuffer.h>
#include <tms/core/varray.h>
#include <tms/core/mesh.h>
#include <tms/core/atlas.h>
#include <tms/core/texture.h>
#include <tms/core/backend.h>
#include <tms/math/matrix.h>
#include <tms/core/glob.h>
#include <tms/math/glob.h>
static int initialized = 0;
static struct tms_shader *shader = 0;

View file

@ -20,6 +20,7 @@
#include "screen.h"
#include "settings.h"
#include "shader.h"
#include "storage.h"
#include "surface.h"
#include "texture.h"
#include "tms.h"

View file

@ -24,60 +24,47 @@ tms_screen_spec tms::_oopassthrough = {
0
};
void
_oopassthrough_entity_update(struct tms_entity *e)
{
void _oopassthrough_entity_update(struct tms_entity *e) {
tms::entity *ent = static_cast<tms::entity *>(e);
ent->update();
}
static int _oopassthrough_pause(struct tms_screen *s)
{
static int _oopassthrough_pause(struct tms_screen *s) {
tms::screen *ss = reinterpret_cast<tms::screen*>(s->data);
return ss->pause();
}
static int _oopassthrough_resume(struct tms_screen *s)
{
static int _oopassthrough_resume(struct tms_screen *s) {
tms::screen *ss = reinterpret_cast<tms::screen*>(s->data);
return ss->resume();
}
static int _oopassthrough_handle_input(struct tms_screen *s, struct tms_event *ev, int action)
{
static int _oopassthrough_handle_input(struct tms_screen *s, struct tms_event *ev, int action) {
tms::screen *ss = reinterpret_cast<tms::screen*>(s->data);
return ss->handle_input(ev, action);
}
static int _oopassthrough_render(struct tms_screen *s)
{
static int _oopassthrough_render(struct tms_screen *s) {
tms::screen *ss = reinterpret_cast<tms::screen*>(s->data);
return ss->render();
}
static int _oopassthrough_post_render(struct tms_screen *s)
{
static int _oopassthrough_post_render(struct tms_screen *s) {
tms::screen *ss = reinterpret_cast<tms::screen*>(s->data);
return ss->post_render();
}
static int _oopassthrough_begin_frame(struct tms_screen *s)
{
static int _oopassthrough_begin_frame(struct tms_screen *s) {
tms::screen *ss = reinterpret_cast<tms::screen*>(s->data);
return ss->begin_frame();
}
static int _oopassthrough_end_frame(struct tms_screen *s)
{
static int _oopassthrough_end_frame(struct tms_screen *s) {
tms::screen *ss = reinterpret_cast<tms::screen*>(s->data);
return ss->end_frame();
}
static int _oopassthrough_step(struct tms_screen *s, double dt)
{
static int _oopassthrough_step(struct tms_screen *s, double dt) {
tms::screen *ss = (tms::screen *)s->data;
return ss->step(dt);
}

View file

@ -1,7 +1,3 @@
/**
* C++ Bindings for TMS
**/
#pragma once
extern "C" {
@ -9,19 +5,15 @@ extern "C" {
#include <tms/math/glob.h>
}
namespace tms
{
/// C++ Bindings for TMS
namespace tms {
extern "C" {
extern tms_screen_spec _oopassthrough;
void _oopassthrough_entity_update(struct tms_entity *e);
}
namespace math
{
class vec2 : public tvec2
{
namespace math {
class vec2 : public tvec2 {
float operator * (vec2 b) {
return this->x * b.x + this->y * b.y;
}
@ -48,8 +40,7 @@ namespace tms
}
};
class vec3 : public tvec3
{
class vec3 : public tvec3 {
vec3 operator * (float b) {
vec3 t;
t.x = this->x * b;
@ -82,234 +73,189 @@ namespace tms
class screen;
class entity;
class texture : public tms_texture
{
class texture : public tms_texture {
public:
texture()
{
tms_texture_init(this);
}
texture() {
tms_texture_init(this);
}
~texture()
{
this->free_buffer();
~texture() {
this->free_buffer();
if (this->is_uploaded) {
glDeleteTextures(1, &this->gl_texture);
}
}
if (this->is_uploaded) {
glDeleteTextures(1, &this->gl_texture);
}
}
inline int load(const char *filename)
{
return tms_texture_load(this, filename);
}
inline int load(const char *filename) {
return tms_texture_load(this, filename);
}
inline int load_mem2(const char *buf, size_t size, int freesrc)
{
return tms_texture_load_mem2(this, buf, size, freesrc);
}
inline int load_mem2(const char *buf, size_t size, int freesrc) {
return tms_texture_load_mem2(this, buf, size, freesrc);
}
inline int upload()
{
return tms_texture_upload(this);
}
inline int upload() {
return tms_texture_upload(this);
}
inline int bind()
{
return tms_texture_bind(this);
}
inline int bind() {
return tms_texture_bind(this);
}
inline int free_buffer()
{
return tms_texture_free_buffer(this);
}
inline int free_buffer() {
return tms_texture_free_buffer(this);
}
inline int flip_x()
{
return tms_texture_flip_x(this);
}
inline int flip_x() {
return tms_texture_flip_x(this);
}
inline int flip_y()
{
return tms_texture_flip_y(this);
}
inline int flip_y() {
return tms_texture_flip_y(this);
}
inline int add_alpha(float a)
{
return tms_texture_add_alpha(this, a);
}
inline int add_alpha(float a) {
return tms_texture_add_alpha(this, a);
}
inline void render()
{
tms_texture_render(this);
}
inline void render() {
tms_texture_render(this);
}
inline unsigned char *alloc_buffer(int width, int height, int num_channels)
{
return tms_texture_alloc_buffer(this, width, height, num_channels);
}
inline unsigned char *alloc_buffer(int width, int height, int num_channels) {
return tms_texture_alloc_buffer(this, width, height, num_channels);
}
inline int clear_buffer(unsigned char clear_value)
{
return tms_texture_clear_buffer(this, clear_value);
}
inline int clear_buffer(unsigned char clear_value) {
return tms_texture_clear_buffer(this, clear_value);
}
inline int get_width()
{
return tms_texture_get_width(this);
}
inline int get_width() {
return tms_texture_get_width(this);
}
inline int get_height()
{
return tms_texture_get_height(this);
}
inline int get_height() {
return tms_texture_get_height(this);
}
inline int get_num_channels()
{
return tms_texture_get_num_channels(this);
}
inline int get_num_channels() {
return tms_texture_get_num_channels(this);
}
inline unsigned char *get_buffer()
{
return tms_texture_get_buffer(this);
}
inline unsigned char *get_buffer() {
return tms_texture_get_buffer(this);
}
};
class ddraw : public tms_ddraw
{
class ddraw : public tms_ddraw {
public:
ddraw()
{
ddraw() {
tms_ddraw_init(this);
}
inline int square_textured(float x, float y, float width, float height, tms::texture *tex)
{
inline int square_textured(float x, float y, float width, float height, tms::texture *tex) {
return tms_ddraw_square_textured(this, x, y, width, height, tex);
}
inline int square(float x, float y, float width, float height)
{
inline int square(float x, float y, float width, float height) {
return tms_ddraw_square(this, x, y, width, height);
}
inline int circle(float x, float y, float width, float height)
{
inline int circle(float x, float y, float width, float height) {
return tms_ddraw_circle(this, x, y, width, height);
}
inline int line(float x1, float y1, float x2, float y2)
{
inline int line(float x1, float y1, float x2, float y2) {
return tms_ddraw_line(this, x1, y1, x2, y2);
}
inline int line3d(float x1, float y1, float z1, float x2, float y2, float z2)
{
inline int line3d(float x1, float y1, float z1, float x2, float y2, float z2) {
return tms_ddraw_line3d(this, x1, y1, z1, x2, y2, z2);
}
inline void set_matrices(float *mv, float *p)
{
inline void set_matrices(float *mv, float *p) {
tms_ddraw_set_matrices(this, mv, p);
}
inline void set_color(float r, float g, float b, float a)
{
inline void set_color(float r, float g, float b, float a) {
tms_ddraw_set_color(this, r, g, b, a);
}
};
class camera : public tms_camera
{
class camera : public tms_camera {
public:
camera()
{
camera() {
tms_camera_init(this);
}
inline float *get_combined_matrix()
{
inline float *get_combined_matrix() {
return this->combined;
}
inline float *get_projection_matrix()
{
inline float *get_projection_matrix() {
return this->projection;
}
inline float *get_view_matrix()
{
inline float *get_view_matrix() {
return this->view;
}
inline void set_position(float x, float y, float z)
{
inline void set_position(float x, float y, float z) {
tms_camera_set_position(this, x,y,z);
}
inline void translate(float x, float y, float z)
{
inline void translate(float x, float y, float z) {
tms_camera_translate(this, x,y,z);
}
inline void confine(float x, float y, float z, float factor_x, float factor_y, float factor_z)
{
inline void confine(float x, float y, float z, float factor_x, float factor_y, float factor_z) {
tms_camera_confine(this, x,y,z, factor_x, factor_y, factor_z);
}
inline void set_lookat(float x, float y, float z)
{
inline void set_lookat(float x, float y, float z) {
tms_camera_set_lookat(this, x, y, z);
}
inline void enable(int flag)
{
inline void enable(int flag) {
tms_camera_enable(this, flag);
}
inline void disable(int flag)
{
inline void disable(int flag) {
tms_camera_disable(this, flag);
}
inline void set_direction(float x, float y, float z)
{
inline void set_direction(float x, float y, float z) {
tms_camera_set_direction(this, x, y, z);
}
inline void calculate()
{
inline void calculate() {
tms_camera_calculate(this);
}
};
class fb : public tms_fb
{
class fb : public tms_fb {
public:
fb(unsigned width, unsigned height, int double_buf)
{
this->width = width;
this->height = width;
this->double_buffering = double_buf;
tms_fb_init(this);
}
fb(unsigned width, unsigned height, int double_buf) {
this->width = width;
this->height = width;
this->double_buffering = double_buf;
tms_fb_init(this);
}
inline int bind()
{
return tms_fb_bind(this);
}
inline int bind() {
return tms_fb_bind(this);
}
inline int unbind()
{
return tms_fb_unbind(this);
}
inline int unbind() {
return tms_fb_unbind(this);
}
};
class material : public tms_material
{
public:
material()
{
material() {
tms_material_init(this);
}
};
@ -317,21 +263,18 @@ namespace tms
class surface : public tms_surface
{
public:
surface()
{
surface() {
tms_surface_init(this);
}
inline int remove_widget(tms_wdg *w)
{
inline int remove_widget(tms_wdg *w) {
return tms_surface_remove_widget(
static_cast<tms_surface *>(this),
w
);
}
inline int add_widget(tms_wdg *w)
{
inline int add_widget(tms_wdg *w) {
return tms_surface_add_widget(
static_cast<tms_surface *>(this),
w
@ -342,29 +285,24 @@ namespace tms
class gbuffer : public tms_gbuffer
{
public:
gbuffer(size_t size)
{
gbuffer(size_t size) {
tms_gbuffer_init(static_cast<tms_gbuffer*>(this), size);
};
}
gbuffer(void *data, size_t size)
{
gbuffer(void *data, size_t size) {
tms_gbuffer_init(static_cast<tms_gbuffer*>(this), size);
memcpy(this->buf, data, size);
};
}
inline void *get_buffer()
{
inline void *get_buffer() {
return tms_gbuffer_get_buffer(static_cast<tms_gbuffer *>(this));
}
inline int upload()
{
inline int upload() {
return tms_gbuffer_upload(static_cast<tms_gbuffer *>(this));
}
inline int upload_partial(size_t size)
{
inline int upload_partial(size_t size) {
return tms_gbuffer_upload_partial(static_cast<tms_gbuffer *>(this), size);
}
};
@ -377,243 +315,187 @@ namespace tms
tms_varray_init(static_cast<tms_varray*>(this), num_attributes);
}
inline gbuffer* get_gbuffer(int index)
{
inline gbuffer* get_gbuffer(int index) {
return static_cast<gbuffer*>(static_cast<tms_varray*>(this)->gbufs[0].gbuf);
}
inline int set_buffer_stride(gbuffer *gbuf, size_t offset)
{
inline int set_buffer_stride(gbuffer *gbuf, size_t offset) {
return tms_varray_set_buffer_stride(static_cast<tms_varray*>(this), gbuf, offset);
}
inline int map_attribute(const char *name, int num_components,
GLenum component_type, gbuffer *gbuf)
{
inline int map_attribute(const char *name, int num_components, GLenum component_type, gbuffer *gbuf) {
return tms_varray_map_attribute(static_cast<tms_varray*>(this), name, num_components, component_type, static_cast<tms_gbuffer*>(gbuf));
}
inline int bind_attributes(int *locations)
{
inline int bind_attributes(int *locations) {
return tms_varray_bind_attributes(static_cast<tms_varray*>(this), locations);
}
inline int unbind_attributes(int *locations)
{
inline int unbind_attributes(int *locations) {
return tms_varray_unbind_attributes(static_cast<tms_varray*>(this), locations);
}
inline void upload_all()
{
inline void upload_all() {
tms_varray_upload_all(static_cast<tms_varray*>(this));
}
};
class program : public tms_program
{
class program : public tms_program {};
class shader : public tms_shader {
public:
shader() {
tms_shader_init(static_cast<struct tms_shader *>(this));
}
shader(const char *_name) {
tms_shader_init(static_cast<struct tms_shader *>(this));
this->name = const_cast<char*>(_name);
}
~shader() {
tms_shader_uninit(static_cast<struct tms_shader *>(this));
}
inline int compile(GLenum type, const char *src) {
return tms_shader_compile(this, type, src);
}
inline tms::program *get_program(int pipeline) {
return reinterpret_cast<tms::program*>(tms_shader_get_program(static_cast<tms_shader*>(this), pipeline));
}
};
class shader : public tms_shader
{
class mesh : public tms_mesh {
public:
shader()
{
tms_shader_init(static_cast<struct tms_shader *>(this));
}
shader(const char *_name)
{
tms_shader_init(static_cast<struct tms_shader *>(this));
this->name = const_cast<char*>(_name);
}
~shader()
{
tms_shader_uninit(static_cast<struct tms_shader *>(this));
}
inline int compile(GLenum type, const char *src)
{
return tms_shader_compile(this, type, src);
}
inline tms::program *get_program(int pipeline)
{
return reinterpret_cast<tms::program*>(tms_shader_get_program(static_cast<tms_shader*>(this), pipeline));
}
};
class mesh : public tms_mesh
{
public:
mesh(varray *va, gbuffer *indices)
{
mesh(varray *va, gbuffer *indices) {
tms_mesh_init(static_cast<struct tms_mesh *>(this), va, indices);
}
inline int render(program *shader)
{
inline int render(program *shader) {
return tms_mesh_render(static_cast<tms_mesh*>(this), static_cast<tms_program*>(shader));
}
inline gbuffer * get_index_buffer()
{
inline gbuffer * get_index_buffer() {
return reinterpret_cast<tms::gbuffer*>(static_cast<tms_mesh*>(this)->indices);
}
inline varray * get_vertex_array()
{
inline varray * get_vertex_array() {
return reinterpret_cast<varray*>(static_cast<tms_mesh*>(this)->vertex_array);
}
inline void set_primitive_type(int type)
{
inline void set_primitive_type(int type) {
tms_mesh_set_primitive_type(static_cast<tms_mesh*>(this), type);
}
inline void set_autofree_buffers(int f)
{
inline void set_autofree_buffers(int f) {
tms_mesh_set_autofree_buffers(static_cast<tms_mesh*>(this), f);
}
};
class meshfactory
{
class meshfactory {
public:
static inline const tms::mesh *get_cube()
{
return reinterpret_cast<const mesh*>(tms_meshfactory_get_cube());
}
static inline const tms::mesh *get_cube() {
return reinterpret_cast<const mesh*>(tms_meshfactory_get_cube());
}
static inline const tms::mesh *get_cylinder()
{
return reinterpret_cast<const mesh*>(tms_meshfactory_get_cylinder());
}
static inline const tms::mesh *get_cylinder() {
return reinterpret_cast<const mesh*>(tms_meshfactory_get_cylinder());
}
};
class entity : public tms_entity
{
class entity : public tms_entity {
public:
entity()
{
entity() {
tms_entity_init(static_cast<tms_entity*>(this));
static_cast<tms_entity*>(this)->update = _oopassthrough_entity_update;
}
virtual ~entity()
{
virtual ~entity() {
tms_entity_uninit(static_cast<tms_entity*>(this));
}
inline int set_mesh(tms::mesh *m)
{
inline int set_mesh(tms::mesh *m) {
return tms_entity_set_mesh(static_cast<tms_entity*>(this), static_cast<tms_mesh*>(m));
}
inline int set_mesh(tms_mesh *m)
{
inline int set_mesh(tms_mesh *m) {
return tms_entity_set_mesh(static_cast<tms_entity*>(this), m);
}
inline int set_material(tms::material *m)
{
inline int set_material(tms::material *m) {
return tms_entity_set_material(static_cast<tms_entity*>(this), m);
}
inline int add_child(entity *e)
{
inline int add_child(entity *e) {
return tms_entity_add_child(static_cast<tms_entity*>(this), static_cast<tms_entity*>(e));
}
inline int remove_child(entity *e)
{
inline int remove_child(entity *e) {
return tms_entity_remove_child(static_cast<tms_entity*>(this), static_cast<tms_entity*>(e));
}
inline int set_uniform(const char *name, float r, float g, float b, float a)
{
inline int set_uniform(const char *name, float r, float g, float b, float a) {
return tms_entity_set_uniform4f(static_cast<tms_entity*>(this), name, r, g, b, a);
}
inline int set_uniform(const char *name, float r, float g)
{
inline int set_uniform(const char *name, float r, float g) {
return tms_entity_set_uniform2f(static_cast<tms_entity*>(this), name, r, g);
}
inline entity *get_child(int index)
{
inline entity *get_child(int index) {
return static_cast<entity*>(static_cast<tms_entity*>(this)->children[index]);
}
inline int get_num_children()
{
inline int get_num_children() {
return static_cast<tms_entity*>(this)->num_children;
}
virtual void update()
{
}
virtual void update() {}
};
class graph : public tms_graph
{
class graph : public tms_graph {
public:
graph(int pipeline)
{
graph(int pipeline) {
memset(this, 0, sizeof(*this));
tms_graph_init(static_cast<tms_graph*>(this), 0, pipeline);
}
inline int render(tms::camera *cam, void *data)
{
return tms_graph_render(static_cast<tms_graph*>(this),
static_cast<tms_camera *>(cam),
data
);
inline int render(tms::camera *cam, void *data) {
return tms_graph_render(static_cast<tms_graph*>(this), static_cast<tms_camera *>(cam), data);
}
inline int render(tms_camera *cam, void *data)
{
return tms_graph_render(static_cast<tms_graph*>(this),
cam,
data
);
inline int render(tms_camera *cam, void *data) {
return tms_graph_render(static_cast<tms_graph*>(this), cam, data);
}
};
class scene : public tms_scene
{
class scene : public tms_scene {
public:
scene()
{
scene() {
tms_scene_init(this);
}
inline tms::graph* create_graph(int pipeline)
{
inline tms::graph* create_graph(int pipeline) {
return reinterpret_cast<tms::graph*>(tms_scene_create_graph(static_cast<tms_scene*>(this), pipeline));
}
inline int add_entity(entity *e)
{
inline int add_entity(entity *e) {
return tms_scene_add_entity(static_cast<tms_scene*>(this), static_cast<tms_entity*>(e));
}
inline int remove_entity(entity *e)
{
inline int remove_entity(entity *e) {
return tms_scene_remove_entity(static_cast<tms_scene*>(this), static_cast<tms_entity*>(e));
}
};
class screen
{
class screen {
public:
struct tms_screen super;
screen()
{
screen() {
super.data = reinterpret_cast<void*>(this);
super.spec = &_oopassthrough;
@ -621,50 +503,43 @@ namespace tms
super.scene = 0;
}
virtual int handle_input(event *ev, int action){return 0;};
virtual int pause(){return 0;};
virtual int resume(){return 0;};
virtual int render(){return 0;};
virtual int post_render(){return 0;};
virtual int begin_frame(){return 0;};
virtual int end_frame(){return 0;};
virtual int step(double dt){return 0;};
virtual int handle_input(event *ev, int action) { return 0; }
virtual int pause() { return 0; }
virtual int resume() { return 0; }
virtual int render() { return 0; }
virtual int post_render() { return 0; }
virtual int begin_frame() { return 0; }
virtual int end_frame() { return 0; }
virtual int step(double dt) { return 0; }
inline int set_surface(surface *surf)
{
inline int set_surface(surface *surf) {
return tms_screen_set_surface(&super, surf);
}
inline int set_scene(scene *s)
{
inline int set_scene(scene *s) {
return tms_screen_set_scene(&super, s);
}
inline scene *get_scene()
{
inline scene *get_scene() {
return reinterpret_cast<scene*>(tms_screen_get_scene(&super));
}
inline surface *get_surface()
{
inline surface *get_surface() {
return (surface*)tms_screen_get_surface(&super);
}
};
/* functions for the singleton object "tms" */
// functions for the singleton object "tms"
inline int set_screen(screen *s)
{
inline int set_screen(screen *s) {
return tms_set_screen((struct tms_screen *)&s->super);
}
inline int get_window_height()
{
inline int get_window_height() {
return _tms.window_height;
}
inline int get_window_width()
{
inline int get_window_width() {
return _tms.window_width;
}
};

View file

@ -1,7 +1,7 @@
#pragma once
#include "tms/math/vector.h"
#include <stdint.h>
#include <tms/cpp.hh>
class entity;

View file

@ -1,11 +1,9 @@
#include "ui.hh"
#include <SDL.h>
#include "main.hh"
#include "game.hh"
#include "game-message.hh"
#include <tms/core/tms.h>
#include "game.hh"
#include "main.hh"
#include <SDL.h>
#include <tms/cpp.hh>
const char *tips[] = {
#ifdef TMS_BACKEND_PC

View file

@ -1,52 +1,49 @@
#include "ui.hh"
#include <SDL.h>
#include "main.hh"
#include "game.hh"
#include "menu_main.hh"
#include "menu-play.hh"
#include "loading_screen.hh"
#include "game-message.hh"
#include "beam.hh"
#include "wheel.hh"
#include "pixel.hh"
#include "command.hh"
#include "i1o1gate.hh"
#include "pkgman.hh"
#include "object_factory.hh"
#include "box.hh"
#include "settings.hh"
#include "fxemitter.hh"
#include "i0o1gate.hh"
#include "i2o0gate.hh"
#include "display.hh"
#include "prompt.hh"
#include "robot_base.hh"
#include "adventure.hh"
#include "speaker.hh"
#include "timer.hh"
#include "jumper.hh"
#include "item.hh"
#include "escript.hh"
#include "tpixel.hh"
#include "factory.hh"
#include "faction.hh"
#include "anchor.hh"
#include "resource.hh"
#include "animal.hh"
#include "beam.hh"
#include "box.hh"
#include "command.hh"
#include "decorations.hh"
#include "display.hh"
#include "escript.hh"
#include "faction.hh"
#include "factory.hh"
#include "fxemitter.hh"
#include "game-message.hh"
#include "game.hh"
#include "i0o1gate.hh"
#include "i1o1gate.hh"
#include "i2o0gate.hh"
#include "item.hh"
#include "jumper.hh"
#include "key_listener.hh"
#include "loading_screen.hh"
#include "main.hh"
#include "menu-play.hh"
#include "menu_main.hh"
#include "object_factory.hh"
#include "pixel.hh"
#include "pkgman.hh"
#include "polygon.hh"
#include "prompt.hh"
#include "resource.hh"
#include "robot_base.hh"
#include "sequencer.hh"
#include "settings.hh"
#include "sfxemitter.hh"
#include "simplebg.hh"
#include "soundman.hh"
#include "polygon.hh"
#include "treasure_chest.hh"
#include "decorations.hh"
#include "sequencer.hh"
#include "sfxemitter.hh"
#include "key_listener.hh"
#include "soundmanager.hh"
#include <tms/core/tms.h>
#include "speaker.hh"
#include "timer.hh"
#include "tpixel.hh"
#include "treasure_chest.hh"
#include "ui.hh"
#include "wheel.hh"
#include <SDL.h>
#include <sstream>
#include <tms/cpp.hh>
#if defined(TMS_BACKEND_ANDROID)

View file

@ -4,7 +4,6 @@
* more time than absolutely necessary on this backend.
*/
#include "ui.hh"
#include "adventure.hh"
#include "anchor.hh"
#include "animal.hh"
@ -36,17 +35,16 @@
#include "speaker.hh"
#include "timer.hh"
#include "treasure_chest.hh"
#include "ui.hh"
#include "wheel.hh"
#include <SDL.h>
#include <tms/core/tms.h>
#include <sstream>
#include <tms/cpp.hh>
#ifdef BUILD_VALGRIND
#include <valgrind/valgrind.h>
#endif
#include <sstream>
#if defined(TMS_BACKEND_PC) && !defined(PRINCIPIA_BACKEND_IMGUI) && !defined(NO_UI)
#define SAVE_REGULAR 0

View file

@ -1,30 +1,20 @@
#ifdef PRINCIPIA_BACKEND_IMGUI
#include "ui_imgui.hh"
#include "game.hh"
#include "main.hh"
#include "misc.hh"
#include "settings.hh"
#include "ui.hh"
#include "tms/backend/print.h"
#include "ui_imgui_impl_tms.hh"
#include <SDL.h>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <stdexcept>
#include <string>
#include <vector>
#include <SDL.h>
#include <SDL_opengl.h>
#include <SDL_syswm.h>
#include "ui_imgui_impl_tms.hh"
#include <cstdio>
#include <cstdlib>
#include <string>
#include <tms/cpp.hh>
#include <vector>
// Misc helper functions

View file

@ -11,9 +11,7 @@
#include "imgui_stdlib.h"
#include "imgui_impl_opengl3.h"
#include "tms/core/tms.h"
#include "tms/core/event.h"
#include "tms/core/err.h"
#include <tms/cpp.hh>
static int tms_mouse_button_to_imgui(int btn) {
switch (btn) {

View file

@ -1,20 +1,17 @@
#include "widget_manager.hh"
#include "text.hh"
#include "game.hh"
#include "gui.hh"
#include "ui.hh"
#include "misc.hh"
#include "menu_shared.hh"
#include "menu_main.hh"
#include "menu_create.hh"
#include "menu-play.hh"
#include "menu_create.hh"
#include "menu_main.hh"
#include "menu_shared.hh"
#include "misc.hh"
#include "settings.hh"
#include "soundmanager.hh"
#include <tms/core/wdg.h>
#include <tms/bindings/cpp/cpp.hh>
#include "text.hh"
#include "ui.hh"
#include <algorithm>
#include <tms/cpp.hh>
#define TOOLTIP_ACTIVATION_TIME 0.2f

View file

@ -1,12 +1,9 @@
#pragma once
#include "pscreen.hh"
#include "font.hh"
#include <tms/core/wdg.h>
#include <tms/bindings/cpp/cpp.hh>
#include "pscreen.hh"
#include <deque>
#include <tms/cpp.hh>
#define TMS_WDG_LABEL 1000
#define TMS_WDG_KNOB 1001

View file

@ -1,11 +1,10 @@
#include "worker.hh"
#include "entity.hh"
#include "settings.hh"
#include <tms/core/graph.h>
#include <Box2D/Dynamics/b2Island.h>
#include <Box2D/Dynamics/b2ContactManager.h>
#include <Box2D/Dynamics/Contacts/b2Contact.h>
#include <Box2D/Dynamics/b2ContactManager.h>
#include <Box2D/Dynamics/b2Island.h>
#include <tms/cpp.hh>
static int _worker_main(void *in);
static void _w_do_solve(struct worker *w);