|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51254 - in sandbox-branches/andreo/guigl: boost/guigl boost/guigl/platform/impl libs/guigl/build/vc8ide libs/guigl/example
From: andreytorba_at_[hidden]
Date: 2009-02-14 13:19:59
Author: andreo
Date: 2009-02-14 13:19:58 EST (Sat, 14 Feb 2009)
New Revision: 51254
URL: http://svn.boost.org/trac/boost/changeset/51254
Log:
light, material
Added:
sandbox-branches/andreo/guigl/boost/guigl/platform/impl/material.hpp (contents, props changed)
Text files modified:
sandbox-branches/andreo/guigl/boost/guigl/gl.hpp | 29 +++++++++++++-
sandbox-branches/andreo/guigl/boost/guigl/platform/impl/light.hpp | 5 ++
sandbox-branches/andreo/guigl/boost/guigl/platform/impl/transform.hpp | 5 ++
sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/build.vcproj | 4 ++
sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp | 75 +++++++++++++++++++++++++++++----------
5 files changed, 96 insertions(+), 22 deletions(-)
Modified: sandbox-branches/andreo/guigl/boost/guigl/gl.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/gl.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/gl.hpp 2009-02-14 13:19:58 EST (Sat, 14 Feb 2009)
@@ -66,6 +66,10 @@
void rect(boost::array<T, 2> const& pt1, boost::array<T, 2> const& pt2);
////////////////////////////////////////////////////////////////////////////////
+ void load_identity();
+ void push_matrix();
+ void pop_matrix();
+
struct scoped_matrix : boost::noncopyable
{
scoped_matrix();
@@ -113,13 +117,13 @@
//////////////////////////////////////////////////////////////////////////
template<class T>
- inline void light(GLenum i_light, GLenum pname, T param);
+ void light(GLenum i_light, GLenum pname, T param);
template<class T>
- inline void light(GLenum i_light, GLenum pname, T const* param);
+ void light(GLenum i_light, GLenum pname, T const* param);
template<class T>
- inline void light_position(GLenum i_light, T x, T y, T z, T w);
+ void light_position(GLenum i_light, T x, T y, T z, T w);
template<class T>
void light_constant_attenuation(GLenum i_light, T value);
@@ -191,6 +195,24 @@
light_setup light(GLenum i_light);
+ //////////////////////////////////////////////////////////////////////////
+ template<class T>
+ void material(GLenum face, GLenum pname, T param);
+
+ template<class T>
+ void material(GLenum face, GLenum pname, T const* param);
+
+ template<class T>
+ void material_shininess(GLenum face, T value);
+
+ template<class T>
+ void material_specular(GLenum face, T r, T g, T b, T a);
+
+ template<class T>
+ void material_diffuse(GLenum face, T r, T g, T b, T a);
+
+ template<class T>
+ void material_ambient(GLenum face, T r, T g, T b, T a);
//////////////////////////////////////////////////////////////////////////
void wired_cube(GLdouble size);
@@ -219,6 +241,7 @@
#include "platform/impl/rect.hpp"
#include "platform/impl/transform.hpp"
#include "platform/impl/light.hpp"
+#include "platform/impl/material.hpp"
#include "platform/impl/glut.hpp"
#endif BOOST__GUIGL__GL_HPP
Modified: sandbox-branches/andreo/guigl/boost/guigl/platform/impl/light.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/platform/impl/light.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/platform/impl/light.hpp 2009-02-14 13:19:58 EST (Sat, 14 Feb 2009)
@@ -7,12 +7,14 @@
template<>
inline void light<GLfloat>(GLenum i_light, GLenum pname, GLfloat param)
{
+ BOOST_ASSERT(GL_LIGHT0 <= i_light && i_light <= GL_LIGHT7);
glLightf(i_light, pname, param);
}
template<>
inline void light<GLint>(GLenum i_light, GLenum pname, GLint param)
{
+ BOOST_ASSERT(GL_LIGHT0 <= i_light && i_light <= GL_LIGHT7);
glLighti(i_light, pname, param);
}
@@ -20,12 +22,14 @@
template<>
inline void light<GLfloat>(GLenum i_light, GLenum pname, GLfloat const* params)
{
+ BOOST_ASSERT(GL_LIGHT0 <= i_light && i_light <= GL_LIGHT7);
glLightfv(i_light, pname, params);
}
template<>
inline void light<GLint>(GLenum i_light, GLenum pname, GLint const* params)
{
+ BOOST_ASSERT(GL_LIGHT0 <= i_light && i_light <= GL_LIGHT7);
glLightiv(i_light, pname, params);
}
@@ -252,6 +256,7 @@
inline light_setup light(GLenum i_light)
{
+ glEnable(i_light);
return light_setup(i_light);
}
Added: sandbox-branches/andreo/guigl/boost/guigl/platform/impl/material.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/andreo/guigl/boost/guigl/platform/impl/material.hpp 2009-02-14 13:19:58 EST (Sat, 14 Feb 2009)
@@ -0,0 +1,276 @@
+#ifndef BOOST__GUIGL__GL__MATERIAL_HPP
+#define BOOST__GUIGL__GL__MATERIAL_HPP
+
+namespace boost{ namespace guigl { namespace gl {
+
+ //////////////////////////////////////////////////////////////////////////
+ template<>
+ inline void material<GLfloat>(GLenum face, GLenum pname, GLfloat param)
+ {
+ glMaterialf(face, pname, param);
+ }
+
+ template<>
+ inline void material<GLint>(GLenum face, GLenum pname, GLint param)
+ {
+ glMateriali(face, pname, param);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ template<>
+ inline void material<GLfloat>(GLenum face, GLenum pname, GLfloat const* params)
+ {
+ glMaterialfv(face, pname, params);
+ }
+
+ template<>
+ inline void material<GLint>(GLenum face, GLenum pname, GLint const* params)
+ {
+ glMaterialiv(face, pname, params);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ template<>
+ inline void material_shininess<GLfloat>(GLenum face, GLfloat value)
+ {
+ GLfloat const values[] = {value};
+ material(face, GL_SHININESS, values);
+ }
+
+ template<>
+ inline void material_shininess<GLint>(GLenum face, GLint value)
+ {
+ GLint const values[] = {value};
+ material(face, GL_SHININESS, values);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ //template<>
+ //inline void light_position<GLfloat>(
+ // GLenum i_light,
+ // GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+ //{
+ // GLfloat const position[] = {x, y, z, w};
+ // light(i_light, GL_POSITION, position);
+ //}
+
+ //template<>
+ //inline void light_position<GLint>(
+ // GLenum i_light,
+ // GLint x, GLint y, GLint z, GLint w)
+ //{
+ // GLint const position[] = {x, y, z, w};
+ // light(i_light, GL_POSITION, position);
+ //}
+
+ ////////////////////////////////////////////////////////////////////////////
+ //template<>
+ //inline void light_constant_attenuation<GLfloat>(GLenum i_light, GLfloat value)
+ //{
+ // light(i_light, GL_CONSTANT_ATTENUATION, value);
+ //}
+
+ //template<>
+ //inline void light_constant_attenuation<GLint>(GLenum i_light, GLint value)
+ //{
+ // light(i_light, GL_CONSTANT_ATTENUATION, value);
+ //}
+
+ ////////////////////////////////////////////////////////////////////////////
+ //template<>
+ //inline void light_linear_attenuation<GLfloat>(GLenum i_light, GLfloat value)
+ //{
+ // light(i_light, GL_LINEAR_ATTENUATION, value);
+ //}
+
+ //template<>
+ //inline void light_linear_attenuation<GLint>(GLenum i_light, GLint value)
+ //{
+ // light(i_light, GL_LINEAR_ATTENUATION, value);
+ //}
+
+ ////////////////////////////////////////////////////////////////////////////
+ //template<>
+ //inline void light_quadratic_attenuation<GLfloat>(GLenum i_light, GLfloat value)
+ //{
+ // light(i_light, GL_QUADRATIC_ATTENUATION, value);
+ //}
+
+ //template<>
+ //inline void light_quadratic_attenuation<GLint>(GLenum i_light, GLint value)
+ //{
+ // light(i_light, GL_QUADRATIC_ATTENUATION, value);
+ //}
+
+ ////////////////////////////////////////////////////////////////////////////
+ //template<>
+ //inline void light_spot_cutoff<GLfloat>(GLenum i_light, GLfloat value)
+ //{
+ // light(i_light, GL_SPOT_CUTOFF, value);
+ //}
+
+ //template<>
+ //inline void light_spot_cutoff<GLint>(GLenum i_light, GLint value)
+ //{
+ // light(i_light, GL_SPOT_CUTOFF, value);
+ //}
+
+ ////////////////////////////////////////////////////////////////////////////
+ //template<>
+ //inline void light_spot_exponent<GLfloat>(GLenum i_light, GLfloat value)
+ //{
+ // light(i_light, GL_SPOT_EXPONENT, value);
+ //}
+
+ //template<>
+ //inline void light_spot_exponent<GLint>(GLenum i_light, GLint value)
+ //{
+ // light(i_light, GL_SPOT_EXPONENT, value);
+ //}
+
+ ////////////////////////////////////////////////////////////////////////////
+ //template<>
+ //inline void light_spot_direction<GLfloat>(GLenum i_light, GLfloat x, GLfloat y, GLfloat z)
+ //{
+ // GLfloat const direction[] = {x, y, z};
+ // light(i_light, GL_SPOT_DIRECTION, direction);
+ //}
+
+ //template<>
+ //inline void light_spot_direction<GLint>(GLenum i_light, GLint x, GLint y, GLint z)
+ //{
+ // GLint const direction[] = {x, y, z};
+ // light(i_light, GL_SPOT_DIRECTION, direction);
+ //}
+
+ //////////////////////////////////////////////////////////////////////////
+ template<>
+ inline void material_specular<GLfloat>(GLenum face,
+ GLfloat r, GLfloat g, GLfloat b, GLfloat a)
+ {
+ GLfloat const specular_color[] = {r, g, b, a};
+ material(face, GL_SPECULAR, specular_color);
+ }
+
+ template<>
+ inline void material_specular<GLint>(GLenum face,
+ GLint r, GLint g, GLint b, GLint a)
+ {
+ GLint const specular_color[] = {r, g, b, a};
+ material(face, GL_SPECULAR, specular_color);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ template<>
+ inline void material_diffuse<GLfloat>(GLenum face,
+ GLfloat r, GLfloat g, GLfloat b, GLfloat a)
+ {
+ GLfloat const diffuse_color[] = {r, g, b, a};
+ material(face, GL_DIFFUSE, diffuse_color);
+ }
+
+ template<>
+ inline void material_diffuse<GLint>(GLenum face,
+ GLint r, GLint g, GLint b, GLint a)
+ {
+ GLint const diffuse_color[] = {r, g, b, a};
+ material(face, GL_DIFFUSE, diffuse_color);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ template<>
+ inline void material_ambient<GLfloat>(GLenum face,
+ GLfloat r, GLfloat g, GLfloat b, GLfloat a)
+ {
+ GLfloat const ambient_color[] = {r, g, b, a};
+ material(face, GL_AMBIENT, ambient_color);
+ }
+
+ template<>
+ inline void material_ambient<GLint>(GLenum face,
+ GLint r, GLint g, GLint b, GLint a)
+ {
+ GLint const ambient_color[] = {r, g, b, a};
+ material(face, GL_AMBIENT, ambient_color);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ //template<class T>
+ //inline light_setup& light_setup::position(T x, T y, T z, T w)
+ //{
+ // light_position(m_light, x, y, z, w);
+ // return *this;
+ //}
+
+ //template<class T>
+ //inline light_setup& light_setup::constant_attenuation(T value)
+ //{
+ // light_constant_attenuation(m_light, value);
+ // return *this;
+ //}
+
+ //template<class T>
+ //inline light_setup& light_setup::linear_attenuation(T value)
+ //{
+ // light_linear_attenuation(m_light, value);
+ // return *this;
+ //}
+
+ //template<class T>
+ //inline light_setup& light_setup::quadratic_attenuation(T value)
+ //{
+ // light_quadratic_attenuation(m_light, value);
+ // return *this;
+ //}
+
+ //template<class T>
+ //inline light_setup& light_setup::spot_cutoff(T value)
+ //{
+ // light_spot_cutoff(m_light, value);
+ // return *this;
+ //}
+
+ //template<class T>
+ //inline light_setup& light_setup::spot_exponent(T value)
+ //{
+ // light_spot_exponent(m_light, value);
+ // return *this;
+ //}
+
+ //template<class T>
+ //inline light_setup& light_setup::spot_direction(T x, T y, T z)
+ //{
+ // light_spot_direction(m_light, x, y, z);
+ // return *this;
+ //}
+
+ //template<class T>
+ //inline light_setup& light_setup::specular(T r, T g, T b, T a)
+ //{
+ // light_specular(m_light, r, g, b, a);
+ // return *this;
+ //}
+
+ //template<class T>
+ //inline light_setup& light_setup::diffuse(T r, T g, T b, T a)
+ //{
+ // light_diffuse(m_light, r, g, b, a);
+ // return *this;
+ //}
+
+ //template<class T>
+ //inline light_setup& light_setup::ambient(T r, T g, T b, T a)
+ //{
+ // light_ambient(m_light, r, g, b, a);
+ // return *this;
+ //}
+
+ //inline light_setup light(GLenum i_light)
+ //{
+ // glEnable(i_light);
+ // return light_setup(i_light);
+ //}
+
+}}}
+
+#endif BOOST__GUIGL__GL__MATERIAL_HPP
Modified: sandbox-branches/andreo/guigl/boost/guigl/platform/impl/transform.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/platform/impl/transform.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/platform/impl/transform.hpp 2009-02-14 13:19:58 EST (Sat, 14 Feb 2009)
@@ -5,6 +5,11 @@
namespace boost{ namespace guigl { namespace gl {
+ inline void load_identity()
+ {
+ glLoadIdentity();
+ }
+
inline void push_matrix()
{
glPushMatrix();
Modified: sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/build.vcproj
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/build.vcproj (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/build.vcproj 2009-02-14 13:19:58 EST (Sat, 14 Feb 2009)
@@ -135,6 +135,10 @@
>
</File>
<File
+ RelativePath="..\..\..\..\boost\guigl\platform\impl\material.hpp"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\boost\guigl\platform\impl\rect.hpp"
>
</File>
Modified: sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp 2009-02-14 13:19:58 EST (Sat, 14 Feb 2009)
@@ -24,47 +24,84 @@
using namespace boost::guigl::gl;
base_type::draw_prologue();
glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
+ load_identity();
+
+ scoped_matrix m;
+ //translate_y(-100.0f);
+ rotate_y(20.0f);
+
//glEnable(GL_DEPTH_TEST);
//glEnable(GL_COLOR_MATERIAL);
+
+ glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT1);
- glEnable(GL_LIGHT2);
+ glEnable(GL_DEPTH_TEST);
+ //glEnable(GL_BLEND);
+ //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ //glShadeModel(GL_SMOOTH);
+ //glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
+ //glEnable(GL_POLYGON_SMOOTH);
- light(GL_LIGHT1)
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ light(GL_LIGHT0)
.ambient(0.3f, 0.3f, 0.3f, 1.0f)
- .diffuse(1.0f, 1.0f, 1.0f, 1.0f)
- .specular(1.0f, 1.0f, 1.0f, 1.0f)
- .spot_direction(100, 100, 100)
- .position(-100, -100, -100, 0)
+ .diffuse(0.5f, 0.5f, 0.5f, 1.0f)
+ .specular(1.0f, 0.0f, 1.0f, 1.0f)
+ .spot_direction(100, -100, 300)
+ .position(-100, 100, -300, 0)
.constant_attenuation(1.5f)
.linear_attenuation(0.5f)
.quadratic_attenuation(0.2f)
.spot_cutoff(180.0f)
.spot_exponent(2.0f);
- light(GL_LIGHT2)
+ light(GL_LIGHT1)
.ambient(0.3f, 0.3f, 0.3f, 1.0f)
- .diffuse(1.0f, 1.0f, 1.0f, 1.0f)
- .specular(1.0f, 0.0f, 1.0f, 1.0f)
- .spot_direction(-100, 100, 100)
- .position(100, -100, -100, 0)
+ .diffuse(0.5f, 0.5f, 0.5f, 1.0f)
+ .specular(1.0f, 1.0f, 1.0f, 1.0f)
+ .spot_direction(-100, 100, -300)
+ .position(100, -100, 300, 0)
.constant_attenuation(1.2f)
.linear_attenuation(0.5f)
.quadratic_attenuation(0.2f)
.spot_cutoff(180.0f)
.spot_exponent(2.0f);
- solid_sphere(50, 50, 50);
- glLoadIdentity();
- translate_x(50.f);
- boost::guigl::gl::color(1.0, 1.0, 0.0, 0.5);
- solid_sphere(50, 100, 100);
+ double offset = 30;
+ material_ambient(GL_FRONT, 1.0f, 0.0f, 0.0f, 0.0f);
+ { scoped_matrix m;
+ translate(offset, offset, 0.0);
+ solid_sphere(50, 30, 30);
+ }
+
+ material_ambient(GL_FRONT, 1.0f, 1.0f, 0.0f, 0.0f);
+ { scoped_matrix m;
+ translate(-offset, offset, 0.0);
+ solid_sphere(50, 30, 30);
+ }
+
+ material_ambient(GL_FRONT, 1.0f, 0.0f, 1.0f, 0.0f);
+ { scoped_matrix m;
+ translate(-offset, -offset, 0.0);
+ solid_sphere(50, 100, 100);
+ }
+
+ material_ambient(GL_FRONT, 0.0f, 0.0f, 1.0f, 0.0f);
+ { scoped_matrix m;
+ translate(offset, -offset, 0.0);
+ solid_sphere(50, 30, 30);
+ }
{
scoped_matrix m;
- translate_x(-100.0f);
+ material_shininess(GL_FRONT, 20.0f);
+ material_specular(GL_FRONT, 0.3f, 0.3f, 0.3f, 0.3f);
+ material_ambient(GL_FRONT, 0.0f, 0.0f, 0.0f, 0.0f);
+ material_diffuse(GL_FRONT, 0.0f, 1.0f, 0.0f, 0.0f);
+
+ translate_z(100.0f);
+ rotate_y(20.0f);
solid_teapot(20);
}
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk