updated godot-cpp
This commit is contained in:
13
src/CMakeLists.txt
Normal file
13
src/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
target_sources( ${PROJECT_NAME}
|
||||
PRIVATE
|
||||
register_types.cpp
|
||||
register_types.h
|
||||
|
||||
)
|
||||
|
||||
target_include_directories( ${PROJECT_NAME}
|
||||
PRIVATE
|
||||
"src"
|
||||
)
|
||||
45
src/Version.h.in
Normal file
45
src/Version.h.in
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
// This file is generated by cmake. Changes will be overwritten.
|
||||
// clang-format off
|
||||
|
||||
#include <string_view>
|
||||
|
||||
// Creates a version number for use in macro comparisons.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// // Check if the version is less than 2.1.0
|
||||
// #if ${UPPER_PROJECT_NAME}_VERSION < ${UPPER_PROJECT_NAME}_VERSION_CHECK(2, 1, 0)
|
||||
// // do stuff
|
||||
// #endif
|
||||
//
|
||||
// Returns an integer which may be used in comparisons
|
||||
#define ${UPPER_PROJECT_NAME}_VERSION_CHECK( major, minor, patch ) ( ((major)<<16) | ((minor)<<8) | (patch) )
|
||||
|
||||
#define ${UPPER_PROJECT_NAME}_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}
|
||||
#define ${UPPER_PROJECT_NAME}_VERSION_MINOR ${PROJECT_VERSION_MINOR}
|
||||
#define ${UPPER_PROJECT_NAME}_VERSION_PATCH ${PROJECT_VERSION_PATCH}
|
||||
|
||||
// The version number of this extension. Used for #if comparisons.
|
||||
// This is generated using the version set in the CMake project macro.
|
||||
#define ${UPPER_PROJECT_NAME}_VERSION ${UPPER_PROJECT_NAME}_VERSION_CHECK( ${PROJECT_VERSION_MAJOR}, ${PROJECT_VERSION_MINOR}, ${PROJECT_VERSION_PATCH} )
|
||||
|
||||
namespace VersionInfo {
|
||||
// Project name and version as a string.
|
||||
// This is generated using the project name from the cmake project macro and the current git commit information.
|
||||
//
|
||||
// It uses the form "<project name> <last tag>-<# commits since last tag>-<short commit hash>".
|
||||
// If there are no commits since the last tag, only the tag is shown.
|
||||
constexpr std::string_view VERSION_STR = "${PROJECT_NAME} ${GIT_SHORT}";
|
||||
|
||||
// The version information as a string.
|
||||
// This is generated using the current git commit information.
|
||||
//
|
||||
// It uses the form "<last tag>-<# commits since last tag>-<short commit hash>".
|
||||
// If there are no commits since the last tag, only the tag is shown.
|
||||
constexpr std::string_view VERSION_SHORT_STR = "${GIT_SHORT}";
|
||||
|
||||
// The full git SHA1 hash as a string.
|
||||
// This is generated using the current git commit information.
|
||||
constexpr std::string_view GIT_SHA1_STR = "${GIT_SHA1}";
|
||||
}
|
||||
30
src/register_types.cpp
Normal file
30
src/register_types.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// src/register_types.cpp
|
||||
#include "register_types.h"
|
||||
#include "steam_audio.h" // your SteamAudio class declaration
|
||||
|
||||
using namespace godot;
|
||||
|
||||
void register_steam_audio_types() {
|
||||
ClassDB::register_class<SteamAudio>();
|
||||
}
|
||||
|
||||
extern "C" GDE_EXPORT GDExtensionBool godot_steam_audio_init(
|
||||
GDExtensionInterfaceGetProcAddress p_get_proc_address,
|
||||
GDExtensionClassLibraryPtr p_library,
|
||||
GDExtensionInitialization *p_initialization
|
||||
) {
|
||||
// Create the InitObject that drives registration.
|
||||
GDExtensionBinding::InitObject init_obj{ p_get_proc_address, p_library, p_initialization };
|
||||
|
||||
// 1) Hook up your initializer
|
||||
init_obj.register_initializer( register_steam_audio_types );
|
||||
|
||||
// 2) Hook up your terminator (must match the expected callback signature)
|
||||
init_obj.register_terminator( [](ModuleInitializationLevel level) {} );
|
||||
|
||||
// 3) Choose the minimum init level (common choices: SCENE, EDITOR, etc.)
|
||||
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
|
||||
|
||||
// 4) Actually perform the registrations
|
||||
return init_obj.init();
|
||||
}
|
||||
20
src/register_types.h
Normal file
20
src/register_types.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// Created by bryce on 5/7/2025.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include <godot_cpp/godot.hpp>
|
||||
#include <godot_cpp/core/binder_common.hpp>
|
||||
#include <godot_cpp/core/class_db.hpp> // for ClassDB
|
||||
|
||||
using namespace godot;
|
||||
|
||||
// Called by the InitObject below to register your SteamAudio class.
|
||||
void register_steam_audio_types();
|
||||
|
||||
// This is the exact symbol Godot will look up in your DLL.
|
||||
extern "C" GDE_EXPORT GDExtensionBool godot_steam_audio_init(
|
||||
GDExtensionInterfaceGetProcAddress p_get_proc_address,
|
||||
GDExtensionClassLibraryPtr p_library,
|
||||
GDExtensionInitialization *p_initialization
|
||||
);
|
||||
32
src/steam_audio.cpp
Normal file
32
src/steam_audio.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created by bryce on 5/7/2025.
|
||||
//
|
||||
|
||||
#include "steam_audio.h"
|
||||
|
||||
using namespace godot;
|
||||
|
||||
SteamAudio::~SteamAudio()
|
||||
{
|
||||
if (context)
|
||||
{
|
||||
steam_audio_release_context(context);
|
||||
context=nullptr;
|
||||
}
|
||||
}
|
||||
void SteamAudio::_bind_methods()
|
||||
{
|
||||
ClassDB::bind_method(D_METHOD("initialize"), &SteamAudio::initialize);
|
||||
}
|
||||
bool SteamAudio::initialize()
|
||||
{
|
||||
IPLContextSettings settings{};
|
||||
settings.version = STEAMAUDIO_VERSION;
|
||||
|
||||
if ( IPLerror err = iplContextCreate( &settings, &context ); err != IPL_STATUS_SUCCESS)
|
||||
{
|
||||
UtilityFunctions::printerr("SteamAudio::initialize()", err);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
26
src/steam_audio.h
Normal file
26
src/steam_audio.h
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by bryce on 5/7/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <godot_cpp/godot.hpp>
|
||||
#include<godot_cpp/core/class_db.hpp>
|
||||
#include <godot_cpp/classes/ref.hpp>
|
||||
#include<godot_cpp/variant/utility_functions.hpp>
|
||||
#include<phonon.h>
|
||||
|
||||
using namespace godot;
|
||||
|
||||
class SteamAudio : RefCounted
|
||||
{
|
||||
GDCLASS( SteamAudio,RefCounted );
|
||||
private:
|
||||
IPLContext context = nullptr;
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
public:
|
||||
SteamAudio();
|
||||
~SteamAudio();
|
||||
bool initialize();
|
||||
};
|
||||
Reference in New Issue
Block a user