summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2020-09-16 10:02:17 +0100
committerJose Fonseca <jfonseca@vmware.com>2020-09-16 10:02:17 +0100
commitcd45113d3c70dbd01d654fe7bd8430dba7bf8210 (patch)
treebd537193efe5b81e5d57d107af903a2bc7159f40
parent98c93dd1e0986326c34cfc9e2ead7fedbf23a166 (diff)
wgl/rtotex: Remove.
This sample is broken, it's not easy to fix, and it's too complicated/niche to be worth the hassle.
-rw-r--r--src/wgl/CMakeLists.txt2
-rw-r--r--src/wgl/rtotex/CMakeLists.txt34
-rw-r--r--src/wgl/rtotex/LICENSE.txt10
-rw-r--r--src/wgl/rtotex/README.txt55
-rw-r--r--src/wgl/rtotex/decal.bmpbin2102 -> 0 bytes
-rw-r--r--src/wgl/rtotex/fps_counter.cpp29
-rw-r--r--src/wgl/rtotex/fps_counter.h34
-rw-r--r--src/wgl/rtotex/image.cpp980
-rw-r--r--src/wgl/rtotex/image.h60
-rw-r--r--src/wgl/rtotex/interactor.cpp118
-rw-r--r--src/wgl/rtotex/interactor.h49
-rw-r--r--src/wgl/rtotex/log.cpp98
-rw-r--r--src/wgl/rtotex/log.h37
-rw-r--r--src/wgl/rtotex/main.cpp440
-rw-r--r--src/wgl/rtotex/main.h28
-rw-r--r--src/wgl/rtotex/maths/color.cpp58
-rw-r--r--src/wgl/rtotex/maths/color.h130
-rw-r--r--src/wgl/rtotex/maths/maths.h30
-rw-r--r--src/wgl/rtotex/maths/matrix4x4.cpp772
-rw-r--r--src/wgl/rtotex/maths/matrix4x4.h132
-rw-r--r--src/wgl/rtotex/maths/plane.cpp85
-rw-r--r--src/wgl/rtotex/maths/plane.h68
-rw-r--r--src/wgl/rtotex/maths/vector2d.cpp51
-rw-r--r--src/wgl/rtotex/maths/vector2d.h115
-rw-r--r--src/wgl/rtotex/maths/vector3d.cpp158
-rw-r--r--src/wgl/rtotex/maths/vector3d.h160
-rw-r--r--src/wgl/rtotex/maths/vector4d.cpp94
-rw-r--r--src/wgl/rtotex/maths/vector4d.h137
-rw-r--r--src/wgl/rtotex/pbuffer.cpp149
-rw-r--r--src/wgl/rtotex/pbuffer.h34
-rw-r--r--src/wgl/rtotex/timer.cpp42
-rw-r--r--src/wgl/rtotex/timer.h36
-rw-r--r--src/wgl/rtotex/window.cpp619
-rw-r--r--src/wgl/rtotex/window.h122
34 files changed, 0 insertions, 4966 deletions
diff --git a/src/wgl/CMakeLists.txt b/src/wgl/CMakeLists.txt
index 4c6e75e3..2b94711e 100644
--- a/src/wgl/CMakeLists.txt
+++ b/src/wgl/CMakeLists.txt
@@ -31,5 +31,3 @@ install (
wglgears
wincopy
DESTINATION wgl)
-
-add_subdirectory (rtotex)
diff --git a/src/wgl/rtotex/CMakeLists.txt b/src/wgl/rtotex/CMakeLists.txt
deleted file mode 100644
index ba5e5e68..00000000
--- a/src/wgl/rtotex/CMakeLists.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-include_directories (
- ${OPENGL_INCLUDE_PATH}
- ${GLUT_INCLUDE_DIR}
- ${GLEW_INCLUDE_DIR}
-)
-
-link_libraries (
- ${OPENGL_gl_LIBRARY}
- ${OPENGL_glu_LIBRARY}
- ${GLUT_glut_LIBRARY}
- ${GLEW_glew_LIBRARY}
-)
-
-add_executable (rtotex WIN32
- fps_counter.cpp
- image.cpp
- interactor.cpp
- log.cpp
- main.cpp
- pbuffer.cpp
- timer.cpp
- window.cpp
- maths/color.cpp
- maths/matrix4x4.cpp
- maths/plane.cpp
- maths/vector2d.cpp
- maths/vector3d.cpp
- maths/vector4d.cpp
-)
-
-install (TARGETS rtotex DESTINATION wgl/rtotex)
-
-install (FILES decal.bmp DESTINATION wgl/rtotex)
-
diff --git a/src/wgl/rtotex/LICENSE.txt b/src/wgl/rtotex/LICENSE.txt
deleted file mode 100644
index b6cd6a5c..00000000
--- a/src/wgl/rtotex/LICENSE.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-Copyright (c) 2006, Paul Baker
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- * Neither the name of paulsprojects.net nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/wgl/rtotex/README.txt b/src/wgl/rtotex/README.txt
deleted file mode 100644
index 3d92b18e..00000000
--- a/src/wgl/rtotex/README.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-**************************************************************************
-** Render to texture
-**
-** www.paulsprojects.net
-**
-** paul@paulsprojects.net
-**************************************************************************
-
-Description:
-
-This is my first use of pbuffers. It is a simple project which creates a render-to-texture-enabled pbuffer, and a texture object related to it. When rendering, the pbuffer is made the current context, and two wire tori are rendered into it. The window is then made current, and the pbuffer is used to texture a single rectangle. The camera can be moved around this rectangle.
-
-If the SGIS_generate_mipmap extension is supported, it is used to automatically generate mipmaps for the texture each time it is updated, and a LINEAR_MIPMAP_LINEAR filter is used. Otherwise, a LINEAR filter is used.
-
-If anisotropic filtering is supported, the maximum degree of anisotropy is enabled at start-up. The anisotropy level can be altered to show the difference this filtering has on the textured quad.
-
-It is also possible to render a second scene into the pbuffer, a textured teapot instead of the wire torus. This demonstrates rendering using textures in the pbuffer, then using the pbuffer image itself as a texture. The important thing to note here is that the texture object which will use the pbuffer image is part of the window context. The image on the teapot is part of the pbuffer context. It is important to load the image when the pbuffer context is current since in this demo, the two contexts do not share textures.
-
-
-Requirements:
-
-WGL_ARB_extensions_string
-WGL_ARB_pbuffer
-WGL_ARB_pixel_format
-WGL_ARB_render_texture
-
-Optional:
-
-EXT_texture_filter_anisotropic
-SGIS_generate_mipmap
-
-
-References:
-
-"Using pbuffers for off-screen rendering", Chris Wynn. From developer.nvidia.com
-"OpenGL Render-to-Texture", Chris Wynn. From developer.nvidia.com
-Extension specifications for the above WGL extensions.
-
-
-Keys:
-
-F1 - Take a screenshot
-Escape - Quit
-
-1 - Draw wire torus shape
-2 - Draw textured teapot
-
-Up - Increase texture max anisotropy (if anisotropic filtering is supported)
-Down - Decrease texture max anisotropy (if anisotropic filtering is supported)
-
-M - Use LINEAR_MIPMAP_LINEAR filtering, if SGIS_generate_mipmap is supported
-L - Use LINEAR filtering
-
-P - Pause
-U - Unpause
diff --git a/src/wgl/rtotex/decal.bmp b/src/wgl/rtotex/decal.bmp
deleted file mode 100644
index b54edf4b..00000000
--- a/src/wgl/rtotex/decal.bmp
+++ /dev/null
Binary files differ
diff --git a/src/wgl/rtotex/fps_counter.cpp b/src/wgl/rtotex/fps_counter.cpp
deleted file mode 100644
index b518ce65..00000000
--- a/src/wgl/rtotex/fps_counter.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// FPS_COUNTER.cpp
-// functions to calculate frames per second
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-#include <windows.h>
-#include "log.h"
-#include "fps_counter.h"
-
-extern LOG errorLog;
-
-void FPS_COUNTER::Update(void)
-{
- //keep track of time lapse and frame count
- time = timeGetTime()*0.001f; //get current time in seconds
- ++frames; //increase frame count
-
- if(time-lastTime>1.0f) //if it has been 1 second
- {
- fps = frames/(time-lastTime); //update fps number
- lastTime= time; //set beginning count
- frames = 0L; //reset frames this second
- }
-}
diff --git a/src/wgl/rtotex/fps_counter.h b/src/wgl/rtotex/fps_counter.h
deleted file mode 100644
index c9114f89..00000000
--- a/src/wgl/rtotex/fps_counter.h
+++ /dev/null
@@ -1,34 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// FPS_COUNTER.h
-// class to calculate frames per second
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef FPS_COUNTER_H
-#define FPS_COUNTER_H
-
-class FPS_COUNTER
-{
-public:
- void Update(void); //updates counter - call once per frame
- void Shutdown(void); //send max, min, average to log
- float GetFps(void) { return fps; }
-
- FPS_COUNTER() : fps(0.0f), lastTime(0.0f), frames(0L), time(0.0f)
- {}
- ~FPS_COUNTER() {}
-
-protected:
- float fps;
-
- float lastTime;
- long frames;
- float time;
-};
-
-#endif //FPS_COUNTER_H \ No newline at end of file
diff --git a/src/wgl/rtotex/image.cpp b/src/wgl/rtotex/image.cpp
deleted file mode 100644
index c6561d39..00000000
--- a/src/wgl/rtotex/image.cpp
+++ /dev/null
@@ -1,980 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// image.cpp
-// functions for image for a texture
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-#include <windows.h>
-#include <GL/gl.h>
-#include "log.h"
-#include "image.h"
-
-extern LOG errorLog;
-
-//Load - load a texture from a file
-bool IMAGE::Load(const char * filename)
-{
- //Clear the data if already used
- if(data)
- delete [] data;
- data=NULL;
- bpp=0;
- width=0;
- height=0;
- format=0;
-
- int filenameLength=strlen(filename);
-
- if( strncmp((filename+filenameLength-3), "BMP", 3)==0 ||
- strncmp((filename+filenameLength-3), "bmp", 3)==0)
- return LoadBMP(filename);
-
- if( strncmp((filename+filenameLength-3), "PCX", 3)==0 ||
- strncmp((filename+filenameLength-3), "pcx", 3)==0)
- return LoadPCX(filename);
-
- if( strncmp((filename+filenameLength-3), "TGA", 3)==0 ||
- strncmp((filename+filenameLength-3), "tga", 3)==0)
- return LoadTGA(filename);
-
- errorLog.OutputError("%s does not end in \".tga\", \".bmp\" or \"pcx\"", filename);
- return false;
-}
-
-
-
-bool IMAGE::LoadBMP(const char * filename)
-{
- FILE * file; //the texture file
- BITMAPFILEHEADER fileHeader; //bitmap file header
- BITMAPINFOHEADER infoHeader; //bitmap info header
-
- //open file for reading
- file=fopen(filename, "rb");
- if(file==NULL)
- {
- errorLog.OutputError("Unable to open %s", filename);
- return false;
- }
-
- //read the file header
- fread(&fileHeader, sizeof(BITMAPFILEHEADER), 1, file);
-
- //check it's a bitmap
- if(fileHeader.bfType != BITMAP_ID)
- {
- fclose(file);
- errorLog.OutputError("%s is not a legal .BMP", filename);
- return false;
- }
-
- //read in the information header
- fread(&infoHeader, sizeof(BITMAPINFOHEADER), 1, file);
-
- //close the file
- fclose(file);
-
- //discover the bpp
- if(infoHeader.biBitCount==24)
- return Load24BitBMP(filename);
- if(infoHeader.biBitCount==8)
- return Load8BitBMP(filename);
-
- errorLog.OutputError("%s has an unknown bpp", filename);
- return false;
-}
-
-
-//Load24BitBMP - load a 24 bit bitmap file
-bool IMAGE::Load24BitBMP(const char * filename)
-{
- errorLog.OutputSuccess("Loading %s in Load24bitBMP()", filename);
-
- //set bpp and format
- bpp=24;
- format=GL_RGB;
-
- FILE * file; //the texture file
- BITMAPFILEHEADER fileHeader; //bitmap file header
- BITMAPINFOHEADER infoHeader; //bitmap info header
-
- //open file for reading
- file=fopen(filename, "rb");
- if(file==NULL)
- {
- errorLog.OutputError("Unable to open %s", filename);
- return false;
- }
-
- //read the file header
- fread(&fileHeader, sizeof(BITMAPFILEHEADER), 1, file);
-
- //check it's a bitmap
- if(fileHeader.bfType != BITMAP_ID)
- {
- fclose(file);
- errorLog.OutputError("%s is not a legal .BMP", filename);
- return false;
- }
-
- //read in the information header
- fread(&infoHeader, sizeof(BITMAPINFOHEADER), 1, file);
-
- //set size
- width=infoHeader.biWidth;
- height=infoHeader.biHeight;
-
- //calculate the stride in bytes: width*bpp/8 plus padding bytes at the end of each row
- unsigned int stride=width*bpp/8;
- if(width%4==1)
- stride+=1;
- if(width%4==2)
- stride+=2;
- if(width%4==3)
- stride+=3;
-
- //point file to the beginning of the data
- fseek(file, fileHeader.bfOffBits, SEEK_SET);
-
- //allocate space for the image data
- data=new unsigned char[stride*height];
- if(!data)
- {
- fclose(file);
- errorLog.OutputError("Unable to allocate memory for %s", filename);
- return false;
- }
-
- //read in the data
- fread(data, 1, stride*height, file);
-
- //close the file
- fclose(file);
-
- //data is in BGR format
- //swap b and r
- for(unsigned int row=0; row<height; row++)
- {
- for(unsigned int i=0; i<width*3; i+=bpp/8)
- {
- //repeated XOR to swap bytes 0 and 2
- data[(row*stride)+i] ^= data[(row*stride)+i+2] ^=
- data[(row*stride)+i] ^= data[(row*stride)+i+2];
- }
- }
-
- errorLog.OutputSuccess("Loaded %s correctly.", filename);
- return true;
-}
-
-//Load8BitBMP - load an 8 bit paletted bitmap file
-bool IMAGE::Load8BitBMP(const char * filename)
-{
- errorLog.OutputSuccess("Loading %s in Load8bitBMP()", filename);
-
- //set bpp and format
- bpp=24; //after conversion
- format=GL_RGB;
-
- FILE * file; //the texture file
- BITMAPFILEHEADER fileHeader; //bitmap file header
- BITMAPINFOHEADER infoHeader; //bitmap info header
-
- //open file for reading
- file=fopen(filename, "rb");
- if(file==NULL)
- {
- errorLog.OutputError("Unable to open %s", filename);
- return false;
- }
-
- //read the file header
- fread(&fileHeader, sizeof(BITMAPFILEHEADER), 1, file);
-
- //check it's a bitmap
- if(fileHeader.bfType != BITMAP_ID)
- {
- fclose(file);
- errorLog.OutputError("%s is not a legal .BMP", filename);
- return false;
- }
-
- //read in the information header
- fread(&infoHeader, sizeof(BITMAPINFOHEADER), 1, file);
-
- //set size
- width=infoHeader.biWidth;
- height=infoHeader.biHeight;
-
- //make space for palette
- unsigned char * palette=new unsigned char[256*4];
- if(!palette)
- {
- errorLog.OutputError("Unable to alllocate memory for palette");
- return false;
- }
-
- //load the palette
- fread(palette, 256*4, 1, file);
-
- //point file to the beginning of the data
- fseek(file, fileHeader.bfOffBits, SEEK_SET);
-
- //calculate the stride in bytes between one row and the next
- unsigned int stride=width;
- if(width%4 != 0)
- stride+=4-width%4;
-
- //allocate space for color indices
- unsigned char * indices=new unsigned char[stride*height];
- if(!indices)
- {
- errorLog.OutputError("Unable to allocate memory for indices");
- return false;
- }
-
- //load indices
- fread(indices, 1, stride*height, file);
-
- //close the file
- fclose(file);
-
- //allocate space for the image data
- data=new unsigned char[stride*height*bpp/8];
- if(!data)
- {
- fclose(file);
- errorLog.OutputError("Unable to allocate memory for %s", filename);
- return false;
- }
-
- //calculate the color values - keeping the padding colors
- for(unsigned int currentRow=0; currentRow<height; currentRow++)
- {
- for(unsigned int i=0; i<stride; i++)
- {
- data[(currentRow*stride+i)*3+0]=palette[indices[currentRow*stride+i]*4+2];
- data[(currentRow*stride+i)*3+1]=palette[indices[currentRow*stride+i]*4+1];
- data[(currentRow*stride+i)*3+2]=palette[indices[currentRow*stride+i]*4+0];//BGR
- }
- }
-
- errorLog.OutputSuccess("Loaded %s correctly.", filename);
- return true;
-}
-
-
-
-
-
-
-
-//LoadPCX - load a .pcx texture - 256 color, paletted
-bool IMAGE::LoadPCX(const char * filename)
-{
- errorLog.OutputSuccess("Loading %s in LoadPCX()", filename);
-
- //set bpp and format
- bpp=24;
- format=GL_RGB;
-
- FILE * file;
-
- file=fopen(filename, "rb");
- if(!file)
- {
- errorLog.OutputError("Unable to open %s", filename);
- return false;
- }
-
- //retrieve header, first 4 bytes, first 2 should be 0x0A0C
- unsigned short header[2];
- fread(header, 4, 1, file);
-
- if(header[0]!=0x050A)
- {
- errorLog.OutputError("%s is not a legal .PCX file", filename);
- fclose(file);
- return false;
- }
-
- //retrieve minimum x value
- int xMin=fgetc(file); //loword
- xMin |= fgetc(file) << 8; //hiword
-
- //retrieve minimum y value
- int yMin=fgetc(file); //loword
- yMin |= fgetc(file) << 8; //hiword
-
- //retrieve maximum x value
- int xMax=fgetc(file); //loword
- xMax |= fgetc(file) << 8; //hiword
-
- //retrieve maximum y value
- int yMax=fgetc(file); //loword
- yMax |= fgetc(file) << 8; //hiword
-
- //calculate width and height
- width = xMax-xMin+1;
- height= yMax-yMin+1;
-
- //allocate memory for pixel data (paletted)
- unsigned char * pixelData=new unsigned char[width*height];
- if(!pixelData)
- {
- errorLog.OutputError("Unable to allocate %d bytes for the image data of %s",
- width*height, filename);
- fclose(file);
- return false;
- }
-
- //set file pointer to beginning of image data
- fseek(file, 128, SEEK_SET);
-
- //decode and store the pixel data
- unsigned int index=0;
-
- while(index<(width*height))
- {
- int c = getc(file);
-
- if(c>0xBF)
- {
- int numRepeat = 0x3F & c;
- c=getc(file);
-
- for(int i=0; i<numRepeat; i++)
- pixelData[index++] = c;
- }
- else
- pixelData[index++] = c;
-
- fflush(stdout);
- }
-
- //allocate memory for the image palette
- unsigned char * paletteData = new unsigned char[768];
-
- //the palette is the last 769 bytes of the file
- fseek(file, -769, SEEK_END);
-
- //retrieve first character, should be equal to 12
- int c=getc(file);
- if(c!=12)
- {
- errorLog.OutputError("%s is not a legal .PCX file - the palette data has an illegal header, %d",
- filename, c);
- fclose(file);
- return false;
- }
-
- //read and store the palette
- fread(paletteData, 1, 768, file);
-
- //close the file
- fclose(file);
-
- //allocate memory for the "unpaletted" data
- data = new unsigned char[width*height*3];
- if(!data)
- {
- errorLog.OutputError("Unable to allocate memory for the expanded data of %s", filename);
- return false;
- }
-
- //calculate the "unpaletted" data - "flipping" the texture top-bottom
- for(unsigned int j=0; j<height; j++)
- {
- for(unsigned int i=0; i<width; i++)
- {
- data[3*(j*width+i)] = (unsigned char) paletteData[3*pixelData[(height-1-j)*width+i]];
- data[3*(j*width+i)+1] = (unsigned char) paletteData[3*pixelData[(height-1-j)*width+i]+1];
- data[3*(j*width+i)+2] = (unsigned char) paletteData[3*pixelData[(height-1-j)*width+i]+2];
- }
- }
-
- errorLog.OutputSuccess("Loaded %s correctly.", filename);
- return true;
-}
-
-
-
-
-
-//Load a TGA texture
-bool IMAGE::LoadTGA(const char * filename)
-{
- unsigned char UncompressedTGAHeader[12]={0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- unsigned char CompressedTGAHeader[12]={0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- unsigned char Uncompressed8BitTGAHeader[12]={0, 1, 1, 0, 0, 0, 1, 24, 0, 0, 0, 0};
-
- unsigned char TGAcompare[12]; //Used to compare TGA header
-
- FILE * file = fopen(filename, "rb"); //Open the TGA file
-
- if( file==NULL ) //Does the file exist?
- {
- errorLog.OutputError("%s does not exist", filename);
- return false;
- }
-
- //read the header
- fread(TGAcompare, 1, sizeof(TGAcompare), file);
- fclose(file);
-
- if(memcmp(UncompressedTGAHeader, TGAcompare, sizeof(UncompressedTGAHeader))==0)
- {
- return LoadUncompressedTrueColorTGA(filename);
- }
- else if(memcmp(CompressedTGAHeader, TGAcompare, sizeof(CompressedTGAHeader))==0)
- {
- return LoadCompressedTrueColorTGA(filename);
- }
- else if(memcmp(Uncompressed8BitTGAHeader, TGAcompare, sizeof(Uncompressed8BitTGAHeader))==0)
- {
- return LoadUncompressed8BitTGA(filename);
- }
- else
- {
- errorLog.OutputError("%s is not a recognised type of TGA", filename);
- return false;
- }
-
- return false;
-}
-
-//load an 8 bit uncompressed paletted TGA
-bool IMAGE::LoadUncompressed8BitTGA(const char * filename)
-{
- unsigned char TGAHeader[12]={0, 1, 1, 0, 0, 0, 1, 24, 0, 0, 0, 0};
- unsigned char TGAcompare[12]; //Used to compare TGA header
- unsigned char header[6]; //First 6 useful bytes of the header
-
- errorLog.OutputSuccess("Loading %s in LoadUncompressed8BitTGA()", filename);
-
- FILE * file = fopen(filename, "rb"); //Open the TGA file
-
- if(file == NULL) //Does the file exist?
- {
- errorLog.OutputError("%s does not exist.", filename);
- return false;
- }
-
- if( fread(TGAcompare, 1, sizeof(TGAcompare), file)!=sizeof(TGAcompare)|| //Are there 12 bytes to read?
- memcmp(TGAHeader, TGAcompare, sizeof(TGAHeader))!=0 || //Is the header correct?
- fread(header, 1, sizeof(header), file)!=sizeof(header)) //Read next 6 bytes
- {
- fclose(file); //If anything else failed, close the file
- errorLog.OutputError("Could not load %s correctly, general failure.", filename);
- return false;
- }
-
- //save data into class member variables
- width= header[1]*256+header[0]; //determine the image width
- height= header[3]*256+header[2]; //determine image height
- bpp= header[4];
-
- if( width<=0 || //if width <=0
- height<=0 || //or height<=0
- bpp!=8) //bpp not 8
- {
- fclose(file); //close the file
- errorLog.OutputError("%s's height or width is less than zero, or the TGA is not 8 bpp.", filename);
- return false;
- }
-
- //set format
- format=GL_RGB;
-
- //make space for palette
- unsigned char * palette=new unsigned char[256*3];
- if(!palette)
- {
- errorLog.OutputError("Unable to allocate memory for palette");
- return false;
- }
-
- //load the palette
- fread(palette, 256*3, 1, file);
-
- //allocate space for color indices
- unsigned char * indices=new unsigned char[width*height];
- if(!indices)
- {
- errorLog.OutputError("Unable to allocate memory for indices");
- return false;
- }
-
- //load indices
- fread(indices, 1, width*height, file);
-
- //close the file
- fclose(file);
-
- //allocate space for the image data
- data=new unsigned char[width*height*3];
- if(!data)
- {
- fclose(file);
- errorLog.OutputError("Unable to allocate memory for %s", filename);
- return false;
- }
-
- //calculate the color values
- for(unsigned int currentRow=0; currentRow<height; currentRow++)
- {
- for(unsigned int i=0; i<width; i++)
- {
- data[(currentRow*width+i)*3+0]=palette[indices[currentRow*width+i]*3+2];
- data[(currentRow*width+i)*3+1]=palette[indices[currentRow*width+i]*3+1];
- data[(currentRow*width+i)*3+2]=palette[indices[currentRow*width+i]*3+0];//BGR
- }
- }
-
- errorLog.OutputSuccess("Loaded %s correctly.", filename);
- return true;
-}
-
-
-
-
-
-//load an uncompressed TGA texture (24 or 32 bpp)
-bool IMAGE::LoadUncompressedTrueColorTGA(const char * filename)
-{
- unsigned char TGAheader[12]={0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //Uncompressed TGA header
- unsigned char TGAcompare[12]; //Used to compare TGA header
- unsigned char header[6]; //First 6 useful bytes of the header
- unsigned int bytesPerPixel; //bytes per pixel
- unsigned int imageSize; //Stores Image size when in RAM
-
- errorLog.OutputSuccess("Loading %s in LoadUncompressedTGA()", filename);
-
- FILE * file = fopen(filename, "rb"); //Open the TGA file
-
- if(file == NULL) //Does the file exist?
- {
- errorLog.OutputError("%s does not exist.", filename);
- return false;
- }
-
- if( fread(TGAcompare, 1, sizeof(TGAcompare), file)!=sizeof(TGAcompare)|| //Are there 12 bytes to read?
- memcmp(TGAheader, TGAcompare, sizeof(TGAheader))!=0 || //Is the header correct?
- fread(header, 1, sizeof(header), file)!=sizeof(header)) //Read next 6 bytes
- {
- fclose(file); //If anything else failed, close the file
- errorLog.OutputError("Could not load %s correctly, general failure.", filename);
- return false;
- }
-
- //save data into class member variables
- width= header[1]*256+header[0]; //determine the image width
- height= header[3]*256+header[2]; //determine image height
- bpp= header[4];
-
- if( width<=0 || //if width <=0
- height<=0 || //or height<=0
- bpp!=24 && bpp!=32) //bpp not 24 or 32
- {
- fclose(file); //close the file
- errorLog.OutputError("%s's height or width is less than zero, or the TGA is not 24 or 32 bpp.", filename);
- return false;
- }
-
- //set format
- if(bpp == 24)
- format=GL_RGB;
- else
- format=GL_RGBA;
-
- bytesPerPixel=bpp/8; //calc bytes per pixel
- imageSize=width*height*bytesPerPixel; //calc memory required
-
- data=new unsigned char[imageSize]; //reserve the memory for the data
-
- if( data==NULL) //Does the storage memory exist?
- {
- errorLog.OutputError("Unable to allocate memory for %s image", filename);
- fclose(file);
- return false;
- }
-
- //read in the image data
- if(fread(data, 1, imageSize, file)!=imageSize) //Does the image size match the required?
- { //If not
- if(data) //If data loaded
- delete [] data; //free memory
- errorLog.OutputError("Could not read %s image data", filename);
- fclose(file); //close file
- return false;
- }
-
- fclose(file);
-
- //data is in BGR format
- //swap b and r
- for(int i=0; i<(int)imageSize; i+=bytesPerPixel)
- {
- //repeated XOR to swap bytes 0 and 2
- data[i] ^= data[i+2] ^= data[i] ^= data[i+2];
- }
-
- errorLog.OutputSuccess("Loaded %s correctly.", filename);
- return true;
-}
-
-
-
-
-
-//load a compressed TGA texture (24 or 32 bpp)
-bool IMAGE::LoadCompressedTrueColorTGA(const char * filename)
-{
- unsigned char TGAheader[12]={0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //Compressed TGA header
- unsigned char TGAcompare[12]; //Used to compare TGA header
- unsigned char header[6]; //First 6 useful bytes of the header
- unsigned int bytesPerPixel; //bytes per pixel
- unsigned int imageSize; //Stores Image size when in RAM
-
- errorLog.OutputSuccess("Loading %s in LoadCompressedTGA()", filename);
-
- FILE * file = fopen(filename, "rb"); //Open the TGA file
-
- if(file == NULL) //Does the file exist?
- {
- errorLog.OutputError("%s does not exist.", filename);
- return false;
- }
-
- if( fread(TGAcompare, 1, sizeof(TGAcompare), file)!=sizeof(TGAcompare)|| //Are there 12 bytes to read?
- memcmp(TGAheader, TGAcompare, sizeof(TGAheader))!=0 || //Is the header correct?
- fread(header, 1, sizeof(header), file)!=sizeof(header)) //Read next 6 bytes
- {
- fclose(file); //If anything else failed, close the file
- errorLog.OutputError("Could not load %s correctly, general failure.", filename);
- return false;
- }
-
- //save data into class member variables
- width= header[1]*256+header[0]; //determine the image width
- height= header[3]*256+header[2]; //determine image height
- bpp= header[4];
-
- if( width<=0 || //if width <=0
- height<=0 || //or height<=0
- bpp!=24 && bpp!=32) //bpp not 24 or 32
- {
- fclose(file); //close the file
- errorLog.OutputError("%s's height or width is less than zero, or the TGA is not 24 or 32 bpp.", filename);
- return false;
- }
-
- //set format
- if(bpp == 24)
- format=GL_RGB;
- else
- format=GL_RGBA;
-
- bytesPerPixel=bpp/8; //calc bytes per pixel
- imageSize=width*height*bytesPerPixel; //calc memory required
-
- data=new unsigned char[imageSize]; //reserve the memory for the data
- if(!data) //Does the storage memory exist?
- {
- errorLog.OutputError("Unable to allocate memory for %s image", filename);
- fclose(file);
- return false;
- }
-
- //read in the image data
- int pixelCount = height*width;
- int currentPixel= 0;
- int currentByte = 0;
- unsigned char * colorBuffer=new unsigned char[bytesPerPixel];
-
- do
- {
- unsigned char chunkHeader=0;
-
- if(fread(&chunkHeader, sizeof(unsigned char), 1, file) == 0)
- {
- errorLog.OutputError("Could not read RLE chunk header");
- if(file)
- fclose(file);
- if(data)
- delete [] data;
- return false;
- }
-
- if(chunkHeader<128) //Read raw color values
- {
- chunkHeader++;
-
- for(short counter=0; counter<chunkHeader; counter++)
- {
- if(fread(colorBuffer, 1, bytesPerPixel, file) != bytesPerPixel)
- {
- errorLog.OutputError("Unable to read %s image data", filename);
-
- if(file)
- fclose(file);
-
- if(colorBuffer)
- delete [] colorBuffer;
-
- if(data)
- delete [] data;
-
- return false;
- }
-
- //transfer pixel color to data (swapping r and b values)
- data[currentByte] = colorBuffer[2];
- data[currentByte+1] = colorBuffer[1];
- data[currentByte+2] = colorBuffer[0];
-
- if(bytesPerPixel==4)
- data[currentByte+3]=colorBuffer[3];
-
- currentByte+=bytesPerPixel;
- currentPixel++;
-
- if(currentPixel > pixelCount)
- {
- errorLog.OutputError("Too many pixels read");
- if(file)
- fclose(file);
- if(colorBuffer)
- delete [] colorBuffer;
- if(data)
- delete [] data;
- return false;
- }
- }
- }
- else //chunkHeader>=128
- {
- chunkHeader-=127;
-
- if(fread(colorBuffer, 1, bytesPerPixel, file) != bytesPerPixel)
- {
- errorLog.OutputError("Unable to read %s image data", filename);
-
- if(file)
- fclose(file);
- if(colorBuffer)
- delete [] colorBuffer;
- if(data)
- delete [] data;
- return false;
- }
-
- for(short counter=0; counter<chunkHeader; counter++)
- {
- //transfer pixel color to data (swapping r and b values)
- data[currentByte] = colorBuffer[2];
- data[currentByte+1] = colorBuffer[1];
- data[currentByte+2] = colorBuffer[0];
-
- if(bytesPerPixel==4)
- data[currentByte+3]=colorBuffer[3];
-
- currentByte+=bytesPerPixel;
- currentPixel++;
-
- if(currentPixel > pixelCount)
- {
- errorLog.OutputError("Too many pixels read");
- if(file)
- fclose(file);
- if(colorBuffer)
- delete [] colorBuffer;
- if(data)
- delete [] data;
- return false;
- }
- }
- }
- }while(currentPixel<pixelCount);
-
- fclose(file);
-
- errorLog.OutputSuccess("Loaded %s correctly.", filename);
- return true;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-//load in an 8 bit greyscale TGA as an alpha channel
-bool IMAGE::LoadAlphaTGA(const char * filename)
-{
- unsigned char TGAHeader[12]={0, 1, 1, 0, 0, 0, 1, 24, 0, 0, 0, 0};
- unsigned char TGAcompare[12]; //Used to compare TGA header
- unsigned char header[6]; //First 6 useful bytes of the header
-
- errorLog.OutputSuccess("Loading %s in LoadAlphaTGA()", filename);
-
- if(!(format==GL_RGB || format==GL_RGBA))
- {
- errorLog.OutputError("Can only load an alpha channel to RGB / RGBA format images. %s caused error", filename);
- return false;
- }
-
- FILE * file = fopen(filename, "rb"); //Open the TGA file
-
- if(file == NULL) //Does the file exist?
- {
- errorLog.OutputError("%s does not exist.", filename);
- return false;
- }
-
- if( fread(TGAcompare, 1, sizeof(TGAcompare), file)!=sizeof(TGAcompare)|| //Are there 12 bytes to read?
- memcmp(TGAHeader, TGAcompare, sizeof(TGAHeader))!=0 || //Is the header correct?
- fread(header, 1, sizeof(header), file)!=sizeof(header)) //Read next 6 bytes
- {
- fclose(file); //If anything else failed, close the file
- errorLog.OutputError("Could not load %s correctly, general failure.", filename);
- return false;
- }
-
- //save data into class member variables
- unsigned int alphaWidth= header[1]*256+header[0]; //determine the image width
- unsigned int alphaHeight= header[3]*256+header[2]; //determine image height
- int alphaBpp= header[4];
-
- if( alphaWidth<=0 || //if width <=0
- alphaHeight<=0 || //or height<=0
- alphaBpp!=8) //bpp not 8
- {
- fclose(file); //close the file
- errorLog.OutputError("%s's height or width is less than zero, or the TGA is not 8 bpp.", filename);
- return false;
- }
-
- //check it is the same size as the image
- if(alphaWidth!=width || alphaHeight!=height)
- {
- errorLog.OutputError("%s is not the same size as the color texture", filename);
- return false;
- }
-
- //make space for palette
- unsigned char * palette=new unsigned char[256*3];
- if(!palette)
- {
- errorLog.OutputError("Unable to allocate memory for palette");
- return false;
- }
-
- //load the palette
- fread(palette, 256*3, 1, file);
-
- //we dont use the palette
- delete [] palette;
- palette=NULL;
-
- //allocate space for alpha values
- unsigned char * values=new unsigned char[width*height];
- if(!values)
- {
- errorLog.OutputError("Unable to allocate memory for alpha values");
- return false;
- }
-
- //load indices
- fread(values, 1, alphaWidth*alphaHeight, file);
-
- //close the file
- fclose(file);
-
- //now put in the alpha data
- if(format==GL_RGBA)
- {
- for(unsigned int i=0; i<width*height; i++)
- {
- data[i*4+3]=values[i];
- }
- }
- else if(format==GL_RGB)
- {
- unsigned char * tempData=new unsigned char[width*height*4];
- if(!tempData)
- {
- errorLog.OutputError("Unable to allocate memory for Temporary Data");
- return false;
- }
-
- for(unsigned int i=0; i<width*height; i++)
- {
- tempData[i*4+0]=data[i*3+0];
- tempData[i*4+1]=data[i*3+1];
- tempData[i*4+2]=data[i*3+2];
- tempData[i*4+3]=values[i];
- }
-
- //update member variables
- bpp=32;
- format=GL_RGBA;
-
- if(data)
- delete [] data;
- data=tempData;
- }
-
- errorLog.OutputSuccess("Loaded %s correctly.", filename);
- return true;
-}
-
-
-void IMAGE::FlipVertically()
-{
- //dont flip zero or 1 height images
- if(height==0 || height==1)
- return;
-
- int rowsToSwap=0;
- //see how many rows to swap
- if(height%2==1)
- rowsToSwap=(height-1)/2;
- else
- rowsToSwap=height/2;
-
- //create space for a temporary row
- GLubyte * tempRow=new GLubyte[width*bpp/8];
- if(!tempRow)
- {
- errorLog.OutputError("Unable to flip image, unable to create space for temporary row");
- return;
- }
-
- //loop through rows to swap
- for(int i=0; i<rowsToSwap; ++i)
- {
- //copy row i into temp
- memcpy(tempRow, &data[i*width*bpp/8], width*bpp/8);
- //copy row height-i-1 to row i
- memcpy(&data[i*width*bpp/8], &data[(height-i-1)*width*bpp/8], width*bpp/8);
- //copy temp into row height-i-1
- memcpy(&data[(height-i-1)*width*bpp/8], tempRow, width*bpp/8);
- }
-
- //free tempRow
- if(tempRow)
- delete [] tempRow;
- tempRow=NULL;
-}
-
diff --git a/src/wgl/rtotex/image.h b/src/wgl/rtotex/image.h
deleted file mode 100644
index bbd2b1a4..00000000
--- a/src/wgl/rtotex/image.h
+++ /dev/null
@@ -1,60 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// IMAGE.h
-// functions for images to be turned to textures
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef IMAGE_H
-#define IMAGE_H
-
-#include <stdio.h>
-
-class IMAGE
-{
-public:
- IMAGE() : data(NULL), bpp(0), width(0), height(0)
- {}
-
- ~IMAGE()
- {
- if(data)
- delete [] data;
- data=NULL;
- }
-
- bool Load(const char * filename); //load a texture from a file
-
- bool LoadBMP(const char * filename); //Load BMP
- bool Load24BitBMP(const char * filename);
- bool Load8BitBMP(const char * filename);
-
- bool LoadPCX(const char * filename); //Load PCX
-
- bool LoadTGA(const char * filename); //Load TGA
- bool LoadUncompressed8BitTGA(const char * filename);
- bool LoadUncompressedTrueColorTGA(const char * filename);
- bool LoadCompressedTrueColorTGA(const char * filename);
-
- //load an uncompressed greyscale TGA for alpha channel
- bool LoadAlphaTGA(const char * filename);
-
- //Alter the image
- void FlipVertically();
-
- unsigned char * data; //Image data
- unsigned int bpp; //Image color depth in bits per pixel
- unsigned int width; //Image width
- unsigned int height; //Image height
-
- GLuint format; //Data format, eg GL_RGBA
-};
-
-//Universal bitmap identifier
-const DWORD BITMAP_ID=0x4D42;
-
-#endif //TEXTURE_IMAGE_H
diff --git a/src/wgl/rtotex/interactor.cpp b/src/wgl/rtotex/interactor.cpp
deleted file mode 100644
index af36a1ee..00000000
--- a/src/wgl/rtotex/interactor.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// INTERACTOR.h
-// Functions for mouse interactor class
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-// Updated: 30th August 2002 - Added bounds on r
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-#include <windows.h>
-#include <GL/gl.h>
-#include "log.h"
-#include "window.h"
-#include "maths/maths.h"
-#include "interactor.h"
-
-extern WINDOW window;
-extern LOG errorLog;
-
-void INTERACTOR::Init( VECTOR3D startPosition, float newMinR, float newMaxR,
- VECTOR3D newLookAt)
-{
- position=startPosition;
- lookAt=newLookAt;
-
- minR=newMinR;
- maxR=newMaxR;
-
- //calculate r and angles
- VECTOR3D lineOfSight=position-lookAt;
- r=lineOfSight.GetLength();
-
- if(lineOfSight.z==0.0f)
- {
- if(lineOfSight.x>0.0f)
- leftRightRotation=-90.0f;
- if(lineOfSight.x<0.0f)
- leftRightRotation=90.0f;
- }
- else
- {
- if(lineOfSight.z<0.0f)
- leftRightRotation=180.0-(180.0/M_PI)*atan(lineOfSight.x/lineOfSight.z);
- if(lineOfSight.z>0.0f)
- leftRightRotation=-(180.0/M_PI)*atan(lineOfSight.x/lineOfSight.z);
- }
-
-
-
- if(lineOfSight.x==0.0f && lineOfSight.z==0.0f)
- upDownRotation=90.0;
- else
- upDownRotation=(180.0/M_PI)*atan(lineOfSight.y/sqrt((lineOfSight.x*lineOfSight.x)+
- (lineOfSight.z*lineOfSight.z)));
-}
-
-void INTERACTOR::Update()
-{
- //update angles
- if(window.isLeftButtonPressed())
- {
- leftRightRotation+=(window.GetMouseXMovement())*rotationSensitivity;
- upDownRotation+=(window.GetMouseYMovement())*rotationSensitivity;
- }
-
- //update radius
- if(window.isRightButtonPressed())
- {
- //move out
- if(window.GetMouseYMovement()>0)
- {
- //move out no further than maxR
- if(r+(window.GetMouseYMovement())*(float)translationSensitivity>maxR)
- r=maxR;
- else
- r+=(window.GetMouseYMovement())*(float)translationSensitivity;
- }
-
- //move in
- if(window.GetMouseYMovement()<0)
- {
- //move in no further than minR
- if(r+(window.GetMouseYMovement())*(float)translationSensitivity<minR)
- r=minR;
- else
- r+=(window.GetMouseYMovement())*(float)translationSensitivity;
- }
- }
-
- //update position if there has been a change
- if(window.isLeftButtonPressed() || window.isRightButtonPressed())
- {
- static MATRIX4X4 tempMatrix;
- glPushMatrix();
- glLoadIdentity();
- glTranslatef(lookAt.x, lookAt.y, lookAt.z);
- glRotated(-leftRightRotation, 0.0f, 1.0f, 0.0f);
- glRotated(-upDownRotation, 1.0f, 0.0f, 0.0f);
- glTranslatef(0.0f, 0.0f, r);
- glGetFloatv(GL_MODELVIEW_MATRIX, tempMatrix);
- position=tempMatrix.GetColumn(3);
- glPopMatrix();
- }
-}
-
-void INTERACTOR::SetupViewMatrix()
-{
- glPushMatrix();
- glLoadIdentity();
- glTranslatef(0.0f, 0.0f, -r);
- glRotated(upDownRotation, 1.0f, 0.0f, 0.0f);
- glRotated(leftRightRotation, 0.0f, 1.0f, 0.0f);
- glTranslatef(-lookAt.x, -lookAt.y, -lookAt.z);
- glGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix);
- glPopMatrix();
-}
diff --git a/src/wgl/rtotex/interactor.h b/src/wgl/rtotex/interactor.h
deleted file mode 100644
index 6962645a..00000000
--- a/src/wgl/rtotex/interactor.h
+++ /dev/null
@@ -1,49 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// INTERACTOR.h
-// Class declaration for mouse interactor class
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef INTERACTOR_H
-#define INTERACTOR_H
-
-class INTERACTOR
-{
-public:
- void Init( VECTOR3D startPosition,
- float newMinR=0.0f, float newMaxR=10000000.0f,
- VECTOR3D newLookAt=VECTOR3D(0.0f, 0.0f, 0.0f));
-
- void SetSensitivity(double newRotationSensitivity=0.5, double newTranslationSensitivity=0.01)
- {
- rotationSensitivity=newRotationSensitivity;
- translationSensitivity=newTranslationSensitivity;
- }
-
- virtual void Update();
- void SetupViewMatrix();
-
- INTERACTOR() : rotationSensitivity(0.5), translationSensitivity(0.01)
- {}
- virtual ~INTERACTOR()
- {}
-
- VECTOR3D position;
- VECTOR3D lookAt;
-
- MATRIX4X4 viewMatrix;
-
- //spherical coordinates
- float r;
- double leftRightRotation, upDownRotation;
-
- double rotationSensitivity, translationSensitivity;
- float minR, maxR;
-};
-
-#endif //INTERACTOR_H \ No newline at end of file
diff --git a/src/wgl/rtotex/log.cpp b/src/wgl/rtotex/log.cpp
deleted file mode 100644
index afbdf769..00000000
--- a/src/wgl/rtotex/log.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// LOG.cpp
-// functions to output an error log
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#include "log.h"
-
-//Initiates log. Dont call, it is in the constructor
-bool LOG::Init(const char * filename)
-{
- //Clear the log file contents
- if((logfile=fopen(filename, "wb"))==NULL)
- return false;
-
- //Close the file, return success
- fclose (logfile);
- return true;
-}
-
-
-//Shuts down log, in the destructor.
-bool LOG::Shutdown()
-{
- if(logfile)
- fclose(logfile);
-
- return true;
-}
-
-
-//output newline
-void LOG::OutputNewline()
-{
- //Open the file for append
- if((logfile=fopen("Error Log.txt", "a+"))==NULL)
- return;
-
- //Write the newline
- putc('\n', logfile);
-
- //Close the file
- fclose(logfile);
-}
-
-
-void LOG::OutputError(const char * text,...)
-{
- va_list arg_list;
-
- //Initialise varible argument list
- va_start(arg_list, text);
-
- //Open the file for append
- if((logfile=fopen("Error Log.txt", "a+"))==NULL)
- return;
-
- //Write the text
- fprintf(logfile, "<!> ");
- vfprintf(logfile, text, arg_list);
- putc('\n', logfile);
-
- //Also write to the console window
- printf("<!> ");
- vprintf(text, arg_list);
- printf("\n");
-
- //Close the file
- fclose(logfile);
- va_end(arg_list);
-}
-
-
-void LOG::OutputSuccess(const char * text,...)
-{
- va_list arg_list;
-
- //Initialise varible argument list
- va_start(arg_list, text);
-
- //Open the file for append
- if((logfile=fopen("Error Log.txt", "a+"))==NULL)
- return;
-
- //Write the text
- fprintf(logfile, "<-> ");
- vfprintf(logfile, text, arg_list);
- putc('\n', logfile);
-
- //Close the file
- fclose(logfile);
- va_end(arg_list);
-}
diff --git a/src/wgl/rtotex/log.h b/src/wgl/rtotex/log.h
deleted file mode 100644
index 76e52c88..00000000
--- a/src/wgl/rtotex/log.h
+++ /dev/null
@@ -1,37 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// log.h
-// class to output an error log
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef LOG_H
-#define LOG_H
-
-#include <stdio.h>
-#include <stdarg.h>
-
-class LOG
-{
-protected:
- FILE * logfile;
-
- bool Shutdown(void);
-
-public:
- bool Init(const char * filename);
-
- //Output to log
- void OutputNewline();
- void OutputError(const char * text, ...);
- void OutputSuccess(const char * text, ...);
-
- LOG() {}
- ~LOG(){ Shutdown(); }
-};
-
-#endif
diff --git a/src/wgl/rtotex/main.cpp b/src/wgl/rtotex/main.cpp
deleted file mode 100644
index 0cfa0d97..00000000
--- a/src/wgl/rtotex/main.cpp
+++ /dev/null
@@ -1,440 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// Main.cpp
-// Render to texture
-// Downloaded from: www.paulsprojects.net
-// Created: 10th September 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-#include <windows.h>
-#include <GL/glew.h>
-#include <GL/wglew.h>
-#include <GL/glu.h>
-#include <GL/glut.h>
-#include "log.h"
-#include "window.h"
-#include "fps_counter.h"
-#include "timer.h"
-#include "maths/maths.h"
-#include "pbuffer.h"
-#include "interactor.h"
-#include "image.h"
-#include "main.h"
-
-//errorLog MUST be kept - it is used by other files
-LOG errorLog;
-WINDOW window;
-FPS_COUNTER fpsCounter;
-TIMER timer;
-
-COLOR windowBackgroundColor(0.0f, 0.0f, 1.0f, 0.0f);
-COLOR pbufferBackgroundColor(0.0f, 0.0f, 0.0f, 0.0f);
-
-INTERACTOR camera;
-
-int pbufferSize=512;
-PBUFFER pbuffer;
-GLuint pbufferTexture; //texture object which is used when pbuffer texture is displayed
-
-//anisotropy
-int currentAnisotropy=1.0f;
-int maxAnisotropy=1.0f;
-
-//Using mipmap filtering?
-bool useMipmapFilter=false;
-
-//Draw the textured teapot into the pbuffer?
-bool drawTextured=false;
-
-GLuint decalTexture; //texture ID
-
-//Set up variables
-bool DemoInit()
-{
- if(!window.Init("Render To Texture", 640, 480, 32, 24, 8, WINDOWED_SCREEN))
- return 0; //quit if not created
-
- glewInit();
-
- camera.Init(VECTOR3D(0.0f, 0.0f, -2.5f), 2.0f, 100.0f);
-
- //Set up extensions
- if( !WGLEW_ARB_extensions_string)
- return false;
-
- //Set up wgl extensions
- if( !WGLEW_ARB_pbuffer || !WGLEW_ARB_pixel_format ||
- !WGLEW_ARB_render_texture)
- return false;
-
-
- //Init the pbuffer
- int pbufferExtraIAttribs[]={WGL_BIND_TO_TEXTURE_RGBA_ARB, true,
- 0};
-
- int pbufferFlags[]={WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB,
- WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB,
-
- //request mipmap space if mipmaps are to be used
- GLEW_SGIS_generate_mipmap ? WGL_MIPMAP_TEXTURE_ARB : 0,
- GLEW_SGIS_generate_mipmap ? true : 0,
-
- 0};
-
- if(!pbuffer.Init(pbufferSize, pbufferSize, 32, 24, 8, 1, pbufferExtraIAttribs, pbufferFlags))
- return false;
-
-
- //Create the texture object to relate to the pbuffer
- glGenTextures(1, &pbufferTexture);
- glBindTexture(GL_TEXTURE_2D, pbufferTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
-
- //Use generated mipmaps if supported
- if(GLEW_SGIS_generate_mipmap)
- {
- glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, true);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
- useMipmapFilter=true;
- }
-
- //Use maximum anisotropy if supported
- if(GLEW_EXT_texture_filter_anisotropic)
- {
- glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
- currentAnisotropy=maxAnisotropy;
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, currentAnisotropy);
- }
-
-
-
- //Load the decal texture
- //Note: This MUST be done when the pbuffer is the current context
- pbuffer.MakeCurrent();
-
- IMAGE decalImage;
- decalImage.Load("decal.bmp");
-
- glGenTextures(1, &decalTexture);
- glBindTexture(GL_TEXTURE_2D, decalTexture);
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, decalImage.width, decalImage.height,
- 0, decalImage.format, GL_UNSIGNED_BYTE, decalImage.data);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
-
-
-
- //reset timer for start
- timer.Reset();
-
- return true;
-}
-
-//Set up openGL
-bool GLInit()
-{
- //Set up for pbuffer
- pbuffer.MakeCurrent();
-
- //set viewport
- glViewport(0, 0, pbufferSize, pbufferSize);
-
- //set up projection matrix
- glMatrixMode(GL_PROJECTION); //select projection matrix
- glLoadIdentity(); //reset
- gluPerspective(45.0f, 1.0f, 1.0f, 100.0f);
-
- //load identity modelview
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- //other states
- //shading
- glShadeModel(GL_SMOOTH);
- glClearColor( pbufferBackgroundColor.r,
- pbufferBackgroundColor.g,
- pbufferBackgroundColor.b,
- pbufferBackgroundColor.a);
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-
- //depth
- glClearDepth(1.0f);
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LEQUAL);
-
- //hints
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
-
-
-
-
-
- //Set up for window
- window.MakeCurrent();
-
- //set viewport
- int height;
- if (window.height==0)
- height=1;
- else
- height=window.height;
-
- glViewport(0, 0, window.width, height); //reset viewport
-
- //set up projection matrix
- glMatrixMode(GL_PROJECTION); //select projection matrix
- glLoadIdentity(); //reset
- gluPerspective(45.0f, (GLfloat)window.width/(GLfloat)height, 1.0f, 100.0f);
-
- //load identity modelview
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- //other states
- //shading
- glShadeModel(GL_SMOOTH);
- glClearColor( windowBackgroundColor.r,
- windowBackgroundColor.g,
- windowBackgroundColor.b,
- windowBackgroundColor.a);
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-
- //depth
- glClearDepth(1.0f);
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LEQUAL);
-
- //hints
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
-
- glEnable(GL_TEXTURE_2D);
-
-
- return true;
-}
-
-//Perform per frame updates
-void UpdateFrame()
-{
- window.Update();
- camera.Update();
-
- //Change anisotropy level
- if( window.isKeyPressed(VK_UP) && GLEW_EXT_texture_filter_anisotropic &&
- currentAnisotropy<maxAnisotropy)
- {
- window.MakeCurrent();
- currentAnisotropy*=2;
- glBindTexture(GL_TEXTURE_2D, pbufferTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, currentAnisotropy);
- window.SetKeyReleased(VK_UP);
- }
-
- if( window.isKeyPressed(VK_DOWN) && GLEW_EXT_texture_filter_anisotropic &&
- currentAnisotropy>1)
- {
- window.MakeCurrent();
- currentAnisotropy/=2;
- glBindTexture(GL_TEXTURE_2D, pbufferTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, currentAnisotropy);
- window.SetKeyReleased(VK_DOWN);
- }
-
- //toggle mipmaps
- if( window.isKeyPressed('M') && useMipmapFilter==false && GLEW_SGIS_generate_mipmap)
- {
- window.MakeCurrent();
- glBindTexture(GL_TEXTURE_2D, pbufferTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, true);
- useMipmapFilter=true;
- }
-
- if( window.isKeyPressed('L') && useMipmapFilter==true && GLEW_SGIS_generate_mipmap)
- {
- window.MakeCurrent();
- glBindTexture(GL_TEXTURE_2D, pbufferTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, false);
- useMipmapFilter=false;
- }
-
- //Pause/unpause
- if(window.isKeyPressed('P'))
- timer.Pause();
-
- if(window.isKeyPressed('U'))
- timer.Unpause();
-
- //Swap between scenes in the pbuffer
- if(window.isKeyPressed('1') && drawTextured)
- {
- //Draw wire tori
- drawTextured=false;
- }
-
- if(window.isKeyPressed('2') && !drawTextured)
- {
- //draw textured sphere
- drawTextured=true;
- }
-}
-
-//draw a frame
-void RenderFrame()
-{
- //Draw to pbuffer
- pbuffer.MakeCurrent();
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glLoadIdentity(); //reset modelview matrix
-
- gluLookAt( 0.0f, 0.0f, 4.0f,
- 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f);
-
- //Draw scene
- if(drawTextured)
- {
- glBindTexture(GL_TEXTURE_2D, decalTexture);
- glEnable(GL_TEXTURE_2D);
-
- glPushMatrix();
- glRotatef(timer.GetTime()/20, 0.0f, 1.0f, 0.0f);
-
- glutSolidTeapot(0.8f);
-
- glPopMatrix();
-
- glDisable(GL_TEXTURE_2D);
- }
- else
- {
- glPushMatrix();
- glRotatef(timer.GetTime()/20, 0.0f, 1.0f, 0.0f);
- glRotatef(55.0f, 1.0f, 0.0f, 0.0f);
- glutWireTorus(0.3f, 1.0f, 12, 24);
- glPopMatrix();
-
- glPushMatrix();
- glRotatef(timer.GetTime()/20, 0.0f, 1.0f, 0.0f);
- glRotatef(-55.0f, 1.0f, 0.0f, 0.0f);
- glutWireTorus(0.3f, 1.0f, 12, 24);
- glPopMatrix();
- }
-
-
-
- //Draw to window
- window.MakeCurrent();
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- camera.SetupViewMatrix();
- glLoadMatrixf(camera.viewMatrix);
-
-
- glBindTexture(GL_TEXTURE_2D, pbufferTexture);
- //use the pbuffer as the texture
- wglBindTexImageARB(pbuffer.hBuffer, WGL_FRONT_LEFT_ARB);
-
-
- //Draw simple rectangle
- glBegin(GL_TRIANGLE_STRIP);
- {
- glTexCoord2f(0.0f, 0.0f);
- glVertex3f(-1.0f, -1.0f, 0.0f);
- glTexCoord2f(0.0f, 1.0f);
- glVertex3f(-1.0f, 1.0f, 0.0f);
- glTexCoord2f(1.0f, 0.0f);
- glVertex3f( 1.0f, -1.0f, 0.0f);
- glTexCoord2f(1.0f, 1.0f);
- glVertex3f( 1.0f, 1.0f, 0.0f);
- }
- glEnd();
-
- //release the pbuffer for further rendering
- wglReleaseTexImageARB(pbuffer.hBuffer, WGL_FRONT_LEFT_ARB);
-
-
-
- fpsCounter.Update(); //update frames per second counter
- glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
- window.StartTextMode();
- window.Print(0, 28, "FPS: %.2f", fpsCounter.GetFps()); //print the fps
- glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
- window.Print(0, 48, "%dx Anisotropy", currentAnisotropy);
- glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
- window.Print(0, 68, "%s", useMipmapFilter ? "LINEAR_MIPMAP_LINEAR filtering" :
- "LINEAR filtering");
- window.EndTextMode();
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-
- if(window.isKeyPressed(VK_F1))
- {
- window.SaveScreenshot();
- window.SetKeyReleased(VK_F1);
- }
-
- window.SwapBuffers(); //swap buffers
-
- //check for any opengl errors
- window.CheckGLError();
-
- //quit if necessary
- if(window.isKeyPressed(VK_ESCAPE))
- PostQuitMessage(0);
-}
-
-void DemoShutdown()
-{
- pbuffer.Shutdown();
-
- window.Shutdown(); //Shutdown window
-}
-
-//ENTRY POINT FOR APPLICATION
-//CALL WINDOW CREATION ROUTINE, DEAL WITH MESSAGES, WATCH FOR INTERACTION
-int WINAPI WinMain( HINSTANCE hInstance, //instance
- HINSTANCE hPrevInstance, //Previous Instance
- LPSTR lpCmdLine, //command line parameters
- int nCmdShow) //Window show state
-{
- //Initiation
- errorLog.Init("Error Log.txt");
-
- //init variables etc, then GL
- if(!DemoInit())
- {
- errorLog.OutputError("Demo Initiation failed");
- return 0;
- }
- else
- errorLog.OutputSuccess("Demo Initiation Successful");
-
- if(!GLInit())
- {
- errorLog.OutputError("OpenGL Initiation failed");
- return 0;
- }
- else
- errorLog.OutputSuccess("OpenGL Initiation Successful");
-
- //Main Loop
- for(;;)
- {
- if(!(window.HandleMessages())) break;//handle windows messages, quit if returns false
- UpdateFrame();
- RenderFrame();
- }
-
- DemoShutdown();
-
- errorLog.OutputSuccess("Exiting...");
- return (window.msg.wParam); //Exit The Program
-}
diff --git a/src/wgl/rtotex/main.h b/src/wgl/rtotex/main.h
deleted file mode 100644
index 73238c71..00000000
--- a/src/wgl/rtotex/main.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// Main.h
-// Render to texture
-// Downloaded from: www.paulsprojects.net
-// Created: 10th September 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef MAIN_H
-#define MAIN_H
-
-bool DemoInit();
-bool GLInit();
-
-void UpdateFrame();
-void RenderFrame();
-
-void DemoShutdown();
-
-int WINAPI WinMain(HINSTANCE hInstance,
- HINSTANCE hPervInstance,
- LPSTR lpCmdLine,
- int nCmdShow); //main entry point
-
-#endif //MAIN_H \ No newline at end of file
diff --git a/src/wgl/rtotex/maths/color.cpp b/src/wgl/rtotex/maths/color.cpp
deleted file mode 100644
index f3dca98e..00000000
--- a/src/wgl/rtotex/maths/color.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// COLOR.cpp
-// function definitions for an RGBA color class
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-// Modified: 7th November 2002 - Some speed improvements
-// - Removed clamping after adds etc. Do it yourself!
-// To enable use with floating point color buffers
-// - Corrected lerp (reversed f and 1-f)
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#include "maths.h"
-
-void COLOR::ClampTo01()
-{
- if(r>1.0f)
- r=1.0f;
- if(r<0.0f)
- r=0.0f;
-
- if(g>1.0f)
- g=1.0f;
- if(g<0.0f)
- g=0.0f;
-
- if(b>1.0f)
- b=1.0f;
- if(b<0.0f)
- b=0.0f;
-
- if(a>1.0f)
- a=1.0f;
- if(a<0.0f)
- a=0.0f;
-}
-
-COLOR operator*(float scaleFactor, const COLOR & rhs)
-{
- return rhs*scaleFactor;
-}
-
-bool COLOR::operator ==(const COLOR & rhs) const
-{
- if(r != rhs.r)
- return false;
- if(g != rhs.g)
- return false;
- if(b != rhs.b)
- return false;
- if(a != rhs.a)
- return false;
-
- return true;
-}
diff --git a/src/wgl/rtotex/maths/color.h b/src/wgl/rtotex/maths/color.h
deleted file mode 100644
index 2ff29dcc..00000000
--- a/src/wgl/rtotex/maths/color.h
+++ /dev/null
@@ -1,130 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// COLOR.h
-// Class declaration for an RGBA color
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-// Modified: 7th November 2002 - Some speed improvements
-// - Removed clamping after adds etc. Do it yourself!
-// To enable use with floating point color buffers
-// - Corrected lerp (reversed f and 1-f)
-// 13th December 2002 - Added default parameter to alpha of Set()
-// - Added red, green, blue constant COLORs
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef COLOR_H
-#define COLOR_H
-
-class COLOR
-{
-public:
- //constructors
- COLOR()
- { r=g=b=a=0.0f; }
-
- COLOR(float newR, float newG, float newB, float newA=0.0f)
- { r=newR; g=newG; b=newB; a=newA; }
-
- COLOR(const float * rhs)
- { r=*rhs; g=*(rhs+1); b=*(rhs+2); a=*(rhs+3); }
-
- COLOR(const COLOR & rhs)
- { r=rhs.r; g=rhs.g; b=rhs.b; a=rhs.a;}
-
- ~COLOR() {} //empty
-
- void Set(float newR, float newG, float newB, float newA=0.0f)
- { r=newR; g=newG; b=newB; a=newA; }
-
- //accessors kept for compatability
- void SetR(float newR) {r = newR;}
- void SetG(float newG) {g = newG;}
- void SetB(float newB) {b = newB;}
- void SetA(float newA) {a = newA;}
-
- float GetR() const {return r;} //public accessor functions
- float GetG() const {return g;} //inline, const
- float GetB() const {return b;}
- float GetA() const {return a;}
-
- void ClampTo01(void); //clamp all components to [0,1]
-
- void SetBlack(void) {r=g=b=a=1.0f;}
- void SetWhite(void) {r=g=b=a=0.0f;}
- void SetGrey(float shade) {r=g=b=a=shade;}
-
- //linear interpolate
- COLOR lerp(const COLOR & c2, float factor)
- { return (*this)*(1.0f-factor) + c2*factor; }
-
- //binary operators
- COLOR operator+(const COLOR & rhs) const
- { return COLOR(r+rhs.r, g+rhs.g, b+rhs.b, a+rhs.a); }
-
- COLOR operator-(const COLOR & rhs) const
- { return COLOR(r-rhs.r, g-rhs.g, b-rhs.b, a-rhs.a); }
-
- COLOR operator*(const COLOR & rhs) const
- { return COLOR(r*rhs.r, g*rhs.g, b*rhs.b, a*rhs.a); }
-
- COLOR operator/(const COLOR & rhs) const
- { return COLOR(r/rhs.r, g/rhs.g, b/rhs.b, a/rhs.a); }
-
- COLOR operator*(const float rhs) const
- { return COLOR(r*rhs, g*rhs, b*rhs, a*rhs); }
-
- COLOR operator/(const float rhs) const
- { return COLOR(r/rhs, g/rhs, b/rhs, a/rhs); }
-
- //multiply by a float, eg 3*c
- friend COLOR operator*(float scaleFactor, const COLOR & rhs);
-
- bool operator==(const COLOR & rhs) const;
- bool operator!=(const COLOR & rhs) const
- { return !((*this)==rhs); }
-
- //self-add etc
- COLOR operator+=(const COLOR & rhs)
- { (*this)=(*this)+rhs; return (*this); }
-
- COLOR operator-=(const COLOR & rhs)
- { (*this)=(*this)-rhs; return (*this); }
-
- COLOR operator*=(const COLOR & rhs)
- { (*this)=(*this)*rhs; return (*this); }
-
- COLOR operator/=(const COLOR & rhs)
- { (*this)=(*this)/rhs; return (*this); }
-
- COLOR operator*=(const float rhs)
- { (*this)=(*this)*rhs; return (*this); }
-
- COLOR operator/=(const float rhs)
- { (*this)=(*this)/rhs; return (*this); }
-
- //unary operators
- COLOR operator-(void) const {return COLOR(-r,-g, -b, -a);}
- COLOR operator+(void) const {return (*this);}
-
- //cast to pointer to float for glColor4fv etc
- operator float* () const {return (float*) this;}
- operator const float* () const {return (const float*) this;}
-
- //member variables
- float r;
- float g;
- float b;
- float a;
-};
-
-const COLOR white(1.0f, 1.0f, 1.0f, 1.0f);
-const COLOR black(0.0f, 0.0f, 0.0f, 0.0f);
-
-const COLOR red(1.0f, 0.0f, 0.0f, 1.0f);
-const COLOR green(0.0f, 1.0f, 0.0f, 1.0f);
-const COLOR blue(0.0f, 0.0f, 1.0f, 1.0f);
-
-#endif //COLOR_H \ No newline at end of file
diff --git a/src/wgl/rtotex/maths/maths.h b/src/wgl/rtotex/maths/maths.h
deleted file mode 100644
index 2ed58531..00000000
--- a/src/wgl/rtotex/maths/maths.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// Maths.h
-// Include maths headers
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-// Modified: 17th December 2002 - Removed QUATERNION
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-#include <math.h>
-
-//VC++ math.h (and others) do not define M_PI
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-//An epsilon value for comparisons
-#ifndef EPSILON
-#define EPSILON 0.01f
-#endif
-
-#include "vector2d.h"
-#include "vector3d.h"
-#include "vector4d.h"
-#include "matrix4x4.h"
-#include "plane.h"
-
-#include "color.h" \ No newline at end of file
diff --git a/src/wgl/rtotex/maths/matrix4x4.cpp b/src/wgl/rtotex/maths/matrix4x4.cpp
deleted file mode 100644
index 2b3ca67d..00000000
--- a/src/wgl/rtotex/maths/matrix4x4.cpp
+++ /dev/null
@@ -1,772 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// MATRIX4X4.cpp
-// function definitions for 4x4 matrix class
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-// Updated: 19th August 2002 - Corrected 2nd SetPerspective for n!=1.0f
-// 26th September 2002 - Added nudge to prevent artifacts with infinite far plane
-// - Improved speed
-// 7th November 2002 - Added Affine Inverse functions
-// - Changed constructors
-// - Added special cases for row3 = (0, 0, 0, 1)
-// 17th December 2002 - Converted from radians to degrees for consistency
-// with OpenGL. Should have been done a long time ago...
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-#include <memory.h>
-#include "maths.h"
-
-MATRIX4X4::MATRIX4X4(float e0, float e1, float e2, float e3,
- float e4, float e5, float e6, float e7,
- float e8, float e9, float e10, float e11,
- float e12, float e13, float e14, float e15)
-{
- entries[0]=e0;
- entries[1]=e1;
- entries[2]=e2;
- entries[3]=e3;
- entries[4]=e4;
- entries[5]=e5;
- entries[6]=e6;
- entries[7]=e7;
- entries[8]=e8;
- entries[9]=e9;
- entries[10]=e10;
- entries[11]=e11;
- entries[12]=e12;
- entries[13]=e13;
- entries[14]=e14;
- entries[15]=e15;
-}
-
-MATRIX4X4::MATRIX4X4(const MATRIX4X4 & rhs)
-{
- memcpy(entries, rhs.entries, 16*sizeof(float));
-}
-
-MATRIX4X4::MATRIX4X4(const float * rhs)
-{
- memcpy(entries, rhs, 16*sizeof(float));
-}
-
-void MATRIX4X4::SetEntry(int position, float value)
-{
- if(position>=0 && position<=15)
- entries[position]=value;
-}
-
-float MATRIX4X4::GetEntry(int position) const
-{
- if(position>=0 && position<=15)
- return entries[position];
-
- return 0.0f;
-}
-
-VECTOR4D MATRIX4X4::GetRow(int position) const
-{
- if(position==0)
- return VECTOR4D(entries[0], entries[4], entries[8], entries[12]);
-
- if(position==1)
- return VECTOR4D(entries[1], entries[5], entries[9], entries[13]);
-
- if(position==2)
- return VECTOR4D(entries[2], entries[6], entries[10], entries[14]);
-
- if(position==3)
- return VECTOR4D(entries[3], entries[7], entries[11], entries[15]);
-
- return VECTOR4D(0.0f, 0.0f, 0.0f, 0.0f);
-}
-
-VECTOR4D MATRIX4X4::GetColumn(int position) const
-{
- if(position==0)
- return VECTOR4D(entries[0], entries[1], entries[2], entries[3]);
-
- if(position==1)
- return VECTOR4D(entries[4], entries[5], entries[6], entries[7]);
-
- if(position==2)
- return VECTOR4D(entries[8], entries[9], entries[10], entries[11]);
-
- if(position==3)
- return VECTOR4D(entries[12], entries[13], entries[14], entries[15]);
-
- return VECTOR4D(0.0f, 0.0f, 0.0f, 0.0f);
-}
-
-void MATRIX4X4::LoadIdentity(void)
-{
- memset(entries, 0, 16*sizeof(float));
- entries[0]=1.0f;
- entries[5]=1.0f;
- entries[10]=1.0f;
- entries[15]=1.0f;
-}
-
-void MATRIX4X4::LoadZero(void)
-{
- memset(entries, 0, 16*sizeof(float));
-}
-
-MATRIX4X4 MATRIX4X4::operator+(const MATRIX4X4 & rhs) const //overloaded operators
-{
- return MATRIX4X4( entries[0]+rhs.entries[0],
- entries[1]+rhs.entries[1],
- entries[2]+rhs.entries[2],
- entries[3]+rhs.entries[3],
- entries[4]+rhs.entries[4],
- entries[5]+rhs.entries[5],
- entries[6]+rhs.entries[6],
- entries[7]+rhs.entries[7],
- entries[8]+rhs.entries[8],
- entries[9]+rhs.entries[9],
- entries[10]+rhs.entries[10],
- entries[11]+rhs.entries[11],
- entries[12]+rhs.entries[12],
- entries[13]+rhs.entries[13],
- entries[14]+rhs.entries[14],
- entries[15]+rhs.entries[15]);
-}
-
-MATRIX4X4 MATRIX4X4::operator-(const MATRIX4X4 & rhs) const //overloaded operators
-{
- return MATRIX4X4( entries[0]-rhs.entries[0],
- entries[1]-rhs.entries[1],
- entries[2]-rhs.entries[2],
- entries[3]-rhs.entries[3],
- entries[4]-rhs.entries[4],
- entries[5]-rhs.entries[5],
- entries[6]-rhs.entries[6],
- entries[7]-rhs.entries[7],
- entries[8]-rhs.entries[8],
- entries[9]-rhs.entries[9],
- entries[10]-rhs.entries[10],
- entries[11]-rhs.entries[11],
- entries[12]-rhs.entries[12],
- entries[13]-rhs.entries[13],
- entries[14]-rhs.entries[14],
- entries[15]-rhs.entries[15]);
-}
-
-MATRIX4X4 MATRIX4X4::operator*(const MATRIX4X4 & rhs) const
-{
- //Optimise for matrices in which bottom row is (0, 0, 0, 1) in both matrices
- if( entries[3]==0.0f && entries[7]==0.0f && entries[11]==0.0f && entries[15]==1.0f &&
- rhs.entries[3]==0.0f && rhs.entries[7]==0.0f &&
- rhs.entries[11]==0.0f && rhs.entries[15]==1.0f)
- {
- return MATRIX4X4( entries[0]*rhs.entries[0]+entries[4]*rhs.entries[1]+entries[8]*rhs.entries[2],
- entries[1]*rhs.entries[0]+entries[5]*rhs.entries[1]+entries[9]*rhs.entries[2],
- entries[2]*rhs.entries[0]+entries[6]*rhs.entries[1]+entries[10]*rhs.entries[2],
- 0.0f,
- entries[0]*rhs.entries[4]+entries[4]*rhs.entries[5]+entries[8]*rhs.entries[6],
- entries[1]*rhs.entries[4]+entries[5]*rhs.entries[5]+entries[9]*rhs.entries[6],
- entries[2]*rhs.entries[4]+entries[6]*rhs.entries[5]+entries[10]*rhs.entries[6],
- 0.0f,
- entries[0]*rhs.entries[8]+entries[4]*rhs.entries[9]+entries[8]*rhs.entries[10],
- entries[1]*rhs.entries[8]+entries[5]*rhs.entries[9]+entries[9]*rhs.entries[10],
- entries[2]*rhs.entries[8]+entries[6]*rhs.entries[9]+entries[10]*rhs.entries[10],
- 0.0f,
- entries[0]*rhs.entries[12]+entries[4]*rhs.entries[13]+entries[8]*rhs.entries[14]+entries[12],
- entries[1]*rhs.entries[12]+entries[5]*rhs.entries[13]+entries[9]*rhs.entries[14]+entries[13],
- entries[2]*rhs.entries[12]+entries[6]*rhs.entries[13]+entries[10]*rhs.entries[14]+entries[14],
- 1.0f);
- }
-
- //Optimise for when bottom row of 1st matrix is (0, 0, 0, 1)
- if( entries[3]==0.0f && entries[7]==0.0f && entries[11]==0.0f && entries[15]==1.0f)
- {
- return MATRIX4X4( entries[0]*rhs.entries[0]+entries[4]*rhs.entries[1]+entries[8]*rhs.entries[2]+entries[12]*rhs.entries[3],
- entries[1]*rhs.entries[0]+entries[5]*rhs.entries[1]+entries[9]*rhs.entries[2]+entries[13]*rhs.entries[3],
- entries[2]*rhs.entries[0]+entries[6]*rhs.entries[1]+entries[10]*rhs.entries[2]+entries[14]*rhs.entries[3],
- rhs.entries[3],
- entries[0]*rhs.entries[4]+entries[4]*rhs.entries[5]+entries[8]*rhs.entries[6]+entries[12]*rhs.entries[7],
- entries[1]*rhs.entries[4]+entries[5]*rhs.entries[5]+entries[9]*rhs.entries[6]+entries[13]*rhs.entries[7],
- entries[2]*rhs.entries[4]+entries[6]*rhs.entries[5]+entries[10]*rhs.entries[6]+entries[14]*rhs.entries[7],
- rhs.entries[7],
- entries[0]*rhs.entries[8]+entries[4]*rhs.entries[9]+entries[8]*rhs.entries[10]+entries[12]*rhs.entries[11],
- entries[1]*rhs.entries[8]+entries[5]*rhs.entries[9]+entries[9]*rhs.entries[10]+entries[13]*rhs.entries[11],
- entries[2]*rhs.entries[8]+entries[6]*rhs.entries[9]+entries[10]*rhs.entries[10]+entries[14]*rhs.entries[11],
- rhs.entries[11],
- entries[0]*rhs.entries[12]+entries[4]*rhs.entries[13]+entries[8]*rhs.entries[14]+entries[12]*rhs.entries[15],
- entries[1]*rhs.entries[12]+entries[5]*rhs.entries[13]+entries[9]*rhs.entries[14]+entries[13]*rhs.entries[15],
- entries[2]*rhs.entries[12]+entries[6]*rhs.entries[13]+entries[10]*rhs.entries[14]+entries[14]*rhs.entries[15],
- rhs.entries[15]);
- }
-
- //Optimise for when bottom row of 2nd matrix is (0, 0, 0, 1)
- if( rhs.entries[3]==0.0f && rhs.entries[7]==0.0f &&
- rhs.entries[11]==0.0f && rhs.entries[15]==1.0f)
- {
- return MATRIX4X4( entries[0]*rhs.entries[0]+entries[4]*rhs.entries[1]+entries[8]*rhs.entries[2],
- entries[1]*rhs.entries[0]+entries[5]*rhs.entries[1]+entries[9]*rhs.entries[2],
- entries[2]*rhs.entries[0]+entries[6]*rhs.entries[1]+entries[10]*rhs.entries[2],
- entries[3]*rhs.entries[0]+entries[7]*rhs.entries[1]+entries[11]*rhs.entries[2],
- entries[0]*rhs.entries[4]+entries[4]*rhs.entries[5]+entries[8]*rhs.entries[6],
- entries[1]*rhs.entries[4]+entries[5]*rhs.entries[5]+entries[9]*rhs.entries[6],
- entries[2]*rhs.entries[4]+entries[6]*rhs.entries[5]+entries[10]*rhs.entries[6],
- entries[3]*rhs.entries[4]+entries[7]*rhs.entries[5]+entries[11]*rhs.entries[6],
- entries[0]*rhs.entries[8]+entries[4]*rhs.entries[9]+entries[8]*rhs.entries[10],
- entries[1]*rhs.entries[8]+entries[5]*rhs.entries[9]+entries[9]*rhs.entries[10],
- entries[2]*rhs.entries[8]+entries[6]*rhs.entries[9]+entries[10]*rhs.entries[10],
- entries[3]*rhs.entries[8]+entries[7]*rhs.entries[9]+entries[11]*rhs.entries[10],
- entries[0]*rhs.entries[12]+entries[4]*rhs.entries[13]+entries[8]*rhs.entries[14]+entries[12],
- entries[1]*rhs.entries[12]+entries[5]*rhs.entries[13]+entries[9]*rhs.entries[14]+entries[13],
- entries[2]*rhs.entries[12]+entries[6]*rhs.entries[13]+entries[10]*rhs.entries[14]+entries[14],
- entries[3]*rhs.entries[12]+entries[7]*rhs.entries[13]+entries[11]*rhs.entries[14]+entries[15]);
- }
-
- return MATRIX4X4( entries[0]*rhs.entries[0]+entries[4]*rhs.entries[1]+entries[8]*rhs.entries[2]+entries[12]*rhs.entries[3],
- entries[1]*rhs.entries[0]+entries[5]*rhs.entries[1]+entries[9]*rhs.entries[2]+entries[13]*rhs.entries[3],
- entries[2]*rhs.entries[0]+entries[6]*rhs.entries[1]+entries[10]*rhs.entries[2]+entries[14]*rhs.entries[3],
- entries[3]*rhs.entries[0]+entries[7]*rhs.entries[1]+entries[11]*rhs.entries[2]+entries[15]*rhs.entries[3],
- entries[0]*rhs.entries[4]+entries[4]*rhs.entries[5]+entries[8]*rhs.entries[6]+entries[12]*rhs.entries[7],
- entries[1]*rhs.entries[4]+entries[5]*rhs.entries[5]+entries[9]*rhs.entries[6]+entries[13]*rhs.entries[7],
- entries[2]*rhs.entries[4]+entries[6]*rhs.entries[5]+entries[10]*rhs.entries[6]+entries[14]*rhs.entries[7],
- entries[3]*rhs.entries[4]+entries[7]*rhs.entries[5]+entries[11]*rhs.entries[6]+entries[15]*rhs.entries[7],
- entries[0]*rhs.entries[8]+entries[4]*rhs.entries[9]+entries[8]*rhs.entries[10]+entries[12]*rhs.entries[11],
- entries[1]*rhs.entries[8]+entries[5]*rhs.entries[9]+entries[9]*rhs.entries[10]+entries[13]*rhs.entries[11],
- entries[2]*rhs.entries[8]+entries[6]*rhs.entries[9]+entries[10]*rhs.entries[10]+entries[14]*rhs.entries[11],
- entries[3]*rhs.entries[8]+entries[7]*rhs.entries[9]+entries[11]*rhs.entries[10]+entries[15]*rhs.entries[11],
- entries[0]*rhs.entries[12]+entries[4]*rhs.entries[13]+entries[8]*rhs.entries[14]+entries[12]*rhs.entries[15],
- entries[1]*rhs.entries[12]+entries[5]*rhs.entries[13]+entries[9]*rhs.entries[14]+entries[13]*rhs.entries[15],
- entries[2]*rhs.entries[12]+entries[6]*rhs.entries[13]+entries[10]*rhs.entries[14]+entries[14]*rhs.entries[15],
- entries[3]*rhs.entries[12]+entries[7]*rhs.entries[13]+entries[11]*rhs.entries[14]+entries[15]*rhs.entries[15]);
-}
-
-MATRIX4X4 MATRIX4X4::operator*(const float rhs) const
-{
- return MATRIX4X4( entries[0]*rhs,
- entries[1]*rhs,
- entries[2]*rhs,
- entries[3]*rhs,
- entries[4]*rhs,
- entries[5]*rhs,
- entries[6]*rhs,
- entries[7]*rhs,
- entries[8]*rhs,
- entries[9]*rhs,
- entries[10]*rhs,
- entries[11]*rhs,
- entries[12]*rhs,
- entries[13]*rhs,
- entries[14]*rhs,
- entries[15]*rhs);
-}
-
-MATRIX4X4 MATRIX4X4::operator/(const float rhs) const
-{
- if (rhs==0.0f || rhs==1.0f)
- return (*this);
-
- float temp=1/rhs;
-
- return (*this)*temp;
-}
-
-MATRIX4X4 operator*(float scaleFactor, const MATRIX4X4 & rhs)
-{
- return rhs*scaleFactor;
-}
-
-bool MATRIX4X4::operator==(const MATRIX4X4 & rhs) const
-{
- for(int i=0; i<16; i++)
- {
- if(entries[i]!=rhs.entries[i])
- return false;
- }
- return true;
-}
-
-bool MATRIX4X4::operator!=(const MATRIX4X4 & rhs) const
-{
- return !((*this)==rhs);
-}
-
-void MATRIX4X4::operator+=(const MATRIX4X4 & rhs)
-{
- (*this)=(*this)+rhs;
-}
-
-void MATRIX4X4::operator-=(const MATRIX4X4 & rhs)
-{
- (*this)=(*this)-rhs;
-}
-
-void MATRIX4X4::operator*=(const MATRIX4X4 & rhs)
-{
- (*this)=(*this)*rhs;
-}
-
-void MATRIX4X4::operator*=(const float rhs)
-{
- (*this)=(*this)*rhs;
-}
-
-void MATRIX4X4::operator/=(const float rhs)
-{
- (*this)=(*this)/rhs;
-}
-
-MATRIX4X4 MATRIX4X4::operator-(void) const
-{
- MATRIX4X4 result(*this);
-
- for(int i=0; i<16; i++)
- result.entries[i]=-result.entries[i];
-
- return result;
-}
-
-VECTOR4D MATRIX4X4::operator*(const VECTOR4D rhs) const
-{
- //Optimise for matrices in which bottom row is (0, 0, 0, 1)
- if(entries[3]==0.0f && entries[7]==0.0f && entries[11]==0.0f && entries[15]==1.0f)
- {
- return VECTOR4D(entries[0]*rhs.x
- + entries[4]*rhs.y
- + entries[8]*rhs.z
- + entries[12]*rhs.w,
-
- entries[1]*rhs.x
- + entries[5]*rhs.y
- + entries[9]*rhs.z
- + entries[13]*rhs.w,
-
- entries[2]*rhs.x
- + entries[6]*rhs.y
- + entries[10]*rhs.z
- + entries[14]*rhs.w,
-
- rhs.w);
- }
-
- return VECTOR4D( entries[0]*rhs.x
- + entries[4]*rhs.y
- + entries[8]*rhs.z
- + entries[12]*rhs.w,
-
- entries[1]*rhs.x
- + entries[5]*rhs.y
- + entries[9]*rhs.z
- + entries[13]*rhs.w,
-
- entries[2]*rhs.x
- + entries[6]*rhs.y
- + entries[10]*rhs.z
- + entries[14]*rhs.w,
-
- entries[3]*rhs.x
- + entries[7]*rhs.y
- + entries[11]*rhs.z
- + entries[15]*rhs.w);
-}
-
-VECTOR3D MATRIX4X4::GetRotatedVector3D(const VECTOR3D & rhs) const
-{
- return VECTOR3D(entries[0]*rhs.x + entries[4]*rhs.y + entries[8]*rhs.z,
- entries[1]*rhs.x + entries[5]*rhs.y + entries[9]*rhs.z,
- entries[2]*rhs.x + entries[6]*rhs.y + entries[10]*rhs.z);
-}
-
-VECTOR3D MATRIX4X4::GetInverseRotatedVector3D(const VECTOR3D & rhs) const
-{
- //rotate by transpose:
- return VECTOR3D(entries[0]*rhs.x + entries[1]*rhs.y + entries[2]*rhs.z,
- entries[4]*rhs.x + entries[5]*rhs.y + entries[6]*rhs.z,
- entries[8]*rhs.x + entries[9]*rhs.y + entries[10]*rhs.z);
-}
-
-VECTOR3D MATRIX4X4::GetTranslatedVector3D(const VECTOR3D & rhs) const
-{
- return VECTOR3D(rhs.x+entries[12], rhs.y+entries[13], rhs.z+entries[14]);
-}
-
-VECTOR3D MATRIX4X4::GetInverseTranslatedVector3D(const VECTOR3D & rhs) const
-{
- return VECTOR3D(rhs.x-entries[12], rhs.y-entries[13], rhs.z-entries[14]);
-}
-
-void MATRIX4X4::Invert(void)
-{
- *this=GetInverse();
-}
-
-MATRIX4X4 MATRIX4X4::GetInverse(void) const
-{
- MATRIX4X4 result=GetInverseTranspose();
-
- result.Transpose();
-
- return result;
-}
-
-
-void MATRIX4X4::Transpose(void)
-{
- *this=GetTranspose();
-}
-
-MATRIX4X4 MATRIX4X4::GetTranspose(void) const
-{
- return MATRIX4X4( entries[ 0], entries[ 4], entries[ 8], entries[12],
- entries[ 1], entries[ 5], entries[ 9], entries[13],
- entries[ 2], entries[ 6], entries[10], entries[14],
- entries[ 3], entries[ 7], entries[11], entries[15]);
-}
-
-void MATRIX4X4::InvertTranspose(void)
-{
- *this=GetInverseTranspose();
-}
-
-MATRIX4X4 MATRIX4X4::GetInverseTranspose(void) const
-{
- MATRIX4X4 result;
-
- float tmp[12]; //temporary pair storage
- float det; //determinant
-
- //calculate pairs for first 8 elements (cofactors)
- tmp[0] = entries[10] * entries[15];
- tmp[1] = entries[11] * entries[14];
- tmp[2] = entries[9] * entries[15];
- tmp[3] = entries[11] * entries[13];
- tmp[4] = entries[9] * entries[14];
- tmp[5] = entries[10] * entries[13];
- tmp[6] = entries[8] * entries[15];
- tmp[7] = entries[11] * entries[12];
- tmp[8] = entries[8] * entries[14];
- tmp[9] = entries[10] * entries[12];
- tmp[10] = entries[8] * entries[13];
- tmp[11] = entries[9] * entries[12];
-
- //calculate first 8 elements (cofactors)
- result.SetEntry(0, tmp[0]*entries[5] + tmp[3]*entries[6] + tmp[4]*entries[7]
- - tmp[1]*entries[5] - tmp[2]*entries[6] - tmp[5]*entries[7]);
-
- result.SetEntry(1, tmp[1]*entries[4] + tmp[6]*entries[6] + tmp[9]*entries[7]
- - tmp[0]*entries[4] - tmp[7]*entries[6] - tmp[8]*entries[7]);
-
- result.SetEntry(2, tmp[2]*entries[4] + tmp[7]*entries[5] + tmp[10]*entries[7]
- - tmp[3]*entries[4] - tmp[6]*entries[5] - tmp[11]*entries[7]);
-
- result.SetEntry(3, tmp[5]*entries[4] + tmp[8]*entries[5] + tmp[11]*entries[6]
- - tmp[4]*entries[4] - tmp[9]*entries[5] - tmp[10]*entries[6]);
-
- result.SetEntry(4, tmp[1]*entries[1] + tmp[2]*entries[2] + tmp[5]*entries[3]
- - tmp[0]*entries[1] - tmp[3]*entries[2] - tmp[4]*entries[3]);
-
- result.SetEntry(5, tmp[0]*entries[0] + tmp[7]*entries[2] + tmp[8]*entries[3]
- - tmp[1]*entries[0] - tmp[6]*entries[2] - tmp[9]*entries[3]);
-
- result.SetEntry(6, tmp[3]*entries[0] + tmp[6]*entries[1] + tmp[11]*entries[3]
- - tmp[2]*entries[0] - tmp[7]*entries[1] - tmp[10]*entries[3]);
-
- result.SetEntry(7, tmp[4]*entries[0] + tmp[9]*entries[1] + tmp[10]*entries[2]
- - tmp[5]*entries[0] - tmp[8]*entries[1] - tmp[11]*entries[2]);
-
- //calculate pairs for second 8 elements (cofactors)
- tmp[0] = entries[2]*entries[7];
- tmp[1] = entries[3]*entries[6];
- tmp[2] = entries[1]*entries[7];
- tmp[3] = entries[3]*entries[5];
- tmp[4] = entries[1]*entries[6];
- tmp[5] = entries[2]*entries[5];
- tmp[6] = entries[0]*entries[7];
- tmp[7] = entries[3]*entries[4];
- tmp[8] = entries[0]*entries[6];
- tmp[9] = entries[2]*entries[4];
- tmp[10] = entries[0]*entries[5];
- tmp[11] = entries[1]*entries[4];
-
- //calculate second 8 elements (cofactors)
- result.SetEntry(8, tmp[0]*entries[13] + tmp[3]*entries[14] + tmp[4]*entries[15]
- - tmp[1]*entries[13] - tmp[2]*entries[14] - tmp[5]*entries[15]);
-
- result.SetEntry(9, tmp[1]*entries[12] + tmp[6]*entries[14] + tmp[9]*entries[15]
- - tmp[0]*entries[12] - tmp[7]*entries[14] - tmp[8]*entries[15]);
-
- result.SetEntry(10, tmp[2]*entries[12] + tmp[7]*entries[13] + tmp[10]*entries[15]
- - tmp[3]*entries[12] - tmp[6]*entries[13] - tmp[11]*entries[15]);
-
- result.SetEntry(11, tmp[5]*entries[12] + tmp[8]*entries[13] + tmp[11]*entries[14]
- - tmp[4]*entries[12] - tmp[9]*entries[13] - tmp[10]*entries[14]);
-
- result.SetEntry(12, tmp[2]*entries[10] + tmp[5]*entries[11] + tmp[1]*entries[9]
- - tmp[4]*entries[11] - tmp[0]*entries[9] - tmp[3]*entries[10]);
-
- result.SetEntry(13, tmp[8]*entries[11] + tmp[0]*entries[8] + tmp[7]*entries[10]
- - tmp[6]*entries[10] - tmp[9]*entries[11] - tmp[1]*entries[8]);
-
- result.SetEntry(14, tmp[6]*entries[9] + tmp[11]*entries[11] + tmp[3]*entries[8]
- - tmp[10]*entries[11] - tmp[2]*entries[8] - tmp[7]*entries[9]);
-
- result.SetEntry(15, tmp[10]*entries[10] + tmp[4]*entries[8] + tmp[9]*entries[9]
- - tmp[8]*entries[9] - tmp[11]*entries[10] - tmp[5]*entries[8]);
-
- // calculate determinant
- det = entries[0]*result.GetEntry(0)
- +entries[1]*result.GetEntry(1)
- +entries[2]*result.GetEntry(2)
- +entries[3]*result.GetEntry(3);
-
- if(det==0.0f)
- {
- MATRIX4X4 id;
- return id;
- }
-
- result=result/det;
-
- return result;
-}
-
-//Invert if only composed of rotations & translations
-void MATRIX4X4::AffineInvert(void)
-{
- (*this)=GetAffineInverse();
-}
-
-MATRIX4X4 MATRIX4X4::GetAffineInverse(void) const
-{
- //return the transpose of the rotation part
- //and the negative of the inverse rotated translation part
- return MATRIX4X4( entries[0],
- entries[4],
- entries[8],
- 0.0f,
- entries[1],
- entries[5],
- entries[9],
- 0.0f,
- entries[2],
- entries[6],
- entries[10],
- 0.0f,
- -(entries[0]*entries[12]+entries[1]*entries[13]+entries[2]*entries[14]),
- -(entries[4]*entries[12]+entries[5]*entries[13]+entries[6]*entries[14]),
- -(entries[8]*entries[12]+entries[9]*entries[13]+entries[10]*entries[14]),
- 1.0f);
-}
-
-void MATRIX4X4::AffineInvertTranspose(void)
-{
- (*this)=GetAffineInverseTranspose();
-}
-
-MATRIX4X4 MATRIX4X4::GetAffineInverseTranspose(void) const
-{
- //return the transpose of the rotation part
- //and the negative of the inverse rotated translation part
- //transposed
- return MATRIX4X4( entries[0],
- entries[1],
- entries[2],
- -(entries[0]*entries[12]+entries[1]*entries[13]+entries[2]*entries[14]),
- entries[4],
- entries[5],
- entries[6],
- -(entries[4]*entries[12]+entries[5]*entries[13]+entries[6]*entries[14]),
- entries[8],
- entries[9],
- entries[10],
- -(entries[8]*entries[12]+entries[9]*entries[13]+entries[10]*entries[14]),
- 0.0f, 0.0f, 0.0f, 1.0f);
-}
-
-void MATRIX4X4::SetTranslation(const VECTOR3D & translation)
-{
- LoadIdentity();
-
- SetTranslationPart(translation);
-}
-
-void MATRIX4X4::SetScale(const VECTOR3D & scaleFactor)
-{
- LoadIdentity();
-
- entries[0]=scaleFactor.x;
- entries[5]=scaleFactor.y;
- entries[10]=scaleFactor.z;
-}
-
-void MATRIX4X4::SetUniformScale(const float scaleFactor)
-{
- LoadIdentity();
-
- entries[0]=entries[5]=entries[10]=scaleFactor;
-}
-
-void MATRIX4X4::SetRotationAxis(const double angle, const VECTOR3D & axis)
-{
- VECTOR3D u=axis.GetNormalized();
-
- float sinAngle=(float)sin(M_PI*angle/180);
- float cosAngle=(float)cos(M_PI*angle/180);
- float oneMinusCosAngle=1.0f-cosAngle;
-
- LoadIdentity();
-
- entries[0]=(u.x)*(u.x) + cosAngle*(1-(u.x)*(u.x));
- entries[4]=(u.x)*(u.y)*(oneMinusCosAngle) - sinAngle*u.z;
- entries[8]=(u.x)*(u.z)*(oneMinusCosAngle) + sinAngle*u.y;
-
- entries[1]=(u.x)*(u.y)*(oneMinusCosAngle) + sinAngle*u.z;
- entries[5]=(u.y)*(u.y) + cosAngle*(1-(u.y)*(u.y));
- entries[9]=(u.y)*(u.z)*(oneMinusCosAngle) - sinAngle*u.x;
-
- entries[2]=(u.x)*(u.z)*(oneMinusCosAngle) - sinAngle*u.y;
- entries[6]=(u.y)*(u.z)*(oneMinusCosAngle) + sinAngle*u.x;
- entries[10]=(u.z)*(u.z) + cosAngle*(1-(u.z)*(u.z));
-}
-
-void MATRIX4X4::SetRotationX(const double angle)
-{
- LoadIdentity();
-
- entries[5]=(float)cos(M_PI*angle/180);
- entries[6]=(float)sin(M_PI*angle/180);
-
- entries[9]=-entries[6];
- entries[10]=entries[5];
-}
-
-void MATRIX4X4::SetRotationY(const double angle)
-{
- LoadIdentity();
-
- entries[0]=(float)cos(M_PI*angle/180);
- entries[2]=-(float)sin(M_PI*angle/180);
-
- entries[8]=-entries[2];
- entries[10]=entries[0];
-}
-
-void MATRIX4X4::SetRotationZ(const double angle)
-{
- LoadIdentity();
-
- entries[0]=(float)cos(M_PI*angle/180);
- entries[1]=(float)sin(M_PI*angle/180);
-
- entries[4]=-entries[1];
- entries[5]=entries[0];
-}
-
-void MATRIX4X4::SetRotationEuler(const double angleX, const double angleY, const double angleZ)
-{
- LoadIdentity();
-
- SetRotationPartEuler(angleX, angleY, angleZ);
-}
-
-void MATRIX4X4::SetPerspective( float left, float right, float bottom,
- float top, float n, float f)
-{
- float nudge=0.999f; //prevent artifacts with infinite far plane
-
- LoadZero();
-
- //check for division by 0
- if(left==right || top==bottom || n==f)
- return;
-
- entries[0]=(2*n)/(right-left);
-
- entries[5]=(2*n)/(top-bottom);
-
- entries[8]=(right+left)/(right-left);
- entries[9]=(top+bottom)/(top-bottom);
-
- if(f!=-1)
- {
- entries[10]=-(f+n)/(f-n);
- }
- else //if f==-1, use an infinite far plane
- {
- entries[10]=-nudge;
- }
-
- entries[11]=-1;
-
- if(f!=-1)
- {
- entries[14]=-(2*f*n)/(f-n);
- }
- else //if f==-1, use an infinite far plane
- {
- entries[14]=-2*n*nudge;
- }
-}
-
-void MATRIX4X4::SetPerspective(float fovy, float aspect, float n, float f)
-{
- float left, right, top, bottom;
-
- //convert fov from degrees to radians
- fovy*=(float)M_PI/180;
-
- top=n*tanf(fovy/2.0f);
- bottom=-top;
-
- left=aspect*bottom;
- right=aspect*top;
-
- SetPerspective(left, right, bottom, top, n, f);
-}
-
-void MATRIX4X4::SetOrtho( float left, float right, float bottom,
- float top, float n, float f)
-{
- LoadIdentity();
-
- entries[0]=2.0f/(right-left);
-
- entries[5]=2.0f/(top-bottom);
-
- entries[10]=-2.0f/(f-n);
-
- entries[12]=-(right+left)/(right-left);
- entries[13]=-(top+bottom)/(top-bottom);
- entries[14]=-(f+n)/(f-n);
-}
-
-void MATRIX4X4::SetTranslationPart(const VECTOR3D & translation)
-{
- entries[12]=translation.x;
- entries[13]=translation.y;
- entries[14]=translation.z;
-}
-
-void MATRIX4X4::SetRotationPartEuler(const double angleX, const double angleY, const double angleZ)
-{
- double cr = cos( M_PI*angleX/180 );
- double sr = sin( M_PI*angleX/180 );
- double cp = cos( M_PI*angleY/180 );
- double sp = sin( M_PI*angleY/180 );
- double cy = cos( M_PI*angleZ/180 );
- double sy = sin( M_PI*angleZ/180 );
-
- entries[0] = ( float )( cp*cy );
- entries[1] = ( float )( cp*sy );
- entries[2] = ( float )( -sp );
-
- double srsp = sr*sp;
- double crsp = cr*sp;
-
- entries[4] = ( float )( srsp*cy-cr*sy );
- entries[5] = ( float )( srsp*sy+cr*cy );
- entries[6] = ( float )( sr*cp );
-
- entries[8] = ( float )( crsp*cy+sr*sy );
- entries[9] = ( float )( crsp*sy-sr*cy );
- entries[10] = ( float )( cr*cp );
-}
diff --git a/src/wgl/rtotex/maths/matrix4x4.h b/src/wgl/rtotex/maths/matrix4x4.h
deleted file mode 100644
index db332531..00000000
--- a/src/wgl/rtotex/maths/matrix4x4.h
+++ /dev/null
@@ -1,132 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// MATRIX4X4.h
-// Class declaration for a 4x4 matrix
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-// Updated: 19th August 2002 - Corrected 2nd SetPerspective for n!=1.0f
-// 26th September 2002 - Added nudge to prevent artifacts with infinite far plane
-// - Improved speed
-// 7th November 2002 - Added Affine Inverse functions
-// - Changed constructors
-// - Added special cases for row3 = (0, 0, 0, 1)
-// 17th December 2002 - Converted from radians to degrees for consistency
-// with OpenGL. Should have been done a long time ago...
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef MATRIX4X4_H
-#define MATRIX4X4_H
-
-class MATRIX4X4
-{
-public:
- MATRIX4X4()
- { LoadIdentity(); }
- MATRIX4X4( float e0, float e1, float e2, float e3,
- float e4, float e5, float e6, float e7,
- float e8, float e9, float e10, float e11,
- float e12, float e13, float e14, float e15);
- MATRIX4X4(const float * rhs);
- MATRIX4X4(const MATRIX4X4 & rhs);
- ~MATRIX4X4() {} //empty
-
- void SetEntry(int position, float value);
- float GetEntry(int position) const;
- VECTOR4D GetRow(int position) const;
- VECTOR4D GetColumn(int position) const;
-
- void LoadIdentity(void);
- void LoadZero(void);
-
- //binary operators
- MATRIX4X4 operator+(const MATRIX4X4 & rhs) const;
- MATRIX4X4 operator-(const MATRIX4X4 & rhs) const;
- MATRIX4X4 operator*(const MATRIX4X4 & rhs) const;
- MATRIX4X4 operator*(const float rhs) const;
- MATRIX4X4 operator/(const float rhs) const;
- friend MATRIX4X4 operator*(float scaleFactor, const MATRIX4X4 & rhs);
-
- bool operator==(const MATRIX4X4 & rhs) const;
- bool operator!=(const MATRIX4X4 & rhs) const;
-
- //self-add etc
- void operator+=(const MATRIX4X4 & rhs);
- void operator-=(const MATRIX4X4 & rhs);
- void operator*=(const MATRIX4X4 & rhs);
- void operator*=(const float rhs);
- void operator/=(const float rhs);
-
- //unary operators
- MATRIX4X4 operator-(void) const;
- MATRIX4X4 operator+(void) const {return (*this);}
-
- //multiply a vector by this matrix
- VECTOR4D operator*(const VECTOR4D rhs) const;
-
- //rotate a 3d vector by rotation part
- void RotateVector3D(VECTOR3D & rhs) const
- {rhs=GetRotatedVector3D(rhs);}
-
- void InverseRotateVector3D(VECTOR3D & rhs) const
- {rhs=GetInverseRotatedVector3D(rhs);}
-
- VECTOR3D GetRotatedVector3D(const VECTOR3D & rhs) const;
- VECTOR3D GetInverseRotatedVector3D(const VECTOR3D & rhs) const;
-
- //translate a 3d vector by translation part
- void TranslateVector3D(VECTOR3D & rhs) const
- {rhs=GetTranslatedVector3D(rhs);}
-
- void InverseTranslateVector3D(VECTOR3D & rhs) const
- {rhs=GetInverseTranslatedVector3D(rhs);}
-
- VECTOR3D GetTranslatedVector3D(const VECTOR3D & rhs) const;
- VECTOR3D GetInverseTranslatedVector3D(const VECTOR3D & rhs) const;
-
- //Other methods
- void Invert(void);
- MATRIX4X4 GetInverse(void) const;
- void Transpose(void);
- MATRIX4X4 GetTranspose(void) const;
- void InvertTranspose(void);
- MATRIX4X4 GetInverseTranspose(void) const;
-
- //Inverse of a rotation/translation only matrix
- void AffineInvert(void);
- MATRIX4X4 GetAffineInverse(void) const;
- void AffineInvertTranspose(void);
- MATRIX4X4 GetAffineInverseTranspose(void) const;
-
- //set to perform an operation on space - removes other entries
- void SetTranslation(const VECTOR3D & translation);
- void SetScale(const VECTOR3D & scaleFactor);
- void SetUniformScale(const float scaleFactor);
- void SetRotationAxis(const double angle, const VECTOR3D & axis);
- void SetRotationX(const double angle);
- void SetRotationY(const double angle);
- void SetRotationZ(const double angle);
- void SetRotationEuler(const double angleX, const double angleY, const double angleZ);
- void SetPerspective(float left, float right, float bottom, float top, float n, float f);
- void SetPerspective(float fovy, float aspect, float n, float f);
- void SetOrtho(float left, float right, float bottom, float top, float n, float f);
-
- //set parts of the matrix
- void SetTranslationPart(const VECTOR3D & translation);
- void SetRotationPartEuler(const double angleX, const double angleY, const double angleZ);
- void SetRotationPartEuler(const VECTOR3D & rotations)
- {
- SetRotationPartEuler((double)rotations.x, (double)rotations.y, (double)rotations.z);
- }
-
- //cast to pointer to a (float *) for glGetFloatv etc
- operator float* () const {return (float*) this;}
- operator const float* () const {return (const float*) this;}
-
- //member variables
- float entries[16];
-};
-
-#endif //MATRIX4X4_H \ No newline at end of file
diff --git a/src/wgl/rtotex/maths/plane.cpp b/src/wgl/rtotex/maths/plane.cpp
deleted file mode 100644
index f86fdf8e..00000000
--- a/src/wgl/rtotex/maths/plane.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// PLANE.cpp
-// function definitions for RGBA color class
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-// Modified: 6th August 2002 - Added "Normalize"
-// 7th November 2002 - Altered constructor layout
-// - Corrected "lerp"
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#include "maths.h"
-
-void PLANE::SetFromPoints(const VECTOR3D & p0, const VECTOR3D & p1, const VECTOR3D & p2)
-{
- normal=(p1-p0).CrossProduct(p2-p0);
-
- normal.Normalize();
-
- CalculateIntercept(p0);
-}
-
-void PLANE::Normalize()
-{
- float normalLength=normal.GetLength();
- normal/=normalLength;
- intercept/=normalLength;
-}
-
-bool PLANE::Intersect3(const PLANE & p2, const PLANE & p3, VECTOR3D & result)//find point of intersection of 3 planes
-{
- float denominator=normal.DotProduct((p2.normal).CrossProduct(p3.normal));
- //scalar triple product of normals
- if(denominator==0.0f) //if zero
- return false; //no intersection
-
- VECTOR3D temp1, temp2, temp3;
- temp1=(p2.normal.CrossProduct(p3.normal))*intercept;
- temp2=(p3.normal.CrossProduct(normal))*p2.intercept;
- temp3=(normal.CrossProduct(p2.normal))*p3.intercept;
-
- result=(temp1+temp2+temp3)/(-denominator);
-
- return true;
-}
-
-float PLANE::GetDistance(const VECTOR3D & point) const
-{
- return point.x*normal.x + point.y*normal.y + point.z*normal.z + intercept;
-}
-
-int PLANE::ClassifyPoint(const VECTOR3D & point) const
-{
- float distance=point.x*normal.x + point.y*normal.y + point.z*normal.z + intercept;
-
- if(distance>EPSILON) //==0.0f is too exact, give a bit of room
- return POINT_IN_FRONT_OF_PLANE;
-
- if(distance<-EPSILON)
- return POINT_BEHIND_PLANE;
-
- return POINT_ON_PLANE; //otherwise
-}
-
-PLANE PLANE::lerp(const PLANE & p2, float factor)
-{
- PLANE result;
- result.normal=normal*(1.0f-factor) + p2.normal*factor;
- result.normal.Normalize();
-
- result.intercept=intercept*(1.0f-factor) + p2.intercept*factor;
-
- return result;
-}
-
-bool PLANE::operator ==(const PLANE & rhs) const
-{
- if(normal==rhs.normal && intercept==rhs.intercept)
- return true;
-
- return false;
-}
diff --git a/src/wgl/rtotex/maths/plane.h b/src/wgl/rtotex/maths/plane.h
deleted file mode 100644
index 2f66714e..00000000
--- a/src/wgl/rtotex/maths/plane.h
+++ /dev/null
@@ -1,68 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// PLANE.h
-// Class declaration for a plane in 3d space
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-// Modified: 6th August 2002 - Added "Normalize"
-// 7th November 2002 - Altered constructor layout
-// - Corrected "lerp"
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef PLANE_H
-#define PLANE_H
-
-class PLANE
-{
-public:
- PLANE() : normal(VECTOR3D(0.0f, 0.0f, 0.0f)), intercept(0.0f)
- {}
- PLANE(VECTOR3D newNormal, float newIntercept) : normal(newNormal), intercept(newIntercept)
- {}
- PLANE(const PLANE & rhs)
- { normal=rhs.normal; intercept=rhs.intercept; }
-
- ~PLANE() {}
-
- void SetNormal(const VECTOR3D & rhs) { normal=rhs; }
- void SetIntercept(float newIntercept) { intercept=newIntercept; }
- void SetFromPoints(const VECTOR3D & p0, const VECTOR3D & p1, const VECTOR3D & p2);
-
- void CalculateIntercept(const VECTOR3D & pointOnPlane) { intercept=-normal.DotProduct(pointOnPlane); }
-
- void Normalize(void);
-
- VECTOR3D GetNormal() { return normal; }
- float GetIntercept() { return intercept; }
-
- //find point of intersection of 3 planes
- bool Intersect3(const PLANE & p2, const PLANE & p3, VECTOR3D & result);
-
- float GetDistance(const VECTOR3D & point) const;
- int ClassifyPoint(const VECTOR3D & point) const;
-
- PLANE lerp(const PLANE & p2, float factor);
-
- //operators
- bool operator==(const PLANE & rhs) const;
- bool operator!=(const PLANE & rhs) const
- { return!((*this)==rhs); }
-
- //unary operators
- PLANE operator-(void) const {return PLANE(-normal, -intercept);}
- PLANE operator+(void) const {return (*this);}
-
- //member variables
- VECTOR3D normal; //X.N+intercept=0
- float intercept;
-};
-
-//constants for ClassifyPoint()
-const int POINT_ON_PLANE=0;
-const int POINT_IN_FRONT_OF_PLANE=1;
-const int POINT_BEHIND_PLANE=2;
-
-#endif //PLANE_H \ No newline at end of file
diff --git a/src/wgl/rtotex/maths/vector2d.cpp b/src/wgl/rtotex/maths/vector2d.cpp
deleted file mode 100644
index c93c0be0..00000000
--- a/src/wgl/rtotex/maths/vector2d.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// VECTOR2D.cpp
-// Function definitions for 2d vector class
-// Downloaded from: www.paulsprojects.net
-// Created: 8th November 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#include "maths.h"
-
-void VECTOR2D::Normalize()
-{
- float length;
- float scalefactor;
- length=GetLength();
-
- if(length==1 || length==0) //return if length is 1 or 0
- return;
-
- scalefactor = 1.0f/length;
- x *= scalefactor;
- y *= scalefactor;
-}
-
-VECTOR2D VECTOR2D::GetNormalized() const
-{
- VECTOR2D result(*this);
-
- result.Normalize();
-
- return result;
-}
-
-VECTOR2D operator*(float scaleFactor, const VECTOR2D & rhs)
-{
- return rhs*scaleFactor;
-}
-
-bool VECTOR2D::operator==(const VECTOR2D & rhs) const
-{
- if(x==rhs.x && y==rhs.y)
- return true;
-
- return false;
-}
-
-
-
diff --git a/src/wgl/rtotex/maths/vector2d.h b/src/wgl/rtotex/maths/vector2d.h
deleted file mode 100644
index 86e71e61..00000000
--- a/src/wgl/rtotex/maths/vector2d.h
+++ /dev/null
@@ -1,115 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// VECTOR2D.h
-// Class declaration for a 2d vector
-// Downloaded from: www.paulsprojects.net
-// Created: 6th November 2002
-// Modified: 7th January 2003 - Added QuadraticInterpolate
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef VECTOR2D_H
-#define VECTOR2D_H
-
-class VECTOR2D
-{
-public:
- //constructors
- VECTOR2D(void) : x(0.0f), y(0.0f)
- {}
-
- VECTOR2D(float newX, float newY): x(newX), y(newY)
- {}
-
- VECTOR2D(const float * rhs) : x(*rhs), y((*rhs)+1)
- {}
-
- VECTOR2D(const VECTOR2D & rhs) : x(rhs.x), y(rhs.y)
- {}
-
- ~VECTOR2D() {} //empty
-
- void Set(float newX, float newY)
- { x=newX; y=newY; }
-
- //Accessors kept for compatibility
- void SetX(float newX) {x = newX;}
- void SetY(float newY) {y = newY;}
-
- float GetX() const {return x;} //public accessor functions
- float GetY() const {return y;} //inline, const
-
- void LoadZero(void);
- void LoadOne(void); //fill with (1, 1)
-
- void Normalize();
- VECTOR2D GetNormalized() const;
-
- float GetLength() const
- { return (float)sqrt((x*x)+(y*y)); }
-
- float GetSquaredLength() const
- { return (x*x)+(y*y); }
-
- //linear interpolate
- VECTOR2D lerp(const VECTOR2D & v2, float factor) const
- { return (*this)*(1.0f-factor) + v2*factor; }
-
- VECTOR2D QuadraticInterpolate(const VECTOR2D & v2, const VECTOR2D & v3, float factor) const
- { return (*this)*(1.0f-factor)*(1.0f-factor) + 2*v2*factor*(1.0f-factor) + v3*factor*factor;}
-
- //overloaded operators
- //binary operators
- VECTOR2D operator+(const VECTOR2D & rhs) const
- { return VECTOR2D(x + rhs.x, y + rhs.y); }
-
- VECTOR2D operator-(const VECTOR2D & rhs) const
- { return VECTOR2D(x - rhs.x, y - rhs.y); }
-
- VECTOR2D operator*(const float rhs) const
- { return VECTOR2D(x*rhs, y*rhs); }
-
- VECTOR2D operator/(const float rhs) const
- { return (rhs==0) ? VECTOR2D(0.0f, 0.0f) : VECTOR2D(x / rhs, y / rhs); }
-
- //multiply by a float, eg 3*v
- friend VECTOR2D operator*(float scaleFactor, const VECTOR2D & rhs);
-
- bool operator==(const VECTOR2D & rhs) const;
- bool operator!=(const VECTOR2D & rhs) const
- { return !((*this)==rhs); }
-
- //self-add etc
- void operator+=(const VECTOR2D & rhs)
- { x+=rhs.x; y+=rhs.y;}
-
- void operator-=(const VECTOR2D & rhs)
- { x-=rhs.x; y-=rhs.y;}
-
- void operator*=(const float rhs)
- { x*=rhs; y*=rhs; }
-
- void operator/=(const float rhs)
- { if(rhs==0.0f)
- return;
- else
- { x/=rhs; y/=rhs; }
- }
-
-
- //unary operators
- VECTOR2D operator-(void) const {return VECTOR2D(-x, -y);}
- VECTOR2D operator+(void) const {return *this;}
-
- //cast to pointer to a (float *) for glVertex3fv etc
- operator float* () const {return (float*) this;}
- operator const float* () const {return (const float*) this;}
-
- //member variables
- float x;
- float y;
-};
-
-#endif //VECTOR2D_H \ No newline at end of file
diff --git a/src/wgl/rtotex/maths/vector3d.cpp b/src/wgl/rtotex/maths/vector3d.cpp
deleted file mode 100644
index ab1b6b2e..00000000
--- a/src/wgl/rtotex/maths/vector3d.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// VECTOR3D.cpp
-// Function definitions for 3d vector class
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-// Modified: 8th November 2002 - Changed Constructor layout
-// - Some speed Improvements
-// - Corrected Lerp
-// 17th December 2002 - Converted from radians to degrees
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#include "maths.h"
-
-void VECTOR3D::Normalize()
-{
- float length=GetLength();
-
- if(length==1 || length==0) //return if length is 1 or 0
- return;
-
- float scalefactor = 1.0f/length;
- x *= scalefactor;
- y *= scalefactor;
- z *= scalefactor;
-}
-
-VECTOR3D VECTOR3D::GetNormalized() const
-{
- VECTOR3D result(*this);
-
- result.Normalize();
-
- return result;
-}
-
-VECTOR3D VECTOR3D::GetRotatedX(double angle) const
-{
- if(angle==0.0)
- return (*this);
-
- float sinAngle=(float)sin(M_PI*angle/180);
- float cosAngle=(float)cos(M_PI*angle/180);
-
- return VECTOR3D( x,
- y*cosAngle - z*sinAngle,
- y*sinAngle + z*cosAngle);
-}
-
-void VECTOR3D::RotateX(double angle)
-{
- (*this)=GetRotatedX(angle);
-}
-
-VECTOR3D VECTOR3D::GetRotatedY(double angle) const
-{
- if(angle==0.0)
- return (*this);
-
- float sinAngle=(float)sin(M_PI*angle/180);
- float cosAngle=(float)cos(M_PI*angle/180);
-
- return VECTOR3D( x*cosAngle + z*sinAngle,
- y,
- -x*sinAngle + z*cosAngle);
-}
-
-void VECTOR3D::RotateY(double angle)
-{
- (*this)=GetRotatedY(angle);
-}
-
-VECTOR3D VECTOR3D::GetRotatedZ(double angle) const
-{
- if(angle==0.0)
- return (*this);
-
- float sinAngle=(float)sin(M_PI*angle/180);
- float cosAngle=(float)cos(M_PI*angle/180);
-
- return VECTOR3D(x*cosAngle - y*sinAngle,
- x*sinAngle + y*cosAngle,
- z);
-}
-
-void VECTOR3D::RotateZ(double angle)
-{
- (*this)=GetRotatedZ(angle);
-}
-
-VECTOR3D VECTOR3D::GetRotatedAxis(double angle, const VECTOR3D & axis) const
-{
- if(angle==0.0)
- return (*this);
-
- VECTOR3D u=axis.GetNormalized();
-
- VECTOR3D rotMatrixRow0, rotMatrixRow1, rotMatrixRow2;
-
- float sinAngle=(float)sin(M_PI*angle/180);
- float cosAngle=(float)cos(M_PI*angle/180);
- float oneMinusCosAngle=1.0f-cosAngle;
-
- rotMatrixRow0.x=(u.x)*(u.x) + cosAngle*(1-(u.x)*(u.x));
- rotMatrixRow0.y=(u.x)*(u.y)*(oneMinusCosAngle) - sinAngle*u.z;
- rotMatrixRow0.z=(u.x)*(u.z)*(oneMinusCosAngle) + sinAngle*u.y;
-
- rotMatrixRow1.x=(u.x)*(u.y)*(oneMinusCosAngle) + sinAngle*u.z;
- rotMatrixRow1.y=(u.y)*(u.y) + cosAngle*(1-(u.y)*(u.y));
- rotMatrixRow1.z=(u.y)*(u.z)*(oneMinusCosAngle) - sinAngle*u.x;
-
- rotMatrixRow2.x=(u.x)*(u.z)*(oneMinusCosAngle) - sinAngle*u.y;
- rotMatrixRow2.y=(u.y)*(u.z)*(oneMinusCosAngle) + sinAngle*u.x;
- rotMatrixRow2.z=(u.z)*(u.z) + cosAngle*(1-(u.z)*(u.z));
-
- return VECTOR3D( this->DotProduct(rotMatrixRow0),
- this->DotProduct(rotMatrixRow1),
- this->DotProduct(rotMatrixRow2));
-}
-
-void VECTOR3D::RotateAxis(double angle, const VECTOR3D & axis)
-{
- (*this)=GetRotatedAxis(angle, axis);
-}
-
-
-void VECTOR3D::PackTo01()
-{
- (*this)=GetPackedTo01();
-}
-
-VECTOR3D VECTOR3D::GetPackedTo01() const
-{
- VECTOR3D temp(*this);
-
- temp.Normalize();
-
- temp=temp*0.5f+VECTOR3D(0.5f, 0.5f, 0.5f);
-
- return temp;
-}
-
-VECTOR3D operator*(float scaleFactor, const VECTOR3D & rhs)
-{
- return rhs*scaleFactor;
-}
-
-bool VECTOR3D::operator==(const VECTOR3D & rhs) const
-{
- if(x==rhs.x && y==rhs.y && z==rhs.z)
- return true;
-
- return false;
-}
-
diff --git a/src/wgl/rtotex/maths/vector3d.h b/src/wgl/rtotex/maths/vector3d.h
deleted file mode 100644
index 82ecc354..00000000
--- a/src/wgl/rtotex/maths/vector3d.h
+++ /dev/null
@@ -1,160 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// VECTOR3D.h
-// Class declaration for a 3d vector
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-// Modified: 8th November 2002 - Changed Constructor layout
-// - Some speed Improvements
-// - Corrected Lerp
-// 7th January 2003 - Added QuadraticInterpolate
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef VECTOR3D_H
-#define VECTOR3D_H
-
-class VECTOR3D
-{
-public:
- //constructors
- VECTOR3D(void) : x(0.0f), y(0.0f), z(0.0f)
- {}
-
- VECTOR3D(float newX, float newY, float newZ) : x(newX), y(newY), z(newZ)
- {}
-
- VECTOR3D(const float * rhs) : x(*rhs), y(*(rhs+1)), z(*(rhs+2))
- {}
-
- VECTOR3D(const VECTOR3D & rhs) : x(rhs.x), y(rhs.y), z(rhs.z)
- {}
-
- ~VECTOR3D() {} //empty
-
- void Set(float newX, float newY, float newZ)
- { x=newX; y=newY; z=newZ; }
-
- //Accessors kept for compatibility
- void SetX(float newX) {x = newX;}
- void SetY(float newY) {y = newY;}
- void SetZ(float newZ) {z = newZ;}
-
- float GetX() const {return x;} //public accessor functions
- float GetY() const {return y;} //inline, const
- float GetZ() const {return z;}
-
- void LoadZero(void)
- { x=y=z=0.0f; }
- void LoadOne(void)
- { x=y=z=1.0f; }
-
- //vector algebra
- VECTOR3D CrossProduct(const VECTOR3D & rhs) const
- { return VECTOR3D(y*rhs.z - z*rhs.y, z*rhs.x - x*rhs.z, x*rhs.y - y*rhs.x); }
-
- float DotProduct(const VECTOR3D & rhs) const
- { return x*rhs.x + y*rhs.y + z*rhs.z; }
-
- void Normalize();
- VECTOR3D GetNormalized() const;
-
- float GetLength() const
- { return (float)sqrt((x*x)+(y*y)+(z*z)); }
-
- float GetSquaredLength() const
- { return (x*x)+(y*y)+(z*z); }
-
- //rotations
- void RotateX(double angle);
- VECTOR3D GetRotatedX(double angle) const;
- void RotateY(double angle);
- VECTOR3D GetRotatedY(double angle) const;
- void RotateZ(double angle);
- VECTOR3D GetRotatedZ(double angle) const;
- void RotateAxis(double angle, const VECTOR3D & axis);
- VECTOR3D GetRotatedAxis(double angle, const VECTOR3D & axis) const;
-
- //pack to [0,1] for color
- void PackTo01();
- VECTOR3D GetPackedTo01() const;
-
- //linear interpolate
- VECTOR3D lerp(const VECTOR3D & v2, float factor) const
- { return (*this)*(1.0f-factor) + v2*factor; }
-
- VECTOR3D QuadraticInterpolate(const VECTOR3D & v2, const VECTOR3D & v3, float factor) const
- { return (*this)*(1.0f-factor)*(1.0f-factor) + 2*v2*factor*(1.0f-factor) + v3*factor*factor;}
-
-
- //overloaded operators
- //binary operators
- VECTOR3D operator+(const VECTOR3D & rhs) const
- { return VECTOR3D(x + rhs.x, y + rhs.y, z + rhs.z); }
-
- VECTOR3D operator-(const VECTOR3D & rhs) const
- { return VECTOR3D(x - rhs.x, y - rhs.y, z - rhs.z); }
-
- VECTOR3D operator*(const float rhs) const
- { return VECTOR3D(x*rhs, y*rhs, z*rhs); }
-
- VECTOR3D operator/(const float rhs) const
- { return (rhs==0.0f) ? VECTOR3D(0.0f, 0.0f, 0.0f) : VECTOR3D(x / rhs, y / rhs, z / rhs); }
-
- //multiply by a float, eg 3*v
- friend VECTOR3D operator*(float scaleFactor, const VECTOR3D & rhs);
-
- //Add, subtract etc, saving the construction of a temporary
- void Add(const VECTOR3D & v2, VECTOR3D & result)
- {
- result.x=x+v2.x;
- result.y=y+v2.y;
- result.z=z+v2.z;
- }
-
- void Subtract(const VECTOR3D & v2, VECTOR3D & result)
- {
- result.x=x-v2.x;
- result.y=y-v2.y;
- result.z=z-v2.z;
- }
-
- bool operator==(const VECTOR3D & rhs) const;
- bool operator!=(const VECTOR3D & rhs) const
- { return !((*this)==rhs); }
-
- //self-add etc
- void operator+=(const VECTOR3D & rhs)
- { x+=rhs.x; y+=rhs.y; z+=rhs.z; }
-
- void operator-=(const VECTOR3D & rhs)
- { x-=rhs.x; y-=rhs.y; z-=rhs.z; }
-
- void operator*=(const float rhs)
- { x*=rhs; y*=rhs; z*=rhs; }
-
- void operator/=(const float rhs)
- { if(rhs==0.0f)
- return;
- else
- { x/=rhs; y/=rhs; z/=rhs; }
- }
-
-
- //unary operators
- VECTOR3D operator-(void) const {return VECTOR3D(-x, -y, -z);}
- VECTOR3D operator+(void) const {return *this;}
-
- //cast to pointer to a (float *) for glVertex3fv etc
- operator float* () const {return (float*) this;}
- operator const float* () const {return (const float*) this;}
-
- //member variables
- float x;
- float y;
- float z;
-};
-
-#endif //VECTOR3D_H \ No newline at end of file
diff --git a/src/wgl/rtotex/maths/vector4d.cpp b/src/wgl/rtotex/maths/vector4d.cpp
deleted file mode 100644
index 17437bd3..00000000
--- a/src/wgl/rtotex/maths/vector4d.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// VECTOR4D.cpp
-// Function definitions for 4d vector class
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-// Modified: 15th August 2002 - prevent divide by zero in operator VECTOR3D()
-// Modified: 8th November 2002 - Changed Constructor layout
-// - Some speed Improvements
-// - Corrected Lerp
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#include "maths.h"
-
-void VECTOR4D::RotateX(double angle)
-{
- (*this)=GetRotatedX(angle);
-}
-
-VECTOR4D VECTOR4D::GetRotatedX(double angle) const
-{
- VECTOR3D v3d(x, y, z);
-
- v3d.RotateX(angle);
-
- return VECTOR4D(v3d.x, v3d.y, v3d.z, w);
-}
-
-void VECTOR4D::RotateY(double angle)
-{
- (*this)=GetRotatedY(angle);
-}
-
-VECTOR4D VECTOR4D::GetRotatedY(double angle) const
-{
- VECTOR3D v3d(x, y, z);
-
- v3d.RotateY(angle);
-
- return VECTOR4D(v3d.x, v3d.y, v3d.z, w);
-}
-
-void VECTOR4D::RotateZ(double angle)
-{
- (*this)=GetRotatedZ(angle);
-}
-
-VECTOR4D VECTOR4D::GetRotatedZ(double angle) const
-{
- VECTOR3D v3d(x, y, z);
-
- v3d.RotateZ(angle);
-
- return VECTOR4D(v3d.x, v3d.y, v3d.z, w);
-}
-
-void VECTOR4D::RotateAxis(double angle, const VECTOR3D & axis)
-{
- (*this)=GetRotatedAxis(angle, axis);
-}
-
-VECTOR4D VECTOR4D::GetRotatedAxis(double angle, const VECTOR3D & axis) const
-{
- VECTOR3D v3d(x, y, z);
-
- v3d.RotateAxis(angle, axis);
-
- return VECTOR4D(v3d.x, v3d.y, v3d.z, w);
-}
-
-
-VECTOR4D operator*(float scaleFactor, const VECTOR4D & rhs)
-{
- return rhs*scaleFactor;
-}
-
-bool VECTOR4D::operator==(const VECTOR4D & rhs) const
-{
- if(x==rhs.x && y==rhs.y && z==rhs.z && w==rhs.w)
- return true;
-
- return false;
-}
-
-VECTOR4D::operator VECTOR3D()
-{
- if(w==0.0f || w==1.0f)
- return VECTOR3D(x, y, z);
- else
- return VECTOR3D(x/w, y/w, z/w);
-}
diff --git a/src/wgl/rtotex/maths/vector4d.h b/src/wgl/rtotex/maths/vector4d.h
deleted file mode 100644
index 1a17b78e..00000000
--- a/src/wgl/rtotex/maths/vector4d.h
+++ /dev/null
@@ -1,137 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// VECTOR4D.h
-// Class declaration for a 4d vector
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-// Modified: 8th November 2002 - Changed Constructor layout
-// - Some speed Improvements
-// - Corrected Lerp
-// 7th January 2003 - Added QuadraticInterpolate
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef VECTOR4D_H
-#define VECTOR4D_H
-
-class VECTOR4D
-{
-public:
- //constructors
- VECTOR4D(void) : x(0.0f), y(0.0f), z(0.0f), w(0.0f)
- {}
-
- VECTOR4D(float newX, float newY, float newZ, float newW)
- : x(newX), y(newY), z(newZ), w(newW)
- {}
-
- VECTOR4D(const float * rhs) : x(*rhs), y(*(rhs+1)), z(*(rhs+2)), w(*(rhs+3))
- {}
-
- VECTOR4D(const VECTOR4D & rhs): x(rhs.x), y(rhs.y), z(rhs.z), w(rhs.w)
- {}
-
- //convert v3d to v4d
- VECTOR4D(const VECTOR3D & rhs): x(rhs.x), y(rhs.y), z(rhs.z), w(1.0f)
- {}
-
- ~VECTOR4D() {} //empty
-
- void Set(float newX, float newY, float newZ, float newW)
- { x=newX; y=newY; z=newZ; w=newW; }
-
- //accessors kept for compatability
- void SetX(float newX) {x = newX;}
- void SetY(float newY) {y = newY;}
- void SetZ(float newZ) {z = newZ;}
- void SetW(float newW) {w = newW;}
-
- float GetX() const {return x;} //public accessor functions
- float GetY() const {return y;} //inline, const
- float GetZ() const {return z;}
- float GetW() const {return w;}
-
- void LoadZero(void)
- { x=0.0f; y=0.0f; z=0.0f; w=0.0f; }
-
- void LoadOne(void)
- { x=1.0f; y=1.0f; z=1.0f; w=1.0f; }
-
- //vector algebra
- float DotProduct(const VECTOR4D & rhs)
- { return x*rhs.x + y*rhs.y + z*rhs.z + w*rhs.w; }
-
- //rotations
- void RotateX(double angle);
- VECTOR4D GetRotatedX(double angle) const;
- void RotateY(double angle);
- VECTOR4D GetRotatedY(double angle) const;
- void RotateZ(double angle);
- VECTOR4D GetRotatedZ(double angle) const;
- void RotateAxis(double angle, const VECTOR3D & axis);
- VECTOR4D GetRotatedAxis(double angle, const VECTOR3D & axis) const;
-
- VECTOR4D lerp(const VECTOR4D & v2, float factor) const
- { return (*this)*(1.0f-factor)+v2*factor; }
-
- VECTOR4D QuadraticInterpolate(const VECTOR4D & v2, const VECTOR4D & v3, float factor) const
- { return (*this)*(1.0f-factor)*(1.0f-factor) + 2*v2*factor*(1.0f-factor) + v3*factor*factor;}
-
- //binary operators
- VECTOR4D operator+(const VECTOR4D & rhs) const
- { return VECTOR4D(x+rhs.x, y+rhs.y, z+rhs.z, w+rhs.w); }
-
- VECTOR4D operator-(const VECTOR4D & rhs) const
- { return VECTOR4D(x-rhs.x, y-rhs.y, z-rhs.z, w-rhs.w); }
-
- VECTOR4D operator*(const float rhs) const
- { return VECTOR4D(x*rhs, y*rhs, z*rhs, w*rhs); }
-
- VECTOR4D operator/(const float rhs) const
- { return rhs==0.0f ? VECTOR4D(0.0f, 0.0f, 0.0f, 0.0f)
- : VECTOR4D(x/rhs, y/rhs, z/rhs, w/rhs); }
-
- //multiply by a float, eg 3*v
- friend VECTOR4D operator*(float scaleFactor, const VECTOR4D & rhs);
-
- bool operator==(const VECTOR4D & rhs) const;
- bool operator!=(const VECTOR4D & rhs) const
- { return !((*this)==rhs); }
-
- //self-add etc
- void operator+=(const VECTOR4D & rhs)
- { x+=rhs.x; y+=rhs.y; z+=rhs.z; w+=rhs.w; }
-
- void operator-=(const VECTOR4D & rhs)
- { x-=rhs.x; y-=rhs.y; z-=rhs.z; w-=rhs.w; }
-
- void operator*=(const float rhs)
- { x*=rhs; y*=rhs; z*=rhs; w*=rhs; }
-
- void operator/=(const float rhs)
- { if(rhs==0.0f)
- return;
- else
- { x/=rhs; y/=rhs; z/=rhs; w/=rhs; }
- }
-
- //unary operators
- VECTOR4D operator-(void) const {return VECTOR4D(-x, -y, -z, -w);}
- VECTOR4D operator+(void) const {return (*this);}
-
- //cast to pointer to float for glVertex4fv etc
- operator float* () const {return (float*) this;}
- operator const float* () const {return (const float*) this;}
-
- operator VECTOR3D(); //convert v4d to v3d
-
- //member variables
- float x;
- float y;
- float z;
- float w;
-};
-
-#endif //VECTOR3D_H \ No newline at end of file
diff --git a/src/wgl/rtotex/pbuffer.cpp b/src/wgl/rtotex/pbuffer.cpp
deleted file mode 100644
index a37966d2..00000000
--- a/src/wgl/rtotex/pbuffer.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// PBUFFER.cpp
-// functions to set up a pbuffer
-// Downloaded from: www.paulsprojects.net
-// Created: 9th September 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#include <windows.h>
-#include <GL/glew.h>
-#include <GL/wglew.h>
-#include <GL/glu.h>
-#include "log.h"
-#include "pbuffer.h"
-
-extern LOG errorLog;
-
-bool PBUFFER::Init( int newWidth, int newHeight,
- int newColorBits, int newDepthBits, int newStencilBits,
- int numExtraIAttribs, int * extraIAttribList, int * flags)
-{
- //Check for pbuffer support
- if( !WGLEW_ARB_extensions_string ||
- !WGLEW_ARB_pixel_format ||
- !WGLEW_ARB_pbuffer)
- {
- errorLog.OutputError("Extension required for pbuffer unsupported");
- return false;
- }
-
- //set class's member variables
- width=newWidth;
- height=newHeight;
- colorBits=newColorBits;
- depthBits=newDepthBits;
- stencilBits=newStencilBits;
-
- //Get the current device context
- HDC hCurrentDC=wglGetCurrentDC();
- if(!hCurrentDC)
- {
- errorLog.OutputError("Unable to get current Device Context");
- return false;
- }
-
-
- //choose pixel format
- GLint pixelFormat;
-
- const int standardIAttribList[]={ WGL_DRAW_TO_PBUFFER_ARB, 1,
- WGL_COLOR_BITS_ARB, colorBits,
- WGL_ALPHA_BITS_ARB, colorBits==32 ? 8 : 0,
- WGL_DEPTH_BITS_ARB, depthBits,
- WGL_STENCIL_BITS_ARB, stencilBits};
- const float fAttribList[]={
- 0};
-
- //add the extraIAttribList to the standardIAttribList
- int * iAttribList=new int[sizeof(standardIAttribList)/sizeof(int)+numExtraIAttribs*2+1];
- if(!iAttribList)
- {
- errorLog.OutputError("Unable to allocate space for iAttribList");
- return false;
- }
-
- memcpy( iAttribList, standardIAttribList, sizeof(standardIAttribList));
- memcpy( iAttribList+sizeof(standardIAttribList)/sizeof(int),
- extraIAttribList, numExtraIAttribs*2*sizeof(int)+sizeof(int));
-
- //Choose pixel format
- unsigned int numFormats;
- if(!wglChoosePixelFormatARB(hCurrentDC, iAttribList, fAttribList, 1,
- &pixelFormat, &numFormats))
- {
- errorLog.OutputError("Unable to find a pixel format for the pbuffer");
- return false;
- }
-
- //Create the pbuffer
- hBuffer=wglCreatePbufferARB(hCurrentDC, pixelFormat, width, height, flags);
- if(!hBuffer)
- {
- errorLog.OutputError("Unable to create pbuffer");
- return false;
- }
-
- //Get the pbuffer's device context
- hDC=wglGetPbufferDCARB(hBuffer);
- if(!hDC)
- {
- errorLog.OutputError("Unable to get pbuffer's device context");
- return false;
- }
-
- //Create a rendering context for the pbuffer
- hRC=wglCreateContext(hDC);
- if(!hRC)
- {
- errorLog.OutputError("Unable to create pbuffer's rendering context");
- return false;
- }
-
- //Set and output the actual pBuffer dimensions
- wglQueryPbufferARB(hBuffer, WGL_PBUFFER_WIDTH_ARB, &width);
- wglQueryPbufferARB(hBuffer, WGL_PBUFFER_HEIGHT_ARB, &height);
- errorLog.OutputSuccess("Pbuffer Created: (%d x %d)", width, height);
-
- return TRUE; //success!
-}
-
-void PBUFFER::Shutdown(void)
-{
- if(hRC) //have a rendering context?
- {
- if(!wglDeleteContext(hRC)) //try to delete RC
- {
- errorLog.OutputError("Release of Pbuffer Rendering Context Failed.");
- }
-
- hRC=NULL; //set RC to NULL
- }
-
- if(hDC && !wglReleasePbufferDCARB(hBuffer, hDC)) //Are we able to release DC?
- {
- errorLog.OutputError("Release of Pbuffer Device Context Failed.");
- hDC=NULL;
- }
-
- if(!wglDestroyPbufferARB(hBuffer))
- {
- errorLog.OutputError("Unable to destroy pbuffer");
- }
-}
-
-
-bool PBUFFER::MakeCurrent()
-{
- if(!wglMakeCurrent(hDC, hRC))
- {
- errorLog.OutputError("Unable to change current context");
- return false;
- }
-
- return true;
-}
-
diff --git a/src/wgl/rtotex/pbuffer.h b/src/wgl/rtotex/pbuffer.h
deleted file mode 100644
index 6a4e1cab..00000000
--- a/src/wgl/rtotex/pbuffer.h
+++ /dev/null
@@ -1,34 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// PBUFFER.h
-// class to setup pBuffer
-// Downloaded from: www.paulsprojects.net
-// Created: 9th September 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef PBUFFER_H
-#define PBUFFER_H
-
-class PBUFFER
-{
-public:
- HGLRC hRC; //rendering context
- HDC hDC; //device context
-
- HPBUFFERARB hBuffer; //buffer handle
-
- int width, height; //window size
- int colorBits, depthBits, stencilBits; //window bpp
-
- bool Init( int newWidth, int newHeight,
- int newColorBits, int newDepthBits, int newStencilBits,
- int numExtraIAttribs, int * extraIAttribList, int * flags);
- void Shutdown(void); //Properly kill pbuffer
-
- bool MakeCurrent(void);
-};
-
-#endif //PBUFFER_H \ No newline at end of file
diff --git a/src/wgl/rtotex/timer.cpp b/src/wgl/rtotex/timer.cpp
deleted file mode 100644
index bce25cb9..00000000
--- a/src/wgl/rtotex/timer.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// TIMER.cpp
-// functions for timer
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-#include "timer.h"
-
-void TIMER::Reset()
-{
- startTime=(double)timeGetTime();
-}
-
-double TIMER::GetTime()
-{
- if(isPaused)
- return pauseTime-startTime;
- else
- return ((double)timeGetTime())-startTime;
-}
-
-void TIMER::Pause()
-{
- if(isPaused)
- return; //only pause if unpaused
-
- isPaused=true;
- pauseTime=(double)timeGetTime();
-}
-
-void TIMER::Unpause()
-{
- if(!isPaused)
- return; //only unpause if paused
-
- isPaused=false;
- startTime+=((double)timeGetTime()-pauseTime); //update start time to reflect pause
-}
diff --git a/src/wgl/rtotex/timer.h b/src/wgl/rtotex/timer.h
deleted file mode 100644
index 64e1bffc..00000000
--- a/src/wgl/rtotex/timer.h
+++ /dev/null
@@ -1,36 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// TIMER.h
-// timer class
-// Downloaded from: www.paulsprojects.net
-// Created: 20th July 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef TIMER_H
-#define TIMER_H
-
-#include <windows.h>
-#include <mmsystem.h>
-
-class TIMER
-{
-public:
- TIMER() : isPaused(false)
- { Reset(); }
- ~TIMER() {}
-
- void Reset();
- double GetTime();
- void Pause();
- void Unpause();
-
-protected:
- bool isPaused;
- double pauseTime;
- double startTime;
-};
-
-#endif //TIMER_H \ No newline at end of file
diff --git a/src/wgl/rtotex/window.cpp b/src/wgl/rtotex/window.cpp
deleted file mode 100644
index 02212817..00000000
--- a/src/wgl/rtotex/window.cpp
+++ /dev/null
@@ -1,619 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// WINDOW.cpp
-// functions to set up an opengl capable window
-// Downloaded from: www.paulsprojects.net
-// Created: 21st June 2002
-// Modified: 26th August 2002 - Added Input management
-// 3rd September 2002 - Added WINDOW::MakeCurrent - to restore focus to
-// window after switch
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#include "windows.h"
-#include "GL/gl.h"
-#include "GL/glu.h"
-#include "log.h"
-#include "window.h"
-
-extern LOG errorLog;
-
-bool WINDOW::Init(const char * windowTitle,
- int newWidth, int newHeight,
- int newColorBits, int newDepthBits, int newStencilBits,
- int fullscreenflag)
- //CREATE WINDOW
-{
- WNDCLASS wc; //windows class structure
- DWORD dwExStyle; //extended style info.
- DWORD dwStyle; //style info
-
- //set class's member variables
- title=windowTitle;
- width=newWidth;
- height=newHeight;
- colorBits=newColorBits;
- depthBits=newDepthBits;
- stencilBits=newStencilBits;
-
- //set class's fullscreen flag
- if(fullscreenflag == FULL_SCREEN)
- {
- fullscreen=true;
- }
-
- if(fullscreenflag == WINDOWED_SCREEN)
- {
- fullscreen=false;
- }
-
- if(fullscreenflag == CHOOSE_SCREEN) //Ask user if fullscreen
- {
- if(MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?","Start FullScreen",MB_YESNO|MB_ICONQUESTION)==IDNO)
- {
- fullscreen=false; //If answered no
- }
- else
- {
- fullscreen=true; //if answered yes
- }
- }
-
- RECT WindowRect; //grab rect. upper left/lower right values
- WindowRect.left=(long)0;
- WindowRect.right=(long)width;
- WindowRect.top=(long)0;
- WindowRect.bottom=(long)height;
-
- hInstance= GetModuleHandle(NULL); //Grab an instance for window
- wc.style= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
- //window style: redraw on move, own DC
- wc.lpfnWndProc= (WNDPROC) WndProc; //Wndproc handles messages
- wc.cbClsExtra= 0;
- wc.cbWndExtra= 0; //no extra window data
- wc.hInstance= hInstance; //Set the instance
- wc.hIcon= LoadIcon(NULL, IDI_WINLOGO); //load default icon
- wc.hCursor= LoadCursor(NULL, IDC_ARROW); //Load arrow cursor
- wc.hbrBackground=NULL; //No background rqd for GL
- wc.lpszMenuName=NULL; //No menu
- wc.lpszClassName="OpenGL"; //set class name
-
- if(!RegisterClass(&wc)) //try to register class
- {
- errorLog.OutputError("Failed to register the window class");
- return FALSE;
- }
- else
- errorLog.OutputSuccess("Window Class Registered");
-
- if(fullscreen) //try to set up fullscreen?
- {
- DEVMODE dmScreenSettings; //Device mode
- memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
- //clear memory
- dmScreenSettings.dmSize=sizeof(dmScreenSettings);
- //size of devmode structure
- dmScreenSettings.dmPelsWidth=width; //selected width
- dmScreenSettings.dmPelsHeight=height; //selected height
- dmScreenSettings.dmBitsPerPel=colorBits; //selected bpp
- dmScreenSettings.dmFields=DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
-
- if(ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
- //try to set mode.CDS_FULLSCREEN removes start bar
- {
- //If mode fails, give 2 options, quit or run in window
- if(MessageBox(NULL, "The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?",title, MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
- {
- fullscreen=FALSE; //if "yes", try windowed
- }
- else
- {
- //tell user program is closing
- errorLog.OutputError("Program Closed, As Fullscreen Mode Not Supported.");
- return FALSE; //exit and return FALSE
- }
- }
- }
-
- if (fullscreen) //still fullscreen?
- {
- dwExStyle=WS_EX_APPWINDOW; //window extended style
- dwStyle=WS_POPUP | WS_VISIBLE; //window style (no border), visible
- ShowCursor(FALSE); //hide mouse pointer
- }
- else
- {
- dwExStyle=WS_EX_CLIENTEDGE; //window extended style(3d look)
- dwStyle=WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_VISIBLE;
- //window style (close button, title bar, border, visible)
- }
-
- AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);
- //adjust window to actual requested size, rather than including borders in size. in fullscreen, no effect
-
- if(!(hWnd=CreateWindowEx( dwExStyle, //extended style for window
- "OpenGL", //class name
- title, //window title
- WS_CLIPSIBLINGS | //required style
- WS_CLIPCHILDREN | //required style
- dwStyle, //Selected style
- 0, 0, //window position
- WindowRect.right-WindowRect.left, //calculate adjusted width
- WindowRect.bottom-WindowRect.top, //calculate adjusted height
- NULL, // no parent window
- NULL, //No Menu
- hInstance, //Instance
- NULL))) //Dont pass anything to WM_CREATE
- {
- Shutdown(); //if not set up, reset display
- errorLog.OutputError("Window Creation Error.");
- //pop up error message
- return FALSE; //return false, to quit program
- }
- else
- errorLog.OutputSuccess("Window Created.");
-
- //set up pixel format(openGL supporting, RGBA, correct bits
- GLuint pixelFormat; //holds result after searching for mode match
-
- //calculate alpha bits
- int alphaBits=0;
-
- if(colorBits==32)
- alphaBits=8;
-
- static PIXELFORMATDESCRIPTOR pfd= //pfd tells windows how we want things to be
- {
- sizeof(PIXELFORMATDESCRIPTOR), //size of Pixel format descriptor
- 1, //Version Number
- PFD_DRAW_TO_WINDOW | //must support window
- PFD_SUPPORT_OPENGL | //must support opengl
- PFD_DOUBLEBUFFER, //must support double buffer
- PFD_TYPE_RGBA, //request RGBA format
- colorBits, //select colour depth
- 0, 0, 0, 0, 0, 0, //colour bits ignored
- alphaBits, //alpha buffer bits
- 0, //shift bit ignored
- 0, //no accumulation buffer
- 0, 0, 0, 0, //accumulation bits ignored
- depthBits, //z buffer bits
- stencilBits, //stencil buffer bits
- 0, //no auxiliary buffer
- PFD_MAIN_PLANE, //main drawing layer
- 0, //reserved
- 0, 0, 0 //layer masks ignored
- };
-
- if(!(hDC=GetDC(hWnd))) //did we get a device context?
- { //if not
- Shutdown(); //Reset display
- errorLog.OutputError("Can't Create a GL Device context.");
- return FALSE; //return false, to exit
- }
- else
- errorLog.OutputSuccess("DC Created");
-
- if(!(pixelFormat=ChoosePixelFormat(hDC,&pfd))) //found a matching pixel format?
- { //if not
- Shutdown();
- errorLog.OutputError("Can't Find a Suitable PixelFormat.");
- return FALSE;
- }
- else
- errorLog.OutputSuccess("Pixel Format Found.");
-
- if(!SetPixelFormat(hDC, pixelFormat,&pfd)) //are we able to set pixel format?
- { //if not
- Shutdown();
- errorLog.OutputError("Can't set the pixelformat.");
- return FALSE;
- }
- else
- errorLog.OutputSuccess("Pixel Format set.");
-
- if(!(hRC=wglCreateContext(hDC))) //are we able to get rendering context?
- { //if not
- Shutdown();
- errorLog.OutputError("Can't create a GL rendering context.");
- return FALSE;
- }
- else
- errorLog.OutputSuccess("GL Rendering Context Created.");
-
- if(!MakeCurrent()) //are we able to activate rendering context?
- { //if not
- Shutdown();
- return FALSE;
- }
- else
- errorLog.OutputSuccess("GL Rendering Context Activated.");
-
- //get pixel format parameters
- static PIXELFORMATDESCRIPTOR finalPfd;
- DescribePixelFormat(hDC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &finalPfd);
-
- //output window parameters
- errorLog.OutputNewline();
- errorLog.OutputSuccess("Window Size: (%d, %d)", width, height);
- errorLog.OutputSuccess("Color Buffer Bits (R, G, B, A): (%d, %d, %d, %d)",
- finalPfd.cRedBits,
- finalPfd.cGreenBits,
- finalPfd.cBlueBits,
- finalPfd.cAlphaBits);
- errorLog.OutputSuccess("Depth Buffer Bits: %d", finalPfd.cDepthBits);
- errorLog.OutputSuccess("Stencil Buffer Bits: %d", finalPfd.cStencilBits);
- errorLog.OutputNewline();
-
- ShowWindow(hWnd,SW_SHOW); //show window
- SetForegroundWindow(hWnd); //slightly higher priority
- SetFocus(hWnd); //Set keyboard focus to the window
-
- errorLog.OutputSuccess("Window Created!");
- errorLog.OutputNewline();
-
- //Init the font
- HFONT font; //windows font ID
-
- //create 96 display lists
- base = glGenLists(96);
-
- font = CreateFont( -18, //font height
- 0, //default width
- 0, 0, //angles - escapement, orientation
- FW_BOLD, //font weight, 0-1000, NORMAL, BOLD
- false, //italic
- false, //underline
- false, //strikeout
- ANSI_CHARSET, //character set
- OUT_TT_PRECIS, //precision
- CLIP_DEFAULT_PRECIS, //clip precision
- ANTIALIASED_QUALITY, //output quality
- FF_DONTCARE | DEFAULT_PITCH,//family and pitch
- "Courier New"); //font name
-
- //select the font
- SelectObject(hDC, font);
-
- //create 96 display lists, starting at 32
- wglUseFontBitmaps(hDC, 32, 96, base);
-
- errorLog.OutputSuccess("Font created successfully.");
-
- return TRUE; //success!
-}
-
-void WINDOW::Shutdown(void) //PROPERLY KILL WINDOW
-{
- //Delete font display lists
- glDeleteLists(base, 96);
-
- if (fullscreen)
- {
- ChangeDisplaySettings(NULL, 0); //restore desktop mode
- ShowCursor(TRUE); //show mouse cursor
- }
-
- errorLog.OutputNewline();
-
- if(hRC) //have a rendering context?
- {
- if(!wglMakeCurrent(NULL, NULL)) //try to release rend cont
- {
- errorLog.OutputError("Release of DC and RC Failed.");
- }
- else
- errorLog.OutputSuccess("DC and RC released.");
-
- if(!wglDeleteContext(hRC)) //try to delete RC
- {
- errorLog.OutputError("Release Rendering Context Failed.");
- }
- else
- errorLog.OutputSuccess("Rendering Context Released.");
-
- hRC=NULL; //set RC to NULL
- }
-
- if(hDC && !ReleaseDC(hWnd, hDC)) //Are we able to release DC?
- {
- errorLog.OutputError("Release of Device Context Failed.");
- hDC=NULL;
- }
- else
- errorLog.OutputSuccess("Device Context Released.");
-
- if(hWnd && !DestroyWindow(hWnd)) //Can we destroy window?
- {
- errorLog.OutputError("Could not release hWnd");
- hWnd=NULL;
- }
- else
- errorLog.OutputSuccess("hWnd released.");
-
- if (!UnregisterClass("OpenGL", hInstance)) //can we unreg. class?
- {
- errorLog.OutputError("Could Not Unregister Class.");
- hInstance=NULL;
- }
- else
- errorLog.OutputSuccess("Class unregistered.");
-}
-
-bool WINDOW::MakeCurrent()
-{
- if(!wglMakeCurrent(hDC, hRC))
- {
- errorLog.OutputError("Unable to change current context");
- return false;
- }
-
- return true;
-}
-
-
-//DEAL WITH ALL WINDOW MESSAGES
-//Message Pump
-bool WINDOW::HandleMessages(void)
-{
- while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) //Is there a message waiting?
- {
- if(msg.message==WM_QUIT)
- return false; //if a quit message, return false
-
- //handle input
- if(msg.message==WM_KEYDOWN)
- SetKeyPressed(msg.wParam);
-
- if(msg.message==WM_KEYUP)
- SetKeyReleased(msg.wParam);
-
- if(msg.message==WM_LBUTTONDOWN)
- SetLeftButtonPressed();
-
- if(msg.message==WM_RBUTTONDOWN)
- SetRightButtonPressed();
-
- TranslateMessage(&msg); //Translate Message
- DispatchMessage(&msg); //dispatch message
- }
- return true;
-}
-
-LRESULT CALLBACK WINDOW::WndProc( HWND hWnd, //handle for this window
- UINT uMsg, //Message for this window
- WPARAM wParam, //Additional message information
- LPARAM lParam) //Additional Message information
-
-{
- switch (uMsg) //check for windows messages
- {
- case WM_SYSCOMMAND: //Intercept system commands
- {
- switch (wParam) //check system calls
- {
- case SC_SCREENSAVE: //screensaver trying to start?
- case SC_MONITORPOWER: //monitor trying to enter powersave?
- return 0; //prevent from happening
- }
- break;
- }
-
- case WM_CLOSE: //receive close message?
- PostQuitMessage(0); //send quit message
- return 0; //quit back
- break;
- }
-
- //pass all unhandled messages to DefWindowProc, windows can handle
- return DefWindowProc(hWnd,uMsg,wParam,lParam);
-}
-
-void WINDOW::SwapBuffers(void)
-{
- ::SwapBuffers(hDC); //swap buffers
-}
-
-//void WINDOW::CheckGLError - check for an opengl error
-void WINDOW::CheckGLError(void)
-{
- GLenum error;
- error=glGetError();
- if(!(error==GL_NO_ERROR))
- {
- errorLog.OutputError("OpenGL Error:");
- if(error==GL_INVALID_ENUM)
- {
- errorLog.OutputError(" GL_INVALID_ENUM");
- errorLog.OutputError(" GLenum Argument out of range.");
- }
- if(error==GL_INVALID_VALUE)
- {
- errorLog.OutputError(" GL_INVALID_VALUE");
- errorLog.OutputError(" Numeric Argument out of range.");
- }
- if(error==GL_INVALID_OPERATION)
- {
- errorLog.OutputError(" GL_INVALID_OPERATION");
- errorLog.OutputError(" Invalid Operation in current state.");
- }
- if(error==GL_STACK_UNDERFLOW)
- {
- errorLog.OutputError(" GL_STACK_UNDERFLOW");
- errorLog.OutputError(" Stack Underflow.");
- }
- if(error==GL_STACK_OVERFLOW)
- {
- errorLog.OutputError(" GL_STACK_OVERFLOW");
- errorLog.OutputError(" Stack Overflow.");
- }
- if(error==GL_OUT_OF_MEMORY)
- {
- errorLog.OutputError(" GL_OUT_OF_MEMORY");
- errorLog.OutputError(" Out of memory.");
- }
- }
-}
-
-void WINDOW::SaveScreenshot(void)
-{
- FILE * file;
-
- //first calculate the filename to save to
- char filename[32];
-
- for(int i=0; i<1000; i++)
- {
- sprintf(filename, "screen%03d.tga", i);
-
- //try opening this file - if not possible, use this filename
- file=fopen(filename, "rb");
-
- if(!file)
- {
- break;
- }
-
- //otherwise, the file exists, try next, except if this is the last one
- fclose(file);
-
- if(i==999)
- {
- errorLog.OutputError("No space to save screenshot - 0-999 exist");
- return;
- }
- }
-
- errorLog.OutputSuccess("Saving %s", filename);
-
- GLubyte TGAheader[12]={0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //Uncompressed TGA header
- GLubyte infoHeader[6];
-
- unsigned char * data=new unsigned char[4*width*height];
- if(!data)
- {
- errorLog.OutputError("Unable to allocate memory for screen data");
- return;
- }
-
- //read in the screen data
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
-
- //data needs to be in BGR format
- //swap b and r
- for(int i=0; i<(int)width*height*4; i+=4)
- {
- //repeated XOR to swap bytes 0 and 2
- data[i] ^= data[i+2] ^= data[i] ^= data[i+2];
- }
-
- //open the file
- file = fopen(filename, "wb");
-
- //save header
- fwrite(TGAheader, 1, sizeof(TGAheader), file);
-
- //save info header
- infoHeader[0]=(width & 0x00FF);
- infoHeader[1]=(width & 0xFF00) >> 8;
- infoHeader[2]=(height & 0x00FF);
- infoHeader[3]=(height & 0xFF00) >> 8;
- infoHeader[4]=32;
- infoHeader[5]=0;
-
- //save info header
- fwrite(infoHeader, 1, sizeof(infoHeader), file);
-
- //save the image data
- fwrite(data, 1, width*height*4, file);
-
- fclose(file);
-
- errorLog.OutputSuccess("Saved Screenshot: %s", filename);
- return;
-}
-
-//Text writing functions
-void WINDOW::StartTextMode(void)
-{
- //If not yet created, make display list
- if(!startTextModeList)
- {
- startTextModeList=glGenLists(1);
- glNewList(startTextModeList, GL_COMPILE);
- {
- //save states
- glPushAttrib(GL_ALL_ATTRIB_BITS);
- glListBase(base-32); //set the list base
-
- //set modelview matrix
- glPushMatrix();
- glLoadIdentity();
-
- //set projection matrix
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0.0f, width, height, 0.0f, -1.0f, 1.0f);
-
- //set states
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_LIGHTING);
-
- glBlendFunc(GL_ONE, GL_ONE); //if blending, use additive
- }
- glEndList();
- }
-
- glCallList(startTextModeList);
-}
-
-void WINDOW::Print(int x, int y, const char * string, ...)
-{
- char text[256]; //Holds our string
- va_list va; //pointer to list of arguments
-
- if(string==NULL) //If there's no text
- return; //Do nothing
-
- va_start(va, string); //parse string for variables
- vsprintf(text, string, va); //convert to actual numbers
- va_end(va); //results stored in text
-
- glRasterPos2i(x, y); //go to correct raster position
-
- glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); //call display lists
-}
-
-void WINDOW::EndTextMode(void)
-{
- //restore states
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glPopAttrib();
-}
-
-//Update input
-void WINDOW::Update()
-{
- //Mouse buttons are marked as pressed by windows messages
- //see if any have been released
- if(mouseLDown && !GetAsyncKeyState(VK_LBUTTON))
- mouseLDown=false;
-
- if(mouseRDown && !GetAsyncKeyState(VK_RBUTTON))
- mouseRDown=false;
-
- //Update the mouse position
- static POINT mousePosition;
- GetCursorPos(&mousePosition);
-
- oldMouseX=mouseX;
- oldMouseY=mouseY;
-
- mouseX=mousePosition.x;
- mouseY=mousePosition.y;
-}
diff --git a/src/wgl/rtotex/window.h b/src/wgl/rtotex/window.h
deleted file mode 100644
index ce30d439..00000000
--- a/src/wgl/rtotex/window.h
+++ /dev/null
@@ -1,122 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////
-// window.h
-// class to setup opengl capable window
-// Downloaded from: www.paulsprojects.net
-// Created: 21st June 2002
-//
-// Copyright (c) 2006, Paul Baker
-// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
-// http://www.paulsprojects.net/NewBSDLicense.txt)
-//////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-class WINDOW
-{
-public:
- HGLRC hRC; //Permanent rendering context
- HDC hDC; //Private GDI device context
- HWND hWnd; //Holds window handle
- HINSTANCE hInstance; //Holds application instance
- MSG msg; //message structure, to see if any pending messages
- const char * title; //Window Title
- int width, height; //window size
- int colorBits, depthBits, stencilBits; //window bpp
- bool fullscreen; //fullscreen?
-
- bool Init(const char * windowTitle,
- int newWidth, int newHeight,
- int newColorBits, int newDepthBits, int newStencilBits,
- int fullscreenflag);
- //Create Window
- void Shutdown(void); //Properly kill window
-
- bool MakeCurrent(void);
-
- bool HandleMessages(void);
- static LRESULT CALLBACK WndProc( HWND hWnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam); //DEAL WITH ALL WINDOW MESSAGES
- //static needed for CALLBACK
- void SwapBuffers();
- void CheckGLError(void); //check for an OpenGL error
-
- void SaveScreenshot(void);
-
-
- //Text writing functions
- void StartTextMode(void);
- void Print(int x, int y, const char * string, ...);
- void EndTextMode(void);
-
- protected:
- GLuint base; //display list base for font
- GLuint startTextModeList;
-
-
-
- //INPUT FUNCTIONS
- public:
- void Update();
-
- //KEYBOARD
- void SetKeyPressed(int keyNumber)
- { keyPressed[keyNumber]=true; }
-
- void SetKeyReleased(int keyNumber)
- { keyPressed[keyNumber]=false; }
-
- bool isKeyPressed(int keyNumber)
- { return keyPressed[keyNumber]; }
-
- protected:
- bool keyPressed[256];
-
- //MOUSE
- public:
- void SetLeftButtonPressed()
- { mouseLDown=true; }
-
- void SetRightButtonPressed()
- { mouseRDown=true; }
-
- bool isLeftButtonPressed()
- { return mouseLDown; }
-
- bool isRightButtonPressed()
- { return mouseRDown; }
-
- int GetMouseX()
- { return mouseX; }
-
- int GetMouseY()
- { return mouseY; }
-
- int GetMouseXMovement()
- { return mouseX-oldMouseX; }
-
- int GetMouseYMovement()
- { return mouseY-oldMouseY; }
-
- protected:
- int oldMouseX, oldMouseY;
- int mouseX, mouseY;
- bool mouseLDown, mouseRDown;
-
-
-
-
- public:
- WINDOW() : title("Paul's Projects"), fullscreen(TRUE)
- {}
- ~WINDOW() {}
-};
-
-//#defines for window or fullscreen
-#define WINDOWED_SCREEN 0
-#define FULL_SCREEN 1
-#define CHOOSE_SCREEN 2
-
-#endif //WINDOW_H