Closed darmie closed 6 years ago
@darmie thanks for mentioning me by X-Lab
, this spelling brings some nostalgia, I used it ~12 years ago :)
As for your problem, I think you copied EGL/GLES context initialization of GLES 1.0..
See https://github.com/golang-ui/nuklear/blob/master/nk/impl_android_gles2.go#L107 for GLES 2 and https://github.com/golang-ui/nuklear/blob/master/nk/impl_android_gles3.go#L36 for examples on how to init GLES 2/ GLES 3 surfaces.
E.g.
display, err := egl.NewDisplayHandle(win, map[int32]int32{
egl.SurfaceType: egl.WindowBit,
egl.ContextClientVersion: 2.0, // OpenGL ES 2.0
egl.RedSize: 8,
egl.GreenSize: 8,
egl.BlueSize: 8,
egl.AlphaSize: 8,
egl.DepthSize: 24,
})
if err != nil {
log.Println("Platform init failed:", err)
return nil
}
if (int)(C.init_ext()) != 0 {
log.Println("GL ES 2.0 extensions load failed:", err)
return nil
}
Thank you. I just did that and it was resolved. But I am getting new errors:
06-08 14:14:34.779 23381-23401/com.go_android.minimal D/MALI: gles_state_set_error_internal:75: [MALI] GLES ctx: 0xa6780008, error code:0x502
06-08 14:14:34.779 23381-23401/com.go_android.minimal D/MALI: gles_state_set_error_internal:76: [MALI] GLES error info: the reserved buffer object 0 is bound to <target>
06-08 14:14:34.779 23381-23401/com.go_android.minimal D/MALI: gles_state_set_error_internal:75: [MALI] GLES ctx: 0xa6780008, error code:0x502
06-08 14:14:34.779 23381-23401/com.go_android.minimal D/MALI: gles_state_set_error_internal:76: [MALI] GLES error info: there is no current program object
06-08 14:14:34.779 23381-23401/com.go_android.minimal D/MALI: gles_state_set_error_internal:75: [MALI] GLES ctx: 0xa6780008, error code:0x502
06-08 14:14:34.779 23381-23401/com.go_android.minimal D/MALI: gles_state_set_error_internal:76: [MALI] GLES error info: there is no current program object
06-08 14:14:34.779 23381-23401/com.go_android.minimal D/MALI: gles_state_set_error_internal:75: [MALI] GLES ctx: 0xa6780008, error code:0x502
06-08 14:14:34.779 23381-23401/com.go_android.minimal D/MALI: gles_state_set_error_internal:76: [MALI] GLES error info: there is no current program object
06-08 14:14:34.779 23381-23401/com.go_android.minimal D/MALI: gles_state_set_error_internal:75: [MALI] GLES ctx: 0xa6780008, error code:0x502
06-08 14:14:34.779 23381-23401/com.go_android.minimal D/MALI: gles_state_set_error_internal:76: [MALI] GLES error info: there is no current program object
@darmie NanoVG is originally for OpenGL, I guess there is an incompatible call in the GL code, you need to search the error in google and understand why it fails for GLESv3.
@xlab the readme on the original NanoVG page says it's backend supports OpenGL ES 2 and 3 However, maybe the problem is from Nanovgo the Golang port.
Thanks for your help so far, I'll keep looking, and would post the solution here if I find any.
@xlab So I realized that the problem is from the shader. The shader is not compiling
This is my shader:
# version 300
uniform vec2 viewSize;
in vec2 vertex;
in vec2 tcoord;
out vec2 ftcoord;
out vec2 fpos;
void main(void) {
ftcoord = tcoord;
fpos = vertex;
gl_Position = vec4(2.0*vertex.x/viewSize.x - 1.0, 1.0 - 2.0*vertex.y/viewSize.y, 0, 1);
}
func (s *glShader) createShader(name, header, opts, vShader, fShader string) error {
program := gl.CreateProgram()
vertexShader := gl.CreateShader(gl.VERTEX_SHADER)
mShader := strings.Join([]string{opts, vShader}, "\x00")
fmt.Println(mShader)
gl.ShaderSource(vertexShader, 1, []string{mShader + "\x00"}, nil)
gl.CompileShader(vertexShader)
var status int32
gl.GetShaderiv(vertexShader, gl.COMPILE_STATUS, &status)
if status != gl.TRUE {
fmt.Println("vertex shader status", status)
return dumpShaderError(vertexShader, name, "vert")
}
}
Error Log:
06-08 20:03:03.624 10771-10789/com.go_android.minimal I/GolangExample: # version 300 es
06-08 20:03:03.624 10771-10789/com.go_android.minimal I/GolangExample: uniform vec2 viewSize;
06-08 20:03:03.624 10771-10789/com.go_android.minimal I/GolangExample: in vec2 vertex;
06-08 20:03:03.624 10771-10789/com.go_android.minimal I/GolangExample: in vec2 tcoord;
06-08 20:03:03.624 10771-10789/com.go_android.minimal I/GolangExample: out vec2 ftcoord;
06-08 20:03:03.624 10771-10789/com.go_android.minimal I/GolangExample: out vec2 fpos;
06-08 20:03:03.624 10771-10789/com.go_android.minimal I/GolangExample: void main(void) {
06-08 20:03:03.624 10771-10789/com.go_android.minimal I/GolangExample: ftcoord = tcoord;
06-08 20:03:03.624 10771-10789/com.go_android.minimal I/GolangExample: fpos = vertex;
06-08 20:03:03.624 10771-10789/com.go_android.minimal I/GolangExample: gl_Position = vec4(2.0*vertex.x/viewSize.x - 1.0, 1.0 - 2.0*vertex.y/viewSize.y, 0, 1);
06-08 20:03:03.624 10771-10789/com.go_android.minimal I/GolangExample: }
06-08 20:03:03.625 10771-10791/com.go_android.minimal I/GolangExample: Shader shader/vert error:
06-08 20:03:03.626 10771-10789/com.go_android.minimal I/GolangExample: vertex shader status 0
vertex shader status
is supposed to be equals to 1
if the shader compiled properly
06-08 21:10:52.641 6524-6559/com.go_android.minimal I/Adreno: ERROR: 0:5: ':' : Syntax error: syntax error
INTERNAL ERROR: no main() function!
ERROR: 1 compilation errors. No code generated.
I am trying to Port Nanovgo example to Android using andrioid-go and EGL
I modified Nanovgo to support GLES2 library from https://github.com/xlab/android-go/tree/master/gles2 , see modified version here nanovgo-gles
demo.go :
BUG:
i am getting a blank screen with these errors