leadedge / ofxNDI

An Openframeworks addon to allow sending and receiving images over a network using the NewTek Network Device Protocol.
GNU General Public License v3.0
134 stars 48 forks source link

Fix macOS compile on latest openframeworks, fixes #46 #48

Closed eduardfrigola closed 8 months ago

eduardfrigola commented 9 months ago

I made conditionals to use the openframeworks file functions for macos and linux, and leave the windows untouched. Can you test this on windows? On macOS compiles fine.

leadedge commented 9 months ago

Thanks for your work here. I will examine each of those things individually.

leadedge commented 9 months ago

ofxNDIdynloader.cpp Line 71. There is indeed a mistake here. m_hNDILib is not defined for OSX in ofxNDIdynloader.h. There has been a "to be checked" comment for some time and you have done so. The other changes support it.

The full path is reconstructed in ReadYUVpixels because with a change to Openframeworks 12, the shader load failed. It requires full paths rather than relative to the data folder. Any change here and the shader load would fail again.

Edit - I will use an Openframeworks function to get the full path instead of GetCurrentModule.

In SetFormat, doesFileExist was used back in 2022 but _access was used given the full path with the change. "ofFile::doesFileExist(shaderpath, false)" is probably better to test for GL2, GL3 etc. I can manage these changes.

eduardfrigola commented 9 months ago

Thanks, I have not been working with ofFile lately so was not aware with those issues. Seeing all this issues for checking files, do you think it will be beneficial to embed the shaders in the source code? Or it is needed that the user can modify those?

leadedge commented 9 months ago

I looked at doing that to remove dependency on the shader files, but as far as I can see, ofShader::load requires a file path. There is a lower level "setupShaderFromSource" but I could not work out how to use it without some complexity.

eduardfrigola commented 9 months ago

I have succesfully implemented that in the past. I can give you a hand with that.

Relevant parts of the implementation: Define string converter link:

#define STRINGIFY(A) #A

Include the shaders and setup from source link:

string defaultVertSource =
#include "defaultVertexShader.h"
;

string drawFragSource =
#include "GradientShader.h"
;

shader.setupShaderFromSource(GL_VERTEX_SHADER, defaultVertSource);
shader.setupShaderFromSource(GL_FRAGMENT_SHADER, drawFragSource);
shader.bindDefaults();
shader.linkProgram();

This are the shaders in separate files: https://github.com/PlaymodesStudio/ofxOceanodeTextures/blob/addon/src/shaders/GradientShader.h https://github.com/PlaymodesStudio/ofxOceanodeTextures/blob/addon/src/shaders/defaultVertexShader.h

defaultVertexShader.h:

R"(
#version 410

uniform mat4 modelViewProjectionMatrix;
layout(location = 0) in vec4  position;

void main(){
    gl_Position = modelViewProjectionMatrix * position;
}
)"
leadedge commented 9 months ago

Thanks very much for that. I will look into it carefully.

leadedge commented 9 months ago

The latest files are now in the repository. I hope it works for OSX.

eduardfrigola commented 8 months ago

Already implemented in https://github.com/leadedge/ofxNDI/commit/73354d2fcba924f8efe94e19d287056096c14360, https://github.com/leadedge/ofxNDI/commit/ea14bfbd8e4359db3451e9fbe7f7ab0631b2d5d1 and https://github.com/leadedge/ofxNDI/commit/046200c7dd1af1fb90eb97a2e21e1f1b4e0aa50d