23 double posX, posY, posZ;
27 double projection[16];
29 glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
30 glGetDoublev(GL_PROJECTION_MATRIX, projection);
31 glGetIntegerv(GL_VIEWPORT, viewport);
34 glColor4f(0.0f, 0.0f, 0.0f, 0.001f);
37 glVertex3f(-100.0f, -100.0f, 0.0f);
39 gluProject(-100.0, -100.0, 0.00, modelview, projection, viewport,
40 &wwinX, &wwinY, &wwinZ);
42 winY = (float) viewport[3] - (
float) y;
43 gluUnProject(winX, winY, wwinZ, modelview, projection, viewport, &posX,
57 double posX, posY, posZ;
58 double posXX, posYY, posZZ;
62 double projection[16];
65 glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
66 glGetDoublev(GL_PROJECTION_MATRIX, projection);
67 glGetIntegerv(GL_VIEWPORT, viewport);
70 glColor4f(0.0f, 0.0f, 0.0f, 0.001f);
73 glVertex3f(10.0f, 10.0f, 1.0f);
75 gluProject(10.0, 10.0, 1.00, modelview, projection, viewport, &wwinX,
78 const float y = 50.0f;
80 winY = (float) viewport[3] - y;
81 gluUnProject(winX, winY, wwinZ, modelview, projection, viewport, &posX,
85 winY = (float) viewport[3] - y;
86 gluUnProject(winX, winY, wwinZ, modelview, projection, viewport,
87 &posXX, &posYY, &posZZ);
88 return ((
float) (posXX - posX));
100void to3D(
int x,
int y,
float *
X,
float *
Y,
float *Z) {
101 int const WIDTH = 20;
104 double modelview[16];
105 double projection[16];
108 double posX, posY, posZ;
111 glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
112 glGetDoublev(GL_PROJECTION_MATRIX, projection);
113 glGetIntegerv(GL_VIEWPORT, viewport);
116 winY = (float) viewport[3] - (
float) y;
119 GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);
120 float comp = -9999999;
122 if (winZ[idx] > comp && winZ[idx] < 1)
126 gluUnProject(winX, winY, comp, modelview, projection, viewport, &posX,
147 return p.
x * q.
x + p.
y * q.
y + p.
z * q.
z;
152 return sqrt(
dot(p, p));
159 r.
x = p.
x + m * (q.
x - p.
x);
160 r.
y = p.
y + m * (q.
y - p.
y);
161 r.
z = p.
z + m * (q.
z - p.
z);
183 U = (float) (
dot(pa, ba) /
dot(ba, ba));
208 borderWidth =
parent->borderWidth;
212 ref->width =
parent->width - 2.0f *borderWidth;
214 ref->height =
parent->height - 2.0f *borderWidth;;
218 ref->pos.x =
parent->refPos.x +
ref->pos.x + borderWidth;
219 ref->pos.y =
parent->refPos.y +
ref->pos.y + borderWidth;
222 switch (child->
align) {
224 ref->pos.x =
parent->refPos.x + borderWidth;
225 ref->pos.y =
parent->refPos.y + borderWidth;
226 ref->height =
parent->height - 2.0f * borderWidth;
231 ref->pos.y =
parent->refPos.y + borderWidth;
232 ref->height =
parent->height - 2.0f * borderWidth;
240 ref->width =
parent->width - 2.0f * borderWidth;
244 ref->pos.y =
parent->refPos.y + borderWidth;
245 ref->pos.x =
parent->refPos.x + borderWidth;
246 ref->width =
parent->width - 2.0f * borderWidth;
249 ref->pos.y =
parent->refPos.y + borderWidth;
250 ref->pos.x =
parent->refPos.x + borderWidth;;
251 ref->width =
parent->width - 2.0f * borderWidth;;
252 ref->height =
parent->height - 2.0f * borderWidth;
288 glVertex3f(p0->
x, p0->
y, p0->
z);
289 glVertex3f(p1->
x, p1->
y, p1->
z);
290 glVertex3f(p2->
x, p2->
y, p2->
z);
291 glVertex3f(p3->
x, p3->
y, p3->
z);
316 color_fac = 1.0f / 1.3f;
347 glColor4f(c->
R * color_fac *
dim, c->
G * color_fac *
dim,
348 c->
B * color_fac *
dim, c->
A);
352 glColor4f(c->
R / color_fac *
dim, c->
G / color_fac *
dim,
353 c->
B / color_fac *
dim, c->
A);
361 float rv = (
A.x -
B.x) * (
A.x -
B.x) + (
A.y -
B.y) * (
A.y -
B.y) + (
A.z -
B.z) * (
A.z -
B.z);
370 if (
X >= RX && X <= RX + RW && Y >= RY &&
Y <= RY + RH)
#define X(prefix, name, str, type, subtype,...)
int GetOGLPosRef(int x, int y, float *X, float *Y)
float GetOGLDistance(float l)
static double len(glCompPoint p)
void glCompDrawRectangle(glCompRect *r)
float distBetweenPts(glCompPoint A, glCompPoint B, float R)
void glCompCalcWidget(glCompCommon *parent, glCompCommon *child, glCompCommon *ref)
int is_point_in_rectangle(float X, float Y, float RX, float RY, float RW, float RH)
void glCompDrawRectPrism(glCompPoint *p, float w, float h, float b, float d, glCompColor *c, bool bumped)
static double dist(glCompPoint p, glCompPoint q)
static void glCompQuadVertex(glCompPoint *p0, glCompPoint *p1, glCompPoint *p2, glCompPoint *p3)
void to3D(int x, int y, float *X, float *Y, float *Z)
double point_to_lineseg_dist(glCompPoint p, glCompPoint a, glCompPoint b)
static glCompPoint blend(glCompPoint p, glCompPoint q, float m)
void glCompSetColor(glCompColor c)