//#include <windows.h>
#include <Afxwin.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>
#include <math.h>
#include <iostream.h>
#include <stdio.h>
#pragma comment(lib,"opengl32.lib")
#pragma comment(lib,"glu32.lib")
#pragma comment(lib,"glaux.lib")
void BoundaryFill4(int x, int y, COLORREF boundColor, COLORREF newColor)
{
COLORREF color=CDC::GetPixel(x,y);
if((color!=boundColor)&&(color!=newColor))
{
CDC::SetPixel(x,y,newColor);
BoundaryFill4(x, y+1, boundColor, newColor);
BoundaryFill4(x, y-1, boundColor, newColor);
BoundaryFill4(x-1, y, boundColor, newColor);
BoundaryFill4(x+1, y, boundColor, newColor);
}
}
void draw(float x0,float y0,float radiu) //画圆
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,0.0);
float angle;
float step=0.001f;
glBegin(GL_POINTS);
float x;
float y;
for (angle=0.0f;angle<=2.0f*3.14159f;angle+=step)
{
x=float(radiu*sin(angle)+x0);
y=float(radiu*cos(angle)+y0);
glVertex2f(x,y);
}
glEnd();
glFlush();
}
void CALLBACK fillcircle(void)
{
draw(300.0,300.0,200.0);
BoundaryFill4(300,300,RGB(1.0,0.0,0.0),RGB(1.0,1.0,0.0));
}
void main()
{
auxInitDisplayMode(AUX_SINGLE | AUX_RGBA);
auxInitPosition(50,50,700,600);
auxInitWindow("An Example of OpenGL");
auxMainLoop(fillcircle);
}
编译出现以下错误:
error C2352: 'CDC::GetPixel' : illegal call of non-static member function
c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(863) : see declaration of 'GetPixel'
error C2352: 'CDC::SetPixel' : illegal call of non-static member function
c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(865) : see declaration of 'SetPixel'