• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

mandelbrot using open gl in c++

amdskip

Lifer
It's been a long time since I've touched C++ and I'm trying to understand the approach to take on this program. Yes it is an assignment and no I do not want you to do it for me. I want help understanding the thing.

If someone has some good links or anything that they could pass along it would be greatly appreciated. I've attached what I have started so far and some of it I understand while other parts I do not.

This is a visual c++ project and we should be able to zoom in and out of the mandelbrot using the mouse (mouse functions).

Try this code, the code attach sucks!

# include<windows.h>
# include<glut.h>

#define Xmax 300
#define Ymax 300


void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}

void int()
{
gluOrtho2d (0.0, Xmax, Ymax, 0.0); // left, right, bottom, top
glPointSize(1);
MakeColors();
}

void MouseStuff (int button, int state, int x, int y) // given to us, assuming it works
{
CenterR = (x * StepR) + Rmin;
CenterL = Lmax - (y * StepL);
if(state == GLUT_DOWN && button == GLUT_LEFT_BUTTON)
{
CmplxHalfWidth = CmplxHalfWidth /2;
Rmax = CenterR + CmplxHalfWidth;
Rmin = CenterR - CmplxHalfWidth;
Lmax = CenterL + CmplxHalfWidth;
Lmin = CenterL - CmplxHalfWidth;
StepR = (Rmax - Rmin)/Xmax;
StepL = (Lmax - Lmin)/Ymax;


void main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_Single | GLUT_RGB);
glutInitWindowSize(Xmax, Ymax);
glutInitWindowPosition(100,100);
glutCreateWindow("Mandelbrot System");
init();
glutMouseFunc(MouseStuff);
glutDisplayFunc(display);
glutMainLoop();
}
 
Back
Top