شما این محصولات را انتخاب کرده اید

سبد خرید

رسم خط متحرک در C++
شناسه پست: 4536
بازدید: 6337

برنامه رسم خط متحرک در C++

				
					#include <iostream.h>
#include <conio.h>
#include <math.h>

//------------sourcea.ir----------------------------------//
#include<windows.h>      // for MS Windows
#include<gl\glut.h>      // GLUT, include glu.h and gl.h
//Note: GLglut.h path depending on the system in use
void init()
{
    // Set display window color to as glClearColor(R,G,B,Alpha)
    glClearColor(0.0, 0.0, 0.0, 0.0);
    // Set projection parameters.
    glMatrixMode(GL_PROJECTION);
    // Set 2D Transformation as gluOrtho2D(Min Width, Max Width, Min Height, Max Height)
    gluOrtho2D(0.0, 800, 0.0, 600);
}
 
void randomLines()
{
    glClear(GL_COLOR_BUFFER_BIT); // Clear display window
    GLint r, g, b;
    GLint x1, y1, x2, y2;
    // Calculate color
 
    r = rand() % 2;
    g = rand() % 2;
    b = rand() % 2;
    // Calculate X1, Y1 Points
    x1 = rand() % 800;
    y1 = rand() % 600;
    // Calculate X2, Y2 Points
    x2 = rand() % 800;
    y2 = rand() % 600;
 
    glLineWidth(10);
    // Set line segment color as glColor3f(R,G,B)
    glColor3f(r, g, b);
 
    glBegin(GL_LINES);
    glVertex2i(x1, y1);
    glVertex2i(x2, y2);
    glEnd();
    // Process all OpenGL routine s as quickly as possible
    glFlush();
    glutSwapBuffers();
}
int main(int argc, char ** argv)
{
    // Initialize GLUT
    glutInit(&argc, argv);
    // Set display mode
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    // Set top - left display window position.
    glutInitWindowPosition(100, 100);
    // Set display window width and height
    glutInitWindowSize(800, 600);
    // Create display window with the given title
    glutCreateWindow("Draw Random Lines using OpenGL");
    // Execute initialization procedure
    init();
    // Send graphics to display window
    glutDisplayFunc(randomLines);
    glutIdleFunc(randomLines);
    // Display everything and wait.
    glutMainLoop();
}
				
			

توضیحات:

صورت سوال:

برنامه رسم خط متحرک در C++

این برنامه در صفحه یک خط که به صورت متحرک در صفحه در حال گردش است را می‌سازد.

شما میتوانید سوالات خود را از طریق ایمیل پشتیبانی – تماس با ما – یا در قسمت نظرات سوال خود را بپرسید.

موفق باشید

A.J

پست های مرتبط:

اشتراک در
اطلاع از
guest

0 نظرات
قدیمی‌ترین
تازه‌ترین بیشترین رأی
بازخورد (Feedback) های اینلاین
مشاهده همه دیدگاه ها