mupen64plus / mupen64plus-video-glide64mk2

Video plugin for Mupen64Plus 2.0 based on 10th anniversary release code from gonetz
28 stars 37 forks source link

GLES port vs OSD problem #17

Closed krnlyng closed 9 years ago

krnlyng commented 9 years ago

In glide64mk2 there is an issue with the GLES implementation (USE_GLES=1). As soon as i enable OSD and start a rom the screen stays black and the game won't output anything on the screen. This also affects my touch input plugin: https://github.com/krnlyng/mupen64plus-input-sdltouch as soon as i enable on screen button display the game won't render anymore (only the buttons are visible, on top of a black screen). Note that my input plugin works with both gles2n64 and ricevideo so this seems to be a glide64mk2 related issue.

ghost commented 9 years ago

OSD uses non-ES code and breaks GL attribs of video plugins. This is why OSD is disabled when compiling against GLES in https://github.com/mupen64plus/mupen64plus-core/pull/43

krnlyng commented 9 years ago

ah i see thanks for the clarification (can probably be closed...) just one more thing, do you have an idea why it fails in my touch input plugin?

ghost commented 9 years ago

You cannot just modify the GL state and hope that a video plugin is happy about it. For example you load new vertex and fragment shader. A video plugin doesn't reset this necessarily in each frame.

Btw. the ifdef 0 code is wrong. You cannot use glGetIntegerv. Better is

GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);

But this is not enough. Everything you change have to be reverted later. Even things like writing to the depth buffer.

krnlyng commented 9 years ago

yeah i tried to restore the GL state with the code in RenderCallback which is if 0'd, but that does not seem to be enough, so there must be something else i need to restore

https://www.khronos.org/opengles/sdk/docs/man/xhtml/glUseProgram.xml and https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml say that glGet is the correct thing to use, http://wiki.delphigl.com/index.php/glGet#GL_CURRENT_PROGRAM and http://wiki.delphigl.com/index.php/glGetHandleARB say that glGetHandleARB is deprecated?

krnlyng commented 9 years ago

@fayvel sorry that i am bugging you but do you have an idea what could be wrong here? i tried storing and restoring GL_CURRENT_PROGRAM, GL_ARRAY_BUFFER_BINDING, GL_ACTIVE_TEXTURE, GL_FRAMEBUFFER_BINDING, GL_RENDERBUFFER_BINDING, GL_TEXTURE_BINDING_2D and GL_VIEWPORT, GL_DEPTH_TEST, GL_DEPTH_FUNC, GL_DEPTH_CLEAR_VALUE, GL_DEPTH_WRITEMASK (all in conjunction) but still only my buttons are displayed. I thought i only had to store and restore GL_CURRENT_PROGRAM and GL_ARRAY_BUFFER_BINDING since this is the only thing i use in my code but that does not seem to be the case. ...GL/GLES beginner talking...

krnlyng commented 9 years ago

okay i've made some (little) progress. if i choose higher location values for a_position and a_color such that they don't collide with glide64mk2's attrib locations, and if i store&restore both GL_CURRENT_PROGRAM and GL_ARRAY_BUFFER_BINDING the game gets rendered - but my buttons don't get rendered above :( any ideas?

krnlyng commented 9 years ago

nvm i exceeded GL_MAX_VERTEX_ATTRIBS, it works now :)

ghost commented 9 years ago

nice work