goat3dgfx

changeset 9:25b911c7c35c

fixed some line endings fixed the cubemap2.jpg file in examples/cubemap/data which was resized improperly causing seams...
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 18 Nov 2013 04:10:19 +0200
parents 98f87a1dbb2f
children b4c9a24c946e
files Makefile examples/cubemap/data/cubemap2.jpg examples/cubemap/sdr/sky.p.glsl examples/cubemap/sdr/sky.v.glsl examples/cubemap/src/main.cc src/3dschunks.h src/texture.cc
diffstat 7 files changed, 336 insertions(+), 331 deletions(-) [+]
line diff
     1.1 --- a/Makefile	Mon Nov 18 03:35:20 2013 +0200
     1.2 +++ b/Makefile	Mon Nov 18 04:10:19 2013 +0200
     1.3 @@ -28,6 +28,8 @@
     1.4  dbg = -g
     1.5  warn = -Wall
     1.6  
     1.7 +libs_ldflags = -limago -lanim -lpsys -lvmath
     1.8 +
     1.9  CFLAGS = -pedantic $(warn) $(dbg) $(pic) $(opt) $(inc) $(libs_cflags)
    1.10  CXXFLAGS =  $(CFLAGS)
    1.11  LDFLAGS = $(libgl) $(libs_ldflags)
     2.1 Binary file examples/cubemap/data/cubemap2.jpg has changed
     3.1 --- a/examples/cubemap/sdr/sky.p.glsl	Mon Nov 18 03:35:20 2013 +0200
     3.2 +++ b/examples/cubemap/sdr/sky.p.glsl	Mon Nov 18 04:10:19 2013 +0200
     3.3 @@ -1,9 +1,9 @@
     3.4 -uniform samplerCube cubemap;
     3.5 -
     3.6 -varying vec3 norm;
     3.7 -
     3.8 -void main()
     3.9 -{
    3.10 -	gl_FragColor = textureCube(cubemap, norm);
    3.11 -	//gl_FragColor = vec4(norm * 0.5 + 0.5, 1.0);
    3.12 -}
    3.13 +uniform samplerCube cubemap;
    3.14 +
    3.15 +varying vec3 norm;
    3.16 +
    3.17 +void main()
    3.18 +{
    3.19 +	gl_FragColor = textureCube(cubemap, norm);
    3.20 +	//gl_FragColor = vec4(norm * 0.5 + 0.5, 1.0);
    3.21 +}
     4.1 --- a/examples/cubemap/sdr/sky.v.glsl	Mon Nov 18 03:35:20 2013 +0200
     4.2 +++ b/examples/cubemap/sdr/sky.v.glsl	Mon Nov 18 04:10:19 2013 +0200
     4.3 @@ -1,7 +1,7 @@
     4.4 -varying vec3 norm;
     4.5 -
     4.6 -void main()
     4.7 -{
     4.8 -	gl_Position = ftransform();
     4.9 -	norm = gl_Vertex.xyz;
    4.10 -}
    4.11 +varying vec3 norm;
    4.12 +
    4.13 +void main()
    4.14 +{
    4.15 +	gl_Position = ftransform();
    4.16 +	norm = gl_Vertex.xyz;
    4.17 +}
     5.1 --- a/examples/cubemap/src/main.cc	Mon Nov 18 03:35:20 2013 +0200
     5.2 +++ b/examples/cubemap/src/main.cc	Mon Nov 18 04:10:19 2013 +0200
     5.3 @@ -1,155 +1,155 @@
     5.4 -#include <stdio.h>
     5.5 -#include <stdlib.h>
     5.6 -#include <algorithm>
     5.7 -#include <goat3dgfx/goat3dgfx.h>
     5.8 -#include <vmath/vmath.h>
     5.9 -
    5.10 -#define CUBEMAP_FILENAME	"data/cubemap2.jpg"
    5.11 -
    5.12 -static bool init();
    5.13 -static void cleanup();
    5.14 -static void display();
    5.15 -static void skybox(const TextureCube *cubemap = 0);
    5.16 -static void reshape(int x, int y);
    5.17 -static void keyboard(unsigned char key, int x, int y);
    5.18 -static void mouse(int bn, int st, int x, int y);
    5.19 -static void motion(int x, int y);
    5.20 -
    5.21 -static float cam_theta, cam_phi;
    5.22 -
    5.23 -static TextureCube *cubemap;
    5.24 -static ShaderProg *sdrsky;
    5.25 -
    5.26 -int main(int argc, char **argv)
    5.27 -{
    5.28 -	glutInit(&argc, argv);
    5.29 -	glutInitWindowSize(800, 600);
    5.30 -	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    5.31 -	glutCreateWindow("cubemap");
    5.32 -
    5.33 -	glutDisplayFunc(display);
    5.34 -	glutReshapeFunc(reshape);
    5.35 -	glutKeyboardFunc(keyboard);
    5.36 -	glutMouseFunc(mouse);
    5.37 -	glutMotionFunc(motion);
    5.38 -
    5.39 -	if(!init()) {
    5.40 -		return 1;
    5.41 -	}
    5.42 -	atexit(cleanup);
    5.43 -
    5.44 -	glutMainLoop();
    5.45 -	return 0;
    5.46 -}
    5.47 -
    5.48 -static bool init()
    5.49 -{
    5.50 -	glewInit();
    5.51 -
    5.52 -	glEnable(GL_DEPTH_TEST);
    5.53 -	//glEnable(GL_CULL_FACE);
    5.54 -
    5.55 -	cubemap = new TextureCube;
    5.56 -	if(!cubemap->load(CUBEMAP_FILENAME)) {
    5.57 -		fatal_log("Failed to load cubemap: %s\n", CUBEMAP_FILENAME);
    5.58 -		return false;
    5.59 -	}
    5.60 -
    5.61 -	if(!(sdrsky = get_sdrprog("sdr/sky.v.glsl", "sdr/sky.p.glsl"))) {
    5.62 -		fatal_log("failed to load skybox shader\n");
    5.63 -		return false;
    5.64 -	}
    5.65 -
    5.66 -	return true;
    5.67 -}
    5.68 -
    5.69 -static void cleanup()
    5.70 -{
    5.71 -	delete cubemap;
    5.72 -}
    5.73 -
    5.74 -static void display()
    5.75 -{
    5.76 -	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    5.77 -
    5.78 -	Matrix4x4 view_matrix;
    5.79 -	view_matrix.rotate(Vector3(1, 0, 0), M_PI * cam_phi / 180.0);
    5.80 -	view_matrix.rotate(Vector3(0, 1, 0), M_PI * cam_theta / 180.0);
    5.81 -	set_view_matrix(view_matrix);
    5.82 -
    5.83 -	setup_gl_matrices();
    5.84 -
    5.85 -	skybox(cubemap);
    5.86 -
    5.87 -	glutSwapBuffers();
    5.88 -	CHECKGLERR;
    5.89 -}
    5.90 -
    5.91 -static void skybox(const TextureCube *cubemap)
    5.92 -{
    5.93 -	static Mesh *skybox;
    5.94 -
    5.95 -	if(!skybox) {
    5.96 -		skybox = new Mesh;
    5.97 -		gen_sphere(skybox, 10.0, 12, 6);
    5.98 -	}
    5.99 -
   5.100 -	glPushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT);
   5.101 -	glDisable(GL_DEPTH_TEST);
   5.102 -	glDisable(GL_CULL_FACE);
   5.103 -	glDisable(GL_LIGHTING);
   5.104 -
   5.105 -	glEnable(GL_TEXTURE_CUBE_MAP);
   5.106 -
   5.107 -	if(cubemap) cubemap->bind();
   5.108 -	sdrsky->bind();
   5.109 -
   5.110 -	skybox->draw();
   5.111 -
   5.112 -	glUseProgram(0);
   5.113 -	glPopAttrib();
   5.114 -}
   5.115 -
   5.116 -static void reshape(int x, int y)
   5.117 -{
   5.118 -	glViewport(0, 0, x, y);
   5.119 -
   5.120 -	Matrix4x4 proj;
   5.121 -	proj.set_perspective(M_PI / 4.0, (float)x / (float)y, 0.5, 500.0);
   5.122 -	set_projection_matrix(proj);
   5.123 -}
   5.124 -
   5.125 -static void keyboard(unsigned char key, int x, int y)
   5.126 -{
   5.127 -	switch(key) {
   5.128 -	case 27:
   5.129 -		exit(0);
   5.130 -	}
   5.131 -}
   5.132 -
   5.133 -static bool bnstate[16];
   5.134 -static int prev_x, prev_y;
   5.135 -
   5.136 -static void mouse(int bn, int st, int x, int y)
   5.137 -{
   5.138 -	bnstate[bn - GLUT_LEFT_BUTTON] = st == GLUT_DOWN;
   5.139 -	prev_x = x;
   5.140 -	prev_y = y;
   5.141 -}
   5.142 -
   5.143 -static void motion(int x, int y)
   5.144 -{
   5.145 -	int dx = x - prev_x;
   5.146 -	int dy = y - prev_y;
   5.147 -	prev_x = x;
   5.148 -	prev_y = y;
   5.149 -
   5.150 -	if(!dx && !dy) return;
   5.151 -
   5.152 -	if(bnstate[0]) {
   5.153 -		cam_theta += dx * 0.5;
   5.154 -		cam_phi += dy * 0.5;
   5.155 -		cam_phi = std::max(-90.0f, std::min(90.0f, cam_phi));
   5.156 -		glutPostRedisplay();
   5.157 -	}
   5.158 -}
   5.159 +#include <stdio.h>
   5.160 +#include <stdlib.h>
   5.161 +#include <algorithm>
   5.162 +#include <goat3dgfx/goat3dgfx.h>
   5.163 +#include <vmath/vmath.h>
   5.164 +
   5.165 +#define CUBEMAP_FILENAME	"data/cubemap2.jpg"
   5.166 +
   5.167 +static bool init();
   5.168 +static void cleanup();
   5.169 +static void display();
   5.170 +static void skybox(const TextureCube *cubemap = 0);
   5.171 +static void reshape(int x, int y);
   5.172 +static void keyboard(unsigned char key, int x, int y);
   5.173 +static void mouse(int bn, int st, int x, int y);
   5.174 +static void motion(int x, int y);
   5.175 +
   5.176 +static float cam_theta, cam_phi;
   5.177 +
   5.178 +static TextureCube *cubemap;
   5.179 +static ShaderProg *sdrsky;
   5.180 +
   5.181 +int main(int argc, char **argv)
   5.182 +{
   5.183 +	glutInit(&argc, argv);
   5.184 +	glutInitWindowSize(800, 600);
   5.185 +	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
   5.186 +	glutCreateWindow("cubemap");
   5.187 +
   5.188 +	glutDisplayFunc(display);
   5.189 +	glutReshapeFunc(reshape);
   5.190 +	glutKeyboardFunc(keyboard);
   5.191 +	glutMouseFunc(mouse);
   5.192 +	glutMotionFunc(motion);
   5.193 +
   5.194 +	if(!init()) {
   5.195 +		return 1;
   5.196 +	}
   5.197 +	atexit(cleanup);
   5.198 +
   5.199 +	glutMainLoop();
   5.200 +	return 0;
   5.201 +}
   5.202 +
   5.203 +static bool init()
   5.204 +{
   5.205 +	glewInit();
   5.206 +
   5.207 +	glEnable(GL_DEPTH_TEST);
   5.208 +	//glEnable(GL_CULL_FACE);
   5.209 +
   5.210 +	cubemap = new TextureCube;
   5.211 +	if(!cubemap->load(CUBEMAP_FILENAME)) {
   5.212 +		fatal_log("Failed to load cubemap: %s\n", CUBEMAP_FILENAME);
   5.213 +		return false;
   5.214 +	}
   5.215 +
   5.216 +	if(!(sdrsky = get_sdrprog("sdr/sky.v.glsl", "sdr/sky.p.glsl"))) {
   5.217 +		fatal_log("failed to load skybox shader\n");
   5.218 +		return false;
   5.219 +	}
   5.220 +
   5.221 +	return true;
   5.222 +}
   5.223 +
   5.224 +static void cleanup()
   5.225 +{
   5.226 +	delete cubemap;
   5.227 +}
   5.228 +
   5.229 +static void display()
   5.230 +{
   5.231 +	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   5.232 +
   5.233 +	Matrix4x4 view_matrix;
   5.234 +	view_matrix.rotate(Vector3(1, 0, 0), M_PI * cam_phi / 180.0);
   5.235 +	view_matrix.rotate(Vector3(0, 1, 0), M_PI * cam_theta / 180.0);
   5.236 +	set_view_matrix(view_matrix);
   5.237 +
   5.238 +	setup_gl_matrices();
   5.239 +
   5.240 +	skybox(cubemap);
   5.241 +
   5.242 +	glutSwapBuffers();
   5.243 +	CHECKGLERR;
   5.244 +}
   5.245 +
   5.246 +static void skybox(const TextureCube *cubemap)
   5.247 +{
   5.248 +	static Mesh *skybox;
   5.249 +
   5.250 +	if(!skybox) {
   5.251 +		skybox = new Mesh;
   5.252 +		gen_sphere(skybox, 10.0, 12, 6);
   5.253 +	}
   5.254 +
   5.255 +	glPushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT);
   5.256 +	glDisable(GL_DEPTH_TEST);
   5.257 +	glDisable(GL_CULL_FACE);
   5.258 +	glDisable(GL_LIGHTING);
   5.259 +
   5.260 +	glEnable(GL_TEXTURE_CUBE_MAP);
   5.261 +
   5.262 +	if(cubemap) cubemap->bind();
   5.263 +	sdrsky->bind();
   5.264 +
   5.265 +	skybox->draw();
   5.266 +
   5.267 +	glUseProgram(0);
   5.268 +	glPopAttrib();
   5.269 +}
   5.270 +
   5.271 +static void reshape(int x, int y)
   5.272 +{
   5.273 +	glViewport(0, 0, x, y);
   5.274 +
   5.275 +	Matrix4x4 proj;
   5.276 +	proj.set_perspective(M_PI / 4.0, (float)x / (float)y, 0.5, 500.0);
   5.277 +	set_projection_matrix(proj);
   5.278 +}
   5.279 +
   5.280 +static void keyboard(unsigned char key, int x, int y)
   5.281 +{
   5.282 +	switch(key) {
   5.283 +	case 27:
   5.284 +		exit(0);
   5.285 +	}
   5.286 +}
   5.287 +
   5.288 +static bool bnstate[16];
   5.289 +static int prev_x, prev_y;
   5.290 +
   5.291 +static void mouse(int bn, int st, int x, int y)
   5.292 +{
   5.293 +	bnstate[bn - GLUT_LEFT_BUTTON] = st == GLUT_DOWN;
   5.294 +	prev_x = x;
   5.295 +	prev_y = y;
   5.296 +}
   5.297 +
   5.298 +static void motion(int x, int y)
   5.299 +{
   5.300 +	int dx = x - prev_x;
   5.301 +	int dy = y - prev_y;
   5.302 +	prev_x = x;
   5.303 +	prev_y = y;
   5.304 +
   5.305 +	if(!dx && !dy) return;
   5.306 +
   5.307 +	if(bnstate[0]) {
   5.308 +		cam_theta += dx * 0.5;
   5.309 +		cam_phi += dy * 0.5;
   5.310 +		cam_phi = std::max(-90.0f, std::min(90.0f, cam_phi));
   5.311 +		glutPostRedisplay();
   5.312 +	}
   5.313 +}
     6.1 --- a/src/3dschunks.h	Mon Nov 18 03:35:20 2013 +0200
     6.2 +++ b/src/3dschunks.h	Mon Nov 18 04:10:19 2013 +0200
     6.3 @@ -1,160 +1,160 @@
     6.4 -#ifndef _3DSCHUNKS_H_
     6.5 -#define _3DSCHUNKS_H_
     6.6 -
     6.7 -enum ChunkID {
     6.8 -	Chunk_Color_Float3					= 0x0010,	// o Floating point color
     6.9 -	Chunk_Color_Byte3					= 0x0011,	// o 24bit color
    6.10 -	Chunk_Color_GammaByte3				= 0x0012,	// o 24bit gamma corrected
    6.11 -	Chunk_Color_GammaFloat3				= 0x0013,	// o Floating point gamma corrected
    6.12 -	Chunk_PercentInt					= 0x0030,	// o Percent Chunk int 0 - 100
    6.13 -	Chunk_PercentFloat					= 0x0031,	// o Percent Chunk float 0 - 1
    6.14 -
    6.15 -	Chunk_3DSMain						= 0x4D4D,	// + Root Chunk
    6.16 -	Chunk_Main_3DSVersion				= 0x0002,	//   - 3DS Version
    6.17 -	Chunk_Main_3DEditor					= 0x3D3D,	//   + 3D Editor Chunk
    6.18 -	Chunk_Edit_Unit						= 0x0100,	//     - Unit
    6.19 -	Chunk_Edit_BGBitmap					= 0x1100,	//     - Background Bitmap
    6.20 -	Chunk_Edit_UseBGBitmap				= 0x1101,	//     - Use Background Bitmap
    6.21 -	Chunk_Edit_BGColor					= 0x1200,	//     - Background Color
    6.22 -	Chunk_Edit_UseBGColor				= 0x1201,	//     - Use Background Color
    6.23 -	Chunk_Edit_GradColor				= 0x1300,	//     - Background Gradient
    6.24 -	Chunk_Edit_UseGradColor				= 0x1301,	//     - Use Gradient Color
    6.25 -	Chunk_Edit_ShadowMapBias			= 0x1400,	//     - Shadow map bias
    6.26 -	Chunk_Edit_ShadowMapSize			= 0x1420,	//     - Shadow map size
    6.27 -	Chunk_Edit_ShadowMapSampleRange		= 0x1450,	//     - Shadow map sample range
    6.28 -	Chunk_Edit_RaytraceBias				= 0x1460,	//     - Raytrace bias
    6.29 -	Chunk_Edit_UseRaytrace				= 0x1470,	//     - Use Raytrace
    6.30 -	Chunk_Edit_AmbientColor				= 0x2100,	//     - Ambient Color
    6.31 -	Chunk_Edit_Fog						= 0x2200,	//     + Fog
    6.32 -	Chunk_Fog_FogColor					= 0x2210,	//	     - Fog Color
    6.33 -	Chunk_Edit_UseFog					= 0x2201,	//     - Use Fog
    6.34 -	Chunk_Edit_DistanceQue				= 0x2300,	//     + Distance que
    6.35 -	Chunk_Dist_DimBackground			= 0x2310,	//       - Dim Background
    6.36 -	Chunk_Edit_UseDistanceQue			= 0x2301,	//     - Use distance que
    6.37 -	Chunk_Edit_LayeredFogOptions		= 0x2302,	//     - Layered fog options
    6.38 -	Chunk_Edit_UseLayeredFog			= 0x2303,	//     - Use Layered Fog
    6.39 -	Chunk_Edit_MeshVersion				= 0x3D3E,	//     - Mesh Version
    6.40 -
    6.41 -	Chunk_Edit_Object					= 0x4000,	//     + Object
    6.42 -	Chunk_Obj_Hidden					= 0x4010,	//       - Hidden
    6.43 -	Chunk_Obj_DontCastShadows			= 0x4012,	//       - Object doesn't cast shadows
    6.44 -	Chunk_Obj_MatteObject				= 0x4013,	//       - Matte
    6.45 -	Chunk_Obj_ExternalProcessOn			= 0x4015,	//       - External Process on (?)
    6.46 -	Chunk_Obj_DontReceiveShadows		= 0x4017,	//       - doesn't reseive shadows
    6.47 -	Chunk_Obj_TriMesh					= 0x4100,	//       + TriMesh
    6.48 -	Chunk_TriMesh_VertexList			= 0x4110,	//         - Vertex List
    6.49 -	Chunk_TriMesh_FaceDesc				= 0x4120,	//         + Faces description
    6.50 -	Chunk_Face_Material					= 0x4130,	//           - Face Materials*
    6.51 -	Chunk_TriMesh_TexCoords				= 0x4140,	//         - Texture Coordinates
    6.52 -	Chunk_TriMesh_SmoothingGroup		= 0x4150,	//         - Smoothing group
    6.53 -	Chunk_TriMesh_WorldTransform		= 0x4160,	//         - Position and Orientation
    6.54 -	Chunk_TriMesh_Color					= 0x4165,   //         - Object color
    6.55 -	Chunk_TriMesh_ExternalProcessName	= 0x4181,	//         - External Process name (?)
    6.56 -	Chunk_TriMesh_ExternalProcessParams	= 0x4182,	//         - External Process parameters (?)
    6.57 -
    6.58 -	Chunk_Obj_Light						= 0x4600,	//       + Light
    6.59 -	Chunk_Light_SpotLight				= 0x4610,	//         + SpotLight
    6.60 -	Chunk_Spot_Raytrace					= 0x4627,	//           - Raytrace
    6.61 -	Chunk_Spot_CastShadows				= 0x4630,	//           - Light casts shadows
    6.62 -	Chunk_Spot_ShadowMap				= 0x4641,	//           - Shadow Map
    6.63 -	Chunk_Spot_ShowCone					= 0x4650,	//           - Show Cone
    6.64 -	Chunk_Spot_Rectangular				= 0x4651,	//           - Rectangular shaped spotlight
    6.65 -	Chunk_Spot_OverShoot				= 0x4652,	//           - Overshoot
    6.66 -	Chunk_Spot_ProjMap					= 0x4653,	//           - Projector Map
    6.67 -	Chunk_Spot_Roll						= 0x4656,	//           - Roll around dir
    6.68 -	Chunk_Spot_RaytraceBias				= 0x4658,	//           - Raytrace Bias
    6.69 -	Chunk_Light_Off						= 0x4620,	//         - Light is disabled
    6.70 -	Chunk_Light_Attenuation				= 0x4625,	//         - Attenuation enabled
    6.71 -	Chunk_Light_AttenuationStart		= 0x4659,	//         - Attenuation Start Range
    6.72 -	Chunk_Light_AttenuationEnd			= 0x465A,	//         - Attenuation End Range
    6.73 -	Chunk_Light_Intensity				= 0x465B,	//         - Light Intensity
    6.74 -
    6.75 -	Chunk_Obj_Camera					= 0x4700,	//       - Camera
    6.76 -	Chunk_Edit_ViewSettings				= 0x7001,	//     - View Settings
    6.77 -	Chunk_Edit_ViewDesc2				= 0x7011,	//     - View Description 2
    6.78 -	Chunk_Edit_ViewDesc1				= 0x7012,	//     - View Description 1
    6.79 -	Chunk_Edit_MeshWindows				= 0x7020,	//     - Mesh Windows (?)
    6.80 -
    6.81 -	Chunk_Edit_Material					= 0xAFFF,	//     + Material Block
    6.82 -	Chunk_Mat_Name						= 0xA000,	//       - Material Name
    6.83 -	Chunk_Mat_AmbientColor				= 0xA010,	//       - Ambient Color
    6.84 -	Chunk_Mat_DiffuseColor				= 0xA020,	//       - Diffuse Color
    6.85 -	Chunk_Mat_SpecularColor				= 0xA030,	//       - Specular Color
    6.86 -	Chunk_Mat_Specular					= 0xA040,	//       - Shininness (Specular Power)
    6.87 -	Chunk_Mat_SpecularIntensity			= 0xA041,	//       - Shininness Strength (specular intensity)
    6.88 -	Chunk_Mat_Transparency				= 0xA050,	//       - Transparency (alpha)
    6.89 -	Chunk_Mat_TransparencyFalloff		= 0xA052,	//       - Transparency Falloff
    6.90 -	Chunk_Mat_ReflectionBlur			= 0xA053,	//       - Reflection Blur
    6.91 -	Chunk_Mat_TwoSided					= 0xA081,	//       - Two Sided
    6.92 -	Chunk_Mat_AddTransparency			= 0xA083,	//       - ?
    6.93 -	Chunk_Mat_SelfIllumination			= 0xA084,	//       - Self Illumination (emissive)
    6.94 -	Chunk_Mat_Wireframe					= 0xA085,	//       - Render in wireframe
    6.95 -	Chunk_Mat_WireframeThickness		= 0xA087,	//       - Wire thickness
    6.96 -	Chunk_Mat_FaceMapping				= 0xA088,	//       - Apply maps to faces seperatly (ignore uv)
    6.97 -	Chunk_Mat_InTranc					= 0xA08A,	// ?
    6.98 -	Chunk_Mat_Soften					= 0xA08C,	//       - Soft Shading
    6.99 -	Chunk_Mat_WireUnits					= 0xA08E,	//       - Wire units (?)
   6.100 -	Chunk_Mat_RenderType				= 0xA100,	//       - Render Type
   6.101 -	Chunk_Mat_BumpMapPercent			= 0xA252,	//       - Bump map intensity
   6.102 -	Chunk_Mat_TextureMap				= 0xA200,	//       + Texture Map
   6.103 -	Chunk_Mat_TextureMap2				= 0xA33A,	//       + Texture Map 2
   6.104 -	Chunk_Mat_OpacityMap				= 0xA210,	//       + Opacity Map
   6.105 -	Chunk_Mat_BumpMap					= 0xA230,	//       + Bump Map
   6.106 -	Chunk_Mat_SpecularMap				= 0xA33C,	//       + Specular Intensity map
   6.107 -	Chunk_Mat_SpecularColorMap			= 0xA204,	//       + Specular color (texture) map
   6.108 -	Chunk_Mat_SelfIlluminationMap		= 0xA33D,	//       + Self Illumination Map
   6.109 -	Chunk_Mat_ReflectionMap				= 0xA220,	//       + Reflection Map
   6.110 -	Chunk_Mat_TextureMask				= 0xA33E,	//       - Texture Mask
   6.111 -	Chunk_Mat_Texture2Mask				= 0xA340,	//       - Texture 2 Mask
   6.112 -	Chunk_Mat_OpacityMask				= 0xA342,	//       - Opacity Mask
   6.113 -	Chunk_Mat_BumpMask					= 0xA344,	//       - Bump Mask
   6.114 -	Chunk_Mat_SpecularMask				= 0xA346,	//       - Specular Mask
   6.115 -	Chunk_Mat_SpecularColorMask			= 0xA348,	//       - Specular color mask
   6.116 -	Chunk_Mat_SelfIlluminationMask		= 0xA34A,	//       - Self Illumination mask
   6.117 -	Chunk_Mat_ReflectionMask			= 0xA34C,	//       - Reflection mask
   6.118 -
   6.119 -	// map subchunks								// -----------------------
   6.120 -	Chunk_Map_FileName					= 0xA300,	//         - Filename
   6.121 -	Chunk_Map_Params					= 0xA351,	//         - Parameters
   6.122 -	Chunk_Map_BlurPercent				= 0xA353,	//         - Blur ammount
   6.123 -	Chunk_Map_VScale					= 0xA354,	//         - Texture V Scale
   6.124 -	Chunk_Map_UScale					= 0xA356,	//         - Texture U Scale
   6.125 -	Chunk_Map_UOffset					= 0xA358,	//         - Texture U Offset
   6.126 -	Chunk_MAP_VOffset					= 0xA35A,	//         - Texture V Offset
   6.127 -	Chunk_Map_RotationAngle				= 0xA35C,	//         - Texture Rotation Angle
   6.128 -	Chunk_Map_RGBLumAlphaTint1			= 0xA360,	//         - RGB Luminance Alpha Tint 1
   6.129 -	Chunk_Map_RGBLumAlphaTint2			= 0xA362,	//         - RGB Luminance Alpha Tint 2
   6.130 -	Chunk_Map_RGBTintR					= 0xA364,	//         - RGB Tint R
   6.131 -	Chunk_Map_RGBTintG					= 0xA366,	//         - RGB Tint G
   6.132 -	Chunk_Map_RGBTintB					= 0xA368,	//         - RGB Tint B
   6.133 -	// map subchunks end							// -----------------------
   6.134 -
   6.135 -	Chunk_Main_Keyframer				= 0xB000,	//     + Keyframer Chunk
   6.136 -	Chunk_Key_AmbientInfo				= 0xB001,	//       - Ambient animation info
   6.137 -	Chunk_Key_MeshInfo					= 0xB002,	//       - Mesh animation info
   6.138 -	Chunk_Key_CameraInfo				= 0xB003,	//       - Camera animation info
   6.139 -	Chunk_Key_CameraTargetInfo			= 0xB004,	//       - Camera Target animation info
   6.140 -	Chunk_Key_OmniLightInfo				= 0xB005,	//       - Omni Light animation info
   6.141 -	Chunk_Key_SpotLightTargetInfo		= 0xB006,	//       - Spotlight target animation info
   6.142 -	Chunk_Key_SpotLightInfo				= 0xB007,	//       - Spotlight animation info
   6.143 -	Chunk_Key_Frames					= 0xB008,	//       - Animation Frames
   6.144 -
   6.145 -	// animation information subchunks				// -----------------------
   6.146 -	Chunk_Info_Object					= 0xB010,	//         - Object information
   6.147 -	Chunk_Info_ObjectPivot				= 0xB013,	//         - Object Pivot
   6.148 -	Chunk_Info_ObjectMorphAngle			= 0xB015,	//         - Object Morph Angle
   6.149 -	Chunk_Info_PositionTrack			= 0xB020,	//         - Position Track
   6.150 -	Chunk_Info_RotationTrack			= 0xB021,	//         - Rotation Track
   6.151 -	Chunk_Info_ScaleTrack				= 0xB022,	//         - Scaling Track
   6.152 -	Chunk_Info_FOVTrack					= 0xB023,	//         - FOV Track
   6.153 -	Chunk_Info_RollTrack				= 0xB024,	//         - Roll Track
   6.154 -	Chunk_Info_ColorTrack				= 0xB025,	//         - Color Track
   6.155 -	Chunk_Info_MorphTrack				= 0xB026,	//         - Morph Track
   6.156 -	Chunk_Info_HotSpotTrack				= 0xB027,	//         - HotSpot Track
   6.157 -	Chunk_Info_FalloffTrack				= 0xB028,	//         - Falloff Track
   6.158 -	Chunk_Info_HideTrack				= 0xB029,	//         - Hide Track
   6.159 -	Chunk_Info_HierarchyPosition		= 0xB030	//         - Hierarchy Position
   6.160 -};
   6.161 -
   6.162 -#endif	// _3DSCHUNKS_H_
   6.163 -
   6.164 +#ifndef _3DSCHUNKS_H_
   6.165 +#define _3DSCHUNKS_H_
   6.166 +
   6.167 +enum ChunkID {
   6.168 +	Chunk_Color_Float3					= 0x0010,	// o Floating point color
   6.169 +	Chunk_Color_Byte3					= 0x0011,	// o 24bit color
   6.170 +	Chunk_Color_GammaByte3				= 0x0012,	// o 24bit gamma corrected
   6.171 +	Chunk_Color_GammaFloat3				= 0x0013,	// o Floating point gamma corrected
   6.172 +	Chunk_PercentInt					= 0x0030,	// o Percent Chunk int 0 - 100
   6.173 +	Chunk_PercentFloat					= 0x0031,	// o Percent Chunk float 0 - 1
   6.174 +
   6.175 +	Chunk_3DSMain						= 0x4D4D,	// + Root Chunk
   6.176 +	Chunk_Main_3DSVersion				= 0x0002,	//   - 3DS Version
   6.177 +	Chunk_Main_3DEditor					= 0x3D3D,	//   + 3D Editor Chunk
   6.178 +	Chunk_Edit_Unit						= 0x0100,	//     - Unit
   6.179 +	Chunk_Edit_BGBitmap					= 0x1100,	//     - Background Bitmap
   6.180 +	Chunk_Edit_UseBGBitmap				= 0x1101,	//     - Use Background Bitmap
   6.181 +	Chunk_Edit_BGColor					= 0x1200,	//     - Background Color
   6.182 +	Chunk_Edit_UseBGColor				= 0x1201,	//     - Use Background Color
   6.183 +	Chunk_Edit_GradColor				= 0x1300,	//     - Background Gradient
   6.184 +	Chunk_Edit_UseGradColor				= 0x1301,	//     - Use Gradient Color
   6.185 +	Chunk_Edit_ShadowMapBias			= 0x1400,	//     - Shadow map bias
   6.186 +	Chunk_Edit_ShadowMapSize			= 0x1420,	//     - Shadow map size
   6.187 +	Chunk_Edit_ShadowMapSampleRange		= 0x1450,	//     - Shadow map sample range
   6.188 +	Chunk_Edit_RaytraceBias				= 0x1460,	//     - Raytrace bias
   6.189 +	Chunk_Edit_UseRaytrace				= 0x1470,	//     - Use Raytrace
   6.190 +	Chunk_Edit_AmbientColor				= 0x2100,	//     - Ambient Color
   6.191 +	Chunk_Edit_Fog						= 0x2200,	//     + Fog
   6.192 +	Chunk_Fog_FogColor					= 0x2210,	//	     - Fog Color
   6.193 +	Chunk_Edit_UseFog					= 0x2201,	//     - Use Fog
   6.194 +	Chunk_Edit_DistanceQue				= 0x2300,	//     + Distance que
   6.195 +	Chunk_Dist_DimBackground			= 0x2310,	//       - Dim Background
   6.196 +	Chunk_Edit_UseDistanceQue			= 0x2301,	//     - Use distance que
   6.197 +	Chunk_Edit_LayeredFogOptions		= 0x2302,	//     - Layered fog options
   6.198 +	Chunk_Edit_UseLayeredFog			= 0x2303,	//     - Use Layered Fog
   6.199 +	Chunk_Edit_MeshVersion				= 0x3D3E,	//     - Mesh Version
   6.200 +
   6.201 +	Chunk_Edit_Object					= 0x4000,	//     + Object
   6.202 +	Chunk_Obj_Hidden					= 0x4010,	//       - Hidden
   6.203 +	Chunk_Obj_DontCastShadows			= 0x4012,	//       - Object doesn't cast shadows
   6.204 +	Chunk_Obj_MatteObject				= 0x4013,	//       - Matte
   6.205 +	Chunk_Obj_ExternalProcessOn			= 0x4015,	//       - External Process on (?)
   6.206 +	Chunk_Obj_DontReceiveShadows		= 0x4017,	//       - doesn't reseive shadows
   6.207 +	Chunk_Obj_TriMesh					= 0x4100,	//       + TriMesh
   6.208 +	Chunk_TriMesh_VertexList			= 0x4110,	//         - Vertex List
   6.209 +	Chunk_TriMesh_FaceDesc				= 0x4120,	//         + Faces description
   6.210 +	Chunk_Face_Material					= 0x4130,	//           - Face Materials*
   6.211 +	Chunk_TriMesh_TexCoords				= 0x4140,	//         - Texture Coordinates
   6.212 +	Chunk_TriMesh_SmoothingGroup		= 0x4150,	//         - Smoothing group
   6.213 +	Chunk_TriMesh_WorldTransform		= 0x4160,	//         - Position and Orientation
   6.214 +	Chunk_TriMesh_Color					= 0x4165,   //         - Object color
   6.215 +	Chunk_TriMesh_ExternalProcessName	= 0x4181,	//         - External Process name (?)
   6.216 +	Chunk_TriMesh_ExternalProcessParams	= 0x4182,	//         - External Process parameters (?)
   6.217 +
   6.218 +	Chunk_Obj_Light						= 0x4600,	//       + Light
   6.219 +	Chunk_Light_SpotLight				= 0x4610,	//         + SpotLight
   6.220 +	Chunk_Spot_Raytrace					= 0x4627,	//           - Raytrace
   6.221 +	Chunk_Spot_CastShadows				= 0x4630,	//           - Light casts shadows
   6.222 +	Chunk_Spot_ShadowMap				= 0x4641,	//           - Shadow Map
   6.223 +	Chunk_Spot_ShowCone					= 0x4650,	//           - Show Cone
   6.224 +	Chunk_Spot_Rectangular				= 0x4651,	//           - Rectangular shaped spotlight
   6.225 +	Chunk_Spot_OverShoot				= 0x4652,	//           - Overshoot
   6.226 +	Chunk_Spot_ProjMap					= 0x4653,	//           - Projector Map
   6.227 +	Chunk_Spot_Roll						= 0x4656,	//           - Roll around dir
   6.228 +	Chunk_Spot_RaytraceBias				= 0x4658,	//           - Raytrace Bias
   6.229 +	Chunk_Light_Off						= 0x4620,	//         - Light is disabled
   6.230 +	Chunk_Light_Attenuation				= 0x4625,	//         - Attenuation enabled
   6.231 +	Chunk_Light_AttenuationStart		= 0x4659,	//         - Attenuation Start Range
   6.232 +	Chunk_Light_AttenuationEnd			= 0x465A,	//         - Attenuation End Range
   6.233 +	Chunk_Light_Intensity				= 0x465B,	//         - Light Intensity
   6.234 +
   6.235 +	Chunk_Obj_Camera					= 0x4700,	//       - Camera
   6.236 +	Chunk_Edit_ViewSettings				= 0x7001,	//     - View Settings
   6.237 +	Chunk_Edit_ViewDesc2				= 0x7011,	//     - View Description 2
   6.238 +	Chunk_Edit_ViewDesc1				= 0x7012,	//     - View Description 1
   6.239 +	Chunk_Edit_MeshWindows				= 0x7020,	//     - Mesh Windows (?)
   6.240 +
   6.241 +	Chunk_Edit_Material					= 0xAFFF,	//     + Material Block
   6.242 +	Chunk_Mat_Name						= 0xA000,	//       - Material Name
   6.243 +	Chunk_Mat_AmbientColor				= 0xA010,	//       - Ambient Color
   6.244 +	Chunk_Mat_DiffuseColor				= 0xA020,	//       - Diffuse Color
   6.245 +	Chunk_Mat_SpecularColor				= 0xA030,	//       - Specular Color
   6.246 +	Chunk_Mat_Specular					= 0xA040,	//       - Shininness (Specular Power)
   6.247 +	Chunk_Mat_SpecularIntensity			= 0xA041,	//       - Shininness Strength (specular intensity)
   6.248 +	Chunk_Mat_Transparency				= 0xA050,	//       - Transparency (alpha)
   6.249 +	Chunk_Mat_TransparencyFalloff		= 0xA052,	//       - Transparency Falloff
   6.250 +	Chunk_Mat_ReflectionBlur			= 0xA053,	//       - Reflection Blur
   6.251 +	Chunk_Mat_TwoSided					= 0xA081,	//       - Two Sided
   6.252 +	Chunk_Mat_AddTransparency			= 0xA083,	//       - ?
   6.253 +	Chunk_Mat_SelfIllumination			= 0xA084,	//       - Self Illumination (emissive)
   6.254 +	Chunk_Mat_Wireframe					= 0xA085,	//       - Render in wireframe
   6.255 +	Chunk_Mat_WireframeThickness		= 0xA087,	//       - Wire thickness
   6.256 +	Chunk_Mat_FaceMapping				= 0xA088,	//       - Apply maps to faces seperatly (ignore uv)
   6.257 +	Chunk_Mat_InTranc					= 0xA08A,	// ?
   6.258 +	Chunk_Mat_Soften					= 0xA08C,	//       - Soft Shading
   6.259 +	Chunk_Mat_WireUnits					= 0xA08E,	//       - Wire units (?)
   6.260 +	Chunk_Mat_RenderType				= 0xA100,	//       - Render Type
   6.261 +	Chunk_Mat_BumpMapPercent			= 0xA252,	//       - Bump map intensity
   6.262 +	Chunk_Mat_TextureMap				= 0xA200,	//       + Texture Map
   6.263 +	Chunk_Mat_TextureMap2				= 0xA33A,	//       + Texture Map 2
   6.264 +	Chunk_Mat_OpacityMap				= 0xA210,	//       + Opacity Map
   6.265 +	Chunk_Mat_BumpMap					= 0xA230,	//       + Bump Map
   6.266 +	Chunk_Mat_SpecularMap				= 0xA33C,	//       + Specular Intensity map
   6.267 +	Chunk_Mat_SpecularColorMap			= 0xA204,	//       + Specular color (texture) map
   6.268 +	Chunk_Mat_SelfIlluminationMap		= 0xA33D,	//       + Self Illumination Map
   6.269 +	Chunk_Mat_ReflectionMap				= 0xA220,	//       + Reflection Map
   6.270 +	Chunk_Mat_TextureMask				= 0xA33E,	//       - Texture Mask
   6.271 +	Chunk_Mat_Texture2Mask				= 0xA340,	//       - Texture 2 Mask
   6.272 +	Chunk_Mat_OpacityMask				= 0xA342,	//       - Opacity Mask
   6.273 +	Chunk_Mat_BumpMask					= 0xA344,	//       - Bump Mask
   6.274 +	Chunk_Mat_SpecularMask				= 0xA346,	//       - Specular Mask
   6.275 +	Chunk_Mat_SpecularColorMask			= 0xA348,	//       - Specular color mask
   6.276 +	Chunk_Mat_SelfIlluminationMask		= 0xA34A,	//       - Self Illumination mask
   6.277 +	Chunk_Mat_ReflectionMask			= 0xA34C,	//       - Reflection mask
   6.278 +
   6.279 +	// map subchunks								// -----------------------
   6.280 +	Chunk_Map_FileName					= 0xA300,	//         - Filename
   6.281 +	Chunk_Map_Params					= 0xA351,	//         - Parameters
   6.282 +	Chunk_Map_BlurPercent				= 0xA353,	//         - Blur ammount
   6.283 +	Chunk_Map_VScale					= 0xA354,	//         - Texture V Scale
   6.284 +	Chunk_Map_UScale					= 0xA356,	//         - Texture U Scale
   6.285 +	Chunk_Map_UOffset					= 0xA358,	//         - Texture U Offset
   6.286 +	Chunk_MAP_VOffset					= 0xA35A,	//         - Texture V Offset
   6.287 +	Chunk_Map_RotationAngle				= 0xA35C,	//         - Texture Rotation Angle
   6.288 +	Chunk_Map_RGBLumAlphaTint1			= 0xA360,	//         - RGB Luminance Alpha Tint 1
   6.289 +	Chunk_Map_RGBLumAlphaTint2			= 0xA362,	//         - RGB Luminance Alpha Tint 2
   6.290 +	Chunk_Map_RGBTintR					= 0xA364,	//         - RGB Tint R
   6.291 +	Chunk_Map_RGBTintG					= 0xA366,	//         - RGB Tint G
   6.292 +	Chunk_Map_RGBTintB					= 0xA368,	//         - RGB Tint B
   6.293 +	// map subchunks end							// -----------------------
   6.294 +
   6.295 +	Chunk_Main_Keyframer				= 0xB000,	//     + Keyframer Chunk
   6.296 +	Chunk_Key_AmbientInfo				= 0xB001,	//       - Ambient animation info
   6.297 +	Chunk_Key_MeshInfo					= 0xB002,	//       - Mesh animation info
   6.298 +	Chunk_Key_CameraInfo				= 0xB003,	//       - Camera animation info
   6.299 +	Chunk_Key_CameraTargetInfo			= 0xB004,	//       - Camera Target animation info
   6.300 +	Chunk_Key_OmniLightInfo				= 0xB005,	//       - Omni Light animation info
   6.301 +	Chunk_Key_SpotLightTargetInfo		= 0xB006,	//       - Spotlight target animation info
   6.302 +	Chunk_Key_SpotLightInfo				= 0xB007,	//       - Spotlight animation info
   6.303 +	Chunk_Key_Frames					= 0xB008,	//       - Animation Frames
   6.304 +
   6.305 +	// animation information subchunks				// -----------------------
   6.306 +	Chunk_Info_Object					= 0xB010,	//         - Object information
   6.307 +	Chunk_Info_ObjectPivot				= 0xB013,	//         - Object Pivot
   6.308 +	Chunk_Info_ObjectMorphAngle			= 0xB015,	//         - Object Morph Angle
   6.309 +	Chunk_Info_PositionTrack			= 0xB020,	//         - Position Track
   6.310 +	Chunk_Info_RotationTrack			= 0xB021,	//         - Rotation Track
   6.311 +	Chunk_Info_ScaleTrack				= 0xB022,	//         - Scaling Track
   6.312 +	Chunk_Info_FOVTrack					= 0xB023,	//         - FOV Track
   6.313 +	Chunk_Info_RollTrack				= 0xB024,	//         - Roll Track
   6.314 +	Chunk_Info_ColorTrack				= 0xB025,	//         - Color Track
   6.315 +	Chunk_Info_MorphTrack				= 0xB026,	//         - Morph Track
   6.316 +	Chunk_Info_HotSpotTrack				= 0xB027,	//         - HotSpot Track
   6.317 +	Chunk_Info_FalloffTrack				= 0xB028,	//         - Falloff Track
   6.318 +	Chunk_Info_HideTrack				= 0xB029,	//         - Hide Track
   6.319 +	Chunk_Info_HierarchyPosition		= 0xB030	//         - Hierarchy Position
   6.320 +};
   6.321 +
   6.322 +#endif	// _3DSCHUNKS_H_
   6.323 +
     7.1 --- a/src/texture.cc	Mon Nov 18 03:35:20 2013 +0200
     7.2 +++ b/src/texture.cc	Mon Nov 18 04:10:19 2013 +0200
     7.3 @@ -1,3 +1,4 @@
     7.4 +#include <math.h>
     7.5  #include "texture.h"
     7.6  #include "image.h"
     7.7  #include "opengl.h"
     7.8 @@ -249,6 +250,7 @@
     7.9  	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    7.10  	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    7.11  	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    7.12 +	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
    7.13  
    7.14  	for(int i=0; i<6; i++) {
    7.15  		glTexImage2D(cube_faces[i], 0, ifmt, xsz, ysz, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
    7.16 @@ -269,6 +271,7 @@
    7.17  	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    7.18  	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    7.19  	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    7.20 +	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
    7.21  
    7.22  	glTexImage2D(cube_faces[idx], 0, texfmt, sz[0], sz[1], 0, fmt, type, img.get_pixels());
    7.23  }