Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin not shown #33

Open
subabrain opened this issue Jul 31, 2021 · 5 comments
Open

plugin not shown #33

subabrain opened this issue Jul 31, 2021 · 5 comments

Comments

@subabrain
Copy link

subabrain commented Jul 31, 2021

Hello,

i now get all clean build for my aircraft - but if i try to include it - its not shown in the admin plugin (but no errors) ...

any suggestions?

CODE:

#include "XPLMDataAccess.h"
#include "XPLMMenus.h"
#include "XPLMProcessing.h"
#include "XPLMPlugin.h"
#include "librain.h"
#include "obj8.h"
#include <cstring>
#include <cstdlib>
#include "XPLMDisplay.h"
#include "XPLMGraphics.h"
#include "XPLMUtilities.h"
#include <string.h>
#include <math.h>

#if IBM
# include <windows.h>
#endif
#if LIN
# include <GL/gl.h>
#elif __GNUC__
# include <OpenGL/gl.h>
#else
# include <GL/gl.h>
#endif

#ifndef XPLM300
# error This is made to be compiled against the XPLM300 SDK
#endif

static const char* windShieldObjPath = "path/to/your/windshield.obj";
static const vect3_t pos_offset = { 0, 0, 0 };

static const char* shaderDir = "librain-shaders";

vect2_t tp = { 0.5, -0.3 };
vect2_t gp = { 0.5, 1.3 };
vect2_t wp = { 1.5, 0.5 };

static librain_glass_t windShield = {
	.slant_factor = 1.0,
	.thrust_point = tp,
	.gravity_point = gp,
	.gravity_factor = 0.5,
	.wind_point = wp,
	.wind_factor = 1.0,
	.wind_normal = 1.0,
	.max_tas = 100.0,
	.therm_inertia = 20.0,
	.cabin_temp = 22.0
};

static librain_glass_t glassElementsArray[1] = { windShield };

static int draw_rain_effects(
	XPLMDrawingPhase inPhase,
	int              inIsBefore,
	void* inRefcon)
{
	librain_draw_prepare(FALSE);
	/* Load these OBJs using obj8_parse as necessary */
	//librain_draw_z_depth(compassObj, NULL);
	//librain_draw_z_depth(fuselageObj, NULL);
	librain_draw_exec();
	librain_draw_finish();
	return 1;
}

PLUGIN_API int XPluginStart(
	char* outName,
	char* outSig,
	char* outDesc)
{
	strcpy(outName, "HelloWorld3RainPlugin");
	strcpy(outSig, "librain.hello.world");
	strcpy(outDesc, "A Hello World plug-in for librain");

	/*
	 * Load our windshield object. You will also want to load
	 * any additional objects used for z-buffer filling.
	 */
	glassElementsArray[0].obj = obj8_parse(windShieldObjPath, pos_offset);
	if (glassElementsArray[0].obj == NULL) {
		XPLMDebugString("Oh noes, failed to load the windshield OBJ!");
		librain_fini();
		return (0);
	}

	/* Once we have loaded all OBJs, initialize the glass structures. */
	if (!librain_init(shaderDir, glassElementsArray, 1)) {
		XPLMDebugString("Oh noes, failed to initialize librain!");
		return (0);
	}
	/*
	 * Turn on debug drawing. This makes all z-buffer drawing
	 * visible to verify it's working right. When you are satisfied
	 * it is working as intended, remove this line.
	 */
	librain_set_debug_draw(TRUE);

	XPLMRegisterDrawCallback(draw_rain_effects, xplm_Phase_LastScene,
		0, NULL);

	return (1);
}

PLUGIN_API void XPluginStop(void)
{
	librain_fini();
	XPLMUnregisterDrawCallback(draw_rain_effects, xplm_Phase_LastScene,
		0, NULL);
}

PLUGIN_API void XPluginDisable(void)
{
}

PLUGIN_API int XPluginEnable(void)
{
	return 1;
}

PLUGIN_API void XPluginReceiveMessage(XPLMPluginID inFrom, int inMsg,
	void* inParam)
{
}

Greets
Robert

@subabrain subabrain changed the title no plugin showed plugin not shown Jul 31, 2021
@subabrain
Copy link
Author

hi,

somebody alive?

