GithubHelp home page GithubHelp logo

admenri / rguplayer Goto Github PK

View Code? Open in Web Editor NEW
21.0 2.0 6.0 84.37 MB

The Ruby Game Universal (RGU) Project

License: BSD 3-Clause "New" or "Revised" License

CMake 1.23% C++ 66.32% Python 0.33% C 16.86% GLSL 0.68% Java 14.58%
rgss gameengine2d gles2 runtime

rguplayer's Introduction

Logo RGU Player Core

概述

  • RGU是一款兼容RGSS 1/2/3,使用 SDL3 作为底层,OpenGL ES(2.0) 图像标准编写渲染部分的异步多线程2D游戏引擎。
  • RGU在提供兼容原版RGSS的同时提供跨平台与性能提升支持,同时提供诸如自定义着色器与网络扩展在内的加强功能。
  • 本项目使用BSD-3协议开源。
  • 本项目语法风格与代码结构与The Chromium Project相似。
  • 程序灵感来源于 Chromium RGM RGD MKXP

程序结构

  • 程序运行结构为多线程架构,程序内存在多个线程worker,每个worker都有任务投递的接口,引擎将事件处理,逻辑渲染处理,音频播放处理,视频解码处理,网络处理等分解为多个线程。
  • 游戏的图像渲染采用 OpenGL ES(2.0) 标准以获得最大兼容。
  • 用户可以选择使用ANGLE运行其他渲染器后端(D3D9 D3D11 Vulkan Metal 软渲染等)以应对显卡驱动兼容问题。
  • 引擎的事件输入处理基于 SDL 的事件处理。
  • 引擎的音频处理基于 SoLoud 库,音频数据通过Soloud核心处理后输出到SDL的音频设备接口。
  • 引擎的脚本处理部分使用了 Ruby3 的解释器。

软件截图

构建项目

0. 注意事项

  • 本项目使用CMake管理编译。
  • 第三方依赖库部分使用Git拉取,部分需要用户自行编译处理。
  • 项目中需要使用Python3来生成自动编译文件,请确保系统中已安装Python3。

1. 拉取源码

拉取项目源码

拉取第三方库源码

  • cd rguproject
  • git submodule update --init --recursive

2. 针对不同环境开始构建

Windows (测试环境:Windows 11 23H2 & Visual Studio 2019 & Clang-LLVM)

  • 可以直接使用 Visual Studio 内置的 CMake 功能进行快捷构建,编译器建议选择Clang-LLVM

Linux (测试环境:Ubuntu 23.10 & Visual Studio Code & GCC 13)

  • 确保系统安装了OpenGL开发库和CRuby开发库
  • 在目录执行:cmake -S . -B out 以生成工程
  • 之后执行cmake --build out执行构建

Android (测试环境:Android 13.0 & Android Studio & Windows 11 23H2)

  • 确保系统安装了Android Studio,Android NDK,CMake
  • 确保可以在开发环境下编译出成品程序(例如Windows下先编译出exe)
  • 然后使用Android Studio打开 “android-project” 文件夹
  • 之后即可直接执行 Build Project 开始构建

系统支持

  • Microsoft Windows 7 及以上
  • GNU/Linux 6.5.0 及以上
  • Android 8.0 及以上
  • 目前不支持Apple系的任何操作系统(macOS,iOS),欢迎有mac设备的同志贡献代码

第三方库使用

联系方式

© 2015-2024 Admenri

rguplayer's People

Contributors

admenri avatar

Stargazers

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

Watchers

 avatar

rguplayer's Issues

[Feature] Graphics API Extension

Properties

  • Graphics.fullscreen

    • Check if it is in fullscreen with Graphics.fullscreen and toggle it to true or false with Graphics.fullscreen=.
  • Graphics.scale

    • Scaling feature allowing users to adjust the game window/screen size dynamically with Graphics.scale= such as scaling it by 2x or 0.5x.
  • Graphics.vsync

    • Toogle it to true or false with Graphics.vsync=.

Methods

  • Graphics.capture_screen

    • Capture in-game screenshots, enabling sharing of memorable moments or troubleshooting assistance through visual representation.
  • Graphics.delta_time

    • Graphics.delta_time is exceptionally useful for modifying your game to stop synchronizing with the frame rate, ensuring consistent gameplay regardless of variations in frame rate.
  • Graphics.shader

    • Applying global shaders that will affect all Viewports/Sprites such as xBRZ, scalefx, GameBoy Color...

Reference from other functional RGSS implementations

Build Instructions

It's better to add a few, otherwise people won't know how to build it, a workflow to build it is also an option

Angle on Linux

It appears that it is unable to detect the .so related to Angle (tested putting it in ANGLE/amd64, ANGLE/i32 and in the root folder), i was trying to test running Angle with Vulkan on Linux

