Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
03c5ab2e
Commit
03c5ab2e
authored
Apr 14, 2017
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
glu32: Import projection functions from Mesa.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
70993531
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
336 additions
and
73 deletions
+336
-73
Makefile.in
dlls/glu32/Makefile.in
+3
-1
glu.c
dlls/glu32/glu.c
+0
-66
glu32.spec
dlls/glu32/glu32.spec
+6
-6
project.c
dlls/glu32/project.c
+327
-0
No files found.
dlls/glu32/Makefile.in
View file @
03c5ab2e
MODULE
=
glu32.dll
MODULE
=
glu32.dll
IMPORTLIB
=
glu32
IMPORTLIB
=
glu32
IMPORTS
=
opengl32
C_SRCS
=
\
C_SRCS
=
\
glu.c
glu.c
\
project.c
dlls/glu32/glu.c
View file @
03c5ab2e
...
@@ -136,7 +136,6 @@ static void (*p_gluEndTrim)( GLUnurbs* nurb );
...
@@ -136,7 +136,6 @@ static void (*p_gluEndTrim)( GLUnurbs* nurb );
static
void
(
*
p_gluGetNurbsProperty
)(
GLUnurbs
*
nurb
,
GLenum
property
,
GLfloat
*
data
);
static
void
(
*
p_gluGetNurbsProperty
)(
GLUnurbs
*
nurb
,
GLenum
property
,
GLfloat
*
data
);
static
void
(
*
p_gluGetTessProperty
)(
GLUtesselator
*
tess
,
GLenum
which
,
GLdouble
*
data
);
static
void
(
*
p_gluGetTessProperty
)(
GLUtesselator
*
tess
,
GLenum
which
,
GLdouble
*
data
);
static
void
(
*
p_gluLoadSamplingMatrices
)(
GLUnurbs
*
nurb
,
const
GLfloat
*
model
,
const
GLfloat
*
perspective
,
const
GLint
*
view
);
static
void
(
*
p_gluLoadSamplingMatrices
)(
GLUnurbs
*
nurb
,
const
GLfloat
*
model
,
const
GLfloat
*
perspective
,
const
GLint
*
view
);
static
void
(
*
p_gluLookAt
)(
GLdouble
eyeX
,
GLdouble
eyeY
,
GLdouble
eyeZ
,
GLdouble
centerX
,
GLdouble
centerY
,
GLdouble
centerZ
,
GLdouble
upX
,
GLdouble
upY
,
GLdouble
upZ
);
static
GLUnurbs
*
(
*
p_gluNewNurbsRenderer
)(
void
);
static
GLUnurbs
*
(
*
p_gluNewNurbsRenderer
)(
void
);
static
GLUquadric
*
(
*
p_gluNewQuadric
)(
void
);
static
GLUquadric
*
(
*
p_gluNewQuadric
)(
void
);
static
GLUtesselator
*
(
*
p_gluNewTess
)(
void
);
static
GLUtesselator
*
(
*
p_gluNewTess
)(
void
);
...
@@ -144,11 +143,7 @@ static void (*p_gluNurbsCallback)( GLUnurbs* nurb, GLenum which, _GLUfuncptr Ca
...
@@ -144,11 +143,7 @@ static void (*p_gluNurbsCallback)( GLUnurbs* nurb, GLenum which, _GLUfuncptr Ca
static
void
(
*
p_gluNurbsCurve
)(
GLUnurbs
*
nurb
,
GLint
knotCount
,
GLfloat
*
knots
,
GLint
stride
,
GLfloat
*
control
,
GLint
order
,
GLenum
type
);
static
void
(
*
p_gluNurbsCurve
)(
GLUnurbs
*
nurb
,
GLint
knotCount
,
GLfloat
*
knots
,
GLint
stride
,
GLfloat
*
control
,
GLint
order
,
GLenum
type
);
static
void
(
*
p_gluNurbsProperty
)(
GLUnurbs
*
nurb
,
GLenum
property
,
GLfloat
value
);
static
void
(
*
p_gluNurbsProperty
)(
GLUnurbs
*
nurb
,
GLenum
property
,
GLfloat
value
);
static
void
(
*
p_gluNurbsSurface
)(
GLUnurbs
*
nurb
,
GLint
sKnotCount
,
GLfloat
*
sKnots
,
GLint
tKnotCount
,
GLfloat
*
tKnots
,
GLint
sStride
,
GLint
tStride
,
GLfloat
*
control
,
GLint
sOrder
,
GLint
tOrder
,
GLenum
type
);
static
void
(
*
p_gluNurbsSurface
)(
GLUnurbs
*
nurb
,
GLint
sKnotCount
,
GLfloat
*
sKnots
,
GLint
tKnotCount
,
GLfloat
*
tKnots
,
GLint
sStride
,
GLint
tStride
,
GLfloat
*
control
,
GLint
sOrder
,
GLint
tOrder
,
GLenum
type
);
static
void
(
*
p_gluOrtho2D
)(
GLdouble
left
,
GLdouble
right
,
GLdouble
bottom
,
GLdouble
top
);
static
void
(
*
p_gluPartialDisk
)(
GLUquadric
*
quad
,
GLdouble
inner
,
GLdouble
outer
,
GLint
slices
,
GLint
loops
,
GLdouble
start
,
GLdouble
sweep
);
static
void
(
*
p_gluPartialDisk
)(
GLUquadric
*
quad
,
GLdouble
inner
,
GLdouble
outer
,
GLint
slices
,
GLint
loops
,
GLdouble
start
,
GLdouble
sweep
);
static
void
(
*
p_gluPerspective
)(
GLdouble
fovy
,
GLdouble
aspect
,
GLdouble
zNear
,
GLdouble
zFar
);
static
void
(
*
p_gluPickMatrix
)(
GLdouble
x
,
GLdouble
y
,
GLdouble
delX
,
GLdouble
delY
,
GLint
*
viewport
);
static
GLint
(
*
p_gluProject
)(
GLdouble
objX
,
GLdouble
objY
,
GLdouble
objZ
,
const
GLdouble
*
model
,
const
GLdouble
*
proj
,
const
GLint
*
view
,
GLdouble
*
winX
,
GLdouble
*
winY
,
GLdouble
*
winZ
);
static
void
(
*
p_gluPwlCurve
)(
GLUnurbs
*
nurb
,
GLint
count
,
GLfloat
*
data
,
GLint
stride
,
GLenum
type
);
static
void
(
*
p_gluPwlCurve
)(
GLUnurbs
*
nurb
,
GLint
count
,
GLfloat
*
data
,
GLint
stride
,
GLenum
type
);
static
void
(
*
p_gluQuadricCallback
)(
GLUquadric
*
quad
,
GLenum
which
,
_GLUfuncptr
CallBackFunc
);
static
void
(
*
p_gluQuadricCallback
)(
GLUquadric
*
quad
,
GLenum
which
,
_GLUfuncptr
CallBackFunc
);
static
void
(
*
p_gluQuadricDrawStyle
)(
GLUquadric
*
quad
,
GLenum
draw
);
static
void
(
*
p_gluQuadricDrawStyle
)(
GLUquadric
*
quad
,
GLenum
draw
);
...
@@ -165,7 +160,6 @@ static void (*p_gluTessEndPolygon)( GLUtesselator* tess );
...
@@ -165,7 +160,6 @@ static void (*p_gluTessEndPolygon)( GLUtesselator* tess );
static
void
(
*
p_gluTessNormal
)(
GLUtesselator
*
tess
,
GLdouble
valueX
,
GLdouble
valueY
,
GLdouble
valueZ
);
static
void
(
*
p_gluTessNormal
)(
GLUtesselator
*
tess
,
GLdouble
valueX
,
GLdouble
valueY
,
GLdouble
valueZ
);
static
void
(
*
p_gluTessProperty
)(
GLUtesselator
*
tess
,
GLenum
which
,
GLdouble
data
);
static
void
(
*
p_gluTessProperty
)(
GLUtesselator
*
tess
,
GLenum
which
,
GLdouble
data
);
static
void
(
*
p_gluTessVertex
)(
GLUtesselator
*
tess
,
GLdouble
*
location
,
GLvoid
*
data
);
static
void
(
*
p_gluTessVertex
)(
GLUtesselator
*
tess
,
GLdouble
*
location
,
GLvoid
*
data
);
static
GLint
(
*
p_gluUnProject
)(
GLdouble
winX
,
GLdouble
winY
,
GLdouble
winZ
,
const
GLdouble
*
model
,
const
GLdouble
*
proj
,
const
GLint
*
view
,
GLdouble
*
objX
,
GLdouble
*
objY
,
GLdouble
*
objZ
);
static
void
*
libglu_handle
;
static
void
*
libglu_handle
;
static
INIT_ONCE
init_once
=
INIT_ONCE_STATIC_INIT
;
static
INIT_ONCE
init_once
=
INIT_ONCE_STATIC_INIT
;
...
@@ -198,66 +192,6 @@ static void *load_glufunc( const char *name )
...
@@ -198,66 +192,6 @@ static void *load_glufunc( const char *name )
/***********************************************************************
/***********************************************************************
* gluLookAt (GLU32.@)
*/
void
WINAPI
wine_gluLookAt
(
GLdouble
eyex
,
GLdouble
eyey
,
GLdouble
eyez
,
GLdouble
centerx
,
GLdouble
centery
,
GLdouble
centerz
,
GLdouble
upx
,
GLdouble
upy
,
GLdouble
upz
)
{
if
(
!
LOAD_FUNCPTR
(
gluLookAt
))
return
;
p_gluLookAt
(
eyex
,
eyey
,
eyez
,
centerx
,
centery
,
centerz
,
upx
,
upy
,
upz
);
}
/***********************************************************************
* gluOrtho2D (GLU32.@)
*/
void
WINAPI
wine_gluOrtho2D
(
GLdouble
left
,
GLdouble
right
,
GLdouble
bottom
,
GLdouble
top
)
{
if
(
!
LOAD_FUNCPTR
(
gluOrtho2D
))
return
;
p_gluOrtho2D
(
left
,
right
,
bottom
,
top
);
}
/***********************************************************************
* gluPerspective (GLU32.@)
*/
void
WINAPI
wine_gluPerspective
(
GLdouble
fovy
,
GLdouble
aspect
,
GLdouble
zNear
,
GLdouble
zFar
)
{
if
(
!
LOAD_FUNCPTR
(
gluPerspective
))
return
;
p_gluPerspective
(
fovy
,
aspect
,
zNear
,
zFar
);
}
/***********************************************************************
* gluPickMatrix (GLU32.@)
*/
void
WINAPI
wine_gluPickMatrix
(
GLdouble
x
,
GLdouble
y
,
GLdouble
width
,
GLdouble
height
,
GLint
viewport
[
4
])
{
if
(
!
LOAD_FUNCPTR
(
gluPickMatrix
))
return
;
p_gluPickMatrix
(
x
,
y
,
width
,
height
,
viewport
);
}
/***********************************************************************
* gluProject (GLU32.@)
*/
int
WINAPI
wine_gluProject
(
GLdouble
objx
,
GLdouble
objy
,
GLdouble
objz
,
const
GLdouble
modelMatrix
[
16
],
const
GLdouble
projMatrix
[
16
],
const
GLint
viewport
[
4
],
GLdouble
*
winx
,
GLdouble
*
winy
,
GLdouble
*
winz
)
{
if
(
!
LOAD_FUNCPTR
(
gluProject
))
return
GLU_FALSE
;
return
p_gluProject
(
objx
,
objy
,
objz
,
modelMatrix
,
projMatrix
,
viewport
,
winx
,
winy
,
winz
);
}
/***********************************************************************
* gluUnProject (GLU32.@)
*/
int
WINAPI
wine_gluUnProject
(
GLdouble
winx
,
GLdouble
winy
,
GLdouble
winz
,
const
GLdouble
modelMatrix
[
16
],
const
GLdouble
projMatrix
[
16
],
const
GLint
viewport
[
4
],
GLdouble
*
objx
,
GLdouble
*
objy
,
GLdouble
*
objz
)
{
if
(
!
LOAD_FUNCPTR
(
gluUnProject
))
return
GLU_FALSE
;
return
p_gluUnProject
(
winx
,
winy
,
winz
,
modelMatrix
,
projMatrix
,
viewport
,
objx
,
objy
,
objz
);
}
/***********************************************************************
* gluErrorString (GLU32.@)
* gluErrorString (GLU32.@)
*/
*/
const
GLubyte
*
WINAPI
wine_gluErrorString
(
GLenum
errCode
)
const
GLubyte
*
WINAPI
wine_gluErrorString
(
GLenum
errCode
)
...
...
dlls/glu32/glu32.spec
View file @
03c5ab2e
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
@ stdcall gluGetString(long) wine_gluGetString
@ stdcall gluGetString(long) wine_gluGetString
@ stdcall gluGetTessProperty(ptr long ptr) wine_gluGetTessProperty
@ stdcall gluGetTessProperty(ptr long ptr) wine_gluGetTessProperty
@ stdcall gluLoadSamplingMatrices(ptr ptr ptr ptr) wine_gluLoadSamplingMatrices
@ stdcall gluLoadSamplingMatrices(ptr ptr ptr ptr) wine_gluLoadSamplingMatrices
@ stdcall gluLookAt(double double double double double double double double double)
wine_gluLookAt
@ stdcall gluLookAt(double double double double double double double double double)
@ stdcall gluNewNurbsRenderer() wine_gluNewNurbsRenderer
@ stdcall gluNewNurbsRenderer() wine_gluNewNurbsRenderer
@ stdcall gluNewQuadric() wine_gluNewQuadric
@ stdcall gluNewQuadric() wine_gluNewQuadric
@ stdcall gluNewTess() wine_gluNewTess
@ stdcall gluNewTess() wine_gluNewTess
...
@@ -29,11 +29,11 @@
...
@@ -29,11 +29,11 @@
@ stdcall gluNurbsCurve(ptr long ptr long ptr long long) wine_gluNurbsCurve
@ stdcall gluNurbsCurve(ptr long ptr long ptr long long) wine_gluNurbsCurve
@ stdcall gluNurbsProperty(ptr long long) wine_gluNurbsProperty
@ stdcall gluNurbsProperty(ptr long long) wine_gluNurbsProperty
@ stdcall gluNurbsSurface(ptr long ptr long ptr long long ptr long long long) wine_gluNurbsSurface
@ stdcall gluNurbsSurface(ptr long ptr long ptr long long ptr long long long) wine_gluNurbsSurface
@ stdcall gluOrtho2D(double double double double)
wine_gluOrtho2D
@ stdcall gluOrtho2D(double double double double)
@ stdcall gluPartialDisk(ptr double double long long double double) wine_gluPartialDisk
@ stdcall gluPartialDisk(ptr double double long long double double) wine_gluPartialDisk
@ stdcall gluPerspective(double double double double)
wine_gluPerspective
@ stdcall gluPerspective(double double double double)
@ stdcall gluPickMatrix(double double double double ptr)
wine_gluPickMatrix
@ stdcall gluPickMatrix(double double double double ptr)
@ stdcall gluProject(double double double ptr ptr ptr ptr ptr ptr)
wine_gluProject
@ stdcall gluProject(double double double ptr ptr ptr ptr ptr ptr)
@ stdcall gluPwlCurve(ptr long ptr long long) wine_gluPwlCurve
@ stdcall gluPwlCurve(ptr long ptr long long) wine_gluPwlCurve
@ stdcall gluQuadricCallback(ptr long ptr) wine_gluQuadricCallback
@ stdcall gluQuadricCallback(ptr long ptr) wine_gluQuadricCallback
@ stdcall gluQuadricDrawStyle(ptr long) wine_gluQuadricDrawStyle
@ stdcall gluQuadricDrawStyle(ptr long) wine_gluQuadricDrawStyle
...
@@ -50,4 +50,4 @@
...
@@ -50,4 +50,4 @@
@ stdcall gluTessNormal(ptr double double double) wine_gluTessNormal
@ stdcall gluTessNormal(ptr double double double) wine_gluTessNormal
@ stdcall gluTessProperty(ptr long double) wine_gluTessProperty
@ stdcall gluTessProperty(ptr long double) wine_gluTessProperty
@ stdcall gluTessVertex(ptr ptr ptr) wine_gluTessVertex
@ stdcall gluTessVertex(ptr ptr ptr) wine_gluTessVertex
@ stdcall gluUnProject(double double double ptr ptr ptr ptr ptr ptr)
wine_gluUnProject
@ stdcall gluUnProject(double double double ptr ptr ptr ptr ptr ptr)
dlls/glu32/project.c
0 → 100644
View file @
03c5ab2e
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
#include "config.h"
#include "wine/port.h"
#include <math.h>
#include "windef.h"
#include "wine/wgl.h"
#include "wine/glu.h"
/*
** Make m an identity matrix
*/
static
void
__gluMakeIdentityd
(
GLdouble
m
[
16
])
{
m
[
0
+
4
*
0
]
=
1
;
m
[
0
+
4
*
1
]
=
0
;
m
[
0
+
4
*
2
]
=
0
;
m
[
0
+
4
*
3
]
=
0
;
m
[
1
+
4
*
0
]
=
0
;
m
[
1
+
4
*
1
]
=
1
;
m
[
1
+
4
*
2
]
=
0
;
m
[
1
+
4
*
3
]
=
0
;
m
[
2
+
4
*
0
]
=
0
;
m
[
2
+
4
*
1
]
=
0
;
m
[
2
+
4
*
2
]
=
1
;
m
[
2
+
4
*
3
]
=
0
;
m
[
3
+
4
*
0
]
=
0
;
m
[
3
+
4
*
1
]
=
0
;
m
[
3
+
4
*
2
]
=
0
;
m
[
3
+
4
*
3
]
=
1
;
}
static
void
__gluMakeIdentityf
(
GLfloat
m
[
16
])
{
m
[
0
+
4
*
0
]
=
1
;
m
[
0
+
4
*
1
]
=
0
;
m
[
0
+
4
*
2
]
=
0
;
m
[
0
+
4
*
3
]
=
0
;
m
[
1
+
4
*
0
]
=
0
;
m
[
1
+
4
*
1
]
=
1
;
m
[
1
+
4
*
2
]
=
0
;
m
[
1
+
4
*
3
]
=
0
;
m
[
2
+
4
*
0
]
=
0
;
m
[
2
+
4
*
1
]
=
0
;
m
[
2
+
4
*
2
]
=
1
;
m
[
2
+
4
*
3
]
=
0
;
m
[
3
+
4
*
0
]
=
0
;
m
[
3
+
4
*
1
]
=
0
;
m
[
3
+
4
*
2
]
=
0
;
m
[
3
+
4
*
3
]
=
1
;
}
/***********************************************************************
* gluOrtho2D (GLU32.@)
*/
void
WINAPI
gluOrtho2D
(
GLdouble
left
,
GLdouble
right
,
GLdouble
bottom
,
GLdouble
top
)
{
glOrtho
(
left
,
right
,
bottom
,
top
,
-
1
,
1
);
}
/***********************************************************************
* gluPerspective (GLU32.@)
*/
void
WINAPI
gluPerspective
(
GLdouble
fovy
,
GLdouble
aspect
,
GLdouble
zNear
,
GLdouble
zFar
)
{
GLdouble
m
[
4
][
4
];
double
sine
,
cotangent
,
deltaZ
;
double
radians
=
fovy
/
2
*
M_PI
/
180
;
deltaZ
=
zFar
-
zNear
;
sine
=
sin
(
radians
);
if
((
deltaZ
==
0
)
||
(
sine
==
0
)
||
(
aspect
==
0
))
{
return
;
}
cotangent
=
cos
(
radians
)
/
sine
;
__gluMakeIdentityd
(
&
m
[
0
][
0
]);
m
[
0
][
0
]
=
cotangent
/
aspect
;
m
[
1
][
1
]
=
cotangent
;
m
[
2
][
2
]
=
-
(
zFar
+
zNear
)
/
deltaZ
;
m
[
2
][
3
]
=
-
1
;
m
[
3
][
2
]
=
-
2
*
zNear
*
zFar
/
deltaZ
;
m
[
3
][
3
]
=
0
;
glMultMatrixd
(
&
m
[
0
][
0
]);
}
static
void
normalize
(
float
v
[
3
])
{
float
r
;
r
=
sqrt
(
v
[
0
]
*
v
[
0
]
+
v
[
1
]
*
v
[
1
]
+
v
[
2
]
*
v
[
2
]
);
if
(
r
==
0
.
0
)
return
;
v
[
0
]
/=
r
;
v
[
1
]
/=
r
;
v
[
2
]
/=
r
;
}
static
void
cross
(
float
v1
[
3
],
float
v2
[
3
],
float
result
[
3
])
{
result
[
0
]
=
v1
[
1
]
*
v2
[
2
]
-
v1
[
2
]
*
v2
[
1
];
result
[
1
]
=
v1
[
2
]
*
v2
[
0
]
-
v1
[
0
]
*
v2
[
2
];
result
[
2
]
=
v1
[
0
]
*
v2
[
1
]
-
v1
[
1
]
*
v2
[
0
];
}
/***********************************************************************
* gluLookAt (GLU32.@)
*/
void
WINAPI
gluLookAt
(
GLdouble
eyex
,
GLdouble
eyey
,
GLdouble
eyez
,
GLdouble
centerx
,
GLdouble
centery
,
GLdouble
centerz
,
GLdouble
upx
,
GLdouble
upy
,
GLdouble
upz
)
{
float
forward
[
3
],
side
[
3
],
up
[
3
];
GLfloat
m
[
4
][
4
];
forward
[
0
]
=
centerx
-
eyex
;
forward
[
1
]
=
centery
-
eyey
;
forward
[
2
]
=
centerz
-
eyez
;
up
[
0
]
=
upx
;
up
[
1
]
=
upy
;
up
[
2
]
=
upz
;
normalize
(
forward
);
/* Side = forward x up */
cross
(
forward
,
up
,
side
);
normalize
(
side
);
/* Recompute up as: up = side x forward */
cross
(
side
,
forward
,
up
);
__gluMakeIdentityf
(
&
m
[
0
][
0
]);
m
[
0
][
0
]
=
side
[
0
];
m
[
1
][
0
]
=
side
[
1
];
m
[
2
][
0
]
=
side
[
2
];
m
[
0
][
1
]
=
up
[
0
];
m
[
1
][
1
]
=
up
[
1
];
m
[
2
][
1
]
=
up
[
2
];
m
[
0
][
2
]
=
-
forward
[
0
];
m
[
1
][
2
]
=
-
forward
[
1
];
m
[
2
][
2
]
=
-
forward
[
2
];
glMultMatrixf
(
&
m
[
0
][
0
]);
glTranslated
(
-
eyex
,
-
eyey
,
-
eyez
);
}
static
void
__gluMultMatrixVecd
(
const
GLdouble
matrix
[
16
],
const
GLdouble
in
[
4
],
GLdouble
out
[
4
])
{
int
i
;
for
(
i
=
0
;
i
<
4
;
i
++
)
{
out
[
i
]
=
in
[
0
]
*
matrix
[
0
*
4
+
i
]
+
in
[
1
]
*
matrix
[
1
*
4
+
i
]
+
in
[
2
]
*
matrix
[
2
*
4
+
i
]
+
in
[
3
]
*
matrix
[
3
*
4
+
i
];
}
}
/*
** Invert 4x4 matrix.
** Contributed by David Moore (See Mesa bug #6748)
*/
static
int
__gluInvertMatrixd
(
const
GLdouble
m
[
16
],
GLdouble
invOut
[
16
])
{
double
inv
[
16
],
det
;
int
i
;
inv
[
0
]
=
m
[
5
]
*
m
[
10
]
*
m
[
15
]
-
m
[
5
]
*
m
[
11
]
*
m
[
14
]
-
m
[
9
]
*
m
[
6
]
*
m
[
15
]
+
m
[
9
]
*
m
[
7
]
*
m
[
14
]
+
m
[
13
]
*
m
[
6
]
*
m
[
11
]
-
m
[
13
]
*
m
[
7
]
*
m
[
10
];
inv
[
4
]
=
-
m
[
4
]
*
m
[
10
]
*
m
[
15
]
+
m
[
4
]
*
m
[
11
]
*
m
[
14
]
+
m
[
8
]
*
m
[
6
]
*
m
[
15
]
-
m
[
8
]
*
m
[
7
]
*
m
[
14
]
-
m
[
12
]
*
m
[
6
]
*
m
[
11
]
+
m
[
12
]
*
m
[
7
]
*
m
[
10
];
inv
[
8
]
=
m
[
4
]
*
m
[
9
]
*
m
[
15
]
-
m
[
4
]
*
m
[
11
]
*
m
[
13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+
j
];
}
}
}
/***********************************************************************
* gluProject (GLU32.@)
*/
GLint
WINAPI
gluProject
(
GLdouble
objx
,
GLdouble
objy
,
GLdouble
objz
,
const
GLdouble
modelMatrix
[
16
],
const
GLdouble
projMatrix
[
16
],
const
GLint
viewport
[
4
],
GLdouble
*
winx
,
GLdouble
*
winy
,
GLdouble
*
winz
)
{
double
in
[
4
];
double
out
[
4
];
in
[
0
]
=
objx
;
in
[
1
]
=
objy
;
in
[
2
]
=
objz
;
in
[
3
]
=
1
.
0
;
__gluMultMatrixVecd
(
modelMatrix
,
in
,
out
);
__gluMultMatrixVecd
(
projMatrix
,
out
,
in
);
if
(
in
[
3
]
==
0
.
0
)
return
(
GL_FALSE
);
in
[
0
]
/=
in
[
3
];
in
[
1
]
/=
in
[
3
];
in
[
2
]
/=
in
[
3
];
/* Map x, y and z to range 0-1 */
in
[
0
]
=
in
[
0
]
*
0
.
5
+
0
.
5
;
in
[
1
]
=
in
[
1
]
*
0
.
5
+
0
.
5
;
in
[
2
]
=
in
[
2
]
*
0
.
5
+
0
.
5
;
/* Map x,y to viewport */
in
[
0
]
=
in
[
0
]
*
viewport
[
2
]
+
viewport
[
0
];
in
[
1
]
=
in
[
1
]
*
viewport
[
3
]
+
viewport
[
1
];
*
winx
=
in
[
0
];
*
winy
=
in
[
1
];
*
winz
=
in
[
2
];
return
(
GL_TRUE
);
}
/***********************************************************************
* gluUnProject (GLU32.@)
*/
GLint
WINAPI
gluUnProject
(
GLdouble
winx
,
GLdouble
winy
,
GLdouble
winz
,
const
GLdouble
modelMatrix
[
16
],
const
GLdouble
projMatrix
[
16
],
const
GLint
viewport
[
4
],
GLdouble
*
objx
,
GLdouble
*
objy
,
GLdouble
*
objz
)
{
double
finalMatrix
[
16
];
double
in
[
4
];
double
out
[
4
];
__gluMultMatricesd
(
modelMatrix
,
projMatrix
,
finalMatrix
);
if
(
!
__gluInvertMatrixd
(
finalMatrix
,
finalMatrix
))
return
(
GL_FALSE
);
in
[
0
]
=
winx
;
in
[
1
]
=
winy
;
in
[
2
]
=
winz
;
in
[
3
]
=
1
.
0
;
/* Map x and y from window coordinates */
in
[
0
]
=
(
in
[
0
]
-
viewport
[
0
])
/
viewport
[
2
];
in
[
1
]
=
(
in
[
1
]
-
viewport
[
1
])
/
viewport
[
3
];
/* Map to range -1 to 1 */
in
[
0
]
=
in
[
0
]
*
2
-
1
;
in
[
1
]
=
in
[
1
]
*
2
-
1
;
in
[
2
]
=
in
[
2
]
*
2
-
1
;
__gluMultMatrixVecd
(
finalMatrix
,
in
,
out
);
if
(
out
[
3
]
==
0
.
0
)
return
(
GL_FALSE
);
out
[
0
]
/=
out
[
3
];
out
[
1
]
/=
out
[
3
];
out
[
2
]
/=
out
[
3
];
*
objx
=
out
[
0
];
*
objy
=
out
[
1
];
*
objz
=
out
[
2
];
return
(
GL_TRUE
);
}
/***********************************************************************
* gluPickMatrix (GLU32.@)
*/
void
WINAPI
gluPickMatrix
(
GLdouble
x
,
GLdouble
y
,
GLdouble
deltax
,
GLdouble
deltay
,
GLint
viewport
[
4
]
)
{
if
(
deltax
<=
0
||
deltay
<=
0
)
{
return
;
}
/* Translate and scale the picked region to the entire window */
glTranslatef
((
viewport
[
2
]
-
2
*
(
x
-
viewport
[
0
]))
/
deltax
,
(
viewport
[
3
]
-
2
*
(
y
-
viewport
[
1
]))
/
deltay
,
0
);
glScalef
(
viewport
[
2
]
/
deltax
,
viewport
[
3
]
/
deltay
,
1
.
0
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment