[CG]11/19 실습
/*
#include <stdlib.h>
#include <GL/glut.h>
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(100,100,0,0);
glViewport(0,0,300,300);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-100.0,100.0,-100.0,100.0);
glColor3f(0,0,1);
glRectf(0.0,0.0,50.0,30.0);
glViewport(300,300,300,300);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-100.0,100.0,-100.0,100.0);
glColor3f(1,0,0);
glRectf(0.0,0.0,30.0,50.0);
glViewport(0,300,100,100);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-100.0,100.0,-100.0,100.0);
glColor3f(0,1,0);
glRectf(0.0,0.0,30.0,50.0);
glFlush();
glutSwapBuffers();
}
void GNU_Keyboard(unsigned char key, int x, int y) {
if(key ==27) exit(0); // 27 ESC , 65 'A'
}
void main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE);
glutInitWindowSize(800,800);
glutCreateWindow("novice");
glutDisplayFunc(myDisplay);
glutKeyboardFunc(GNU_Keyboard);
glutMainLoop();
}
*/
/*
#include<GL/glut.h>//P1
void MyDisplay(){
glClearColor(1.0,1.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0,0.0,1.0);
//glutSolidSphere(0.5, 20, 10);
glutWireSphere(1.1, 5, 5);
//glutWireTeapot(0.5);
glFlush();
}
int main(int argc,char** argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(300,300);
glutCreateWindow("OpenGL Sample Drawing");
glutDisplayFunc(MyDisplay);
glutMainLoop();
return 0;
}*/
/*
#include<GL/glut.h>//P2 L11
void MyDisplay(){
glClearColor(1.0,1.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
//glColor3f(0.0,1.0,0.0); glutWireSphere(0.5,10,10);
glColor3f(0.0,0.0,1.0); glutWireDodecahedron();
//glColor3f(1.0,0.0,0.0); glutWireTorus(0.2,0.6,10,10);
//glutWireTeapot(0.5);
glPointSize(20);
glBegin(GL_POINTS);
glColor3f(0,0,0);glVertex3f(0,0,0);
glColor3f(1,0,0);glVertex3f(0.75,0.75,0);
glColor3f(0,0,1);glVertex3f(-0.75,-0.75,0);
glEnd();
glFlush();
}
int main(int argc,char** argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(500,500);
glutCreateWindow("OpenGL Sample Drawing");
glutDisplayFunc(MyDisplay);
glutMainLoop();
return 0;
}*/
#include<GL/glut.h>//P2 L14
void MyDisplay(){
GLfloat v[3][3] = {{0,0,0},{0.5,0.5,0},{0.25,0,0}};
glClearColor(1.0,1.0,0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
/*
glRotatef(45,0,0,1);
glTranslatef(-0.5,-0.5,0);
glBegin(GL_POLYGON);
glColor4f(1,0,0,1); glVertex3fv(v[0]);
glColor4f(0,1,0,1); glVertex3fv(v[1]);
glColor4f(0,0,1,1); glVertex3fv(v[2]);
glEnd();
*/
glTranslatef(-0.5,-0.5,0);
glRotatef(45,0,0,1);
glBegin(GL_POLYGON);
glColor4f(1,0,0,1); glVertex3fv(v[0]);
glColor4f(0,1,0,1); glVertex3fv(v[1]);
glColor4f(0,0,1,1); glVertex3fv(v[2]);
glEnd();
/*
glRotatef(90,1,0,1);
glBegin(GL_POLYGON);
glColor4f(1,0,0,1);glVertex3fv(v[0]);
glColor4f(0,1,0,1);glVertex3fv(v[1]);
glColor4f(0,0,1,1);glVertex3fv(v[2]);
glEnd();
*/
glFlush();
}
int main(int argc,char** argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(500,500);
glutCreateWindow("OpenGL Sample Drawing");
glutDisplayFunc(MyDisplay);
glutMainLoop();
return 0;
}
/*
#include<GL/glut.h>//P1 L14
void MyDisplay(){
GLfloat v[3][3] = {{0,0,0},{0.5,0.5,0},{0.25,0,0}};
glClearColor(1.0,1.0,0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor4f(1,0,0,1); glVertex3fv(v[0]);
glColor4f(0,1,0,1); glVertex3fv(v[1]);
glColor4f(0,0,1,1); glVertex3fv(v[2]);
glEnd();
glFlush();
}
int main(int argc,char** argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(500,500);
glutCreateWindow("OpenGL Sample Drawing");
glutDisplayFunc(MyDisplay);
glutMainLoop();
return 0;
}*/
/*
#include<GL/glut.h>//P3 L14
void DrawTriangle(){
glColor3f(1,0,0);
glBegin(GL_TRIANGLES);
glVertex3f(0,0,0);glVertex3f(0.2,0,0);glVertex3f(0,0.2,0);
glEnd();
}
void MyDisplay(){
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
DrawTriangle();
glTranslatef(0.3f,0.3f,0);
glRotatef(45,0,0,1);
DrawTriangle();
glFlush();
}
int main(int argc,char** argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(500,500);
glutCreateWindow("OpenGL Sample Drawing");
glClearColor(1,1,1,0);
glutDisplayFunc(MyDisplay);
glutMainLoop();
return 0;
}*/
/*
#include<GL/glut.h>//P3 L14
void DrawTriangle(){
glColor3f(1,0,0);
glBegin(GL_TRIANGLES);
glVertex3f(0,0,0);glVertex3f(0.2,0,0);glVertex3f(0,0.2,0);
glEnd();
}
void MyDisplay(){
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
DrawTriangle();
glTranslatef(0.3f,0.3f,0);
glRotatef(45,0,0,1);
DrawTriangle();
glTranslatef(0.3f,0.3f,0);
glutWireTeapot(0.2);
glFlush();
}
int main(int argc,char** argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(500,500);
glutCreateWindow("OpenGL Sample Drawing");
glClearColor(1,1,1,0);
glutDisplayFunc(MyDisplay);
glutMainLoop();
return 0;
}*/