returning opengl display callback in D

Posted by Max on Stack Overflow See other posts from Stack Overflow or by Max
Published on 2010-12-25T04:12:40Z Indexed on 2010/12/25 7:54 UTC
Read the original article Hit count: 247

Filed under:
|

I've written a simple hello world opengl program in D, using the converted gl headers here.

My code so far:

import std.string;
import c.gl.glut;

Display_callback display()
{
    return Display_callback // line 7
    {
        return; // just display a blank window
    };
} // line 10

void main(string[] args)
{
    glutInit(args.length, args);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    glutInitWindowSize(800,600);
    glutCreateWindow("Hello World");
    glutDisplayFunc(display);
    glutMainLoop();
}

My problem is with the display() function. glutDisplayFunc() expects a function that returns a Display_callback, which is typedef'd as typedef GLvoid function() Display_callback;. When I try to compile, dmd says

line 7: found '{' when expecting ';' following return statement
line 10: unrecognized declaration

How do I properly return the Display_callback here? Also, how do I change D strings and string literals into char*? My calls to glutInit and glutCreateWindow don't like the D strings they're getting. Thanks for your help.

© Stack Overflow or respective owner

Related posts about opengl

Related posts about d