Tugas 4: Source Code
Tugas 4: Source Code
TUGAS 4
Source Code
#include <windows.h>
#include <gl/Gl.h>
#include <gl/glut.h>
void garis(void)
{
MAB = (yB - yA) / (xB - xA);
CAB = yA - (MAB * xA);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
//GARIS AB
glColor3f(0, 0, 1);
glVertex2i(xA, yA);
glVertex2i(xB, yB);
//GARIS CD
glColor3f(0, 1, 0);
glVertex2i(xC, yC);
glVertex2i(xD, yD);
glEnd();
glFlush();
//TITIK POTONG
glBegin(GL_POINTS);
glColor3f(1, 0, 0);
glVertex2i(titik_X, titik_Y);
glEnd();
glFlush();
}
void display(void) {
glClearColor(1, 1, 1, 0);
glColor3f(0.0f, 0.0f, 0.0f);
glPointSize(6.0);
glLineWidth(4.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, 640, 0, 480);
glFlush();
Perhitungan
MAB = (475 - 50) / (450 - 200)
= 1,7
CAB = 50 - (1,7 * 200)
= -290