So I have been working on a Project for quite some time. In the interest of improving performance, I decided to look into GDNative and alike, but found some stumbling stones (things that I do not understand).
I am unsure how it would be possible to use "draw_line" for example.
Now this might be, because I do not know enough about c++ to figure out on my own, but let me give an example:
TestDLL.cpp
#include "TestDLL.h"
using namespace godot;
void TestDLL::_register_methods() {
register_method("_process", &TestDLL::_process);
register_method("_draw", &TestDLL::_draw);
}
void TestDLL::_init() {
}
void TestDLL::_process(float delta)
{
_draw();
}
void TestDLL::_draw()
{
CanvasItem::draw_line(Vector2(200, 100), Vector2(200, 1000), Color(255, 255, 255, 1), 1);
}
TestDLL.h
#pragma once
#include <Godot.hpp>
#include <Node.hpp>
#include <CanvasItem.hpp>
namespace godot {
class TestDLL : public Node
{
private:
GODOT_CLASS(TestDLL, Node)
public:
static void _register_methods();
void _init();
void _process(float delta);
void _draw();
};
}
The code will not compile since it detects an error with "CanvasItem::draw_line" which says: "a nonstatic member reference must be relative to a specific object"
The biggest problem here is that I have no clue where to go from here, or if what I have written would even work, without this error.
Any suggestion are appreciated, though if someone could show me a more generalized guide on how to use c++ in this context that might be even more helpful. Thanks! :)