Está en la página 1de 4

D

Dibujamos los líneas perpendiculares para tener una referencia de 90 grados


una de color rojo y otra de color verde, todo este esta dentro de un método
que se llama render

LINEA COLOR ROJA


glBegin(GL_LINES)
glColor3ub(255, 0, 0)
glVertex2fv(np.array([0.,0.]))
glVertex2fv(np.array([1.,0.]))

LINEA COLOR VERDE


glColor3ub(0, 255, 0)
glVertex2fv(np.array([0.,0.]))
glVertex2fv(np.array([0.,1.]))
glEnd()

Dibujamos 4 triangulos uno opuesto al otro

glBegin(GL_TRIANGLES)
glColor3ub(255, 255, 255)
glVertex2fv( (T @ np.array([-.5,0,1.]))[:-1] )
glVertex2fv( (T @ np.array([.0,-.5,1.]))[:-1] )
glVertex2fv( (T @ np.array([-.5,-.5,1.]))[:-1] )
glEnd()

glBegin(GL_TRIANGLES)
glColor3ub(255, 25, 255)
glVertex2fv( (T @ np.array([.0,.5,1.]))[:-1] )
glVertex2fv( (T @ np.array([.0,.0,1.]))[:-1] )
glVertex2fv( (T @ np.array([.5,.0,1.]))[:-1] )
glEnd()

glBegin(GL_TRIANGLES)
glColor3ub(25, 255, 255)
glVertex2fv( (T @ np.array([.0,-.5,1.]))[:-1] )
glVertex2fv( (T @ np.array([.0,.0,1.]))[:-1] )
glVertex2fv( (T @ np.array([-.5,.0,1.]))[:-1] )
glEnd()

glBegin(GL_TRIANGLES)
glColor3ub(255, 2, 0)
glVertex2fv( (T @ np.array([.5,0,1.]))[:-1] )
glVertex2fv( (T @ np.array([.0,.5,1.]))[:-1] )
glVertex2fv( (T @ np.array([.5,.5,1.]))[:-1] )
glEnd()
Tenemos el método main donde se encuentra la creación de la ventana, la dimisiones de la
ventana, la rotación y traslación de las figuras

ROTACION

t = glfw.get_time()
th = t
R = np.array([[np.cos(th), -np.sin(th), 0.],
[np.sin(th), np.cos(th), 0.],
[0., 0., 1.]])

TRASLACION

T = np.array([[1., 0., .5],


[0., 1., 0.],
[0., 0., 1.]])

RENDERIZACION

En el método render se envía la rotación y traslación para dibujarlos en la pantalla donde


corresponde

render(R @ T)

REPRESENTACION

También podría gustarte