Skip to content

Osc shader #223

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

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Osc shader #223

wants to merge 17 commits into from

Conversation

avilleret
Copy link

this patch add a new OpenGL scene to Raspistill application.
It's called shader and let the user load vertex and fragment shader via command line.
Also, if compiled with liblo, it automatically exposed each uniform via OSC.
Thus any shader parameter can be controlled by another OSC capable application locally on the Pi or remotely.

@Ruffio
Copy link

Ruffio commented Nov 18, 2016

@6by9 does this PR have any chance to be merged (look aside from the conflicts)? If not, it should be closed

Copy link
Contributor

@6by9 6by9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already done. Needs to be dropped. It's not relevant to the PR either.

@6by9
Copy link
Contributor

6by9 commented Nov 18, 2016

I know next to nothing about OpenGL so can't comment on that side. I don't know if @timgover has a few minutes and would be prepared to review the GL side of this.

There are several other bits mixed in to the PR as well (eg liblo, and extra exposure mode) - if this is for a new OpenGL scene then it should ideally be just that bit. Raise separate PRs for the other things.
There's also no need for the development history that lead to the PR - changes should really be squashed into one commit.

I will find 10 mins to go through and review this, but comments like "don't fully understand all the consequences of this.." instill a deep sense of foreboding.

# Conflicts:
#	host_applications/linux/apps/raspicam/CMakeLists.txt
#	host_applications/linux/apps/raspicam/RaspiStill.c
@avilleret
Copy link
Author

Hi,

I just merge master into osc-shader branch to fix merging conflict.
Merging should be safe now.
Liblo is optionnal, if you don't have it, it will not be enabled and build fine.
You will still be able to load vertex and fragment shader, but you can't control it with OSC.

Fell free to ask me some modification before merging.

Copy link
Contributor

@timg236 timg236 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've only scanned the GL code, it looks ok, a few minor comments. It would be useful to have something in a comment that explains how people can use this.

It would be better if the GL scenes were plugins that were dynamically loaded with a slightly better defined GL interface. However, that's my fault for not designing it that way in the first place!

array[i].size = 0;
array[i].type = 0;
array[i].loc = 0;
// uniform_array[i].param = (float*) malloc(sizeof(float)*16);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

array[i].size = 0;
array[i].type = 0;
array[i].loc = 0;
// attribute_array[i].param = (float*) malloc(sizeof(float)*16);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


static const GLfloat vertices[] =
{
#define V0 -0.8, 0.8, 0.8,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for the choice of 0.8 ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't remember, maybe just aesthetic


// allocate memory to contain the whole file:
shader.fragment_source = (GLchar*) malloc (sizeof(GLchar)*lSize);
if (shader.fragment_source == NULL) {fputs ("Memory error",stderr); exit (2);}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these files are huge then it might be better to use mmap instead of malloc. If they are small then it's simpler to assume that malloc will succeed in userspace linux applications

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then I'll assume that malloc succeed

if (result != lSize) {fputs ("Reading error",stderr); exit (3);}

printf("vertex shader file : %s\n", state->vertex_shader_filename);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be cleaner to return an erorr from this function instead of just exiting. RaspiStill might want to do explicit cleanup

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then shader_open() will return -1 on fread error, 0 on success and nothing if malloc fails


pfFile = fopen (state->fragment_shader_filename,"rb");
if (pfFile==NULL) {
printf("No or invalid fragment file provided, used the default one\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nicer to use stderr

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@avilleret
Copy link
Author

Do I need to make more changes to see this PR merged ?

@JamesH65
Copy link
Collaborator

@avilleret @6by9 Another one that has slipped through the cracks - what should we do here?

@JamesH65
Copy link
Collaborator

JamesH65 commented Jul 2, 2018

@avilleret Sorry about the delay, would it be possible to rebase against the latest tree then we can try and get this merged.

@JamesH65
Copy link
Collaborator

@avilleret ping

@avilleret
Copy link
Author

I'll try to rebase this against master in the next few weeks and let you know

@JamesH65
Copy link
Collaborator

Thanks. Quite a few changes in the camera code, so good luck!

avilleret and others added 3 commits December 25, 2018 19:24
# Conflicts:
#	host_applications/linux/apps/raspicam/CMakeLists.txt
#	host_applications/linux/apps/raspicam/RaspiTex.c
#	host_applications/linux/apps/raspicam/RaspiTex.h
@avilleret
Copy link
Author

@JamesH65 could you give it a try ? I don't have a camera to check until January 6th

@Ruffio
Copy link

Ruffio commented May 3, 2020

@avilleret what do you say?

@avilleret
Copy link
Author

@Ruffio, sorry, what is the question ?

@Ruffio
Copy link

Ruffio commented May 4, 2020

@avilleret did you check with camera?
@JamesH65 could you give it a try ?

@JamesH65
Copy link
Collaborator

JamesH65 commented May 4, 2020

Sorry, this has just completely slipped past. I have no idea whether this would work on a Pi4, I suspect not. @timg236

Unfortunately needs to be rebased again.

@timg236
Copy link
Contributor

timg236 commented May 4, 2020

Sorry, this has just completely slipped past. I have no idea whether this would work on a Pi4, I suspect not. @timg236

Unfortunately needs to be rebased again.

The Broadcom specific extensions are never going to work on Pi4, although if someone was sufficiently enthusiastic they could implement equivalent functionality using GLES 3.0 / MESA on Pi4.

@Ruffio
Copy link

Ruffio commented May 12, 2020

If this specific PR is never going to work, and therefor never goint to be accepted, then it should be rejected IMHO.

@timg236
Copy link
Contributor

timg236 commented May 12, 2020

It will work on Pi3 or older so long as the legacy GL driver is selected which I believe is the default

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

Successfully merging this pull request may close these issues.

5 participants