[Feature] Shaders

RGD has this cool thing where you can apply shaders to Graphic/Sprites/Viewports, it would be really cool to see something like that here

[Feature] Geometry API Extension

After reviewing common extensions to the Bitmap class, it's evident that shapes such as lines, circles, triangles, polygons, isogons, and ellipses are frequently added. As RGU already includes a Geometry class, extending it to handle common geometry shapes beyond just triangles seems beneficial.

  • Line
  • Circle
  • Polygon
  • Isogon
  • Ellipse

Sprite Drawing Benchmark

As it is still in development, it may help you, LiteRGSS2 seems to be the fastest of the bunch for now

Engine Sprites Frames per Second
MKXP-Z 20,000 34
RGM 50,000 33
LiteRGSS2 50,000 47
class SpriteGenerator
  DEFAULT_SPRITE_COUNT = 20_000
  SCREEN_WIDTH = 640
  SCREEN_HEIGHT = 480
  SPRITE_SIZE = 32

  def initialize
    @sprite_count = DEFAULT_SPRITE_COUNT
    @viewport = Viewport.new(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)
    @bitmap = nil
  end

  def run
    initialize_sprites
    loop do
      Graphics.update
    end
  rescue StandardError
    puts "\nEND\n"
  end

  private

  def initialize_sprites
    puts "Sprite Count: #{@sprite_count}"

    @sprites = @sprite_count.times.map do |i|
      initialize_bitmap if (i % 100).zero?
      initialize_sprite
    end
  end

  def initialize_bitmap
    @bitmap = Bitmap.new(320, 320)
    @bitmap.fill_rect(0, 0, 320, 320, random_color)
  end

  def initialize_sprite
    sprite = Sprite.new(@viewport)
    sprite.bitmap = @bitmap
    sprite.x = rand(SCREEN_WIDTH) - SPRITE_SIZE
    sprite.y = rand(SCREEN_HEIGHT) - SPRITE_SIZE
    set_sprite_src_rect(sprite)
    sprite
  end

  def set_sprite_src_rect(sprite)
    j = @sprite_count % 100
    sprite.src_rect.set(32 * (j / 10), 32 * (j % 10), SPRITE_SIZE, SPRITE_SIZE)
  end

  def random_color
    Color.new(rand(256), rand(256), rand(256), 32)
  end
end

SpriteGenerator.new.run

[Bug]项目编译失败,修补后编译的程序运行游戏时闪退

我的编译环境为Arch Linux(已滚至最新)+GCC13/GCC14+Ruby 3.0.6,按照README编译时多次报错,在修补了部分文件后编译出可执行文件rgm,用来测试运行游戏(使用青鬼6.23汉化版)时,程序每次均卡死(使用killall -9结束)或闪退,日志中有[LOG] [Binding] Quit mri binding engine.,推测是Ruby部分出错。
使用GDB调试,在binding/mri/mri_util.h:150binding/mri/mri_main.cc:405处下断点,于150行处获取到每个载入Ruby的脚本,最终在载入102: Main时产生非0state,转至405行,循环中断。
已在x86_64和loongarch64(龙芯的自主架构)复现。
所做的改动:

