Open GL - Cómo podría graficar esta figura en glut openGL?

 
Vista:
sin imagen de perfil
Val: 2
Ha mantenido su posición en Open GL (en relación al último mes)
Gráfica de Open GL

Cómo podría graficar esta figura en glut openGL?

Publicado por Urzu23 (1 intervención) el 14/01/2021 20:46:11
Cómo podría graficar una cabeza clava que está en la imagen del centro en openGL glut, por más que trato solo me sale lo del código. ¿Alguien podría ayudarme por favor a completarlo?.




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include <windows.h>
#include <GL/glut.h>
#include<cmath>
 
 
#include <stdlib.h>
 
void inicio()
{
    glMatrixMode(GL_PROJECTION);
    gluOrtho2D(-20,20,-20,20);
    glClearColor(1,1,1,0);
}
 
 
void lineas(double x,double y,double x1,double y1, double grosor,float *color){
    glLineWidth(grosor);
    glColor3fv(color);
 
    glBegin(GL_LINE_STRIP);
    glVertex2d(x,y);
    glVertex2d(x1,y1);
    glEnd();
}
 
 
void circulo2(float x1,float y1, float a, float b,float angulo1, float angulo2,float *C){
 
glColor3fv(C);
float x,y;
 
glBegin(GL_TRIANGLE_FAN);
 
glVertex2d(x1,y1);
 
for(float Theta=angulo1;Theta<angulo2;Theta=Theta+0.00005){
    x=a*cos(Theta);
    y=b*sin(Theta);
    glVertex2d(x+x1,y+y1);
}
 
glEnd();
 
 
 
}
 
 
void display(void)
{
   //glClearColor(1,1,1,1);
 
glClear(GL_COLOR_BUFFER_BIT);
 
 
float negro[] ={0,0,0};
float plomo[] ={0.5,0.5,0.5};
float plomo1[] ={0.32,0.33,0.3};
float plomo2[] ={0.37,0.38,0.33};
 
 
circulo2(0,0,10,8,0,2*M_PI,plomo);
//******************************
circulo2(5,2,2.2,2.2,0,2*M_PI,negro);
circulo2(5,2,2,2,0,2*M_PI,plomo2);
 
circulo2(-5,2,2.2,2.2,0,2*M_PI,negro);
circulo2(-5,2,2,2,0,2*M_PI,plomo2);
 
circulo2(5,1.5,1.6,1.6,0,2*M_PI,negro);
circulo2(5,1.5,1.5,1.5,0,2*M_PI,plomo1);
circulo2(-5,1.5,1.6,1.6,0,2*M_PI,negro);
circulo2(-5,1.5,1.5,1.5,0,2*M_PI,plomo1);
 
circulo2(5.3,1.3,0.9,0.9,0,2*M_PI,negro);
circulo2(-5.3,1.3,0.9,0.9,0,2*M_PI,negro);
 
lineas(-3.5,3.5,3.5,3.5,3,negro);
 
circulo2(8,0.7,1.5,1,0,2*M_PI,plomo2);
circulo2(7.5,2,0.8,1,0,2*M_PI,plomo2);
circulo2(9.2,1.8,0.6,0.6,0,2*M_PI,plomo2);
 
//***********************************
glColor3f(0.32,0.33,0.3);
glBegin(GL_POLYGON);
 
   for(float theta=0*M_PI;theta<2*M_PI;theta=theta+0.0001)
   {
       glVertex2f((sin(theta)*sqrt(abs(cos(theta)))/(sin(theta) + 7/5.0)-2*sin(theta)+2)*cos(theta),(sin(theta)*sqrt(abs(cos(theta)))/(sin(theta)+7.0/5.0)-2*sin(theta)+2)*sin(theta));
       //glVertex2f(12*sin(theta)-4*sin(3*theta),12*cos(theta)-5*cos(2*theta)-2*cos(3*theta)-cos(4*theta));
   }
glEnd();
 
 
circulo2(-1,-2,0.7,0.7,0,2*M_PI,negro);
circulo2(-1,-2,0.6,0.6,0,2*M_PI,plomo1);
 
circulo2(1,-2,0.7,0.7,0,2*M_PI,negro);
circulo2(1,-2,0.6,0.6,0,2*M_PI,plomo1);
 
 
 
glPushMatrix();
glTranslated(3,-0.5,0);
glColor3f(0.5,0.5,0.5);
glBegin(GL_POLYGON);
glVertex2d(-5,-5);
glVertex2d(-5,-1);
glVertex2d(-3,-2);
glVertex2d(-1,-1);
glVertex2d(-1,-5);
glEnd();
lineas(-2.85,1,-2.85,4,2,plomo1);
glPopMatrix();
 
 
 
 
 
 
 
//*******************************************
 
glutSwapBuffers();
 
}
 
int main(int argc, char *argv[])
{
    glutInit(&argc, argv); //Inicializa la ventana
    glutInitWindowSize(800,900); //Tamaño de la ventana
    glutInitWindowPosition(10,10); //Posición de la ventana
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
 
    glutCreateWindow("DIBUJANDO CIRCULOS");
    inicio();
    // glutReshapeFunc(resize);
    glutDisplayFunc(display); //Evento renderizado
    // glutKeyboardFunc(key);
    //glutIdleFunc(idle);
 
    glutMainLoop();
 
    return EXIT_SUCCESS;
}
[/code]
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder