D Paste by h3r3tic
Description: None
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | module dog.test; import dog.Dog, dog.ext.WGL_EXT_swap_control, dog.ext.WGL_EXT_extensions_string, dog.ext.ARB_shader_objects, dog.ext.VERSION_1_3; import tango.io.Stdout : Stdout; import tango.stdc.stringz : fromStringz; void draw(GL gl) { gl.Clear(GL_COLOR_BUFFER_BIT); gl.withState(GL_BLEND).withoutState(GL_LIGHTING) in { gl.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl.Rotatef(.5f, 0, 0, 1); gl.immediate(GL_TRIANGLES, { gl.Color4f (1, 0, 0, 0.5f); gl.Vertex3f(-1, -1, -2); gl.Color4f (0, 1, 0, 0.5f); gl.Vertex3f(1, -1, -2); gl.Color4f (0, 0, 1, 0.5f); gl.Vertex3f(0, 1, -2); }); }; } void main() { auto context = GLWindow(); context .title(`Dog Demo`) .fullscreen(false) .width(800) .height(600) .create(); // setup gl data use(context) in (GL gl) { version (Windows) { gl.ext(WGL_EXT_swap_control, WGL_EXT_extensions_string, VERSION_1_3) in { Stdout.formatln(`refresh = {}`, gl.wglGetSwapInterval()); char* extp = gl.wglGetExtensionsString(); if (extp !is null) { Stdout.formatln(fromStringz(extp)); } extp = gl.GetString(GL_EXTENSIONS); if (extp !is null) { Stdout.formatln(fromStringz(extp)); } Stdout.formatln(fromStringz(gl.GetString(GL_VERSION))); }; } gl.MatrixMode(GL_PROJECTION); gl.LoadIdentity(); gl.gluPerspective(90.f, 1.333f, 0.1f, 100.f); gl.MatrixMode(GL_MODELVIEW); gl.LoadIdentity(); if (gl.ext(ARB_shader_objects).supported) { Stdout.formatln("ARB_shader_objects supported"); } else { Stdout.formatln("ARB_shader_objects NOT supported"); } }; // draw some stuff while (context.created) { use(context) in (GL gl) { draw(gl); if (!(gl.ext(VERSION_1_3) in { gl.ActiveTexture(GL_TEXTURE0); })) { Stdout.formatln(`ARB_multitexture not supported`); } }; context.update().show(); } } |