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

Fix for #29: Failed to compile vertex shader #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

richardwilkes
Copy link

This pulls in the changes @tfriedel6 suggested in the discussion in #29.

Also added GetGlobalAlpha() to the Canvas to allow apps a way to set a new global alpha based on the existing global alpha.

Also added GetGlobalAlpha() to the Canvas to allow apps a way to set a new global alpha based on the existing global alpha.
@tfriedel6
Copy link
Owner

Sorry this is taking a while, but unfortunately the change in the shader is now incompatible with my Android phone. Looks like I'm going to have to make the OpenGL version configurable somehow.

@richardwilkes
Copy link
Author

No worries. On a side-note, I don't seem to be seeing any sort of anti-aliasing in any of the resulting graphics, so curves don't have a smooth appearance, etc. Is this expected or am I not configuring something correctly?

@tfriedel6
Copy link
Owner

That needs to be configured when setting up the OpenGL context. Looking at the code you wrote in the issue, I think you need to add NSOpenGLPFAMultisample, 4 or something like that to the NSOpenGLPixelFormatAttribute array. Then add glEnable(GL_MULTISAMPLE) into prepareOpenGL.

@richardwilkes
Copy link
Author

Thanks, that fixed the lack of anti-aliasing. A few more questions, if you have the time (and if there is a better place to be asking these, please let me know and I'll shift to that):

  • Colors are coming out completely wrong for me. Again, I assume there is some sort of setup in the OpenGL code that I need to do that I've not done. For example, if I do a fill with "#323232", I instead get "#7a7a7a" on the screen.

  • I've noticed that the performance is roughly 15-20x slower than the equivalent written using direct calls to the Quartz API on macOS (the only platform I've tried this on so far). One of the reasons I was looking at your library was to get a good-performing, cross-platform drawing solution. Is it likely this is also a configuration issue or is this expected at this stage in the library's development?

@tfriedel6
Copy link
Owner

Hmm, the color problem sounds strange. I just tried it, but for me the right color comes out. Sounds like maybe there's some color processing going on on the system. Gamma correction? Something with sRGB maybe? I'm afraid I don't really know.

The performance difference certainly sounds bad. I hoped it wouldn't be that bad. Partly it depends on what you are doing though. Are you doing a lot of text? I'm pretty sure that could be a lot faster than it is currently. For shape drawing, using the NewPath2D instead of recreating a path every frame is much faster, so you can try that in case it applies. In general though the Quartz project is very likely to be much more optimized than my library...

@richardwilkes
Copy link
Author

Quartz is Apple's standard drawing library, so I'm sure it is heavily optimized. This particular example has very little text and is more of a sample than anything real -- just strokes and fills of rectangles and lines, for the most part, although a few curves and a few short pieces of text are in the mix as well. Even a factor of 2x would probably work for what I'm doing... but 15-20x is certainly more than the app can afford. Unfortunate, as I was really hoping to use this library to eliminate the need to write custom drawing logic for every platform.

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

Successfully merging this pull request may close these issues.

None yet

2 participants