-
Notifications
You must be signed in to change notification settings - Fork 8
/
drawing.cpp
92 lines (74 loc) · 1.49 KB
/
drawing.cpp
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
/*
* drawing.cpp
* lorenz
*
* Created by McK on 17/02/10.
* Copyright 2010 __MyCompanyName__. All rights reserved.
*
*/
#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/CGLDevice.h>
#include <GLUT/glut.h>
#elif __linux__
#include <GL/glut.h>
#endif
#include "drawing.h"
void GetColour(double v,double vmin,double vmax, COLOUR *c)
{
c->r = 1.0;
c->g = 1.0;
c->b = 1.0;
if (v < vmin)
v = vmin;
if (v > vmax)
v = vmax;
double dv = vmax - vmin;
if (v < (vmin + 0.25 * dv)) {
c->r = 0;
c->g = 4 * (v - vmin) / dv;
} else if (v < (vmin + 0.5 * dv)) {
c->r = 0;
c->b = 1 + 4 * (vmin + 0.25 * dv - v) / dv;
} else if (v < (vmin + 0.75 * dv)) {
c->r = 4 * (v - vmin - 0.5 * dv) / dv;
c->b = 0;
} else {
c->g = 1 + 4 * (vmin + 0.75 * dv - v) / dv;
c->b = 0;
}
}
void drawCoords() {
glColor4f(1, 0, 0, 1);
glBegin(GL_LINES);
glVertex3f(0, 0, 0);
glVertex3f(1, 0, 0);
glEnd();
glColor4f(0, 1, 0, 1);
glBegin(GL_LINES);
glVertex3f(0, 0, 0);
glVertex3f(0, 1, 0);
glEnd();
glColor4f(0, 0, 1, 1);
glBegin(GL_LINES);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
glEnd();
glColor4f(1,0,0,1);
//glutSolidSphere(1, 20, 20);
}
void drawText(char *cadena, float x, float y, float z)
{
char *c;
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glColor4f(1,1,1,1);
glRasterPos3f(x, y, z);
for (c = cadena; *c; c++)
{
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *c);
}
//glEnable(GL_LIGHTING);
//glEnable(GL_DEPTH_TEST);
}