fr0nkk / matogl

OpenGL framework for MATLAB
MIT License
11 stars 1 forks source link

displayed in a quarter size #2

Open elgar328 opened 1 year ago

elgar328 commented 1 year ago

Thank you for this amazing work. I had a few problems when I tried to use this framework. glExample1~5 are displayed in a quarter size. And glViewer3D and bunny showed only black background. (GL Error 0x0502)

MacBook Pro (2021) Chip : Apple M1 Pro OS : Ventura 13.1 Matlab R2022b

image image
fr0nkk commented 1 year ago

Thank you for the feedback! I looked around and it seems to be related to the fact that on retina displays, pixels and screen coordinates are not 1:1. (see https://stackoverflow.com/questions/35715579/opengl-created-window-size-twice-as-large)

I will try to reproduce the behaviour on windows (maybe with resolution supersampling) or find a macbook to test and fix this issue.

fr0nkk commented 1 year ago

Hello again @elgar328, If you don't mind, could you try adding obj.java.setSurfaceScale([1 1]); right after line 43 in the file gl/glCanvas.m? Does that fix the display issue?

elgar328 commented 1 year ago

oh! this works! Thank you very much :)

image
elgar328 commented 1 year ago

Let me know if you need another test in mac environment. I will do it :)

fr0nkk commented 1 year ago

Cool!!! Did that also fix glViewer3D? And are the duplicated view in your screenshot normal? It should look like this with the original example: image Thank you very much for the tests!

elgar328 commented 1 year ago

In glExample5 it looks like this at first glance.

image

However, if I rotate the view slightly with the mouse, a repeating shape appears from then on.

image

glViewer3D() still doesn't work.

image
fr0nkk commented 1 year ago

Alright, there seems to be a problem with textures in mac environment (glViewer3D renders on a texture). I will try to find the cause and probably ask you to run some tests eventually! Thanks again :)

fr0nkk commented 1 year ago

There seem to be an issue in mac with using a texture sampler on unit 0 (see https://stackoverflow.com/questions/70338946/gl-texturen1-activated-and-bound-instead-of-gl-texturen-on-apple-silicon-m1-po)

Could you try to change line 13 of gl/+glmu/Texture.m to obj.unit = unit+1;

Does that change anything in the behaviour of the examples?

elgar328 commented 1 year ago

glExample5 works properly!

image

glViewer3D() and bunny does not work.

fr0nkk commented 1 year ago

Ok we're getting closer! It is probably related to the framebuffers, I will continue to look for a solution. And just for my information, does the glMandelbrot example work?

elgar328 commented 1 year ago

glMandelbrot(100,false) works fine :)

image
fr0nkk commented 1 year ago

I created the branch macDebug which implements error checking at almost every gl calls in glViewer3D. Could you switch to it and copy the matlab error stack when running glViewer3D? It will help me knowing which call returns an error. Thanks a lot :)

elgar328 commented 1 year ago

here it is!

image
fr0nkk commented 1 year ago

I removed the call which was causing this one error as it was optional. If you still get an error, paste it again please

fr0nkk commented 1 year ago

Did you pull the updates on macDebug? I think the error should now happen somewhere else than glViewer3D/InitFcn line 158

Also, if you have discord, add me if you want: fr0nk#2095

elgar328 commented 1 year ago

I used the 'dbstop if error' statement together.

image
elgar328 commented 1 year ago

I downloaded a new zip file from github, but it seems that the same error came out because Matlab was referring to the previous version. I sent a friend request on discord. I'm not familiar with how to use discord, but I have discord turned on.