kugimasa / OpenGL-Study

An introduction to OpenGL in MacOS
0 stars 0 forks source link

Triangle #4

Closed kugimasa closed 4 years ago

kugimasa commented 4 years ago

GOAL

The cursor draws the triangle. The triangle gets bigger(or smaller).

IMG_6368

kugimasa commented 4 years ago

Input from cursor using GLUT

glutPassiveMotionFunc() : Get the cursor position in the window (x, y) when nothing is pressed

スクリーンショット 2020-04-21 23 01 22

Commit here

kugimasa commented 4 years ago

Draw Triangle

The origin of Cursor Coordinate System and Display Coordinate System is different

スクリーンショット 2020-04-21 23 23 35

Commit here

kugimasa commented 4 years ago

Match Coordinate System

displayX =   2.0 * (cursorX / w) - 1.0
displayY = - 2.0 * (cursorY / y) + 1.0

スクリーンショット 2020-04-21 23 55 46

Commit here

kugimasa commented 4 years ago

Draw triangle in polar coordinate system

x = cos(theta)
y = sin(theta)

The 3 vertexes' position

Commit [here]()

スクリーンショット 2020-04-22 0 40 15

Commit [here]()

kugimasa commented 4 years ago

Move triangle according to cursor position

Triangle

Commit here

kugimasa commented 4 years ago

Change triangle size

Triangle

Commit here

kugimasa commented 4 years ago

Change triangle color

Color

Commit here

kugimasa commented 4 years ago

Draw triangle when cursor is not moving (and Refactor)

glutIdleFunc()

Commit here

kugimasa commented 4 years ago

Add motion blur

glEnable(GL_BLEND) and glBlendFunc(src, dst)

TriangleBlur

Commit here