Greets
Robert

@Sebizarro
Copy link

I am!

@Sebizarro
Copy link

Just don't know how to add this plugin to X plane 11, Is it a LUA script?

@subabrain
Copy link
Author

its C++

Greets
Robert

@subabrain
Copy link
Author

subabrain commented Mar 11, 2022

Okay - this should work now :)

#define XPLM_DEPRECATED

#include "include/librain.h"
#include "include/obj8.h"
#include "XPLMDisplay.h"
#include "XPLMGraphics.h"
#include "XPLMUtilities.h"
#include <string.h>
#include <math.h>

#if IBM
# include <windows.h>
#endif
#if LIN
# include <GL/gl.h>
#elif __GNUC__
# include <OpenGL/gl.h>
#else
# include <GL/gl.h>
#endif

#ifndef XPLM300
# error This is made to be compiled against the XPLM300 SDK
#endif

const char* windShieldObjPath = "path/to/your/windshield.obj";
vect3_t pos_offset = { 0, 0, 0 };

obj8_t* windShieldObj = obj8_parse(windShieldObjPath, pos_offset);

const char* shaderDir = "librain-shaders";

static const vect2_t tp = { 0.5, -0.3 };
static const vect2_t gp = { 0.5, 1.3 };
static const vect2_t wp = { 1.5, 0.5 };

static librain_glass_t windShield = {
	.group_ids = NULL,     // const char **
	.slant_factor = 1.0,   // double
	.thrust_point = tp,    // vect2_t
	.gravity_point = gp,   // vect2_t
	.gravity_factor = 0.5, // double
	.wind_point = wp,      // vect2_t
	.wind_factor = 1.0,    // double
	.wind_normal = 1.0,    // double
	.max_tas = 100.0,      // double
	.therm_inertia = 20.0, // float
	.cabin_temp = 22.0     // float
};

static librain_glass_t sideWindow = { "" };
static librain_glass_t glassElementsArray[2] = { windShield, sideWindow };

static int draw_rain_effects(
	XPLMDrawingPhase inPhase,
	int              inIsBefore,
	void* inRefcon)
{
	//librain_draw_prepare(FALSE);
	/* Load these OBJs using obj8_parse as necessary */
	//librain_draw_z_depth(compassObj, NULL);
	//librain_draw_z_depth(fuselageObj, NULL);
	librain_draw_exec();
	//librain_draw_finish();
	return 1;
}

PLUGIN_API int XPluginStart(
	char* outName,
	char* outSig,
	char* outDesc)
{

	strcpy(outName, "HelloWorld3RainPlugin");
	strcpy(outSig, "librain.hello.world");
	strcpy(outDesc, "A Hello World plug-in for librain");

	/*
	 * Load our windshield object. You will also want to load
	 * any additional objects used for z-buffer filling.
	 */
	glassElementsArray[0].obj = obj8_parse(windShieldObjPath, pos_offset);
	if (glassElementsArray[0].obj == NULL) {
		XPLMDebugString("Oh noes, failed to load the windshield OBJ!");
		librain_fini();
		return (0);
	}

	/* Once we have loaded all OBJs, initialize the glass structures. */
	if (!librain_init(shaderDir, glassElementsArray, 1)) {
		XPLMDebugString("Oh noes, failed to initialize librain!");
		return (0);
	}
	/*
	 * Turn on debug drawing. This makes all z-buffer drawing
	 * visible to verify it's working right. When you are satisfied
	 * it is working as intended, remove this line.
	 */
	librain_set_debug_draw(TRUE);

	XPLMRegisterDrawCallback(draw_rain_effects, xplm_Phase_LastScene,
		0, NULL);

	return (1);
}

PLUGIN_API void XPluginStop(void)
{
	librain_fini();
	XPLMUnregisterDrawCallback(draw_rain_effects, xplm_Phase_LastScene,
		0, NULL);
}

PLUGIN_API void XPluginDisable(void)
{
}

PLUGIN_API int XPluginEnable(void)
{
	return 1;
}

PLUGIN_API void XPluginReceiveMessage(XPLMPluginID inFrom, int inMsg,
	void* inParam)
{
}

Greets
Robert

PS: Please make sure you have named the plugin with the .cpp extension :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants