Commit a9bdb75c authored by Eric Bruneton's avatar Eric Bruneton
Browse files

small API improvements and bug fixes

git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/ork/trunk@18 28599a00-4e59-401b-b2d8-d34d4661a6c9
parent d6787117
......@@ -28,6 +28,8 @@ variables:
- glut (base) : either glut32 or freeglut
- glut (cflags) : either USE_GLUT or USE_FREEGLUT
- glew : the path to the glew DLL, e.g. C:\Progra~1\glew\glew32.dll
You also need to set the "Explicitly add project's top-level directory to
compiler search dirs" options in "Global compiler settings/Other settings"
The USE_SHARED_PTR preprocessor flag can be set to use std::tr1::shared_ptr
(needs a compiler providing support for this). Otherwise smart pointers use
......
......@@ -186,6 +186,11 @@ public:
*/
type dotproduct(const vec4& v) const;
/**
* Returns the 3D vector defined by (x/w,y/w,z/w).
*/
vec3<type> xyzw() const;
/**
* Returns the 3D vector defined by (x,y,z).
*/
......@@ -447,6 +452,12 @@ inline type vec4<type>::dotproduct(const vec4<type>& v) const
return (x*v.x + y*v.y + z*v.z + w*v.w);
}
template <typename type>
inline vec3<type> vec4<type>::xyzw() const
{
return vec3<type>(x / w, y / w, z / w);
}
template <typename type>
inline vec3<type> vec4<type>::xyz() const
{
......
......@@ -67,6 +67,7 @@ GLuint Query::getId()
void Query::begin()
{
resultRead = false;
glBeginQuery(target, id);
if (target == GL_TIME_ELAPSED) {
glQueryCounter(id, GL_TIMESTAMP);
......
......@@ -375,16 +375,34 @@ ORK_API void getParameters(const ptr<ResourceDescriptor> desc, const TiXmlElemen
throw exception();
}
v = e->Attribute("wrapr");
if (v == NULL) {
// params.wrapR("CLAMP_TO_BORDER");
} else if (strcmp(v, "CLAMP_TO_EDGE") == 0) {
params.wrapR(CLAMP_TO_EDGE);
} else if (strcmp(v, "CLAMP_TO_BORDER") == 0) {
params.wrapR(CLAMP_TO_BORDER);
} else if (strcmp(v, "REPEAT") == 0) {
params.wrapR(REPEAT);
} else if (strcmp(v, "MIRRORED_REPEAT") == 0) {
params.wrapR(MIRRORED_REPEAT);
} else {
if (Logger::ERROR_LOGGER != NULL) {
Resource::log(Logger::ERROR_LOGGER, desc, e, "Bad wrap R attribute");
}
throw exception();
}
v = e->Attribute("borderType");
int borderType = 0;
if (v == NULL) {
} else if (strcmp(v, "INT")) {
} else if (strcmp(v, "INT") == 0) {
borderType = 0;
} else if (strcmp(v, "FLOAT")) {
} else if (strcmp(v, "FLOAT") == 0) {
borderType = 1;
} else if (strcmp(v, "IINT")) {
} else if (strcmp(v, "IINT") == 0) {
borderType = 2;
} else if (strcmp(v, "IUNSIGNED_INT")) {
} else if (strcmp(v, "IUNSIGNED_INT") == 0) {
borderType = 3;
} else {
if (Logger::ERROR_LOGGER != NULL) {
......@@ -418,12 +436,12 @@ ORK_API void getParameters(const ptr<ResourceDescriptor> desc, const TiXmlElemen
if (e->Attribute("minLevel") != NULL) {
float level;
Resource::getFloatParameter(desc, e, "minLevel", &level);
params.lodMin(level);
params.minLevel(level);
}
if (e->Attribute("maxLevel") != NULL) {
float level;
Resource::getFloatParameter(desc, e, "maxLevel", &level);
params.lodMax(level);
params.maxLevel(level);
}
if (e->Attribute("minLod") != NULL) {
float lod;
......@@ -449,21 +467,21 @@ ORK_API void getParameters(const ptr<ResourceDescriptor> desc, const TiXmlElemen
v = e->Attribute("compare");
if (v == NULL) {
} else if (strcmp(v, "LEQUAL")) {
} else if (strcmp(v, "LEQUAL") == 0) {
params.compareFunc(LEQUAL);
} else if (strcmp(v, "GEQUAL")) {
} else if (strcmp(v, "GEQUAL") == 0) {
params.compareFunc(GEQUAL);
} else if (strcmp(v, "LESS")) {
} else if (strcmp(v, "LESS") == 0) {
params.compareFunc(LESS);
} else if (strcmp(v, "GREATER")) {
} else if (strcmp(v, "GREATER") == 0) {
params.compareFunc(GREATER);
} else if (strcmp(v, "EQUAL")) {
} else if (strcmp(v, "EQUAL") == 0) {
params.compareFunc(EQUAL);
} else if (strcmp(v, "NOTEQUAL")) {
} else if (strcmp(v, "NOTEQUAL") == 0) {
params.compareFunc(NOTEQUAL);
} else if (strcmp(v, "ALWAYS")) {
} else if (strcmp(v, "ALWAYS") == 0) {
params.compareFunc(ALWAYS);
} else if (strcmp(v, "NEVER")) {
} else if (strcmp(v, "NEVER") == 0) {
params.compareFunc(NEVER);
} else {
if (Logger::ERROR_LOGGER != NULL) {
......
......@@ -154,7 +154,7 @@ public:
int w;
int h;
try {
checkParameters(desc, e, "name,source,internalformat,format,type,min,mag,wraps,wrapt,maxAniso,width,height,");
checkParameters(desc, e, "name,source,internalformat,format,type,min,mag,wraps,wrapt,compare,borderType,borderr,borderg,borderb,bordera,maxAniso,width,height,");
getIntParameter(desc, e, "width", &w);
getIntParameter(desc, e, "height", &h);
getParameters(desc, e, tf, f, t);
......
......@@ -150,7 +150,7 @@ public:
int h;
int l;
try {
checkParameters(desc, e, "name,source,internalformat,format,type,min,mag,wraps,wrapt,maxAniso,width,height,depth,layers,");
checkParameters(desc, e, "name,source,internalformat,format,type,min,mag,wraps,wrapt,compare,borderType,borderr,borderg,borderb,bordera,maxAniso,width,height,depth,layers,");
getIntParameter(desc, e, "width", &w);
getIntParameter(desc, e, "height", &h);
if (e->Attribute("depth") != NULL) {
......
......@@ -189,7 +189,7 @@ SceneManager::visibility SceneManager::getVisibility(const box3d &worldBounds)
return getVisibility(worldFrustumPlanes, worldBounds);
}
SceneManager::visibility SceneManager::getVisibility(const vec4d frustumPlanes[6], const box3d &b)
SceneManager::visibility SceneManager::getVisibility(const vec4d *frustumPlanes, const box3d &b)
{
visibility v0 = getVisibility(frustumPlanes[0], b);
if (v0 == INVISIBLE) {
......@@ -220,7 +220,7 @@ SceneManager::visibility SceneManager::getVisibility(const vec4d frustumPlanes[6
return PARTIALLY_VISIBLE;
}
void SceneManager::getFrustumPlanes(const mat4d &toScreen, vec4d frustumPlanes[6])
void SceneManager::getFrustumPlanes(const mat4d &toScreen, vec4d *frustumPlanes)
{
const double *m = toScreen.coefficients();
// Extract the LEFT plane
......
......@@ -179,7 +179,7 @@ public:
* @param b a bounding box, in the same reference frame as the frustum
* planes.
*/
static visibility getVisibility(const vec4d frustumPlanes[6], const box3d &b);
static visibility getVisibility(const vec4d *frustumPlanes, const box3d &b);
/**
* Returns the frustum plane equations from a projection matrix.
......@@ -187,7 +187,7 @@ public:
* @param toScreen a camera to screen projection matrix.
* @param[out] frustumPlanes the frustum plane equations in camera space.
*/
static void getFrustumPlanes(const mat4d &toScreen, vec4d frustumPlanes[6]);
static void getFrustumPlanes(const mat4d &toScreen, vec4d *frustumPlanes);
/**
* Updates all the transformation matrices in the scene graph.
......
......@@ -126,7 +126,7 @@ GlutWindow::GlutWindow(const Parameters &params) : Window(params)
#ifdef USEFREEGLUT
//Init OpenGL context
glutInitContextVersion(params.major(), params.minor());
glutInitContextVersion(params.version().x, params.version().y);
glutInitContextProfile(GLUT_CORE_PROFILE);
glutInitContextFlags(GLUT_FORWARD_COMPATIBLE | (params.debug() ? GLUT_DEBUG : 0));
#endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment