Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Window#gl segfaults with shader when deferring drawing #133

Open
Spooner opened this Issue · 2 comments

2 participants

@Spooner
Owner

Minimal test-case

You need to gem install opengl and have LargeStar.png in the appropriate path (or change #media_path method)

https://gist.github.com/3098868

@jlnr
Owner

Does it crash in the same way if you comment out all the shaders? Calling Image#draw in gl blocks is not supported. gl blocks are run when Gosu loops over the rendering queue in Z order, Image#draw inserts a quad right into this queue.

In the absence of zImmediate the only clean way would be to complete your duplication of Image#draw inside the GL block. Not just select the texture, but also call glVertex or any modern equivalent of it.

But who cares about clean. :D Since Gosu does not reset the current shader, you can simply do this for now:

# z must be exactly the same value in these three calls so that they will be executed consecutively
gl(z) { glUseProgram @program; glActiveTexture GL_TEXTURE0 }
@star.draw x, y, z
gl(z) { glUseProgram 0 }
@Spooner
Owner

The middle case (shader and Image#draw in gl(nil)) works fine as does running shaders & draw entierly outside of a gl block. I know they are not guaranteed to work, but they do right now.

I have changed my test case to use your workaround and it works fine! I'll update Ashton - I just needed something that worked, so that is excellent, even if not, perhaps as perfect as it could be.

@jlnr jlnr modified the milestone: 1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.