ANGLE load properly but does not work

54 views
Skip to first unread message

Claud

unread,
Jul 13, 2023, 11:02:16 PM7/13/23
to angleproject
Applying ANGLE is explained as if it were very simple,
but it doesn't seem to be as easy as I thought.
Whether it's because of the lack of relevant data or just the name,
it's not easy to find reference, so I'm asking here.
(If I search for ANGLE, it's all about rotation or degrees. lol)

I'm working on connecting ANGLE to a C# app on Windows.
At the end of twists and turns, ANGLE seems to load properly, but it doesn't work.

The only code on the C# side is hWnd = CreateWindowEx( ... ).
Below is the CPP code.

void angleTest(HWND hWnd) {
        EGLint error;
        EGLint major;
        EGLint minor;
        GLenum err;

        EGLNativeDisplayType hDC = (EGLNativeDisplayType) GetDC(hWnd);

        EGLint dispAttr[] = {
            EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
            EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE,
            EGL_NONE
        };

        EGLDisplay display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, hDC, dispAttr);
        error = eglGetError(); // EGL_SUCCESS

        eglInitialize(display, &major, &minor); // major = 1, minor = 5
        error = eglGetError(); // EGL_SUCCESS

        hinstEgl = LoadLibrary(L"libEGL.dll");
        gladLoadEGLLoader((GLADloadproc) GetProcAddressWithFallback);

        EGLint configAttr[] = {
            EGL_RED_SIZE, 8,
            EGL_GREEN_SIZE, 8,
            EGL_BLUE_SIZE, 8,
            EGL_ALPHA_SIZE, 8,
            EGL_DEPTH_SIZE, EGL_DONT_CARE,
            EGL_STENCIL_SIZE, EGL_DONT_CARE,
            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
            EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
            EGL_NONE
        };

        EGLConfig configs;
        EGLint numConfig = 0;
        eglChooseConfig(display, configAttr, &configs, 1, &numConfig); // numConfig = 1
        error = eglGetError(); // EGL_SUCCESS

        eglBindAPI(EGL_OPENGL_ES_API);
        error = eglGetError(); // EGL_SUCCESS

        EGLint contextAttr[] = {
            EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL_CONTEXT_MAJOR_VERSION, 2,
            EGL_CONTEXT_MINOR_VERSION, 0,
            EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE, EGL_FALSE,
            EGL_NONE
        };

        EGLContext context = eglCreateContext(display, configs, EGL_NO_CONTEXT, contextAttr);
        error = eglGetError(); // EGL_SUCCESS

        EGLint surfaceAttr[] = {
            EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
            EGL_NONE
        };

        EGLSurface surface = eglCreateWindowSurface(display, configs, hWnd, surfaceAttr);
        error = eglGetError(); // EGL_SUCCESS

        eglMakeCurrent(display, surface, surface, context);
        error = eglGetError(); // EGL_SUCCESS

        hinstGles = LoadLibrary(L"libGLESv2.dll");
        gladLoadGLES2Loader((GLADloadproc) GetProcAddressWithFallback);

        const GLubyte* ven = glGetString(GL_VENDOR);    // Google Inc. (NVIDIA)
        const GLubyte* ren = glGetString(GL_RENDERER);  // ANGLE (NVIDIA, NVIDIA GeForce GTX 1050 Direct3D11 vs_5_0 ps_5_0, D3D11-31.0.15.3640)
        const GLubyte* ver = glGetString(GL_VERSION);   // OpenGL ES 2.0.0 (ANGLE 2.1.21199 git hash: b0e9bbd79fb6)

        glViewport(0, 0, 400, 400);
        err = glGetError(); // 0

        glClearColor(1.f, 0.f, 0.f, 1.f);
        err = glGetError(); // 0

        glClear(GL_COLOR_BUFFER_BIT);
        err = glGetError(); // 0

//        glFlush();
//        err = glGetError(); // 0

        eglSwapBuffers(display, surface); // EGL_SUCCESS
    }

But no color changes...
It's originally a separate code, but it's running in the same thread anyway.

If I change the settings related to ANGLE,
there is a difference between the screen coming out in blue or gray,
so it doesn't seem to be working completely separately.
(If it comes out in blue, if I move the window or change the window size,
 it will be erased in gray.)

Any kind of help would be appreciated.

ps. Sorry, I'm not good at English.

Claud

unread,
Jul 13, 2023, 11:07:21 PM7/13/23
to angleproject

There is a part where I made a mistake while uploading the code.


hinstEgl = LoadLibrary(L"libEGL.dll");
gladLoadEGLLoader((GLADloadproc) GetProcAddressWithFallback);

This code is at the top.
I can't edit the post.

2023년 7월 14일 금요일 오후 3시 2분 16초 UTC+9에 Claud님이 작성:

Claud

unread,
Jul 13, 2023, 11:38:05 PM7/13/23
to angleproject
Wow... writing here solves it right away.
At least the code I've uploaded here is rendering normally.
Now I need to find out why it's not working in my code. lol

2023년 7월 14일 금요일 오후 3시 7분 21초 UTC+9에 Claud님이 작성:

Shahbaz Youssefi

unread,
Jul 14, 2023, 6:19:15 AM7/14/23
to angleproject
Glad we could help you, lol :D
Reply all
Reply to author
Forward
0 new messages