I have a program in visual Studio C++ but somthing is wrong and it doesn't work.
#include <windows.h>
#include <gl/glut.h>
#include <stdlib.h>
#include <math.h>
#include <ctime>
#include <cstdlib>
#include <gl/gl.h>
#define randomize() (srand(time(0)))
#define random(x) (rand() % x)
#include "opengl.h"
#include "Complex_Number.cpp"
Complex_Number getest(Complex_Number pt, Complex_Number c_temp);
void drawfractal(MSG msg, HDC hDC);
bool bQuit = false; int color=0;
int GLOB;
LRESULT CALLBACK
WndProc( HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam );
int WINAPI
void Main( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int iCmdShow )
{
WNDCLASS wc;
HWND hWnd;
HDC hDC;
HGLRC hRC;
MSG msg;
int cx=GetSystemMetrics(SM_CXSCREEN);
int cy=GetSystemMetrics(SM_CYSCREEN);
wc.style = CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_CROSS );
wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wc.lpszMenuName = NULL;
wc.lpszClassName = "Fractal";
RegisterClass( &wc );
hWnd = CreateWindow(
"Fractal", "Fractal",
WS_POPUPWINDOW | WS_VISIBLE,
0, 0, cx, cy, NULL, NULL, hInstance, NULL );
EnableOpenGL( hWnd, &hDC, &hRC );
randomize();
while ( !bQuit ) {
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) {
if ( msg.message == WM_QUIT ) {
bQuit = TRUE;
} else {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
else
{
GLOB=rand()%10+1;
drawfractal(msg, hDC);
color++;
}
}
DisableOpenGL( hWnd, hDC, hRC );
DestroyWindow( hWnd );
return msg.wParam;
}
LRESULT CALLBACK
WndProc( HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam )
{
switch ( message ) {
case WM_CREATE:
return 0;
case WM_LBUTTONDOWN:
bQuit = TRUE;
return 0;
case WM_RBUTTONDOWN:
bQuit = TRUE;
return 0;
case WM_SETCURSOR:
SetCursor(NULL);
break;
case WM_MOUSEMOVE:
return 0;
case WM_KEYDOWN:
bQuit = TRUE;
return 0;
case WM_CLOSE:
PostQuitMessage( 0 );
return 0;
case WM_DESTROY:
return 0;
default:
return DefWindowProc( hWnd,
message, wParam, lParam );
}
return 0;
}
void drawfractal(MSG msg, HDC hDC)
{
double a, b;
Complex_Number c(0,-1);
Complex_Number point(1,1);
Complex_Number temp(0,0);
const double STEP = .0017; const double bound = 1; for (double y = -bound; y<bound; y+=STEP) {
for (double x = -bound; x<bound; x+=STEP) {
if (bQuit == TRUE) break; if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) {
if ( msg.message == WM_QUIT ){ bQuit = TRUE;}
else {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
else
{
glBegin(GL_POINTS);
point = getest(point, c);
point.Get_ab(a, b);
glVertex2d(a,b);
glEnd();
point.Set_ab(x, y);
}
}
SwapBuffers( hDC );
glFlush();
} }
Complex_Number getest(Complex_Number pt, Complex_Number c_temp)
{
double red=0;
double green=0;
double blue=0;
double a, b;
pt.Get_ab(a, b);
Complex_Number temp(a,b);
for (int i=0; i<15; i++) {
double j, k;
for (int dum=0; dum < GLOB; dum ++)
{
temp.Multiply(pt);
}
temp.Add(c_temp);
temp.Get_ab(j, k);
pt.Set_ab(j,k);
if ((fabs(j) > 10) || (fabs(k) > 10))
{
red =log(fabs(k)+1)*.25;
green=sin(.005*j);
blue=(1/log(i+2))*.25;
break;
}
}
if (color%5==0)
glColor3f (blue,green,red); else if (color%2==0)
glColor3f (green,red,blue); else
glColor3f (red,blue,green); pt.Set_ab(a,b);
return pt;
}
this program has run time error and i cant run the program. - [email address removed]