$ git diff
diff --git a/app/rgu_main.cc b/app/rgu_main.cc
index 8e528b6..13ed552 100644
--- a/app/rgu_main.cc
+++ b/app/rgu_main.cc
@@ -148,10 +148,12 @@ int main(int argc, char* argv[]) {
 
 #if defined(OS_LINUX)
   auto* icon_ops =
-      SDL_RWFromConstMem(rgu_favicon_64_png, rgu_favicon_64_png_len);
+      SDL_IOFromConstMem(rgu_favicon_64_png, rgu_favicon_64_png_len);  // Renamed
+      //SDL_RWFromConstMem(rgu_favicon_64_png, rgu_favicon_64_png_len);
 
   if (icon_ops) {
-    auto* icon = IMG_Load_RW(icon_ops, SDL_TRUE);
+    //auto* icon = IMG_Load_RW(icon_ops, SDL_TRUE);
+    auto* icon = IMG_Load_IO(icon_ops, SDL_TRUE);  // Renamed
 
     if (icon) {
       SDL_SetWindowIcon(win->AsSDLWindow(), icon);
diff --git a/base/CMakeLists.txt b/base/CMakeLists.txt
index 231dc50..ee88637 100644
--- a/base/CMakeLists.txt
+++ b/base/CMakeLists.txt
@@ -66,5 +66,6 @@ endif()
 if (MSVC)
   target_compile_options(core_base PRIVATE /O2 /WX "$<$<CXX_COMPILER_ID:MSVC>:-utf-8>")
 else()
-  target_compile_options(core_base PRIVATE -O2 -Werror)
+	#target_compile_options(core_base PRIVATE -O2 -Werror)
+	#target_compile_options(core_base PRIVATE -O2)  # Removed -Werror
 endif()
diff --git a/base/buildflags/build.h b/base/buildflags/build.h
index 2b331c7..d4189fb 100644
--- a/base/buildflags/build.h
+++ b/base/buildflags/build.h
@@ -197,6 +197,11 @@
 #elif defined(__pnacl__) || defined(__asmjs__) || defined(__wasm__)
 #define ARCH_CPU_32_BITS 1
 #define ARCH_CPU_LITTLE_ENDIAN 1
+#elif defined(__loongarch64)  // Add loongarch
+#define ARCH_CPU_LOONGARCH_FAMILY 1
+#define ARCH_CPU_LOONGARCH64 1
+#define ARCH_CPU_64_BITS 1
+#define ARCH_CPU_LITTLE_ENDIAN 1
 #elif defined(__MIPSEL__)
 #if defined(__LP64__)
 #define ARCH_CPU_MIPS_FAMILY 1
diff --git a/base/math/math.h b/base/math/math.h
index 58a3eed..80db061 100644
--- a/base/math/math.h
+++ b/base/math/math.h
@@ -332,7 +332,7 @@ class Rect {
     width = other.width;
     height = other.height;
     return other;
-  };
+  }  // Remove ';'
 
   bool operator==(const Rect& other) const {
     return other.x == x && other.y == y && other.width == width &&
@@ -453,4 +453,4 @@ class RectF {
 
 }  // namespace base
 
-#endif  // BASE_MATH_H_
\ No newline at end of file
+#endif  // BASE_MATH_H_
diff --git a/base/worker/run_loop.cc b/base/worker/run_loop.cc
index 6ab7469..764fa44 100644
--- a/base/worker/run_loop.cc
+++ b/base/worker/run_loop.cc
@@ -8,6 +8,7 @@
 #include <mutex>
 #include <queue>
 #include <thread>
+#include <condition_variable>  // Fix inclusions
 
 #include "base/third_party/concurrentqueue/blockingconcurrentqueue.h"
 
diff --git a/binding/mri/CMakeLists.txt b/binding/mri/CMakeLists.txt
index 81482fc..155013a 100644
--- a/binding/mri/CMakeLists.txt
+++ b/binding/mri/CMakeLists.txt
@@ -88,11 +88,18 @@ endif()
 
 add_library(binding_mri ${BINDING_MRI_SRC})
 target_link_libraries(binding_mri PUBLIC core_base core_renderer core_content core_ui mri_ruby zlibstatic)
-
+#target_link_libraries(binding_mri PUBLIC core_base core_renderer core_content core_ui mri_ruby zlibstatic -lruby)
+if (MSVC)  // From other modules
+  target_compile_options(binding_mri PRIVATE /O2 /WX "$<$<CXX_COMPILER_ID:MSVC>:-utf-8>")
+else()
+  #target_compile_options(binding_mri PRIVATE -O2 -Wno-incompatible-pointer-types)  // Suppress err
+  target_compile_options(binding_mri PRIVATE -Wno-incompatible-pointer-types)  // Remove -O2 for gdb debugging
+  endif()
 if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
 if(EXISTS ${LIBFFI_DIR})
   target_compile_definitions(binding_mri PRIVATE HAS_LIBFFI_SUPPORT=1)
   target_link_libraries(binding_mri PRIVATE external-libffi)
   target_include_directories(binding_mri PRIVATE fiddle)
 endif()
-endif()
\ No newline at end of file
+endif()
diff --git a/binding/mri/mri_main.cc b/binding/mri/mri_main.cc
index 3ba8575..2ee0a7d 100644
--- a/binding/mri/mri_main.cc
+++ b/binding/mri/mri_main.cc
@@ -39,9 +39,9 @@
 #include "zlib.h"
 
 extern "C" {
-#if RAPI_FULL >= 300
-void rb_call_builtin_inits();
-#endif
+//#if RAPI_FULL >= 300
+//void rb_call_builtin_inits();
+//#endif  // In order to link the executable
 
 void Init_zlib(void);
 void Init_fiddle(void);
@@ -201,9 +201,9 @@ void BindingEngineMri::InitializeBinding(
 
   ruby_init_loadpath();
 
-#if RAPI_FULL >= 300
-  rb_call_builtin_inits();
-#endif
+//#if RAPI_FULL >= 300
+//  rb_call_builtin_inits();
+//#endif  // In order to link the executable
 
   rb_enc_set_default_internal(rb_enc_from_encoding(rb_utf8_encoding()));
   rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding()));
diff --git a/content/CMakeLists.txt b/content/CMakeLists.txt
index 0faa405..26e0b42 100644
--- a/content/CMakeLists.txt
+++ b/content/CMakeLists.txt
@@ -85,5 +85,6 @@ target_link_libraries(core_content PUBLIC
 if (MSVC)
   target_compile_options(core_content PRIVATE /O2 /WX "$<$<CXX_COMPILER_ID:MSVC>:-utf-8>")
 else()
-  target_compile_options(core_content PRIVATE -O2 -Werror)
+	#target_compile_options(core_content PRIVATE -O2 -Werror)
+	#target_compile_options(core_content PRIVATE -O2)  // Remove -Werror
 endif()
diff --git a/renderer/CMakeLists.txt b/renderer/CMakeLists.txt
index 93f3f83..82b13d3 100644
--- a/renderer/CMakeLists.txt
+++ b/renderer/CMakeLists.txt
@@ -72,5 +72,6 @@ target_link_libraries(core_renderer PUBLIC core_base)
 if (MSVC)
   target_compile_options(core_renderer PRIVATE /O2 /WX "$<$<CXX_COMPILER_ID:MSVC>:-utf-8>")
 else()
-  target_compile_options(core_renderer PRIVATE -O2 -Werror)
+	#target_compile_options(core_renderer PRIVATE -O2 -Werror)
+	#target_compile_options(core_renderer PRIVATE -O2)  // Remove -Werror
 endif()
diff --git a/third_party/SDL b/third_party/SDL
--- a/third_party/SDL
+++ b/third_party/SDL
@@ -1 +1 @@
-Subproject commit a8ed32c5f74d282a902f5629a1398235ccec0789
+Subproject commit a8ed32c5f74d282a902f5629a1398235ccec0789-dirty
diff --git a/third_party/SDL_image b/third_party/SDL_image
--- a/third_party/SDL_image
+++ b/third_party/SDL_image
@@ -1 +1 @@
-Subproject commit affd69f7c37cd1b1e81838adf0d4f91c8c15e07b
+Subproject commit affd69f7c37cd1b1e81838adf0d4f91c8c15e07b-dirty
diff --git a/third_party/SDL_ttf b/third_party/SDL_ttf
--- a/third_party/SDL_ttf
+++ b/third_party/SDL_ttf
@@ -1 +1 @@
-Subproject commit 221ca5c837b59d0f2038701fb11e0b2690a6eef1
+Subproject commit 221ca5c837b59d0f2038701fb11e0b2690a6eef1-dirty
diff --git a/third_party/physfs b/third_party/physfs
--- a/third_party/physfs
+++ b/third_party/physfs
@@ -1 +1 @@
-Subproject commit 31209b7c2ce629dbda0db2329ce469ab9a2b90b9
+Subproject commit 31209b7c2ce629dbda0db2329ce469ab9a2b90b9-dirty
diff --git a/third_party/vorbis b/third_party/vorbis
--- a/third_party/vorbis
+++ b/third_party/vorbis
@@ -1 +1 @@
-Subproject commit 84c023699cdf023a32fa4ded32019f194afcdad0
+Subproject commit 84c023699cdf023a32fa4ded32019f194afcdad0-dirty
diff --git a/third_party/zlib b/third_party/zlib
--- a/third_party/zlib
+++ b/third_party/zlib
@@ -1 +1 @@
-Subproject commit 5c42a230b7b468dff011f444161c0145b5efae59
+Subproject commit 5c42a230b7b468dff011f444161c0145b5efae59-dirty

其中:

diff --git a/binding/mri/mri_main.cc b/binding/mri/mri_main.cc
index 3ba8575..2ee0a7d 100644
--- a/binding/mri/mri_main.cc
+++ b/binding/mri/mri_main.cc
@@ -39,9 +39,9 @@
 #include "zlib.h"
 
 extern "C" {
-#if RAPI_FULL >= 300
-void rb_call_builtin_inits();
-#endif
+//#if RAPI_FULL >= 300
+//void rb_call_builtin_inits();
+//#endif  // In order to link the executable
 
 void Init_zlib(void);
 void Init_fiddle(void);
@@ -201,9 +201,9 @@ void BindingEngineMri::InitializeBinding(
 
   ruby_init_loadpath();
 
-#if RAPI_FULL >= 300
-  rb_call_builtin_inits();
-#endif
+//#if RAPI_FULL >= 300
+//  rb_call_builtin_inits();
+//#endif  // In order to link the executable
 
   rb_enc_set_default_internal(rb_enc_from_encoding(rb_utf8_encoding()));
   rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding()));

此处删除了rb_call_builtin_inits,因为此处一直链接失败(报undefined reference),经查证此函数位于ruby/array.c,推测此处是一个失效的hack。此处较大可能导致了闪退。
顺便问一下主程最后一次构建出可用的二进制时使用了什么环境,Ruby版本多少?

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

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

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.