Lagi lagi tugas ^^ yaaa namanyaa juga orang kuliah ...hehe
ini diaaa tugas rombel 1 tadi pagi.. :)
[ upsssssssss...jangan lupaa klo uda new project di atur yaa linker settingsnya, add terlebih dulu libopengl32, libfreeglut, dan libglu32 nyaaa yaaa... ^^ ]
-----------------------------------------------
//Nim : 5302410027
//Rombel : 01
#include <GL/glut.h>
void renderScene(void); // rendering function
void myInit(void);
void drawPixel(int, int);
int main(int argc,char*argv[])
{
// init GLUT dan buat window
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutCreateWindow("5302410027_TEORI 1");
glutInitWindowPosition(0,0);
glutInitWindowSize(500, 500);
glutDisplayFunc(renderScene); // register callbacks
myInit();
glutMainLoop(); // enter GLUT event processing cycle
return 0;
}
void renderScene (void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//drawPixel(100, 100);
float B, x, y, m, dx, dy, x0, y0, x1, y1;
y0=0;
x0=0;
x1=500;
y1=250;
B=20;
dx=x1-x0;
dy=y1-y0;
m=dy/dx;
y=y0;
for(x=x0;x<=x1;x++)
{
y=m*x+B;
drawPixel (x, y);
}
glFlush();
}
void drawPixel(int x, int y)
{
glBegin(GL_POINTS);
glVertex2i(x, y);
glEnd();
}
void myInit(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glColor3f(1.0f, 1.0f, 1.0f);
glPointSize(10.0);
gluOrtho2D(0.0, 500.0, 0.0, 500.0);
}
----------------------------------------------
selamat mencoba ^^
Tidak ada komentar:
Posting Komentar