1 /* 2 * Copyright (C) 2014 Adrián Arroyo Calle 3 * Released under the terms of the MIT license. 4 * 5 * Authors: 6 * Adrián Arroyo Calle <adrian.arroyocalle@gmail.com> 7 * 8 */ 9 10 // Haiku EGL Test 11 // 12 // g++ -o HaikuTest HaikuTest.cpp /boot/home/mesa/build/haiku-x86-debug/egl/main/libEGL.so \ 13 // -lGL -lbe -I/boot/home/mesa/include && EGL_LOG_LEVEL=debug MESA_DEBUG=1 \ 14 // LIBGL_DRIVERS_PATH=/boot/home/mesa/build/haiku-x86-debug/mesa/drivers/haiku/swrast/ \ 15 // ./HaikuTest 16 17 #include <InterfaceKit.h> 18 #include <OpenGLKit.h> 19 #include <EGL/egl.h> 20 #include <stdio.h> 21 22 23 class EGLApp : public BApplication{ 24 public: 25 EGLApp() : BApplication("application/x-egl-test"){}; 26 27 void 28 ReadyToRun() 29 { 30 EGLContext ctx; 31 EGLSurface surf; 32 EGLConfig* configs; 33 EGLint numConfigs; 34 35 int maj; 36 int min; 37 38 printf("Starting EGL test...\n"); 39 40 printf("getDisplay...\n"); 41 EGLDisplay d=eglGetDisplay(EGL_DEFAULT_DISPLAY); 42 43 printf("eglInitialize...\n"); 44 eglInitialize(d, &maj, &min); 45 46 printf("eglGetConfigs...\n"); 47 eglGetConfigs(d, configs, numConfigs, &numConfigs); 48 49 printf("eglBindAPI...\n"); 50 eglBindAPI(EGL_OPENGL_API); 51 52 printf("eglCreateContext...\n"); 53 ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL); 54 55 printf("new BWindow...\n"); 56 BWindow* win=new BWindow(BRect(100,100,500,500),"EGL App",B_TITLED_WINDOW,0); 57 58 printf("eglCreateWindowSurface...\n"); 59 surf = eglCreateWindowSurface ( d, configs[0], 60 (EGLNativeWindowType)win, NULL ); 61 62 printf("eglMakeCurrent...\n"); 63 eglMakeCurrent( d, surf, surf, ctx ); 64 65 printf("glClearColor + glClear + eglSwapBuffers...\n"); 66 float green=0.0f; 67 while(1) 68 { 69 //sleep(1); 70 glClearColor(1.0f,green,0.0f,1.0f); 71 glClear ( GL_COLOR_BUFFER_BIT ); 72 eglSwapBuffers ( d, surf ); 73 green += 0.0001; 74 } 75 } 76 }; 77 78 79 int 80 main() 81 { 82 EGLApp* app=new EGLApp(); 83 84 app->Run(); 85 86 return 0; 87 } 88