Difference between r1.2 and the current
@@ -1,7 +1,7 @@
 == Contents ==
 
== Source code ==
주석은 차후에 다시
#include <gl\freeglut.h>
 
== Source code ==
주석 및 페이지 정리는 나중에 다시
 {{{#include <gl\freeglut.h>
@@ -105,6 +105,8 @@
 	return 0;
}
}}}
 
#include <math.h>
 
}
}}}
{{{
 #include <gl\freeglut.h>#include <math.h>
@@ -149,6 +151,136 @@
 	glutMainLoop();
return 0;
}
 {{{
 
	
	
	
 
 
 
 
 
 
 
 
 
 
 
 
 
	
 
 
return 0;
}
}}}
#include <gl\freeglut.h>
void display()
{
	// I don't know, but it uses to transparent
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	// White Base
	glClearColor(1, 1, 1, 1);
	glClear(GL_COLOR_BUFFER_BIT);
	glBegin(GL_QUADS);
	// Black Square
	glColor3f(0, 0, 0);
	glVertex2f(0.0, 1.0);
	glVertex2f(0.0, -1.0);
	glVertex2f(1.0, -1.0);
	glVertex2f(1.0, 1.0);
	// Red Square
	for (float i=1,j = 1;i>-1; i -= 0.5, j-= 0.25)
	{
		glColor4f(1, 0, 0, j);
		glVertex2f(-1.0, i);
		glVertex2f(1.0, i);
		glVertex2f(1.0, i-0.4);
		glVertex2f(-1.0, i-0.4);
	}
	glEnd();
	glFlush();
}
int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowSize(600, 600);
	glutInitWindowPosition(200, 200);
	glutCreateWindow("Homework0_4");
	glutDisplayFunc(display);
	glutMainLoop();
	return 0;
}
}}}
{{{
#include <gl\freeglut.h>
#include <math.h>
#define PI 3.145926
#define rad2the(x) x * PI / 180.0
void cycle(float x, float y, float roundx, float roundy, float begin, float end)
{
	glBegin(GL_TRIANGLE_FAN);
	for (float i = begin; i <= end; i += 0.005)
	{
		float a = 0, b = 0;
		a = roundx * cos(rad2the(i));
		b = roundy * sin(rad2the(i));
		glVertex2f(x + a, y + b);
	}
	glEnd();
	glFlush();
}
void car(float x, float y)
{
	glColor3f(1, 0, 0);
	cycle(x, y-0.2, 0.8, 0.2, -30, 210);
	cycle(x, y, 0.5, 0.2, -30, 210);
	glColor3f(0, 0, 0);
	cycle(x-0.35, y-0.3, 0.17,0.17, 0, 360);
	cycle(x+0.35, y-0.3, 0.17, 0.17, 0, 360);
	glColor3f(0.8, 0.8, 0.8);
	cycle(x-0.35, y-0.3, 0.1, 0.1, 0, 360);
	cycle(x + 0.35, y-0.3, 0.1, 0.1, 0, 360);
 	glColor3f(0, 0, 1);
	cycle(x-0.15, y, 0.3, 0.1, 90, 180);
	cycle(x + 0.15, y, 0.3, 0.1, 0, 90);
	glBegin(GL_TRIANGLE_FAN);
	glVertex2f(x - 0.45, y);
	glVertex2f(x-0.15, y);
	glVertex2f(x-0.15, y + 0.1);
	glEnd();
	glBegin(GL_TRIANGLE_FAN);
	glVertex2f(x + 0.45, y);
	glVertex2f(x + 0.15, y);
	glVertex2f(x + 0.15, y + 0.1);
	glEnd();
	glBegin(GL_TRIANGLE_FAN);
	glVertex2f(x - 0.1, y);
	glVertex2f(x - 0.1, y + 0.1);
	glVertex2f(x + 0.1, y + 0.1);
	glVertex2f(x + 0.1, y);
	glEnd();
	glFlush();
}
void display()
{
	glClearColor(1, 1, 1, 1);
	glClear(GL_COLOR_BUFFER_BIT);
	car(0, 0);
}
int main(int argc, char**argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowSize(600, 600);
	glutInitWindowPosition(200, 200);
	glutCreateWindow("Homework0 5");
	glutDisplayFunc(display);
	glutMainLoop();
	return 0;
}
 }}} * 개인적인 문서는 하위로 넣어주세요 - [강민승]
