السلام عليكم ورحمة الله وبركاته
أنا عضو جديد في هذا المنتدى وقد عرفت أن هذا المنتدى من أفضل المواقع العربية التي تثرينا بالعلم، فأرجو منكم مساعدتي في هذه المشكلة
أنا طالب مبتدئ في ال OpenGL ، طلب مني كتابة برنامج ال
Triangle Sierpinski Gasket وتنفيذه وكتبت الكود لكن يوجد لدي خطأ وحيد لم أستطع معالجته فأرجو ممن لديه الخبرة مساعدتي كما أرجو منكم مراجعة الإحداثيات للرسم هل ستظهر بشكل صحيح أي هل ستظهر الرسمة كاملة أو سيظهر جزء معين منها فإذا كانت خاطئة أرجو تعديلها ولكم جزيل الشكر، طبعاً البرنامج مكتوب بال visual c++ ومكتوب داخل ال console win32وإليكم الكود:
#include "stdafx.h"
#include "windows.h"
#include "GL/glut.h"
class GLintPoint
{
public: GLint x, y;
};
int random(int m) { return rand() % m; }
void myInit(void)
{
glClearColor(9.0,7.0,8.0,0.0);
glColor3f(5.0f,0.0f,0.0f);
glPointSize(4.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,640.0,0.0,480.0);
}
void drawDot(GLint x, GLint y)
{
// draw dot at integer point (x, y)
glBegin(GL_POINTS);
glVertex2i(x, y);
glEnd();
}
void Sierpinski(void)
{
GLintPoint T[3]= {{10,10},{300,30},{200, 300}};
int index = random(3); // 0, 1, or 2 equally likely
GLintPoint point = T[index]; // initial point
drawDot(point.x, point.y); // draw initial point
for(int i = 0; i < 1000; i++) // draw 1000 dots
{
index = random(3);
point.x = (point.x + T[index].x) / 2;
point.y = (point.y + T[index].y) / 2;
drawDot(point.x,point.y);
}
glFlush();
}
void main(int argc,char**argv)
{
glutInit(&argc, argv); // initialize the toolkit
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set display mode
glutInitWindowSize(640,480); // set window size
glutInitWindowPosition(100, 150); // set window position on screen
glutCreateWindow("Triangle Sierpinski Gasket "); // open the screen window
glutDisplayFunc(Sierpinski); // register redraw function
myInit();
//Sierpinski();
glutMainLoop(); // go into a perpetual Loop
}