Displaying changing lines in OpenGL

I am new to OpenGL. I am coding in Visual C++ 2005 environment, and I have some problem of calling the display.


The “display” is a callback function, so i declared it as a static function in the header.

 static void __cdecl display();

In the display function, i wanted it to read an array from a non static function, and display the lines from there.

glClearColor(0,0,0,0);//set the background color to black

	x=((COpenGL*) pDummy)->myArray[i].x;
	y=((COpenGL*) pDummy)->myArray[i].y;

Each array represents a frame that i want to display in the OpenGL window. These frames will be continously streaming in, and in the openGL window will form an animation of different frames.

Unfortunately, it cannot be done as Visual C++ reported a wrong type of casting in

 ((COpenGL*) pDummy)

What is wrong here?
Are there any other alternatives?

Well, you realize that this has nothing at all to do with OpenGL? You do have GL errors in your code hovewer: the glVertex calls shoudl be put inside ghBegin … glEnd block (look glBegin up in the documentation).

As for your question, I have no idea about C++ type system, but you will also don’t say what kind of variable pDummy ist and why do you need to cast it to the COpenGL* type (what is this type anyway?). Also, there is a contradiction in your code: you redeclare the x and y variables in your loop, so that pDummy lines are absolutely irrelevant to your program.

You need to tell us the actual error message as reported by VC++ (also, what version of GLUT).

I don’t know why you’re throwing __cdecl in display()'s prototype, either. Just “static void display(void);” should be enough.

Also, is this C (.c) or C++ (.cpp)?