Contents ¶
Source code ¶
주석 및 페이지 정리는 나중에 다시
#include <gl\freeglut.h>
void Line()
{
	glLineWidth(5);
	glColor3f(0, 0, 0);
	glBegin(GL_LINES);
	glVertex2f(-1.0, 1.0);
	glVertex2f(1.0, -1.0);
	glEnd();
}
void Square()
{
	glColor3f(1, 0, 0);
	glBegin(GL_LINE_LOOP);
	glVertex2f(-0.7, 0.7);
	glVertex2f(-0.7, 0.2);
	glVertex2f(-0.2, 0.2);
	glVertex2f(-0.2, 0.7);
	glEnd();
}
void display()
{
	glClearColor(1, 1, 1, 1);
	glClear(GL_COLOR_BUFFER_BIT);
	Line();
	Square();
	glFlush();
}
int main(int argc, char**argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowSize(600, 600);
	glutInitWindowPosition(200, 200);
	glutCreateWindow("Homework0_1");
	glutDisplayFunc(display);
	glutMainLoop();
	return 0;
}
#include <gl\freeglut.h>
#include <diging.h>
float speed = 0;
void Rec(float locationX, float locationY, float size)
{
	vec2 rec[4] = { { -size + locationX, size + locationY }, { size + locationX, size + locationY },
	{ size + locationX, -size + locationY }, { -size + locationX, -size + locationY } };
	glBegin(GL_QUADS);
	for (int i = 0; i < 4;i++)
		glVertex2fv(rec[i]);
	glEnd();
}
void idle()
{
	speed += 0.0005;
	glutPostRedisplay();
}
void display()
{
	glClearColor(0.5, 0.5, 0.5, 0.5);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	mat4 m(1.0);
	glMatrixMode(GL_MODELVIEW);
	glLoadMatrixf(matrix_to_float(m));
	m *= Translate(speed, 0.0, 0.0);
	glPushMatrix();
	glLoadMatrixf(matrix_to_float(m));
	glColor3f(1, 1, 1);
	Rec(-1.0, 0.2, 0.2);
	m *= Translate(speed, 0.0, 0.0);
	glPushMatrix();
	glLoadMatrixf(matrix_to_float(m));
	glColor3f(0, 0, 0);
	Rec(-1.0, -0.2, 0.2);
	glutSwapBuffers();
}
int main(int argc, char**argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
	glutInitWindowPosition(200, 200);
	glutInitWindowSize(600, 600);
	glutCreateWindow("Homework2-1");
	glutIdleFunc(idle);
	glutDisplayFunc(display);
	glutMainLoop();
	return 0;
}
#include <gl\freeglut.h>
#include <math.h>
#define Round 0.2
#define PI 3.145926
#define radi2theta(x) x*PI/180.0
void cycle(float x, float y, float r, float g, float b)
{
	float dx = 0, dy = 0;
	glColor3f(r, g, b);
	glBegin(GL_POLYGON);
	for (float i = 0; i < 360; i += 0.01)
	{
		dx = Round*cos(radi2theta(i));
		dy = Round*sin(radi2theta(i));
		glVertex2f(x + dx, y + dy);
	}
	glEnd();
}
void display()
{
	glClearColor(1.0, 1.0, 1.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);
	cycle(-0.7, 0.7, 1, 0, 0);
	cycle(-0.25, 0.7, 0, 1, 0);
	cycle(0.2, 0.7, 0, 0, 1);
	glFlush();
}
int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowSize(600, 600);
	glutInitWindowPosition(200, 200);
	glutCreateWindow("Homework0_3");
	glutDisplayFunc(display);
	glutMainLoop();
	return 0;
}
#include <gl\freeglut.h>
void display()
{
	// I don't know, but it uses to transparent
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	// White Base
	glClearColor(1, 1, 1, 1);
	glClear(GL_COLOR_BUFFER_BIT);
	
	glBegin(GL_QUADS);
	
	// Black Square
	glColor3f(0, 0, 0);
	glVertex2f(0.0, 1.0);
	glVertex2f(0.0, -1.0);
	glVertex2f(1.0, -1.0);
	glVertex2f(1.0, 1.0);
	// Red Square
	for (float i=1,j = 1;i>-1; i -= 0.5, j-= 0.25)
	{
		glColor4f(1, 0, 0, j);
		glVertex2f(-1.0, i);
		glVertex2f(1.0, i);
		glVertex2f(1.0, i-0.4);
		glVertex2f(-1.0, i-0.4);
	}
	glEnd();
	glFlush();
}
int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowSize(600, 600);
	glutInitWindowPosition(200, 200);
	glutCreateWindow("Homework0_4");
	glutDisplayFunc(display);
	glutMainLoop();
	return 0;
}
#include <gl\freeglut.h>
#include <math.h>
#define PI 3.145926
#define rad2the(x) x * PI / 180.0
void cycle(float x, float y, float roundx, float roundy, float begin, float end)
{
	glBegin(GL_TRIANGLE_FAN);
	for (float i = begin; i <= end; i += 0.005)
	{
		float a = 0, b = 0;
		a = roundx * cos(rad2the(i));
		b = roundy * sin(rad2the(i));
		glVertex2f(x + a, y + b);
	}
	glEnd();
	glFlush();
}
void car(float x, float y)
{
	glColor3f(1, 0, 0);
	cycle(x, y-0.2, 0.8, 0.2, -30, 210);
	cycle(x, y, 0.5, 0.2, -30, 210);
	glColor3f(0, 0, 0);
	cycle(x-0.35, y-0.3, 0.17,0.17, 0, 360);
	cycle(x+0.35, y-0.3, 0.17, 0.17, 0, 360);
	glColor3f(0.8, 0.8, 0.8);
	cycle(x-0.35, y-0.3, 0.1, 0.1, 0, 360);
	cycle(x + 0.35, y-0.3, 0.1, 0.1, 0, 360);
	glColor3f(0, 0, 1);
	cycle(x-0.15, y, 0.3, 0.1, 90, 180);
	cycle(x + 0.15, y, 0.3, 0.1, 0, 90);
	glBegin(GL_TRIANGLE_FAN);
	glVertex2f(x - 0.45, y);
	glVertex2f(x-0.15, y);
	glVertex2f(x-0.15, y + 0.1);
	glEnd();
	glBegin(GL_TRIANGLE_FAN);
	glVertex2f(x + 0.45, y);
	glVertex2f(x + 0.15, y);
	glVertex2f(x + 0.15, y + 0.1);
	glEnd();
	glBegin(GL_TRIANGLE_FAN);
	glVertex2f(x - 0.1, y);
	glVertex2f(x - 0.1, y + 0.1);
	glVertex2f(x + 0.1, y + 0.1);
	glVertex2f(x + 0.1, y);
	glEnd();
	glFlush();
}
void display()
{
	glClearColor(1, 1, 1, 1);
	glClear(GL_COLOR_BUFFER_BIT);
	car(0, 0);
	
}
int main(int argc, char**argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowSize(600, 600);
	glutInitWindowPosition(200, 200);
	glutCreateWindow("Homework0 5");
	glutDisplayFunc(display);
	glutMainLoop();
	return 0;
}
- 개인적인 문서는 하위로 넣어주세요 - 강민승
 












