Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2018-04-16 15:07:42 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-04-17 18:51:28 +0300
commit159806140fd33e6ddab951c0f6f180cfbf927d38 (patch)
treeda076be3baa4d987fb5935e220a3d901c926e0e7 /source/gameengine/Rasterizer
parent28b996a9d2090efdd74115a653629ef9d7d871f7 (diff)
Removing Blender Game Engine from Blender 2.8
Folders removed entirely: * //extern/recastnavigation * //intern/decklink * //intern/moto * //source/blender/editors/space_logic * //source/blenderplayer * //source/gameengine This includes DNA data and any reference to the BGE code in Blender itself. We are bumping the subversion. Pending tasks: * Tile/clamp code in image editor draw code. * Viewport drawing code (so much of this will go away because of BI removal that we can wait until then to remove this.
Diffstat (limited to 'source/gameengine/Rasterizer')
-rw-r--r--source/gameengine/Rasterizer/CMakeLists.txt92
-rw-r--r--source/gameengine/Rasterizer/RAS_2DFilterManager.cpp562
-rw-r--r--source/gameengine/Rasterizer/RAS_2DFilterManager.h114
-rw-r--r--source/gameengine/Rasterizer/RAS_BucketManager.cpp380
-rw-r--r--source/gameengine/Rasterizer/RAS_BucketManager.h93
-rw-r--r--source/gameengine/Rasterizer/RAS_CameraData.h79
-rw-r--r--source/gameengine/Rasterizer/RAS_Deformer.h103
-rw-r--r--source/gameengine/Rasterizer/RAS_FramingManager.cpp425
-rw-r--r--source/gameengine/Rasterizer/RAS_FramingManager.h316
-rw-r--r--source/gameengine/Rasterizer/RAS_ICanvas.cpp128
-rw-r--r--source/gameengine/Rasterizer/RAS_ICanvas.h287
-rw-r--r--source/gameengine/Rasterizer/RAS_ILightObject.h95
-rw-r--r--source/gameengine/Rasterizer/RAS_IOffScreen.h84
-rw-r--r--source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp292
-rw-r--r--source/gameengine/Rasterizer/RAS_IPolygonMaterial.h206
-rw-r--r--source/gameengine/Rasterizer/RAS_IRasterizer.h506
-rw-r--r--source/gameengine/Rasterizer/RAS_ISync.h48
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.cpp679
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.h267
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.cpp573
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.h161
-rw-r--r--source/gameengine/Rasterizer/RAS_ObjectColor.h41
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h55
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h55
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h54
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h45
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h45
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h57
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h62
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h45
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h55
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h61
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt72
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h56
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp278
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h77
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp300
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.h56
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.cpp347
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.h65
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp1694
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h343
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.cpp82
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.h50
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp260
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h77
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp227
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h100
-rw-r--r--source/gameengine/Rasterizer/RAS_Polygon.cpp123
-rw-r--r--source/gameengine/Rasterizer/RAS_Polygon.h101
-rw-r--r--source/gameengine/Rasterizer/RAS_Rect.h104
-rw-r--r--source/gameengine/Rasterizer/RAS_TexMatrix.h42
-rw-r--r--source/gameengine/Rasterizer/RAS_TexVert.cpp164
-rw-r--r--source/gameengine/Rasterizer/RAS_TexVert.h146
-rw-r--r--source/gameengine/Rasterizer/RAS_texmatrix.cpp131
55 files changed, 0 insertions, 10960 deletions
diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt
deleted file mode 100644
index fc7dc90e03b..00000000000
--- a/source/gameengine/Rasterizer/CMakeLists.txt
+++ /dev/null
@@ -1,92 +0,0 @@
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# The Original Code is Copyright (C) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ../Expressions
- ../Ketsji
- ../SceneGraph
- ../../blender/makesdna
- ../../blender/blenlib
- ../../blender/blenkernel
- ../../blender/gpu
- ../../blender/imbuf
- ../../../intern/container
- ../../../intern/glew-mx
- ../../../intern/guardedalloc
- ../../../intern/string
-)
-
-set(INC_SYS
- ../../../intern/moto/include
- ${GLEW_INCLUDE_PATH}
- ${PYTHON_INCLUDE_DIRS}
-)
-
-set(SRC
- RAS_2DFilterManager.cpp
- RAS_BucketManager.cpp
- RAS_FramingManager.cpp
- RAS_IPolygonMaterial.cpp
- RAS_MaterialBucket.cpp
- RAS_MeshObject.cpp
- RAS_Polygon.cpp
- RAS_TexVert.cpp
- RAS_texmatrix.cpp
- RAS_ICanvas.cpp
-
- RAS_2DFilterManager.h
- RAS_BucketManager.h
- RAS_CameraData.h
- RAS_Deformer.h
- RAS_FramingManager.h
- RAS_ICanvas.h
- RAS_IPolygonMaterial.h
- RAS_IRasterizer.h
- RAS_ILightObject.h
- RAS_IOffScreen.h
- RAS_ISync.h
- RAS_MaterialBucket.h
- RAS_MeshObject.h
- RAS_ObjectColor.h
- RAS_Polygon.h
- RAS_Rect.h
- RAS_TexMatrix.h
- RAS_TexVert.h
- RAS_OpenGLFilters/RAS_Blur2DFilter.h
- RAS_OpenGLFilters/RAS_Dilation2DFilter.h
- RAS_OpenGLFilters/RAS_Erosion2DFilter.h
- RAS_OpenGLFilters/RAS_GrayScale2DFilter.h
- RAS_OpenGLFilters/RAS_Invert2DFilter.h
- RAS_OpenGLFilters/RAS_Laplacian2DFilter.h
- RAS_OpenGLFilters/RAS_Prewitt2DFilter.h
- RAS_OpenGLFilters/RAS_Sepia2DFilter.h
- RAS_OpenGLFilters/RAS_Sharpen2DFilter.h
- RAS_OpenGLFilters/RAS_Sobel2DFilter.h
-)
-
-add_definitions(${GL_DEFINITIONS})
-
-blender_add_lib(ge_rasterizer "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
deleted file mode 100644
index f379e2eb486..00000000000
--- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
+++ /dev/null
@@ -1,562 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_2DFilterManager.cpp
- * \ingroup bgerast
- */
-
-#include "BLI_utildefines.h"
-
-#include "RAS_OpenGLFilters/RAS_Blur2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Sharpen2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Dilation2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Erosion2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Laplacian2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Sobel2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Prewitt2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_GrayScale2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Sepia2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Invert2DFilter.h"
-
-#include "STR_String.h"
-#include "RAS_ICanvas.h"
-#include "RAS_Rect.h"
-#include "RAS_2DFilterManager.h"
-#include <iostream>
-
-#include "GPU_glew.h"
-
-#include <stdio.h>
-
-#include "EXP_Value.h"
-
-RAS_2DFilterManager::RAS_2DFilterManager():
-texturewidth(-1), textureheight(-1),
-/* numberoffilters(0), */ /* UNUSED */ need_tex_update(true)
-{
- isshadersupported = GLEW_ARB_shader_objects &&
- GLEW_ARB_fragment_shader && GLEW_ARB_multitexture;
-
- /* used to return before 2.49 but need to initialize values so don't */
- if (!isshadersupported)
- std::cout<<"shaders not supported!" << std::endl;
-
- int passindex;
- for (passindex =0; passindex<MAX_RENDER_PASS; passindex++)
- {
- m_filters[passindex] = 0;
- m_enabled[passindex] = 0;
- texflag[passindex] = 0;
- m_gameObjects[passindex] = NULL;
- }
- texname[0] = texname[1] = texname[2] = -1;
- errorprinted= false;
-}
-
-RAS_2DFilterManager::~RAS_2DFilterManager()
-{
- FreeTextures();
-
- for (int passindex = 0; passindex < MAX_RENDER_PASS; passindex++) {
- if (m_filters[passindex]) {
- glDeleteObjectARB(m_filters[passindex]);
- }
- }
-}
-
-void RAS_2DFilterManager::PrintShaderErrors(unsigned int shader, const char *task, const char *code)
-{
- GLcharARB log[5000];
- GLsizei length = 0;
- const char *c, *pos, *end;
- int line = 1;
-
- if (errorprinted)
- return;
-
- errorprinted= true;
-
- glGetInfoLogARB(shader, sizeof(log), &length, log);
- end = code + strlen(code);
-
- printf("2D Filter GLSL Shader: %s error:\n", task);
-
- c = code;
- while ((c < end) && (pos = strchr(c, '\n'))) {
- printf("%2d ", line);
- fwrite(c, (pos+1)-c, 1, stdout);
- c = pos+1;
- line++;
- }
-
- puts(c);
- puts(log);
- puts("\n");
-}
-
-unsigned int RAS_2DFilterManager::CreateShaderProgram(const char* shadersource)
-{
- GLuint program = 0;
- GLuint fShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER);
- GLint success;
-
- glShaderSourceARB(fShader, 1, (const char**)&shadersource, NULL);
-
- glCompileShaderARB(fShader);
-
-
- glGetObjectParameterivARB(fShader, GL_COMPILE_STATUS, &success);
- if (!success) {
- /*Shader Comile Error*/
- PrintShaderErrors(fShader, "compile", shadersource);
- goto fail;
- }
-
- program = glCreateProgramObjectARB();
- glAttachObjectARB(program, fShader);
-
- glLinkProgramARB(program);
- glGetObjectParameterivARB(program, GL_LINK_STATUS, &success);
- if (!success) {
- /*Program Link Error*/
- PrintShaderErrors(fShader, "link", shadersource);
- goto fail;
- }
-
- glValidateProgramARB(program);
- glGetObjectParameterivARB(program, GL_VALIDATE_STATUS, &success);
- if (!success) {
- /*Program Validation Error*/
- PrintShaderErrors(fShader, "validate", shadersource);
- goto fail;
- }
-
- /* owned by 'program' */
- if (fShader) {
- glDeleteObjectARB(fShader);
- }
-
- return program;
-
-
-fail:
- if (fShader) {
- glDeleteObjectARB(fShader);
- }
-
- if (program) {
- glDeleteObjectARB(program);
- }
- return 0;
-}
-
-unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode)
-{
- switch (filtermode) {
- case RAS_2DFILTER_BLUR:
- return CreateShaderProgram(BlurFragmentShader);
- case RAS_2DFILTER_SHARPEN:
- return CreateShaderProgram(SharpenFragmentShader);
- case RAS_2DFILTER_DILATION:
- return CreateShaderProgram(DilationFragmentShader);
- case RAS_2DFILTER_EROSION:
- return CreateShaderProgram(ErosionFragmentShader);
- case RAS_2DFILTER_LAPLACIAN:
- return CreateShaderProgram(LaplacionFragmentShader);
- case RAS_2DFILTER_SOBEL:
- return CreateShaderProgram(SobelFragmentShader);
- case RAS_2DFILTER_PREWITT:
- return CreateShaderProgram(PrewittFragmentShader);
- case RAS_2DFILTER_GRAYSCALE:
- return CreateShaderProgram(GrayScaleFragmentShader);
- case RAS_2DFILTER_SEPIA:
- return CreateShaderProgram(SepiaFragmentShader);
- case RAS_2DFILTER_INVERT:
- return CreateShaderProgram(InvertFragmentShader);
- }
- return 0;
-}
-
-void RAS_2DFilterManager::AnalyseShader(int passindex, vector<STR_String>& propNames)
-{
- texflag[passindex] = 0;
- if (glGetUniformLocationARB(m_filters[passindex], "bgl_DepthTexture") != -1)
- {
- if (GLEW_ARB_depth_texture)
- texflag[passindex] |= 0x1;
- }
- if (glGetUniformLocationARB(m_filters[passindex], "bgl_LuminanceTexture") != -1)
- {
- texflag[passindex] |= 0x2;
- }
-
- if (m_gameObjects[passindex])
- {
- int objProperties = propNames.size();
- int i;
- for (i=0; i<objProperties; i++)
- if (glGetUniformLocationARB(m_filters[passindex], propNames[i]) != -1)
- m_properties[passindex].push_back(propNames[i]);
- }
-}
-
-void RAS_2DFilterManager::StartShaderProgram(int passindex)
-{
- GLint uniformLoc;
- glUseProgramObjectARB(m_filters[passindex]);
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTexture");
- glActiveTextureARB(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, texname[0]);
-
- if (uniformLoc != -1)
- {
- glUniform1iARB(uniformLoc, 0);
- }
-
- /* send depth texture to glsl program if it needs */
- if (texflag[passindex] & 0x1) {
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_DepthTexture");
- glActiveTextureARB(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, texname[1]);
-
- if (uniformLoc != -1)
- {
- glUniform1iARB(uniformLoc, 1);
- }
- }
-
- /* send luminance texture to glsl program if it needs */
- if (texflag[passindex] & 0x2) {
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_LuminanceTexture");
- glActiveTextureARB(GL_TEXTURE2);
- glBindTexture(GL_TEXTURE_2D, texname[2]);
-
- if (uniformLoc != -1)
- {
- glUniform1iARB(uniformLoc, 2);
- }
- }
-
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_TextureCoordinateOffset");
- if (uniformLoc != -1)
- {
- glUniform2fvARB(uniformLoc, 9, textureoffsets);
- }
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureWidth");
- if (uniformLoc != -1)
- {
- glUniform1fARB(uniformLoc,texturewidth);
- }
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureHeight");
- if (uniformLoc != -1)
- {
- glUniform1fARB(uniformLoc,textureheight);
- }
-
- int i, objProperties = m_properties[passindex].size();
- for (i=0; i<objProperties; i++)
- {
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], m_properties[passindex][i]);
-
- if (uniformLoc == -1)
- continue;
-
- CValue *property = ((CValue *)m_gameObjects[passindex])->GetProperty(m_properties[passindex][i]);
-
- if (!property)
- continue;
-
- switch (property->GetValueType()) {
- case VALUE_INT_TYPE:
- glUniform1iARB(uniformLoc, property->GetNumber());
- break;
- case VALUE_FLOAT_TYPE:
- glUniform1fARB(uniformLoc, property->GetNumber());
- break;
- default:
- break;
- }
- }
-}
-
-void RAS_2DFilterManager::EndShaderProgram()
-{
- glUseProgramObjectARB(0);
-}
-
-void RAS_2DFilterManager::FreeTextures()
-{
- if (texname[0]!=(unsigned int)-1)
- glDeleteTextures(1, (GLuint*)&texname[0]);
- if (texname[1]!=(unsigned int)-1)
- glDeleteTextures(1, (GLuint*)&texname[1]);
- if (texname[2]!=(unsigned int)-1)
- glDeleteTextures(1, (GLuint*)&texname[2]);
-}
-
-void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance)
-{
- FreeTextures();
-
- glGenTextures(1, (GLuint*)&texname[0]);
- glBindTexture(GL_TEXTURE_2D, texname[0]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturewidth, textureheight, 0, GL_RGBA,
- GL_UNSIGNED_BYTE, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-
- if (depth) {
- glGenTextures(1, (GLuint*)&texname[1]);
- glBindTexture(GL_TEXTURE_2D, texname[1]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, texturewidth,textureheight,
- 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE,NULL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE,
- GL_NONE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- }
-
- if (luminance) {
- glGenTextures(1, (GLuint*)&texname[2]);
- glBindTexture(GL_TEXTURE_2D, texname[2]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16, texturewidth, textureheight,
- 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- }
-}
-
-void RAS_2DFilterManager::UpdateOffsetMatrix(RAS_ICanvas* canvas)
-{
- /* RAS_Rect canvas_rect = canvas->GetWindowArea(); */ /* UNUSED */
- texturewidth = canvas->GetWidth()+1;
- textureheight = canvas->GetHeight()+1;
- GLint i,j;
-
- if (!GL_ARB_texture_non_power_of_two)
- {
- i = 0;
- while ((1 << i) <= texturewidth)
- i++;
- texturewidth = (1 << (i));
-
- // Now for height
- i = 0;
- while ((1 << i) <= textureheight)
- i++;
- textureheight = (1 << (i));
- }
-
- GLfloat xInc = 1.0f / (GLfloat)texturewidth;
- GLfloat yInc = 1.0f / (GLfloat)textureheight;
-
- for (i = 0; i < 3; i++)
- {
- for (j = 0; j < 3; j++)
- {
- textureoffsets[(((i*3)+j)*2)+0] = (-1.0f * xInc) + ((GLfloat)i * xInc);
- textureoffsets[(((i*3)+j)*2)+1] = (-1.0f * yInc) + ((GLfloat)j * yInc);
- }
- }
-}
-
-void RAS_2DFilterManager::UpdateCanvasTextureCoord(const int viewport[4])
-{
- /*
- * This function update canvascoord[].
- * These parameters are used to create texcoord[1]
- * That way we can access the texcoord relative to the canvas:
- * (0.0,0.0) bottom left, (1.0,1.0) top right, (0.5,0.5) center
- */
- canvascoord[0] = (GLfloat) viewport[0] / -viewport[2];
- canvascoord[1] = (GLfloat) (texturewidth - viewport[0]) / viewport[2];
-
- canvascoord[2] = (GLfloat) viewport[1] / -viewport[3];
- canvascoord[3] = (GLfloat)(textureheight - viewport[1]) / viewport[3];
-}
-
-void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas)
-{
- bool need_depth=false;
- bool need_luminance=false;
- int num_filters = 0;
-
- int passindex;
-
- if (!isshadersupported)
- return;
-
- for (passindex =0; passindex<MAX_RENDER_PASS; passindex++)
- {
- if (m_filters[passindex] && m_enabled[passindex]) {
- num_filters ++;
- if (texflag[passindex] & 0x1)
- need_depth = true;
- if (texflag[passindex] & 0x2)
- need_luminance = true;
- if (need_depth && need_luminance)
- break;
- }
- }
-
- if (num_filters <= 0)
- return;
-
- const int *viewport = canvas->GetViewPort();
-
- if (texturewidth != viewport[2] || textureheight != viewport[3])
- {
- UpdateOffsetMatrix(canvas);
- UpdateCanvasTextureCoord(viewport);
- need_tex_update = true;
- }
-
- if (need_tex_update)
- {
- SetupTextures(need_depth, need_luminance);
- need_tex_update = false;
- }
-
- if (need_depth) {
- glActiveTextureARB(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, texname[1]);
- glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, viewport[0], viewport[1], viewport[2], viewport[3], 0);
- }
-
- if (need_luminance) {
- glActiveTextureARB(GL_TEXTURE2);
- glBindTexture(GL_TEXTURE_2D, texname[2]);
- glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, viewport[0], viewport[1], viewport[2], viewport[3], 0);
- }
-
- // reverting to texunit 0, without this we get bug [#28462]
- glActiveTextureARB(GL_TEXTURE0);
-
- // We do this to make side-by-side stereo rendering work correctly with 2D filters. It would probably be nicer to just set the viewport,
- // but it can be easier for writing shaders to have the coordinates for the whole screen instead of just part of the screen.
- RAS_Rect scissor_rect = canvas->GetDisplayArea();
-
- glScissor(scissor_rect.GetLeft() + viewport[0],
- scissor_rect.GetBottom() + viewport[1],
- scissor_rect.GetWidth() + 1,
- scissor_rect.GetHeight() + 1);
-
- glDisable(GL_DEPTH_TEST);
- // in case the previous material was wire
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- // if the last rendered face had alpha add it would messes with the color of the plane we apply 2DFilter to
- glDisable(GL_BLEND);
- // fix for [#34523] alpha buffer is now available for all OSs
- glDisable(GL_ALPHA_TEST);
-
- glPushMatrix(); //GL_MODELVIEW
- glLoadIdentity(); // GL_MODELVIEW
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
-
- for (passindex =0; passindex<MAX_RENDER_PASS; passindex++)
- {
- if (m_filters[passindex] && m_enabled[passindex])
- {
- StartShaderProgram(passindex);
-
- glActiveTextureARB(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, texname[0]);
- glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, viewport[0], viewport[1], viewport[2], viewport[3], 0); // Don't use texturewidth and textureheight in case we don't have NPOT support
- glClear(GL_COLOR_BUFFER_BIT);
-
- glBegin(GL_QUADS);
- glColor4f(1.f, 1.f, 1.f, 1.f);
- glTexCoord2f(1.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[1], canvascoord[3]); glVertex2f(1.0f,1.0f);
- glTexCoord2f(0.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[0], canvascoord[3]); glVertex2f(-1.0f,1.0f);
- glTexCoord2f(0.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[0], canvascoord[2]); glVertex2f(-1.0f,-1.0f);
- glTexCoord2f(1.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[1], canvascoord[2]); glVertex2f(1.0f,-1.0f);
- glEnd();
- }
- }
-
- glEnable(GL_DEPTH_TEST);
- EndShaderProgram();
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
-}
-
-void RAS_2DFilterManager::EnableFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text)
-{
- if (!isshadersupported)
- return;
- if (pass<0 || pass>=MAX_RENDER_PASS)
- return;
- need_tex_update = true;
- if (mode == RAS_2DFILTER_DISABLED)
- {
- m_enabled[pass] = 0;
- return;
- }
-
- if (mode == RAS_2DFILTER_ENABLED)
- {
- m_enabled[pass] = 1;
- return;
- }
-
- if (mode == RAS_2DFILTER_NOFILTER)
- {
- if (m_filters[pass])
- glDeleteObjectARB(m_filters[pass]);
- m_enabled[pass] = 0;
- m_filters[pass] = 0;
- m_gameObjects[pass] = NULL;
- m_properties[pass].clear();
- texflag[pass] = 0;
- return;
- }
-
- if (mode == RAS_2DFILTER_CUSTOMFILTER)
- {
- if (m_filters[pass])
- glDeleteObjectARB(m_filters[pass]);
- m_filters[pass] = CreateShaderProgram(text.Ptr());
- m_gameObjects[pass] = gameObj;
- AnalyseShader(pass, propNames);
- m_enabled[pass] = 1;
- return;
- }
-
- // We've checked all other cases, which means we must be dealing with a builtin filter
- if (m_filters[pass])
- glDeleteObjectARB(m_filters[pass]);
- m_filters[pass] = CreateShaderProgram(mode);
- m_gameObjects[pass] = NULL;
- AnalyseShader(pass, propNames);
- m_enabled[pass] = 1;
-}
diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h
deleted file mode 100644
index bb727fe3b29..00000000000
--- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_2DFilterManager.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_2DFILTERMANAGER_H__
-#define __RAS_2DFILTERMANAGER_H__
-
-#define MAX_RENDER_PASS 100
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class RAS_ICanvas;
-
-class RAS_2DFilterManager
-{
-private:
- unsigned int CreateShaderProgram(const char* shadersource);
- unsigned int CreateShaderProgram(int filtermode);
- void AnalyseShader(int passindex, std::vector<STR_String>& propNames);
- void StartShaderProgram(int passindex);
- void EndShaderProgram();
- void PrintShaderErrors(unsigned int shader, const char *task, const char *code);
-
- void SetupTextures(bool depth, bool luminance);
- void FreeTextures();
-
- void UpdateOffsetMatrix(RAS_ICanvas* canvas);
- void UpdateCanvasTextureCoord(const int viewport[4]);
-
- float canvascoord[4];
- float textureoffsets[18];
- /* float view[4]; */ /* UNUSED */
- /* texname[0] contains render to texture, texname[1] contains depth texture, texname[2] contains luminance texture*/
- unsigned int texname[3];
- int texturewidth;
- int textureheight;
- /* int numberoffilters; */ /* UNUSED */
- /* bit 0: enable/disable depth texture
- * bit 1: enable/disable luminance texture*/
- short texflag[MAX_RENDER_PASS];
-
- bool isshadersupported;
- bool errorprinted;
- bool need_tex_update;
-
- unsigned int m_filters[MAX_RENDER_PASS];
- short m_enabled[MAX_RENDER_PASS];
-
- // stores object properties to send to shaders in each pass
- std::vector<STR_String> m_properties[MAX_RENDER_PASS];
- void* m_gameObjects[MAX_RENDER_PASS];
-public:
- enum RAS_2DFILTER_MODE {
- RAS_2DFILTER_ENABLED = -2,
- RAS_2DFILTER_DISABLED = -1,
- RAS_2DFILTER_NOFILTER = 0,
- RAS_2DFILTER_MOTIONBLUR,
- RAS_2DFILTER_BLUR,
- RAS_2DFILTER_SHARPEN,
- RAS_2DFILTER_DILATION,
- RAS_2DFILTER_EROSION,
- RAS_2DFILTER_LAPLACIAN,
- RAS_2DFILTER_SOBEL,
- RAS_2DFILTER_PREWITT,
- RAS_2DFILTER_GRAYSCALE,
- RAS_2DFILTER_SEPIA,
- RAS_2DFILTER_INVERT,
- RAS_2DFILTER_CUSTOMFILTER,
- RAS_2DFILTER_NUMBER_OF_FILTERS
- };
-
- RAS_2DFilterManager();
-
- ~RAS_2DFilterManager();
-
- void RenderFilters(RAS_ICanvas* canvas);
-
- void EnableFilter(std::vector<STR_String>& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_2DFilterManager")
-#endif
-};
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp
deleted file mode 100644
index deca7cbed9f..00000000000
--- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_BucketManager.cpp
- * \ingroup bgerast
- */
-
-#ifdef _MSC_VER
- /* don't show these anoying STL warnings */
-# pragma warning (disable:4786)
-#endif
-
-#include "RAS_MaterialBucket.h"
-#include "RAS_MeshObject.h"
-#include "RAS_Polygon.h"
-#include "RAS_IPolygonMaterial.h"
-#include "RAS_IRasterizer.h"
-
-#include "RAS_BucketManager.h"
-
-#include <algorithm>
-/* sorting */
-
-struct RAS_BucketManager::sortedmeshslot
-{
-public:
- MT_Scalar m_z; /* depth */
- RAS_MeshSlot *m_ms; /* mesh slot */
- RAS_MaterialBucket *m_bucket; /* buck mesh slot came from */
-
- sortedmeshslot() {}
-
- void set(RAS_MeshSlot *ms, RAS_MaterialBucket *bucket, const MT_Vector3& pnorm)
- {
- // would be good to use the actual bounding box center instead
- MT_Point3 pos(ms->m_OpenGLMatrix[12], ms->m_OpenGLMatrix[13], ms->m_OpenGLMatrix[14]);
-
- m_z = MT_dot(pnorm, pos);
- m_ms = ms;
- m_bucket = bucket;
- }
-};
-
-struct RAS_BucketManager::backtofront
-{
- bool operator()(const sortedmeshslot &a, const sortedmeshslot &b)
- {
- return (a.m_z < b.m_z) || (a.m_z == b.m_z && a.m_ms < b.m_ms);
- }
-};
-
-struct RAS_BucketManager::fronttoback
-{
- bool operator()(const sortedmeshslot &a, const sortedmeshslot &b)
- {
- return (a.m_z > b.m_z) || (a.m_z == b.m_z && a.m_ms > b.m_ms);
- }
-};
-
-/* bucket manager */
-
-RAS_BucketManager::RAS_BucketManager()
-{
-
-}
-
-RAS_BucketManager::~RAS_BucketManager()
-{
- BucketList::iterator it;
-
- for (it = m_SolidBuckets.begin(); it != m_SolidBuckets.end(); it++)
- delete (*it);
-
- for (it = m_AlphaBuckets.begin(); it != m_AlphaBuckets.end(); it++)
- delete(*it);
-
- m_SolidBuckets.clear();
- m_AlphaBuckets.clear();
-}
-
-void RAS_BucketManager::OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector<sortedmeshslot>& slots, bool alpha)
-{
- BucketList::iterator bit;
- list<RAS_MeshSlot>::iterator mit;
- size_t size = 0, i = 0;
-
- /* Camera's near plane equation: pnorm.dot(point) + pval,
- * but we leave out pval since it's constant anyway */
- const MT_Vector3 pnorm(cameratrans.getBasis()[2]);
-
- for (bit = buckets.begin(); bit != buckets.end(); ++bit)
- {
- SG_DList::iterator<RAS_MeshSlot> mit((*bit)->GetActiveMeshSlots());
- for (mit.begin(); !mit.end(); ++mit)
- size++;
- }
-
- slots.resize(size);
-
- for (bit = buckets.begin(); bit != buckets.end(); ++bit)
- {
- RAS_MaterialBucket* bucket = *bit;
- RAS_MeshSlot* ms;
- // remove the mesh slot from the list, it culls them automatically for next frame
- while ((ms = bucket->GetNextActiveMeshSlot())) {
- slots[i++].set(ms, bucket, pnorm);
- }
- }
-
- if (alpha)
- sort(slots.begin(), slots.end(), backtofront());
- else
- sort(slots.begin(), slots.end(), fronttoback());
-}
-
-void RAS_BucketManager::RenderAlphaBuckets(const MT_Transform& cameratrans, RAS_IRasterizer* rasty)
-{
- vector<sortedmeshslot> slots;
- vector<sortedmeshslot>::iterator sit;
-
- // Having depth masks disabled/enabled gives different artifacts in
- // case no sorting is done or is done inexact. For compatibility, we
- // disable it.
- if (rasty->GetDrawingMode() != RAS_IRasterizer::KX_SHADOW)
- rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_DISABLED);
-
- OrderBuckets(cameratrans, m_AlphaBuckets, slots, true);
-
- for (sit=slots.begin(); sit!=slots.end(); ++sit) {
- rasty->SetClientObject(sit->m_ms->m_clientObj);
-
- while (sit->m_bucket->ActivateMaterial(cameratrans, rasty))
- sit->m_bucket->RenderMeshSlot(cameratrans, rasty, *(sit->m_ms));
-
- // make this mesh slot culled automatically for next frame
- // it will be culled out by frustum culling
- sit->m_ms->SetCulled(true);
- }
-
- rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED);
-}
-
-void RAS_BucketManager::RenderSolidBuckets(const MT_Transform& cameratrans, RAS_IRasterizer* rasty)
-{
- BucketList::iterator bit;
-
- rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED);
-
- for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) {
-#if 1
- RAS_MaterialBucket* bucket = *bit;
- RAS_MeshSlot* ms;
- // remove the mesh slot from the list, it culls them automatically for next frame
- while ((ms = bucket->GetNextActiveMeshSlot())) {
- rasty->SetClientObject(ms->m_clientObj);
- while (bucket->ActivateMaterial(cameratrans, rasty))
- bucket->RenderMeshSlot(cameratrans, rasty, *ms);
-
- // make this mesh slot culled automatically for next frame
- // it will be culled out by frustum culling
- ms->SetCulled(true);
- }
-#else
- list<RAS_MeshSlot>::iterator mit;
- for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
- if (mit->IsCulled())
- continue;
-
- rasty->SetClientObject(rasty, mit->m_clientObj);
-
- while ((*bit)->ActivateMaterial(cameratrans, rasty))
- (*bit)->RenderMeshSlot(cameratrans, rasty, *mit);
-
- // make this mesh slot culled automatically for next frame
- // it will be culled out by frustum culling
- mit->SetCulled(true);
- }
-#endif
- }
-
- /* this code draws meshes order front-to-back instead to reduce overdraw.
- * it turned out slower due to much material state switching, a more clever
- * algorithm might do better. */
-#if 0
- vector<sortedmeshslot> slots;
- vector<sortedmeshslot>::iterator sit;
-
- OrderBuckets(cameratrans, m_SolidBuckets, slots, false);
-
- for (sit=slots.begin(); sit!=slots.end(); ++sit) {
- rendertools->SetClientObject(rasty, sit->m_ms->m_clientObj);
-
- while (sit->m_bucket->ActivateMaterial(cameratrans, rasty))
- sit->m_bucket->RenderMeshSlot(cameratrans, rasty, *(sit->m_ms));
- }
-#endif
-}
-
-void RAS_BucketManager::Renderbuckets(const MT_Transform& cameratrans, RAS_IRasterizer* rasty)
-{
- /* beginning each frame, clear (texture/material) caching information */
- rasty->ClearCachingInfo();
-
- RenderSolidBuckets(cameratrans, rasty);
- RenderAlphaBuckets(cameratrans, rasty);
-
- /* If we're drawing shadows and bucket wasn't rendered (outside of the lamp frustum or doesn't cast shadows)
- * then the mesh is still modified, so we don't want to set MeshModified to false yet (it will mess up
- * updating display lists). Just leave this step for the main render pass.
- */
- if (rasty->GetDrawingMode() != RAS_IRasterizer::KX_SHADOW) {
- /* All meshes should be up to date now */
- /* Don't do this while processing buckets because some meshes are split between buckets */
- BucketList::iterator bit;
- list<RAS_MeshSlot>::iterator mit;
- for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) {
- for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
- mit->m_mesh->SetMeshModified(false);
- }
- }
- for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit) {
- for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
- mit->m_mesh->SetMeshModified(false);
- }
- }
- }
-
-
- rasty->SetClientObject(NULL);
-}
-
-RAS_MaterialBucket *RAS_BucketManager::FindBucket(RAS_IPolyMaterial *material, bool &bucketCreated)
-{
- BucketList::iterator it;
-
- bucketCreated = false;
-
- for (it = m_SolidBuckets.begin(); it != m_SolidBuckets.end(); it++)
- if (*(*it)->GetPolyMaterial() == *material)
- return *it;
-
- for (it = m_AlphaBuckets.begin(); it != m_AlphaBuckets.end(); it++)
- if (*(*it)->GetPolyMaterial() == *material)
- return *it;
-
- RAS_MaterialBucket *bucket = new RAS_MaterialBucket(material);
- bucketCreated = true;
-
- if (bucket->IsAlpha())
- m_AlphaBuckets.push_back(bucket);
- else
- m_SolidBuckets.push_back(bucket);
-
- return bucket;
-}
-
-void RAS_BucketManager::OptimizeBuckets(MT_Scalar distance)
-{
- BucketList::iterator bit;
-
- distance = 10.0f;
-
- for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit)
- (*bit)->Optimize(distance);
- for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit)
- (*bit)->Optimize(distance);
-}
-
-void RAS_BucketManager::ReleaseDisplayLists(RAS_IPolyMaterial *mat)
-{
- BucketList::iterator bit;
- list<RAS_MeshSlot>::iterator mit;
-
- for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) {
- if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) {
- for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
- if (mit->m_DisplayList) {
- mit->m_DisplayList->Release();
- mit->m_DisplayList = NULL;
- }
- }
- }
- }
-
- for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit) {
- if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) {
- for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
- if (mit->m_DisplayList) {
- mit->m_DisplayList->Release();
- mit->m_DisplayList = NULL;
- }
- }
- }
- }
-}
-
-void RAS_BucketManager::ReleaseMaterials(RAS_IPolyMaterial * mat)
-{
- BucketList::iterator bit;
- list<RAS_MeshSlot>::iterator mit;
-
- for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) {
- if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) {
- (*bit)->GetPolyMaterial()->ReleaseMaterial();
- }
- }
-
- for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit) {
- if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) {
- (*bit)->GetPolyMaterial()->ReleaseMaterial();
- }
- }
-}
-
-/* frees the bucket, only used when freeing scenes */
-void RAS_BucketManager::RemoveMaterial(RAS_IPolyMaterial * mat)
-{
- BucketList::iterator bit, bitp;
- list<RAS_MeshSlot>::iterator mit;
- int i;
-
-
- for (i=0; i<m_SolidBuckets.size(); i++) {
- RAS_MaterialBucket *bucket = m_SolidBuckets[i];
- if (mat == bucket->GetPolyMaterial()) {
- m_SolidBuckets.erase(m_SolidBuckets.begin()+i);
- delete bucket;
- i--;
- }
- }
-
- for (int i=0; i<m_AlphaBuckets.size(); i++) {
- RAS_MaterialBucket *bucket = m_AlphaBuckets[i];
- if (mat == bucket->GetPolyMaterial()) {
- m_AlphaBuckets.erase(m_AlphaBuckets.begin()+i);
- delete bucket;
- i--;
- }
- }
-}
-
-//#include <stdio.h>
-
-void RAS_BucketManager::MergeBucketManager(RAS_BucketManager *other, SCA_IScene *scene)
-{
- /* concatenate lists */
- // printf("BEFORE %d %d\n", GetSolidBuckets().size(), GetAlphaBuckets().size());
-
- GetSolidBuckets().insert( GetSolidBuckets().end(), other->GetSolidBuckets().begin(), other->GetSolidBuckets().end() );
- other->GetSolidBuckets().clear();
-
- GetAlphaBuckets().insert( GetAlphaBuckets().end(), other->GetAlphaBuckets().begin(), other->GetAlphaBuckets().end() );
- other->GetAlphaBuckets().clear();
- //printf("AFTER %d %d\n", GetSolidBuckets().size(), GetAlphaBuckets().size());
-}
-
diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h
deleted file mode 100644
index 5ed212ebee0..00000000000
--- a/source/gameengine/Rasterizer/RAS_BucketManager.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_BucketManager.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_BUCKETMANAGER_H__
-#define __RAS_BUCKETMANAGER_H__
-
-#include "MT_Transform.h"
-#include "RAS_MaterialBucket.h"
-
-#include <vector>
-
-class RAS_BucketManager
-{
-public:
- typedef std::vector<class RAS_MaterialBucket*> BucketList;
-private:
- BucketList m_SolidBuckets;
- BucketList m_AlphaBuckets;
-
- struct sortedmeshslot;
- struct backtofront;
- struct fronttoback;
-
-public:
- RAS_BucketManager();
- virtual ~RAS_BucketManager();
-
- void Renderbuckets(const MT_Transform & cameratrans, RAS_IRasterizer* rasty);
-
- RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial *material, bool &bucketCreated);
- void OptimizeBuckets(MT_Scalar distance);
-
- void ReleaseDisplayLists(RAS_IPolyMaterial *material = NULL);
- void ReleaseMaterials(RAS_IPolyMaterial *material = NULL);
-
- void RemoveMaterial(RAS_IPolyMaterial *mat); // freeing scenes only
-
- /* for merging */
- void MergeBucketManager(RAS_BucketManager *other, SCA_IScene *scene);
- BucketList & GetSolidBuckets() {return m_SolidBuckets;}
- BucketList & GetAlphaBuckets() {return m_AlphaBuckets;}
-
- /*void PrintStats(int verbose_level) {
- printf("\nMappings...\n");
- printf("\t m_SolidBuckets: %d\n", m_SolidBuckets.size());
- printf("\t\t m_SolidBuckets: %d\n", m_SolidBuckets.size());
- printf("\t m_AlphaBuckets: %d\n", m_AlphaBuckets.size());
- }*/
-
-
-private:
- void OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector<sortedmeshslot>& slots, bool alpha);
-
- void RenderSolidBuckets(const MT_Transform& cameratrans,
- RAS_IRasterizer* rasty);
- void RenderAlphaBuckets(const MT_Transform& cameratrans,
- RAS_IRasterizer* rasty);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_BucketManager")
-#endif
-};
-
-#endif /* __RAS_BUCKETMANAGER_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_CameraData.h b/source/gameengine/Rasterizer/RAS_CameraData.h
deleted file mode 100644
index bc8433afd05..00000000000
--- a/source/gameengine/Rasterizer/RAS_CameraData.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_CameraData.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_CAMERADATA_H__
-#define __RAS_CAMERADATA_H__
-
-struct RAS_CameraData
-{
- float m_lens;
- float m_scale;
- float m_sensor_x;
- float m_sensor_y;
- short m_sensor_fit;
- float m_shift_x;
- float m_shift_y;
- float m_clipstart;
- float m_clipend;
- bool m_perspective;
- bool m_viewport;
- int m_viewportleft;
- int m_viewportbottom;
- int m_viewportright;
- int m_viewporttop;
- float m_focallength;
-
- RAS_CameraData(float lens = 35.0f, float scale = 6.0f, float sensor_x = 32.0f, float sensor_y = 18.0f, short sensor_fit = 0,
- float shift_x = 0.0f, float shift_y = 0.0f,
- float clipstart = 0.1f, float clipend = 5000.0f, bool perspective = true,
- float focallength = 3.0f, bool viewport = false, int viewportleft = 0, int viewportbottom = 0,
- int viewportright = 0, int viewporttop = 0) :
- m_lens(lens),
- m_scale(scale),
- m_sensor_x(sensor_x),
- m_sensor_y(sensor_y),
- m_sensor_fit(sensor_fit),
- m_shift_x(shift_x),
- m_shift_y(shift_y),
- m_clipstart(clipstart),
- m_clipend(clipend),
- m_perspective(perspective),
- m_viewport(viewport),
- m_viewportleft(viewportleft),
- m_viewportbottom(viewportbottom),
- m_viewportright(viewportright),
- m_viewporttop(viewporttop),
- m_focallength(focallength)
- {
- }
-};
-
-#endif /* __RAS_CAMERADATA_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h
deleted file mode 100644
index 058f2304f3d..00000000000
--- a/source/gameengine/Rasterizer/RAS_Deformer.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_Deformer.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_DEFORMER_H__
-#define __RAS_DEFORMER_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786) /* get rid of stupid stl-visual compiler debug warning */
-#endif
-
-#include <stdlib.h>
-#include "CTR_Map.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-struct DerivedMesh;
-class RAS_MeshObject;
-
-class RAS_Deformer
-{
-public:
- RAS_Deformer() : m_pMesh(NULL), m_bDynamic(false) {}
- virtual ~RAS_Deformer() {}
- virtual void Relink(CTR_Map<class CTR_HashedPtr, void*>*map)=0;
- virtual bool Apply(class RAS_IPolyMaterial *polymat)=0;
- virtual bool Update(void)=0;
- virtual bool UpdateBuckets(void)=0;
- virtual RAS_Deformer *GetReplica()=0;
- virtual void ProcessReplica()=0;
- virtual bool SkipVertexTransform()
- {
- return false;
- }
- virtual bool ShareVertexArray()
- {
- return true;
- }
- virtual bool UseVertexArray()
- {
- return true;
- }
- // true when deformer produces varying vertex (shape or armature)
- bool IsDynamic()
- {
- return m_bDynamic;
- }
- virtual struct DerivedMesh* GetFinalMesh()
- {
- return NULL;
- }
- virtual struct DerivedMesh* GetPhysicsMesh()
- {
- return NULL;
- }
- virtual class RAS_MeshObject* GetRasMesh()
- {
- /* m_pMesh does not seem to be being used?? */
- return NULL;
- }
- virtual float (* GetTransVerts(int *tot))[3] { *tot= 0; return NULL; }
-
-protected:
- class RAS_MeshObject *m_pMesh;
- bool m_bDynamic;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_Deformer")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.cpp b/source/gameengine/Rasterizer/RAS_FramingManager.cpp
deleted file mode 100644
index 8b0ec22fde3..00000000000
--- a/source/gameengine/Rasterizer/RAS_FramingManager.cpp
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_FramingManager.cpp
- * \ingroup bgerast
- */
-
-
-#include "RAS_FramingManager.h"
-#include "RAS_Rect.h"
-
- void
-RAS_FramingManager::
-ComputeDefaultFrustum(
- const float camnear,
- const float camfar,
- const float lens,
- const float sensor_x, const float sensor_y,
- const short sensor_fit,
- const float shift_x,
- const float shift_y,
- const float design_aspect_ratio,
- RAS_FrameFrustum & frustum
-) {
- float size;
- float halfSize;
- float sizeX;
- float sizeY;
- float offsetX;
- float offsetY;
-
- if (sensor_fit==RAS_SENSORFIT_AUTO) {
- size = sensor_x * camnear / lens;
- halfSize = size * 0.5f;
-
- if (design_aspect_ratio > 1.f) {
- // halfsize defines the width
- sizeX = halfSize;
- sizeY = halfSize/design_aspect_ratio;
- } else {
- // halfsize defines the height
- sizeX = halfSize * design_aspect_ratio;
- sizeY = halfSize;
- }
- }
- else if (sensor_fit==RAS_SENSORFIT_HOR) {
- size = sensor_x * camnear / lens;
- halfSize = size * 0.5f;
- sizeX = halfSize;
- sizeY = halfSize/design_aspect_ratio;
- }
- else {
- size = sensor_y * camnear / lens;
- halfSize = size * 0.5f;
- sizeX = halfSize * design_aspect_ratio;
- sizeY = halfSize;
- }
-
- offsetX = size * shift_x;
- offsetY = size * shift_y;
-
- frustum.x2 = sizeX + offsetX;
- frustum.x1 = -sizeX + offsetX;
- frustum.y2 = sizeY + offsetY;
- frustum.y1 = -sizeY + offsetY;
- frustum.camnear = camnear;
- frustum.camfar = camfar;
-}
-
- void
-RAS_FramingManager::
-ComputeDefaultOrtho(
- const float camnear,
- const float camfar,
- const float scale,
- const float design_aspect_ratio,
- const short sensor_fit,
- const float shift_x,
- const float shift_y,
- RAS_FrameFrustum & frustum
-)
-{
- float halfSize = scale*0.5f;
- float sizeX;
- float sizeY;
- float offsetX;
- float offsetY;
-
- if (sensor_fit==RAS_SENSORFIT_AUTO) {
- if (design_aspect_ratio > 1.f) {
- // halfsize defines the width
- sizeX = halfSize;
- sizeY = halfSize/design_aspect_ratio;
- } else {
- // halfsize defines the height
- sizeX = halfSize * design_aspect_ratio;
- sizeY = halfSize;
- }
- }
- else if (sensor_fit==RAS_SENSORFIT_HOR) {
- sizeX = halfSize;
- sizeY = halfSize/design_aspect_ratio;
- }
- else {
- sizeX = halfSize * design_aspect_ratio;
- sizeY = halfSize;
- }
-
- offsetX = scale * shift_x;
- offsetY = scale * shift_y;
-
- frustum.x2 = sizeX + offsetX;
- frustum.x1 = -sizeX + offsetX;
- frustum.y2 = sizeY + offsetY;
- frustum.y1 = -sizeY + offsetY;
- frustum.camnear = camnear;
- frustum.camfar = camfar;
-}
-
-
- void
-RAS_FramingManager::
-ComputeBestFitViewRect(
- const RAS_Rect &availableViewport,
- const float design_aspect_ratio,
- RAS_Rect &viewport
-) {
- // try and honour the aspect ratio when setting the
- // drawable area. If we don't do this we are liable
- // to get a lot of distortion in the rendered image.
-
- int width = availableViewport.GetWidth();
- int height = availableViewport.GetHeight();
- float window_aspect = float(width)/float(height);
-
- if (window_aspect < design_aspect_ratio) {
- int v_height = (int)(width / design_aspect_ratio);
- int left_over = (height - v_height) / 2;
-
- viewport.SetLeft(availableViewport.GetLeft());
- viewport.SetBottom(availableViewport.GetBottom() + left_over);
- viewport.SetRight(availableViewport.GetLeft() + width);
- viewport.SetTop(availableViewport.GetBottom() + left_over + v_height);
-
- } else {
- int v_width = (int)(height * design_aspect_ratio);
- int left_over = (width - v_width) / 2;
-
- viewport.SetLeft(availableViewport.GetLeft() + left_over);
- viewport.SetBottom(availableViewport.GetBottom());
- viewport.SetRight(availableViewport.GetLeft() + v_width + left_over);
- viewport.SetTop(availableViewport.GetBottom() + height);
- }
-}
-
- void
-RAS_FramingManager::
-ComputeViewport(
- const RAS_FrameSettings &settings,
- const RAS_Rect &availableViewport,
- RAS_Rect &viewport
-) {
-
- RAS_FrameSettings::RAS_FrameType type = settings.FrameType();
- const int winx = availableViewport.GetWidth();
- const int winy = availableViewport.GetHeight();
-
- const float design_width = float(settings.DesignAspectWidth());
- const float design_height = float(settings.DesignAspectHeight());
-
- float design_aspect_ratio = float(1);
-
- if (design_height == float(0)) {
- // well this is ill defined
- // lets just scale the thing
-
- type = RAS_FrameSettings::e_frame_scale;
- } else {
- design_aspect_ratio = design_width/design_height;
- }
-
- switch (type) {
-
- case RAS_FrameSettings::e_frame_scale :
- case RAS_FrameSettings::e_frame_extend:
- {
- viewport.SetLeft(availableViewport.GetLeft());
- viewport.SetBottom(availableViewport.GetBottom());
- viewport.SetRight(availableViewport.GetLeft() + int(winx));
- viewport.SetTop(availableViewport.GetBottom() + int(winy));
-
- break;
- }
-
- case RAS_FrameSettings::e_frame_bars:
- {
- ComputeBestFitViewRect(
- availableViewport,
- design_aspect_ratio,
- viewport
- );
-
- break;
- }
- default :
- break;
- }
-}
-
- void
-RAS_FramingManager::
-ComputeFrustum(
- const RAS_FrameSettings &settings,
- const RAS_Rect &availableViewport,
- const RAS_Rect &viewport,
- const float lens,
- const float sensor_x, const float sensor_y, const short sensor_fit,
- const float shift_x,
- const float shift_y,
- const float camnear,
- const float camfar,
- RAS_FrameFrustum &frustum
-) {
-
- RAS_FrameSettings::RAS_FrameType type = settings.FrameType();
-
- const float design_width = float(settings.DesignAspectWidth());
- const float design_height = float(settings.DesignAspectHeight());
-
- float design_aspect_ratio = float(1);
-
- if (design_height == float(0)) {
- // well this is ill defined
- // lets just scale the thing
-
- type = RAS_FrameSettings::e_frame_scale;
- } else {
- design_aspect_ratio = design_width/design_height;
- }
-
- ComputeDefaultFrustum(
- camnear,
- camfar,
- lens,
- sensor_x,
- sensor_y,
- sensor_fit,
- shift_x,
- shift_y,
- design_aspect_ratio,
- frustum
- );
-
- switch (type) {
-
- case RAS_FrameSettings::e_frame_extend:
- {
- float x_scale, y_scale;
- switch (sensor_fit) {
- case RAS_SENSORFIT_HOR:
- {
- x_scale = 1.0f;
- y_scale = float(viewport.GetHeight()) / float(viewport.GetWidth());
- break;
- }
- case RAS_SENSORFIT_VERT:
- {
- x_scale = float(viewport.GetWidth()) / float(viewport.GetHeight());
- y_scale = 1.0f;
- break;
- }
- case RAS_SENSORFIT_AUTO:
- default:
- {
- RAS_Rect vt;
- ComputeBestFitViewRect(
- availableViewport,
- design_aspect_ratio,
- vt
- );
-
- // now scale the calculated frustum by the difference
- // between vt and the viewport in each axis.
- // These are always > 1
-
- x_scale = float(viewport.GetWidth())/float(vt.GetWidth());
- y_scale = float(viewport.GetHeight())/float(vt.GetHeight());
- break;
- }
- }
-
- frustum.x1 *= x_scale;
- frustum.x2 *= x_scale;
- frustum.y1 *= y_scale;
- frustum.y2 *= y_scale;
-
- break;
- }
- case RAS_FrameSettings::e_frame_scale :
- case RAS_FrameSettings::e_frame_bars:
- default :
- break;
- }
-}
-
- void
-RAS_FramingManager::
- ComputeOrtho(
- const RAS_FrameSettings &settings,
- const RAS_Rect &availableViewport,
- const RAS_Rect &viewport,
- const float scale,
- const float camnear,
- const float camfar,
- const short sensor_fit,
- const float shift_x,
- const float shift_y,
- RAS_FrameFrustum &frustum
- )
-{
- RAS_FrameSettings::RAS_FrameType type = settings.FrameType();
-
- const float design_width = float(settings.DesignAspectWidth());
- const float design_height = float(settings.DesignAspectHeight());
-
- float design_aspect_ratio = float(1);
-
- if (design_height == float(0)) {
- // well this is ill defined
- // lets just scale the thing
- type = RAS_FrameSettings::e_frame_scale;
- } else {
- design_aspect_ratio = design_width/design_height;
- }
-
-
- ComputeDefaultOrtho(
- camnear,
- camfar,
- scale,
- design_aspect_ratio,
- sensor_fit,
- shift_x,
- shift_y,
- frustum
- );
-
- switch (type) {
-
- case RAS_FrameSettings::e_frame_extend:
- {
- float x_scale, y_scale;
- switch (sensor_fit) {
- case RAS_SENSORFIT_HOR:
- {
- x_scale = 1.0f;
- y_scale = float(viewport.GetHeight()) / float(viewport.GetWidth());
- break;
- }
- case RAS_SENSORFIT_VERT:
- {
- x_scale = float(viewport.GetWidth()) / float(viewport.GetHeight());
- y_scale = 1.0f;
- break;
- }
- case RAS_SENSORFIT_AUTO:
- default:
- {
- RAS_Rect vt;
- ComputeBestFitViewRect(
- availableViewport,
- design_aspect_ratio,
- vt
- );
-
- // now scale the calculated frustum by the difference
- // between vt and the viewport in each axis.
- // These are always > 1
-
- x_scale = float(viewport.GetWidth())/float(vt.GetWidth());
- y_scale = float(viewport.GetHeight())/float(vt.GetHeight());
- break;
- }
- }
-
- frustum.x1 *= x_scale;
- frustum.x2 *= x_scale;
- frustum.y1 *= y_scale;
- frustum.y2 *= y_scale;
-
- break;
- }
- case RAS_FrameSettings::e_frame_scale :
- case RAS_FrameSettings::e_frame_bars:
- default :
- break;
- }
-
-}
-
-
diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.h b/source/gameengine/Rasterizer/RAS_FramingManager.h
deleted file mode 100644
index cb86a7a4484..00000000000
--- a/source/gameengine/Rasterizer/RAS_FramingManager.h
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_FramingManager.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_FRAMINGMANAGER_H__
-#define __RAS_FRAMINGMANAGER_H__
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class RAS_Rect;
-
-/**
- * \section RAS_FrameSettings
- * This is a value type describing the framing used
- * by a particular scene in the game engine.
- * Each KX_Scene contains a RAS_FrameSetting describing
- * how the frustum and viewport are to be modified
- * depending on the canvas size.
- *
- * e_frame_scale means that the viewport is set to the current
- * canvas size. If the view frustum aspect ratio is different
- * to the canvas aspect this will lead to stretching.
- *
- * e_frame_extend means that the best fit viewport will be
- * computed based upon the design aspect ratio
- * and the view frustum will be adjusted so that
- * more of the scene is visible.
- *
- * e_frame_bars means that the best fit viewport will be
- * be computed based upon the design aspect ratio.
- */
-
-class RAS_FrameSettings
-{
-public :
- /**
- * enum defining the policy to use
- * in each axis.
- */
- enum RAS_FrameType {
- e_frame_scale,
- e_frame_extend,
- e_frame_bars
- };
-
- /**
- * Constructor
- */
-
- RAS_FrameSettings(
- RAS_FrameType frame_type,
- float bar_r,
- float bar_g,
- float bar_b,
- unsigned int design_aspect_width,
- unsigned int design_aspect_height
- ):
- m_frame_type(frame_type),
- m_bar_r(bar_r),
- m_bar_g(bar_g),
- m_bar_b(bar_b),
- m_design_aspect_width(design_aspect_width),
- m_design_aspect_height(design_aspect_height)
- {
- };
-
- RAS_FrameSettings(
- ):
- m_frame_type(e_frame_scale),
- m_bar_r(0),
- m_bar_g(0),
- m_bar_b(0),
- m_design_aspect_width(1),
- m_design_aspect_height(1)
- {
- };
-
- /**
- * Accessors
- */
-
- const
- RAS_FrameType &
- FrameType(
- ) const {
- return m_frame_type;
- };
-
- void
- SetFrameType(
- RAS_FrameType type
- ) {
- m_frame_type = type;
- };
-
- float
- BarRed(
- ) const {
- return m_bar_r;
- };
-
- float
- BarGreen(
- ) const {
- return m_bar_g;
- };
-
- float
- BarBlue(
- ) const {
- return m_bar_b;
- };
-
- unsigned int
- DesignAspectWidth(
- ) const {
- return m_design_aspect_width;
- };
-
- unsigned int
- DesignAspectHeight(
- ) const {
- return m_design_aspect_height;
- };
-
-private :
-
- RAS_FrameType m_frame_type;
- float m_bar_r;
- float m_bar_g;
- float m_bar_b;
- unsigned int m_design_aspect_width;
- unsigned int m_design_aspect_height;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_FrameSettings")
-#endif
-};
-
-struct RAS_FrameFrustum
-{
- float camnear,camfar;
- float x1,y1;
- float x2,y2;
-};
-
-/* must match R_CULLING_... from DNA_scene_types.h */
-enum RAS_CullingMode
-{
- RAS_CULLING_DBVT = 0,
- RAS_CULLING_NORMAL,
- RAS_CULLING_NONE
-};
-
-/* Should match CAMERA_SENSOR_FIT... from DNA_camera_types.h */
-enum RAS_SensorFit
-{
- RAS_SENSORFIT_AUTO = 0,
- RAS_SENSORFIT_HOR,
- RAS_SENSORFIT_VERT
-};
-
-/**
- * \section RAS_FramingManager
- * This class helps to compute a view frustum
- * and a viewport rectangle given the
- * above settings and a description of the
- * current canvas dimensions.
- *
- * You do not have to instantiate this class
- * directly, it only contains static helper functions
- */
-
-class RAS_FramingManager
-{
-public :
-
- /**
- * Compute a viewport given
- * a RAS_FrameSettings and a description of the
- * canvas.
- */
-
- static
- void
- ComputeViewport(
- const RAS_FrameSettings &settings,
- const RAS_Rect &availableViewport,
- RAS_Rect &viewport
- );
-
-
- /**
- * compute a frustum given a valid viewport,
- * RAS_FrameSettings, canvas description
- * and camera description
- */
-
- static
- void
- ComputeOrtho(
- const RAS_FrameSettings &settings,
- const RAS_Rect &availableViewport,
- const RAS_Rect &viewport,
- const float scale,
- const float camnear,
- const float camfar,
- const short sensor_fit,
- const float shift_x,
- const float shift_y,
- RAS_FrameFrustum &frustum
- );
-
- static
- void
- ComputeFrustum(
- const RAS_FrameSettings &settings,
- const RAS_Rect &availableViewport,
- const RAS_Rect &viewport,
- const float lens,
- const float sensor_x, const float sensor_y, const short sensor_fit,
- const float shift_x,
- const float shift_y,
- const float camnear,
- const float camfar,
- RAS_FrameFrustum &frustum
- );
-
- static
- void
- ComputeDefaultFrustum(
- const float camnear,
- const float camfar,
- const float lens,
- const float sensor_x, const float sensor_y,
- const short sensor_fit,
- const float shift_x,
- const float shift_y,
- const float design_aspect_ratio,
- RAS_FrameFrustum & frustum
- );
-
- static
- void
- ComputeDefaultOrtho(
- const float camnear,
- const float camfar,
- const float scale,
- const float design_aspect_ratio,
- const short sensor_fit,
- const float shift_x,
- const float shift_y,
- RAS_FrameFrustum & frustum
- );
-
-private :
-
- static
- void
- ComputeBestFitViewRect(
- const RAS_Rect &availableViewport,
- const float design_aspect_ratio,
- RAS_Rect &viewport
- );
-
-
-
- /**
- * Private constructor - this class is not meant
- * for instantiation.
- */
-
- RAS_FramingManager(
- );
-
- RAS_FramingManager(
- const RAS_FramingManager &
- );
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_FramingManager")
-#endif
-};
-
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.cpp b/source/gameengine/Rasterizer/RAS_ICanvas.cpp
deleted file mode 100644
index 808d257f8f0..00000000000
--- a/source/gameengine/Rasterizer/RAS_ICanvas.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_ICanvas.cpp
- * \ingroup bgerast
- */
-
-#include "RAS_ICanvas.h"
-#include "DNA_scene_types.h"
-
-#include "BKE_image.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-
-#include "BLI_task.h"
-#include "BLI_path_util.h"
-#include "BLI_string.h"
-
-#include "MEM_guardedalloc.h"
-
-extern "C" {
-#include "IMB_imbuf.h"
-#include "IMB_imbuf_types.h"
-}
-
-
-// Task data for saving screenshots in a different thread.
-struct ScreenshotTaskData
-{
- unsigned int *dumprect;
- int dumpsx;
- int dumpsy;
- char *path;
- ImageFormatData *im_format;
-};
-
-/**
- * Function that actually performs the image compression and saving to disk of a screenshot.
- * Run in a separate thread by RAS_ICanvas::save_screenshot().
- *
- * @param taskdata Must point to a ScreenshotTaskData object. This function takes ownership
- * of all pointers in the ScreenshotTaskData, and frees them.
- */
-void save_screenshot_thread_func(TaskPool *__restrict pool, void *taskdata, int threadid);
-
-
-RAS_ICanvas::RAS_ICanvas()
-{
- m_taskscheduler = BLI_task_scheduler_create(TASK_SCHEDULER_AUTO_THREADS);
- m_taskpool = BLI_task_pool_create(m_taskscheduler, NULL);
-}
-
-RAS_ICanvas::~RAS_ICanvas()
-{
- if (m_taskpool) {
- BLI_task_pool_work_and_wait(m_taskpool);
- BLI_task_pool_free(m_taskpool);
- m_taskpool = NULL;
- }
-
- if (m_taskscheduler) {
- BLI_task_scheduler_free(m_taskscheduler);
- m_taskscheduler = NULL;
- }
-}
-
-
-void save_screenshot_thread_func(TaskPool *__restrict UNUSED(pool), void *taskdata, int UNUSED(threadid))
-{
- ScreenshotTaskData *task = static_cast<ScreenshotTaskData *>(taskdata);
-
- /* create and save imbuf */
- ImBuf *ibuf = IMB_allocImBuf(task->dumpsx, task->dumpsy, 24, 0);
- ibuf->rect = task->dumprect;
-
- BKE_imbuf_write_as(ibuf, task->path, task->im_format, false);
-
- ibuf->rect = NULL;
- IMB_freeImBuf(ibuf);
- MEM_freeN(task->dumprect);
- MEM_freeN(task->path);
- MEM_freeN(task->im_format);
-}
-
-
-void RAS_ICanvas::save_screenshot(const char *filename, int dumpsx, int dumpsy, unsigned int *dumprect,
- ImageFormatData * im_format)
-{
- /* create file path */
- char *path = (char *)MEM_mallocN(FILE_MAX, "screenshot-path");
- BLI_strncpy(path, filename, FILE_MAX);
- BLI_path_abs(path, G.main->name);
- BLI_path_frame(path, m_frame, 0);
- m_frame++;
- BKE_image_path_ensure_ext_from_imtype(path, im_format->imtype);
-
- /* Save the actual file in a different thread, so that the
- * game engine can keep running at full speed. */
- ScreenshotTaskData *task = (ScreenshotTaskData *)MEM_mallocN(sizeof(ScreenshotTaskData), "screenshot-data");
- task->dumprect = dumprect;
- task->dumpsx = dumpsx;
- task->dumpsy = dumpsy;
- task->path = path;
- task->im_format = im_format;
-
- BLI_task_pool_push(m_taskpool,
- save_screenshot_thread_func,
- task,
- true, // free task data
- TASK_PRIORITY_LOW);
-}
diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h
deleted file mode 100644
index 91cc13c8f85..00000000000
--- a/source/gameengine/Rasterizer/RAS_ICanvas.h
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_ICanvas.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_ICANVAS_H__
-#define __RAS_ICANVAS_H__
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class RAS_Rect;
-struct TaskScheduler;
-struct TaskPool;
-struct ImageFormatData;
-
-/**
- * 2D rendering device context. The connection from 3d rendercontext to 2d surface.
- */
-class RAS_ICanvas
-{
-public:
- enum BufferType {
- COLOR_BUFFER=1,
- DEPTH_BUFFER=2
- };
-
- enum RAS_MouseState
- {
- MOUSE_INVISIBLE=1,
- MOUSE_WAIT,
- MOUSE_NORMAL
- };
-
- RAS_ICanvas();
- virtual ~RAS_ICanvas();
-
- virtual
- void
- Init(
- ) = 0;
-
- virtual
- void
- BeginFrame(
- )=0;
-
- virtual
- void
- EndFrame(
- )=0;
-
- /**
- * Initializes the canvas for drawing. Drawing to the canvas is
- * only allowed between BeginDraw() and EndDraw().
- *
- * \retval false Acquiring the canvas failed.
- * \retval true Acquiring the canvas succeeded.
- *
- */
-
- virtual
- bool
- BeginDraw(
- )=0;
-
- /**
- * Unitializes the canvas for drawing.
- */
-
- virtual
- void
- EndDraw(
- )=0;
-
-
- /// probably needs some arguments for PS2 in future
- virtual
- void
- SwapBuffers(
- )=0;
-
- virtual
- void
- SetSwapInterval(
- int interval
- )=0;
-
- virtual
- bool
- GetSwapInterval(
- int& intervalOut
- )=0;
-
- virtual
- void
- ClearBuffer(
- int type
- )=0;
-
- virtual
- void
- ClearColor(
- float r,
- float g,
- float b,
- float a
- )=0;
-
- virtual
- int
- GetWidth(
- ) const = 0;
-
- virtual
- int
- GetHeight(
- ) const = 0;
-
- virtual
- int
- GetMouseX(int x
- )=0;
-
- virtual
- int
- GetMouseY(int y
- )= 0;
-
- virtual
- float
- GetMouseNormalizedX(int x
- )=0;
-
- virtual
- float
- GetMouseNormalizedY(int y
- )= 0;
-
- virtual
- const RAS_Rect &
- GetDisplayArea(
- ) const = 0;
-
- virtual
- void
- SetDisplayArea(RAS_Rect *rect
- ) = 0;
-
- /**
- * Used to get canvas area within blender.
- */
- virtual
- RAS_Rect &
- GetWindowArea(
- ) = 0;
-
- /**
- * Set the visible view-port
- */
-
- virtual
- void
- SetViewPort(
- int x1, int y1,
- int x2, int y2
- ) = 0;
-
- /**
- * Update the Canvas' viewport (used when the viewport changes without using SetViewPort()
- * eg: Shadow buffers and FBOs
- */
-
- virtual
- void
- UpdateViewPort(
- int x1, int y1,
- int x2, int y2
- ) = 0;
-
- /**
- * Get the visible viewport
- */
- virtual
- const int*
- GetViewPort() = 0;
-
- virtual
- void
- SetMouseState(
- RAS_MouseState mousestate
- )=0;
-
- virtual
- void
- SetMousePosition(
- int x,
- int y
- )=0;
-
- virtual
- RAS_MouseState
- GetMouseState()
- {
- return m_mousestate;
- }
-
- virtual
- void
- MakeScreenShot(
- const char* filename
- )=0;
-
- virtual void GetDisplayDimensions(int &width, int &height) = 0;
-
- virtual
- void
- ResizeWindow(
- int width,
- int height
- )=0;
-
- virtual
- void
- SetFullScreen(
- bool enable
- )=0;
-
- virtual
- bool
- GetFullScreen()=0;
-
-
-
-protected:
- RAS_MouseState m_mousestate;
- int m_frame; /// frame number for screenshots.
- TaskScheduler *m_taskscheduler;
- TaskPool *m_taskpool;
-
- /**
- * Saves screenshot data to a file. The actual compression and disk I/O is performed in
- * a separate thread.
- *
- * @param filename name of the file, can contain "###" for sequential numbering. A copy of the string
- * is made, so the pointer can be freed by the caller.
- * @param dumpsx width in pixels.
- * @param dumpsy height in pixels.
- * @param dumprect pixel data; ownership is passed to this function, which also frees the data.
- * @param im_format image format for the file; ownership is passed to this function, which also frees the data.
- */
- void save_screenshot(const char *filename, int dumpsx, int dumpsy, unsigned int *dumprect,
- ImageFormatData * im_format);
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_ICanvas")
-#endif
-};
-
-#endif /* __RAS_ICANVAS_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_ILightObject.h b/source/gameengine/Rasterizer/RAS_ILightObject.h
deleted file mode 100644
index a3d55c925d6..00000000000
--- a/source/gameengine/Rasterizer/RAS_ILightObject.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Mitchell Stokes
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_ILightObject.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_LIGHTOBJECT_H__
-#define __RAS_LIGHTOBJECT_H__
-
-class RAS_ICanvas;
-
-class KX_Camera;
-class KX_Scene;
-
-class MT_Transform;
-class MT_Matrix4x4;
-
-struct Image;
-
-class RAS_ILightObject
-{
-public:
- enum LightType {
- LIGHT_SPOT,
- LIGHT_SUN,
- LIGHT_NORMAL
- };
- bool m_modified;
- int m_layer;
- void *m_scene;
- void *m_light;
-
- float m_energy;
- float m_distance;
- float m_shadowclipstart;
- float m_shadowfrustumsize;
- float m_shadowclipend;
- float m_shadowbias;
- float m_shadowbleedbias;
- short m_shadowmaptype;
- float m_shadowcolor[3];
-
- float m_color[3];
-
- float m_att1;
- float m_att2;
- float m_coeff_const, m_coeff_lin, m_coeff_quad;
- float m_spotsize;
- float m_spotblend;
-
- LightType m_type;
-
- bool m_nodiffuse;
- bool m_nospecular;
- bool m_glsl;
-
- virtual ~RAS_ILightObject() {}
- virtual RAS_ILightObject* Clone() = 0;
-
- virtual bool HasShadowBuffer() = 0;
- virtual int GetShadowBindCode() = 0;
- virtual MT_Matrix4x4 GetShadowMatrix() = 0;
- virtual int GetShadowLayer() = 0;
- virtual void BindShadowBuffer(RAS_ICanvas *canvas, KX_Camera *cam, MT_Transform& camtrans) = 0;
- virtual void UnbindShadowBuffer() = 0;
- virtual Image *GetTextureImage(short texslot) = 0;
- virtual void Update() = 0;
-};
-
-#endif /* __RAS_LIGHTOBJECT_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_IOffScreen.h b/source/gameengine/Rasterizer/RAS_IOffScreen.h
deleted file mode 100644
index d61a31504b8..00000000000
--- a/source/gameengine/Rasterizer/RAS_IOffScreen.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_IOffScreen.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_OFFSCREEN_H__
-#define __RAS_OFFSCREEN_H__
-
-#include "EXP_Python.h"
-
-class RAS_ICanvas;
-
-class MT_Transform;
-
-struct Image;
-
-class RAS_IOffScreen
-{
-public:
- enum RAS_OFS_BIND_MODE {
- RAS_OFS_BIND_RENDER = 0,
- RAS_OFS_BIND_READ,
- };
- enum RAS_OFS_RENDER_TARGET {
- RAS_OFS_RENDER_BUFFER = 0, // use render buffer as render target
- RAS_OFS_RENDER_TEXTURE, // use texture as render target
- };
-
- int m_width;
- int m_height;
- int m_samples;
- int m_color; // if used, holds the texture object, 0 if not used
-
- virtual ~RAS_IOffScreen() {}
-
- virtual bool Create(int width, int height, int samples, RAS_OFS_RENDER_TARGET target) = 0;
- virtual void Destroy() = 0;
- virtual void Bind(RAS_OFS_BIND_MODE mode) = 0;
- virtual void Blit() = 0;
- virtual void Unbind() = 0;
- virtual void MipMap() = 0;
-
- virtual int GetWidth() { return m_width; }
- virtual int GetHeight() { return m_height; }
- virtual int GetSamples() { return m_samples; }
- virtual int GetColor() { return m_color; }
-};
-
-#ifdef WITH_PYTHON
-typedef struct {
- PyObject_HEAD
- RAS_IOffScreen *ofs;
-} PyRASOffScreen;
-
-extern PyTypeObject PyRASOffScreen_Type;
-#endif
-
-#endif /* __RAS_OFFSCREEN_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
deleted file mode 100644
index 1d22d2debf9..00000000000
--- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
- * \ingroup bgerast
- */
-
-
-#include "RAS_IPolygonMaterial.h"
-#include "RAS_IRasterizer.h"
-
-#include "DNA_material_types.h"
-
-void RAS_IPolyMaterial::Initialize(
- const STR_String& texname,
- const STR_String& matname,
- int materialindex,
- int tile,
- int tilexrep,
- int tileyrep,
- int alphablend,
- bool alpha,
- bool zsort,
- bool light,
- bool image,
- struct GameSettings* game)
-{
- m_texturename = texname;
- m_materialname = matname;
- m_materialindex = materialindex;
- m_tile = tile;
- m_tilexrep = tilexrep;
- m_tileyrep = tileyrep;
- m_alphablend = alphablend;
- m_alpha = alpha;
- m_zsort = zsort;
- m_light = light;
- m_polymatid = m_newpolymatid++;
- m_flag = 0;
- m_multimode = 0;
- m_shininess = 35.0f;
- m_specular.setValue(0.5f,0.5f,0.5f);
- m_specularity = 1.0f;
- m_diffuse.setValue(0.5f,0.5f,0.5f);
- m_drawingmode = ConvertFaceMode(game, image);
-}
-
-RAS_IPolyMaterial::RAS_IPolyMaterial()
- : m_texturename("__Dummy_Texture_Name__"),
- m_materialname("__Dummy_Material_Name__"),
- m_tile(0),
- m_tilexrep(0),
- m_tileyrep(0),
- m_drawingmode (0),
- m_alphablend(0),
- m_alpha(false),
- m_zsort(false),
- m_light(false),
- m_materialindex(0),
- m_polymatid(0),
- m_flag(0),
- m_multimode(0)
-{
- m_shininess = 35.0f;
- m_specular = MT_Vector3(0.5f,0.5f,0.5f);
- m_specularity = 1.0f;
- m_diffuse = MT_Vector3(0.5f,0.5f,0.5f);
-}
-
-RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname,
- const STR_String& matname,
- int materialindex,
- int tile,
- int tilexrep,
- int tileyrep,
- int alphablend,
- bool alpha,
- bool zsort)
- : m_texturename(texname),
- m_materialname(matname),
- m_tile(tile),
- m_tilexrep(tilexrep),
- m_tileyrep(tileyrep),
- m_alphablend(alphablend),
- m_alpha(alpha),
- m_zsort(zsort),
- m_materialindex(materialindex),
- m_polymatid(m_newpolymatid++),
- m_flag(0),
- m_multimode(0)
-{
- m_shininess = 35.0f;
- m_specular = MT_Vector3(0.5f,0.5f,0.5f);
- m_specularity = 1.0f;
- m_diffuse = MT_Vector3(0.5f,0.5f,0.5f);
-}
-
-
-bool RAS_IPolyMaterial::Equals(const RAS_IPolyMaterial& lhs) const
-{
- if (m_flag &RAS_BLENDERMAT)
- {
- bool test = (
- this->m_multimode == lhs.m_multimode &&
- this->m_flag == lhs.m_flag &&
- this->m_drawingmode == lhs.m_drawingmode &&
- this->m_alphablend == lhs.m_alphablend &&
- this->m_texturename.hash() == lhs.m_texturename.hash() &&
- this->m_materialname.hash() == lhs.m_materialname.hash()
- );
-
- return test;
- }
- else
- {
- return (
- this->m_tile == lhs.m_tile &&
- this->m_tilexrep == lhs.m_tilexrep &&
- this->m_tileyrep == lhs.m_tileyrep &&
- this->m_alphablend == lhs.m_alphablend &&
- this->m_alpha == lhs.m_alpha &&
- this->m_zsort == lhs.m_zsort &&
- this->m_light == lhs.m_light &&
- this->m_drawingmode == lhs.m_drawingmode &&
- this->m_texturename.hash() == lhs.m_texturename.hash() &&
- this->m_materialname.hash() == lhs.m_materialname.hash()
- );
- }
-}
-
-int RAS_IPolyMaterial::ConvertFaceMode(struct GameSettings *game, bool image) const
-{
- if (!game) return (image?GEMAT_TEX:0);
-
- int modefinal = 0;
-
- int orimode = game->face_orientation;
- int alpha_blend = game->alpha_blend;
- int flags = game->flag & (GEMAT_TEXT | GEMAT_BACKCULL);
-
- modefinal = orimode | alpha_blend | flags;
- modefinal |= (image ? GEMAT_TEX : 0);
-
- return modefinal;
-}
-
-void RAS_IPolyMaterial::GetMaterialRGBAColor(unsigned char *rgba) const
-{
- *rgba++ = 0xFF;
- *rgba++ = 0xFF;
- *rgba++ = 0xFF;
- *rgba++ = 0xFF;
-}
-
-bool RAS_IPolyMaterial::Less(const RAS_IPolyMaterial& rhs) const
-{
- if (Equals(rhs))
- return false;
-
- return m_polymatid < rhs.m_polymatid;
-}
-
-bool RAS_IPolyMaterial::IsAlpha() const
-{
- return m_alpha || m_zsort;
-}
-
-bool RAS_IPolyMaterial::IsZSort() const
-{
- return m_zsort;
-}
-
-unsigned int RAS_IPolyMaterial::hash() const
-{
- return m_texturename.hash();
-}
-
-int RAS_IPolyMaterial::GetDrawingMode() const
-{
- return m_drawingmode;
-}
-
-const STR_String& RAS_IPolyMaterial::GetMaterialName() const
-{
- return m_materialname;
-}
-
-dword RAS_IPolyMaterial::GetMaterialNameHash() const
-{
- return m_materialname.hash();
-}
-
-const STR_String& RAS_IPolyMaterial::GetTextureName() const
-{
- return m_texturename;
-}
-
-int RAS_IPolyMaterial::GetMaterialIndex() const
-{
- return m_materialindex;
-}
-
-Material *RAS_IPolyMaterial::GetBlenderMaterial() const
-{
- return NULL;
-}
-
-Image *RAS_IPolyMaterial::GetBlenderImage() const
-{
- return NULL;
-}
-
-unsigned int *RAS_IPolyMaterial::GetMCol() const
-{
- return NULL;
-}
-
-Scene* RAS_IPolyMaterial::GetBlenderScene() const
-{
- return NULL;
-}
-
-void RAS_IPolyMaterial::ReleaseMaterial()
-{
-}
-
-unsigned int RAS_IPolyMaterial::GetFlag() const
-{
- return m_flag;
-}
-
-bool RAS_IPolyMaterial::UsesLighting(RAS_IRasterizer *rasty) const
-{
- bool dolights = false;
-
- if (m_flag & RAS_BLENDERMAT) {
- dolights = (m_flag & RAS_MULTILIGHT) != 0;
- }
- else if (rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID) {
- /* pass */
- }
- else if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW) {
- /* pass */
- }
- else {
- dolights = m_light;
- }
-
- return dolights;
-}
-
-bool RAS_IPolyMaterial::CastsShadows() const
-{
- return (m_flag & RAS_CASTSHADOW) != 0;
-}
-
-bool RAS_IPolyMaterial::OnlyShadow() const
-{
- return (m_flag & RAS_ONLYSHADOW) != 0;
-}
-
-bool RAS_IPolyMaterial::UsesObjectColor() const
-{
- return !(m_flag & RAS_BLENDERGLSL);
-}
-
-unsigned int RAS_IPolyMaterial::m_newpolymatid = 0;
-
diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
deleted file mode 100644
index 7023d305510..00000000000
--- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_IPolygonMaterial.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_IPOLYGONMATERIAL_H__
-#define __RAS_IPOLYGONMATERIAL_H__
-
-#include "STR_HashedString.h"
-
-#include "MT_Vector3.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class RAS_IRasterizer;
-struct Material;
-struct Image;
-struct Scene;
-class SCA_IScene;
-struct GameSettings;
-
-enum MaterialProps
-{
- RAS_ZSORT =1,
- RAS_TRANSPARENT =2,
- RAS_TRIANGLE =4,
- RAS_MULTITEX =8,
- RAS_MULTILIGHT =16,
- RAS_BLENDERMAT =32,
- RAS_GLSHADER =64,
- RAS_AUTOGEN =128,
- RAS_NORMAL =256,
- RAS_DEFMULTI =512,
- RAS_BLENDERGLSL =1024,
- RAS_CASTSHADOW =2048,
- RAS_ONLYSHADOW =4096,
-};
-
-/**
- * Polygon Material on which the material buckets are sorted
- *
- */
-class RAS_IPolyMaterial
-{
- //todo: remove these variables from this interface/protocol class
-protected:
- STR_HashedString m_texturename;
- STR_HashedString m_materialname; //also needed for touchsensor
- int m_tile;
- int m_tilexrep,m_tileyrep;
- int m_drawingmode;
- int m_alphablend;
- bool m_alpha;
- bool m_zsort;
- bool m_light;
- int m_materialindex;
-
- unsigned int m_polymatid;
- static unsigned int m_newpolymatid;
-
- // will move...
- unsigned int m_flag;//MaterialProps
- int m_multimode; // sum of values
-public:
- MT_Vector3 m_diffuse;
- float m_shininess;
- MT_Vector3 m_specular;
- float m_specularity;
-
- /** Used to store caching information for materials. */
- typedef void* TCachingInfo;
-
- // care! these are taken from blender polygonflags, see file DNA_mesh_types.h for #define TF_BILLBOARD etc.
- enum MaterialFlags
- {
- BILLBOARD_SCREENALIGNED = 512, /* GEMAT_HALO */
- BILLBOARD_AXISALIGNED = 1024, /* GEMAT_BILLBOARD */
- SHADOW =2048 /* GEMAT_SHADOW */
- };
-
- RAS_IPolyMaterial();
- RAS_IPolyMaterial(const STR_String& texname,
- const STR_String& matname,
- int materialindex,
- int tile,
- int tilexrep,
- int tileyrep,
- int transp,
- bool alpha,
- bool zsort);
- void Initialize(const STR_String& texname,
- const STR_String& matname,
- int materialindex,
- int tile,
- int tilexrep,
- int tileyrep,
- int transp,
- bool alpha,
- bool zsort,
- bool light,
- bool image,
- struct GameSettings* game);
-
- virtual ~RAS_IPolyMaterial() {}
-
- /**
- * Returns the caching information for this material,
- * This can be used to speed up the rasterizing process.
- * \return The caching information.
- */
- virtual TCachingInfo GetCachingInfo(void) const { return 0; }
-
- /**
- * Activates the material in the rasterizer.
- * On entry, the cachingInfo contains info about the last activated material.
- * On exit, the cachingInfo should contain updated info about this material.
- * \param rasty The rasterizer in which the material should be active.
- * \param cachingInfo The information about the material used to speed up rasterizing.
- */
- virtual bool Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const
- {
- return false;
- }
- virtual void ActivateMeshSlot(const class RAS_MeshSlot & ms, RAS_IRasterizer* rasty) const {}
-
- virtual bool Equals(const RAS_IPolyMaterial& lhs) const;
- bool Less(const RAS_IPolyMaterial& rhs) const;
- //int GetLightLayer() const;
- bool IsAlpha() const;
- bool IsZSort() const;
- unsigned int hash() const;
- int GetDrawingMode() const;
- const STR_String& GetMaterialName() const;
- dword GetMaterialNameHash() const;
- const STR_String& GetTextureName() const;
- unsigned int GetFlag() const;
- int GetMaterialIndex() const;
-
- virtual Material* GetBlenderMaterial() const;
- virtual Image* GetBlenderImage() const;
- virtual unsigned int* GetMCol() const;
- virtual Scene* GetBlenderScene() const;
- virtual void ReleaseMaterial();
- virtual void GetMaterialRGBAColor(unsigned char *rgba) const;
- virtual bool UsesLighting(RAS_IRasterizer *rasty) const;
- virtual bool UsesObjectColor() const;
- virtual bool CastsShadows() const;
- virtual bool OnlyShadow() const;
-
- virtual void Replace_IScene(SCA_IScene *val) {} /* overridden by KX_BlenderMaterial */
-
- /**
- * \return the equivalent drawing mode for the material settings (equivalent to old TexFace tface->mode).
- */
- int ConvertFaceMode(struct GameSettings *game, bool image) const;
-
- /*
- * PreCalculate texture gen
- */
- virtual void OnConstruction() {}
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IPolyMaterial")
-#endif
-};
-
-inline bool operator ==( const RAS_IPolyMaterial & rhs,const RAS_IPolyMaterial & lhs)
-{
- return ( rhs.Equals(lhs));
-}
-
-inline bool operator < ( const RAS_IPolyMaterial & lhs, const RAS_IPolyMaterial & rhs)
-{
- return lhs.Less(rhs);
-}
-
-#endif /* __RAS_IPOLYGONMATERIAL_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h
deleted file mode 100644
index dc92408915b..00000000000
--- a/source/gameengine/Rasterizer/RAS_IRasterizer.h
+++ /dev/null
@@ -1,506 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_IRasterizer.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_IRASTERIZER_H__
-#define __RAS_IRASTERIZER_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include "STR_HashedString.h"
-
-#include "MT_CmMatrix4x4.h"
-#include "MT_Matrix4x4.h"
-
-#include "RAS_TexVert.h"
-
-#include <vector>
-using namespace std;
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class RAS_ICanvas;
-class RAS_IPolyMaterial;
-class RAS_MeshSlot;
-class RAS_ILightObject;
-class SCA_IScene;
-class RAS_IOffScreen;
-class RAS_ISync;
-
-typedef vector<unsigned short> KX_IndexArray;
-typedef vector<RAS_TexVert> KX_VertexArray;
-typedef vector<KX_VertexArray *> vecVertexArray;
-typedef vector<KX_IndexArray *> vecIndexArrays;
-
-/**
- * 3D rendering device context interface.
- */
-class RAS_IRasterizer
-{
-public:
- enum RAS_TEXT_RENDER_MODE {
- RAS_TEXT_RENDER_NODEF = 0,
- RAS_TEXT_NORMAL,
- RAS_TEXT_PADDED,
- RAS_TEXT_MAX,
- };
-
- RAS_IRasterizer(RAS_ICanvas* canv) {};
- virtual ~RAS_IRasterizer() {};
-
- /**
- * Drawing types
- */
- enum DrawType {
- KX_BOUNDINGBOX = 1,
- KX_WIREFRAME,
- KX_SOLID,
- KX_SHADED,
- KX_TEXTURED,
- KX_SHADOW,
- };
-
- /**
- * Drawing modes
- */
-
- enum DrawMode {
- KX_MODE_LINES = 1,
- KX_MODE_TRIANGLES,
- KX_MODE_QUADS,
- };
-
- /**
- * Valid SetDepthMask parameters
- */
- enum DepthMask {
- KX_DEPTHMASK_ENABLED = 1,
- KX_DEPTHMASK_DISABLED,
- };
-
- /**
- */
- enum {
- RAS_RENDER_3DPOLYGON_TEXT = 64, /* GEMAT_TEXT */
- KX_BACKCULL = 16, /* GEMAT_BACKCULL */
- KX_TEX = 4096, /* GEMAT_TEX */
- KX_LINES = 32768,
- };
-
- /**
- * Stereo mode types
- */
- enum StereoMode {
- RAS_STEREO_NOSTEREO = 1,
- RAS_STEREO_QUADBUFFERED,
- RAS_STEREO_ABOVEBELOW,
- RAS_STEREO_INTERLACED,
- RAS_STEREO_ANAGLYPH,
- RAS_STEREO_SIDEBYSIDE,
- RAS_STEREO_VINTERLACE,
- RAS_STEREO_DOME,
- RAS_STEREO_3DTVTOPBOTTOM,
-
- RAS_STEREO_MAXSTEREO
- };
-
- /**
- * Texture gen modes.
- */
- enum TexCoGen {
- RAS_TEXCO_GEN, /* < GPU will generate texture coordinates */
- RAS_TEXCO_ORCO, /* < Vertex coordinates (object space) */
- RAS_TEXCO_GLOB, /* < Vertex coordinates (world space) */
- RAS_TEXCO_UV, /* < UV coordinates */
- RAS_TEXCO_OBJECT, /* < Use another object's position as coordinates */
- RAS_TEXCO_LAVECTOR, /* < Light vector as coordinates */
- RAS_TEXCO_VIEW, /* < View vector as coordinates */
- RAS_TEXCO_STICKY, /* < Sticky coordinates */
- RAS_TEXCO_WINDOW, /* < Window coordinates */
- RAS_TEXCO_NORM, /* < Normal coordinates */
- RAS_TEXTANGENT, /* < */
- RAS_TEXCO_VCOL, /* < Vertex Color */
- RAS_TEXCO_DISABLE, /* < Disable this texture unit (cached) */
- };
-
- /**
- * Render pass identifiers for stereo.
- */
- enum StereoEye {
- RAS_STEREO_LEFTEYE = 1,
- RAS_STEREO_RIGHTEYE,
- };
-
- /**
- * Mipmap options
- */
- enum MipmapOption {
- RAS_MIPMAP_NONE,
- RAS_MIPMAP_NEAREST,
- RAS_MIPMAP_LINEAR,
-
- RAS_MIPMAP_MAX, /* Should always be last */
- };
-
- /**
- * SetDepthMask enables or disables writing a fragment's depth value
- * to the Z buffer.
- */
- virtual void SetDepthMask(DepthMask depthmask) = 0;
-
- /**
- * SetMaterial sets the material settings for subsequent primitives
- * to be rendered with.
- * The material will be cached.
- */
- virtual bool SetMaterial(const RAS_IPolyMaterial &mat) = 0;
-
- /**
- * Init initializes the renderer.
- */
- virtual bool Init() = 0;
-
- /**
- * Exit cleans up the renderer.
- */
- virtual void Exit() = 0;
-
- /**
- * BeginFrame is called at the start of each frame.
- */
- virtual bool BeginFrame(double time) = 0;
-
- /**
- * ClearColorBuffer clears the color buffer.
- */
- virtual void ClearColorBuffer() = 0;
-
- /**
- * ClearDepthBuffer clears the depth buffer.
- */
- virtual void ClearDepthBuffer() = 0;
-
- /**
- * ClearCachingInfo clears the currently cached material.
- */
- virtual void ClearCachingInfo(void) = 0;
-
- /**
- * EndFrame is called at the end of each frame.
- */
- virtual void EndFrame() = 0;
-
- /**
- * SetRenderArea sets the render area from the 2d canvas.
- * Returns true if only of subset of the canvas is used.
- */
- virtual void SetRenderArea() = 0;
-
- // Stereo Functions
- /**
- * SetStereoMode will set the stereo mode
- */
- virtual void SetStereoMode(const StereoMode stereomode) = 0;
-
- /**
- * Stereo can be used to query if the rasterizer is in stereo mode.
- * \return true if stereo mode is enabled.
- */
- virtual bool Stereo() = 0;
- virtual StereoMode GetStereoMode() = 0;
- virtual bool InterlacedStereo() = 0;
-
- /**
- * Sets which eye buffer subsequent primitives will be rendered to.
- */
- virtual void SetEye(const StereoEye eye) = 0;
- virtual StereoEye GetEye() = 0;
-
- /**
- * Sets the distance between eyes for stereo mode.
- */
- virtual void SetEyeSeparation(const float eyeseparation) = 0;
- virtual float GetEyeSeparation() = 0;
-
- /**
- * Sets the focal length for stereo mode.
- */
- virtual void SetFocalLength(const float focallength) = 0;
- virtual float GetFocalLength() = 0;
-
- /**
- * Create an offscreen render buffer that can be used as target for render.
- * For the time being, it is only used in VideoTexture for custom render.
- */
- virtual RAS_IOffScreen *CreateOffScreen(int width, int height, int samples, int target) = 0;
-
- /**
- * Create a sync object
- * For use with offscreen render
- */
- virtual RAS_ISync *CreateSync(int type) = 0;
-
- /**
- * SwapBuffers swaps the back buffer with the front buffer.
- */
- virtual void SwapBuffers() = 0;
-
- // Drawing Functions
- /**
- * IndexPrimitives: Renders primitives from mesh slot.
- */
- virtual void IndexPrimitives(class RAS_MeshSlot &ms) = 0;
-
- /**
- * IndexPrimitives_3DText will render text into the polygons.
- */
- virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat) = 0;
-
- virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat) = 0;
-
- /* This one should become our final version, methinks. */
- /**
- * Set the projection matrix for the rasterizer. This projects
- * from camera coordinates to window coordinates.
- * \param mat The projection matrix.
- */
- virtual void SetProjectionMatrix(const MT_Matrix4x4 &mat) = 0;
-
- /**
- * Sets the modelview matrix.
- */
- virtual void SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Matrix3x3 &ori,
- const MT_Point3 &pos, const MT_Vector3 &scale, bool perspective) = 0;
-
- /**
- */
- virtual const MT_Point3& GetCameraPosition() = 0;
- virtual bool GetCameraOrtho() = 0;
-
- /**
- * Fog
- */
- virtual void SetFog(short type, float start, float dist, float intensity, float color[3]) = 0;
- virtual void DisplayFog() = 0;
- virtual void EnableFog(bool enable) = 0;
-
- virtual void SetBackColor(float color[3]) = 0;
-
- /**
- * \param drawingmode = KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED.
- */
- virtual void SetDrawingMode(int drawingmode) = 0;
-
- /**
- * \return the current drawing mode: KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED.
- */
- virtual int GetDrawingMode() = 0;
-
- /**
- * Sets face culling
- */
- virtual void SetCullFace(bool enable) = 0;
-
- /**
- * Sets wireframe mode.
- */
- virtual void SetLines(bool enable) = 0;
-
- /**
- */
- virtual double GetTime() = 0;
-
- /**
- * Generates a projection matrix from the specified frustum.
- * \param left the left clipping plane
- * \param right the right clipping plane
- * \param bottom the bottom clipping plane
- * \param top the top clipping plane
- * \param frustnear the near clipping plane
- * \param frustfar the far clipping plane
- * \return a 4x4 matrix representing the projection transform.
- */
- virtual MT_Matrix4x4 GetFrustumMatrix(
- float left, float right, float bottom, float top,
- float frustnear, float frustfar,
- float focallength = 0.0f, bool perspective = true) = 0;
-
- /**
- * Generates a orthographic projection matrix from the specified frustum.
- * \param left the left clipping plane
- * \param right the right clipping plane
- * \param bottom the bottom clipping plane
- * \param top the top clipping plane
- * \param frustnear the near clipping plane
- * \param frustfar the far clipping plane
- * \return a 4x4 matrix representing the projection transform.
- */
- virtual MT_Matrix4x4 GetOrthoMatrix(
- float left, float right, float bottom, float top,
- float frustnear, float frustfar) = 0;
-
- /**
- * Sets the specular color component of the lighting equation.
- */
- virtual void SetSpecularity(float specX, float specY, float specZ, float specval) = 0;
-
- /**
- * Sets the specular exponent component of the lighting equation.
- */
- virtual void SetShinyness(float shiny) = 0;
-
- /**
- * Sets the diffuse color component of the lighting equation.
- */
- virtual void SetDiffuse(float difX,float difY, float difZ, float diffuse) = 0;
-
- /**
- * Sets the emissive color component of the lighting equation.
- */
- virtual void SetEmissive(float eX, float eY, float eZ, float e) = 0;
-
- virtual void SetAmbientColor(float color[3]) = 0;
- virtual void SetAmbient(float factor) = 0;
-
- /**
- * Sets a polygon offset. z depth will be: z1 = mult*z0 + add
- */
- virtual void SetPolygonOffset(float mult, float add) = 0;
-
- virtual void DrawDebugLine(SCA_IScene *scene, const MT_Vector3 &from, const MT_Vector3 &to, const MT_Vector3& color) = 0;
- virtual void DrawDebugCircle(SCA_IScene *scene, const MT_Vector3 &center, const MT_Scalar radius,
- const MT_Vector3 &color, const MT_Vector3 &normal, int nsector) = 0;
- virtual void FlushDebugShapes(SCA_IScene *scene) = 0;
-
- virtual void SetTexCoordNum(int num) = 0;
- virtual void SetAttribNum(int num) = 0;
- virtual void SetTexCoord(TexCoGen coords, int unit) = 0;
- virtual void SetAttrib(TexCoGen coords, int unit, int layer = 0) = 0;
-
- virtual const MT_Matrix4x4 &GetViewMatrix() const = 0;
- virtual const MT_Matrix4x4 &GetViewInvMatrix() const = 0;
-
- virtual bool QueryLists() { return false; }
- virtual bool QueryArrays() { return false; }
-
- virtual void EnableMotionBlur(float motionblurvalue) = 0;
- virtual void DisableMotionBlur() = 0;
-
- virtual float GetMotionBlurValue() = 0;
- virtual int GetMotionBlurState() = 0;
- virtual void SetMotionBlurState(int newstate) = 0;
-
- virtual void SetAlphaBlend(int alphablend) = 0;
- virtual void SetFrontFace(bool ccw) = 0;
-
- virtual void SetAnisotropicFiltering(short level) = 0;
- virtual short GetAnisotropicFiltering() = 0;
-
- virtual void SetMipmapping(MipmapOption val) = 0;
- virtual MipmapOption GetMipmapping() = 0;
-
- virtual void SetUsingOverrideShader(bool val) = 0;
- virtual bool GetUsingOverrideShader() = 0;
-
- /**
- * Render Tools
- */
- virtual void applyTransform(float *oglmatrix, int drawingmode) = 0;
-
- /**
- * Renders 2D boxes.
- * \param xco Position on the screen (origin in lower left corner).
- * \param yco Position on the screen (origin in lower left corner).
- * \param width Width of the canvas to draw to.
- * \param height Height of the canvas to draw to.
- * \param percentage Percentage of bar.
- */
- virtual void RenderBox2D(int xco, int yco, int width, int height, float percentage) = 0;
-
- /**
- * Renders 3D text string using BFL.
- * \param fontid The id of the font.
- * \param text The string to render.
- * \param size The size of the text.
- * \param dpi The resolution of the text.
- * \param color The color of the object.
- * \param mat The Matrix of the text object.
- * \param aspect A scaling factor to compensate for the size.
- */
- virtual void RenderText3D(
- int fontid, const char *text, int size, int dpi,
- const float color[4], const float mat[16], float aspect) = 0;
-
- /**
- * Renders 2D text string.
- * \param mode The type of text
- * \param text The string to render.
- * \param xco Position on the screen (origin in lower left corner).
- * \param yco Position on the screen (origin in lower left corner).
- * \param width Width of the canvas to draw to.
- * \param height Height of the canvas to draw to.
- */
- virtual void RenderText2D(
- RAS_TEXT_RENDER_MODE mode, const char *text,
- int xco, int yco, int width, int height) = 0;
-
- virtual void ProcessLighting(bool uselights, const MT_Transform &trans) = 0;
-
- virtual void PushMatrix() = 0;
-
- virtual void PopMatrix() = 0;
-
- virtual RAS_ILightObject *CreateLight() = 0;
-
- virtual void AddLight(RAS_ILightObject *lightobject) = 0;
-
- virtual void RemoveLight(RAS_ILightObject *lightobject) = 0;
-
- virtual void MotionBlur() = 0;
-
- virtual void SetClientObject(void *obj) = 0;
-
- virtual void SetAuxilaryClientInfo(void *inf) = 0;
-
- /**
- * Prints information about what the hardware supports.
- */
- virtual void PrintHardwareInfo() = 0;
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IRasterizer")
-#endif
-};
-
-#endif /* __RAS_IRASTERIZER_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_ISync.h b/source/gameengine/Rasterizer/RAS_ISync.h
deleted file mode 100644
index 7e34172c2a3..00000000000
--- a/source/gameengine/Rasterizer/RAS_ISync.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_ISync.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_ISYNC_H__
-#define __RAS_ISYNC_H__
-
-class RAS_ISync
-{
-public:
- enum RAS_SYNC_TYPE {
- RAS_SYNC_TYPE_FENCE = 0,
- };
- virtual ~RAS_ISync() {}
-
- virtual bool Create(RAS_SYNC_TYPE type) = 0;
- virtual void Destroy() = 0;
- virtual void Wait() = 0;
-};
-
-#endif /* __RAS_ISYNC_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
deleted file mode 100644
index 9cd8f77adfd..00000000000
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
+++ /dev/null
@@ -1,679 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_MaterialBucket.cpp
- * \ingroup bgerast
- */
-
-
-#include "RAS_MaterialBucket.h"
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#ifdef WIN32
-#include <windows.h>
-#endif // WIN32
-
-#include "RAS_IPolygonMaterial.h"
-#include "RAS_TexVert.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_MeshObject.h"
-#include "RAS_Deformer.h" // __NLA
-
-/* mesh slot */
-
-RAS_MeshSlot::RAS_MeshSlot() : SG_QList()
-{
- m_clientObj = NULL;
- m_pDeformer = NULL;
- m_OpenGLMatrix = NULL;
- m_mesh = NULL;
- m_bucket = NULL;
- m_bVisible = false;
- m_bCulled = true;
- m_bObjectColor = false;
- m_RGBAcolor = MT_Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- m_DisplayList = NULL;
- m_bDisplayList = true;
- m_joinSlot = NULL;
- m_pDerivedMesh = NULL;
-}
-
-RAS_MeshSlot::~RAS_MeshSlot()
-{
- RAS_DisplayArrayList::iterator it;
-
-#ifdef USE_SPLIT
- Split(true);
-
- while (m_joinedSlots.size())
- m_joinedSlots.front()->Split(true);
-#endif
-
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- (*it)->m_users--;
- if ((*it)->m_users == 0)
- delete *it;
- }
-
- if (m_DisplayList) {
- m_DisplayList->Release();
- m_DisplayList = NULL;
- }
-}
-
-RAS_MeshSlot::RAS_MeshSlot(const RAS_MeshSlot& slot) : SG_QList()
-{
- RAS_DisplayArrayList::iterator it;
-
- m_clientObj = NULL;
- m_pDeformer = NULL;
- m_pDerivedMesh = NULL;
- m_OpenGLMatrix = NULL;
- m_mesh = slot.m_mesh;
- m_bucket = slot.m_bucket;
- m_bVisible = slot.m_bVisible;
- m_bCulled = slot.m_bCulled;
- m_bObjectColor = slot.m_bObjectColor;
- m_RGBAcolor = slot.m_RGBAcolor;
- m_DisplayList = NULL;
- m_bDisplayList = slot.m_bDisplayList;
- m_joinSlot = NULL;
- m_currentArray = slot.m_currentArray;
- m_displayArrays = slot.m_displayArrays;
- m_joinedSlots = slot.m_joinedSlots;
-
- m_startarray = slot.m_startarray;
- m_startvertex = slot.m_startvertex;
- m_startindex = slot.m_startindex;
- m_endarray = slot.m_endarray;
- m_endvertex = slot.m_endvertex;
- m_endindex = slot.m_endindex;
-
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- // don't copy display arrays for now because it breaks python
- // access to vertices, but we'll need a solution if we want to
- // join display arrays for reducing draw calls.
- //*it = new RAS_DisplayArray(**it);
- //(*it)->m_users = 1;
-
- (*it)->m_users++;
- }
-}
-
-void RAS_MeshSlot::init(RAS_MaterialBucket *bucket, int numverts)
-{
- m_bucket = bucket;
-
- SetDisplayArray(numverts);
-
- m_startarray = 0;
- m_startvertex = 0;
- m_startindex = 0;
- m_endarray = 0;
- m_endvertex = 0;
- m_endindex = 0;
-}
-
-void RAS_MeshSlot::begin(RAS_MeshSlot::iterator& it)
-{
- int startvertex, endvertex;
- int startindex, endindex;
-
- it.array = m_displayArrays.empty() ? NULL : m_displayArrays[m_startarray];
-
- if (it.array == NULL || it.array->m_index.size() == 0 || it.array->m_vertex.size() == 0) {
- it.array = NULL;
- it.vertex = NULL;
- it.index = NULL;
- it.startvertex = 0;
- it.endvertex = 0;
- it.totindex = 0;
- }
- else {
- startvertex = m_startvertex;
- endvertex = (m_startarray == m_endarray)? m_endvertex: it.array->m_vertex.size();
- startindex = m_startindex;
- endindex = (m_startarray == m_endarray)? m_endindex: it.array->m_index.size();
-
- it.vertex = &it.array->m_vertex[0];
- it.index = &it.array->m_index[startindex];
- it.startvertex = startvertex;
- it.endvertex = endvertex;
- it.totindex = endindex-startindex;
- it.arraynum = m_startarray;
- }
-}
-
-void RAS_MeshSlot::next(RAS_MeshSlot::iterator& it)
-{
- int startvertex, endvertex;
- int startindex, endindex;
-
- if (it.arraynum == (size_t)m_endarray) {
- it.array = NULL;
- it.vertex = NULL;
- it.index = NULL;
- it.startvertex = 0;
- it.endvertex = 0;
- it.totindex = 0;
- }
- else {
- it.arraynum++;
- it.array = m_displayArrays[it.arraynum];
-
- startindex = 0;
- endindex = (it.arraynum == (size_t)m_endarray)? m_endindex: it.array->m_index.size();
- startvertex = 0;
- endvertex = (it.arraynum == (size_t)m_endarray)? m_endvertex: it.array->m_vertex.size();
-
- it.vertex = &it.array->m_vertex[0];
- it.index = &it.array->m_index[startindex];
- it.startvertex = startvertex;
- it.endvertex = endvertex;
- it.totindex = endindex-startindex;
- }
-}
-
-bool RAS_MeshSlot::end(RAS_MeshSlot::iterator& it)
-{
- return (it.array == NULL);
-}
-
-RAS_DisplayArray *RAS_MeshSlot::CurrentDisplayArray()
-{
- return m_currentArray;
-}
-
-void RAS_MeshSlot::SetDisplayArray(int numverts)
-{
- RAS_DisplayArrayList::iterator it;
- RAS_DisplayArray *darray = NULL;
-
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- darray = *it;
-
- if (darray->m_type == numverts) {
- if (darray->m_index.size()+numverts >= RAS_DisplayArray::BUCKET_MAX_INDEX)
- darray = NULL;
- else if (darray->m_vertex.size()+numverts >= RAS_DisplayArray::BUCKET_MAX_VERTEX)
- darray = NULL;
- else
- break;
- }
- else
- darray = NULL;
- }
-
- if (!darray) {
- darray = new RAS_DisplayArray();
- darray->m_users = 1;
-
- if (numverts == 2) darray->m_type = RAS_DisplayArray::LINE;
- else if (numverts == 3) darray->m_type = RAS_DisplayArray::TRIANGLE;
- else darray->m_type = RAS_DisplayArray::QUAD;
-
- m_displayArrays.push_back(darray);
-
- if (numverts == 2)
- darray->m_type = RAS_DisplayArray::LINE;
- else if (numverts == 3)
- darray->m_type = RAS_DisplayArray::TRIANGLE;
- else if (numverts == 4)
- darray->m_type = RAS_DisplayArray::QUAD;
-
- m_endarray = m_displayArrays.size()-1;
- m_endvertex = 0;
- m_endindex = 0;
- }
-
- m_currentArray = darray;
-}
-
-void RAS_MeshSlot::AddPolygon(int numverts)
-{
- SetDisplayArray(numverts);
-}
-
-int RAS_MeshSlot::AddVertex(const RAS_TexVert& tv)
-{
- RAS_DisplayArray *darray;
- int offset;
-
- darray = m_currentArray;
- darray->m_vertex.push_back(tv);
- offset = darray->m_vertex.size()-1;
-
- if (darray == m_displayArrays[m_endarray])
- m_endvertex++;
-
- return offset;
-}
-
-void RAS_MeshSlot::AddPolygonVertex(int offset)
-{
- RAS_DisplayArray *darray;
-
- darray = m_currentArray;
- darray->m_index.push_back(offset);
-
- if (darray == m_displayArrays[m_endarray])
- m_endindex++;
-}
-
-void RAS_MeshSlot::UpdateDisplayArraysOffset()
-{
- unsigned int offset = 0;
- for (unsigned short i = 0; i < m_displayArrays.size(); ++i) {
- RAS_DisplayArray *darray = m_displayArrays[i];
- darray->m_offset = offset;
- offset += darray->m_vertex.size();
- }
-}
-
-void RAS_MeshSlot::SetDeformer(RAS_Deformer* deformer)
-{
- if (deformer && m_pDeformer != deformer) {
- RAS_DisplayArrayList::iterator it;
- if (deformer->ShareVertexArray()) {
- // this deformer uses the base vertex array, first release the current ones
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- (*it)->m_users--;
- if ((*it)->m_users == 0)
- delete *it;
- }
- m_displayArrays.clear();
- // then hook to the base ones
- RAS_MeshMaterial *mmat = m_mesh->GetMeshMaterial(m_bucket->GetPolyMaterial());
- if (mmat && mmat->m_baseslot) {
- m_displayArrays = mmat->m_baseslot->m_displayArrays;
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- (*it)->m_users++;
- }
- }
- }
- else {
- // no sharing
- // we create local copy of RAS_DisplayArray when we have a deformer:
- // this way we can avoid conflict between the vertex cache of duplicates
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- if (deformer->UseVertexArray()) {
- // the deformer makes use of vertex array, make sure we have our local copy
- if ((*it)->m_users > 1) {
- // only need to copy if there are other users
- // note that this is the usual case as vertex arrays are held by the material base slot
- RAS_DisplayArray *newarray = new RAS_DisplayArray(*(*it));
- newarray->m_users = 1;
- (*it)->m_users--;
- *it = newarray;
- }
- } else {
- // the deformer is not using vertex array (Modifier), release them
- (*it)->m_users--;
- if ((*it)->m_users == 0)
- delete *it;
- }
- }
- if (!deformer->UseVertexArray()) {
- m_displayArrays.clear();
- m_startarray = 0;
- m_startvertex = 0;
- m_startindex = 0;
- m_endarray = 0;
- m_endvertex = 0;
- m_endindex = 0;
- }
- }
- }
- m_pDeformer = deformer;
-}
-
-bool RAS_MeshSlot::Equals(RAS_MeshSlot *target)
-{
- if (!m_OpenGLMatrix || !target->m_OpenGLMatrix)
- return false;
- if (m_pDeformer || target->m_pDeformer)
- return false;
- if (m_bVisible != target->m_bVisible)
- return false;
- if (m_bObjectColor != target->m_bObjectColor)
- return false;
- if (m_bObjectColor && !(m_RGBAcolor == target->m_RGBAcolor))
- return false;
-
- return true;
-}
-
-bool RAS_MeshSlot::Join(RAS_MeshSlot *target, MT_Scalar distance)
-{
- RAS_DisplayArrayList::iterator it;
- iterator mit;
- size_t i;
-
- // verify if we can join
- if (m_joinSlot || (m_joinedSlots.empty() == false) || target->m_joinSlot)
- return false;
-
- if (!Equals(target))
- return false;
-
- MT_Vector3 co(&m_OpenGLMatrix[12]);
- MT_Vector3 targetco(&target->m_OpenGLMatrix[12]);
-
- if ((co - targetco).length() > distance)
- return false;
-
- MT_Matrix4x4 mat(m_OpenGLMatrix);
- MT_Matrix4x4 targetmat(target->m_OpenGLMatrix);
- targetmat.invert();
-
- MT_Matrix4x4 transform = targetmat*mat;
-
- // m_mesh, clientobj
- m_joinSlot = target;
- m_joinInvTransform = transform;
- m_joinInvTransform.invert();
- target->m_joinedSlots.push_back(this);
-
- MT_Matrix4x4 ntransform = m_joinInvTransform.transposed();
- ntransform[0][3] = ntransform[1][3] = ntransform[2][3] = 0.0f;
-
- for (begin(mit); !end(mit); next(mit))
- for (i=mit.startvertex; i<mit.endvertex; i++)
- mit.vertex[i].Transform(transform, ntransform);
-
- /* We know we'll need a list at least this big, reserve in advance */
- target->m_displayArrays.reserve(target->m_displayArrays.size() + m_displayArrays.size());
-
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- target->m_displayArrays.push_back(*it);
- target->m_endarray++;
- target->m_endvertex = target->m_displayArrays.back()->m_vertex.size();
- target->m_endindex = target->m_displayArrays.back()->m_index.size();
- }
-
- if (m_DisplayList) {
- m_DisplayList->Release();
- m_DisplayList = NULL;
- }
- if (target->m_DisplayList) {
- target->m_DisplayList->Release();
- target->m_DisplayList = NULL;
- }
-
- return true;
-#if 0
- return false;
-#endif
-}
-
-bool RAS_MeshSlot::Split(bool force)
-{
- list<RAS_MeshSlot*>::iterator jit;
- RAS_MeshSlot *target = m_joinSlot;
- RAS_DisplayArrayList::iterator it, jt;
- iterator mit;
- size_t i, found0 = 0, found1 = 0;
-
- if (target && (force || !Equals(target))) {
- m_joinSlot = NULL;
-
- for (jit=target->m_joinedSlots.begin(); jit!=target->m_joinedSlots.end(); jit++) {
- if (*jit == this) {
- target->m_joinedSlots.erase(jit);
- found0 = 1;
- break;
- }
- }
-
- if (!found0)
- abort();
-
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- found1 = 0;
- for (jt=target->m_displayArrays.begin(); jt!=target->m_displayArrays.end(); jt++) {
- if (*jt == *it) {
- target->m_displayArrays.erase(jt);
- target->m_endarray--;
- found1 = 1;
- break;
- }
- }
-
- if (!found1)
- abort();
- }
-
- if (target->m_displayArrays.empty() == false) {
- target->m_endvertex = target->m_displayArrays.back()->m_vertex.size();
- target->m_endindex = target->m_displayArrays.back()->m_index.size();
- }
- else {
- target->m_endvertex = 0;
- target->m_endindex = 0;
- }
-
- MT_Matrix4x4 ntransform = m_joinInvTransform.inverse().transposed();
- ntransform[0][3] = ntransform[1][3] = ntransform[2][3] = 0.0f;
-
- for (begin(mit); !end(mit); next(mit))
- for (i=mit.startvertex; i<mit.endvertex; i++)
- mit.vertex[i].Transform(m_joinInvTransform, ntransform);
-
- if (target->m_DisplayList) {
- target->m_DisplayList->Release();
- target->m_DisplayList = NULL;
- }
-
- return true;
- }
-
- return false;
-}
-
-
-#ifdef USE_SPLIT
-bool RAS_MeshSlot::IsCulled()
-{
- if (m_joinSlot)
- return true;
- if (!m_bCulled)
- return false;
- list<RAS_MeshSlot*>::iterator it;
- for (it=m_joinedSlots.begin(); it!=m_joinedSlots.end(); it++)
- if (!(*it)->m_bCulled)
- return false;
- return true;
-}
-#endif
-
-/* material bucket sorting */
-
-struct RAS_MaterialBucket::less
-{
- bool operator()(const RAS_MaterialBucket* x, const RAS_MaterialBucket* y) const
- {
- return *x->GetPolyMaterial() < *y->GetPolyMaterial();
- }
-};
-
-/* material bucket */
-
-RAS_MaterialBucket::RAS_MaterialBucket(RAS_IPolyMaterial* mat)
-{
- m_material = mat;
-}
-
-RAS_MaterialBucket::~RAS_MaterialBucket()
-{
-}
-
-RAS_IPolyMaterial* RAS_MaterialBucket::GetPolyMaterial() const
-{
- return m_material;
-}
-
-bool RAS_MaterialBucket::IsAlpha() const
-{
- return (m_material->IsAlpha());
-}
-
-bool RAS_MaterialBucket::IsZSort() const
-{
- return (m_material->IsZSort());
-}
-
-RAS_MeshSlot* RAS_MaterialBucket::AddMesh(int numverts)
-{
- RAS_MeshSlot *ms;
-
- m_meshSlots.push_back(RAS_MeshSlot());
-
- ms = &m_meshSlots.back();
- ms->init(this, numverts);
-
- return ms;
-}
-
-RAS_MeshSlot* RAS_MaterialBucket::CopyMesh(RAS_MeshSlot *ms)
-{
- m_meshSlots.push_back(RAS_MeshSlot(*ms));
-
- return &m_meshSlots.back();
-}
-
-void RAS_MaterialBucket::RemoveMesh(RAS_MeshSlot* ms)
-{
- list<RAS_MeshSlot>::iterator it;
-
- for (it=m_meshSlots.begin(); it!=m_meshSlots.end(); it++) {
- if (&*it == ms) {
- m_meshSlots.erase(it);
- return;
- }
- }
-}
-
-list<RAS_MeshSlot>::iterator RAS_MaterialBucket::msBegin()
-{
- return m_meshSlots.begin();
-}
-
-list<RAS_MeshSlot>::iterator RAS_MaterialBucket::msEnd()
-{
- return m_meshSlots.end();
-}
-
-bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty)
-{
- bool uselights;
-
- if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && !m_material->CastsShadows())
- return false;
-
- if (rasty->GetDrawingMode() != RAS_IRasterizer::KX_SHADOW && m_material->OnlyShadow())
- return false;
-
- if (!rasty->SetMaterial(*m_material))
- return false;
-
- uselights= m_material->UsesLighting(rasty);
- rasty->ProcessLighting(uselights, cameratrans);
-
- return true;
-}
-
-void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_MeshSlot &ms)
-{
- m_material->ActivateMeshSlot(ms, rasty);
-
- if (ms.m_pDeformer)
- {
- if (ms.m_pDeformer->Apply(m_material))
- ms.m_mesh->SetMeshModified(true);
- // KX_ReInstanceShapeFromMesh(ms.m_mesh); // Recompute the physics mesh. (Can't call KX_* from RAS_)
- }
-
- if (IsZSort() && rasty->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID)
- ms.m_mesh->SortPolygons(ms, cameratrans*MT_Transform(ms.m_OpenGLMatrix));
-
- rasty->PushMatrix();
- if (!ms.m_pDeformer || !ms.m_pDeformer->SkipVertexTransform())
- {
- rasty->applyTransform(ms.m_OpenGLMatrix,m_material->GetDrawingMode());
- }
-
- if (rasty->QueryLists())
- if (ms.m_DisplayList)
- ms.m_DisplayList->SetModified(ms.m_mesh->MeshModified());
-
- // verify if we can use display list, not for deformed object, and
- // also don't create a new display list when drawing shadow buffers,
- // then it won't have texture coordinates for actual drawing. also
- // for zsort we can't make a display list, since the polygon order
- // changes all the time.
- if (ms.m_pDeformer && ms.m_pDeformer->IsDynamic())
- ms.m_bDisplayList = false;
- else if (!ms.m_DisplayList && rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW)
- ms.m_bDisplayList = false;
- else if (IsZSort())
- ms.m_bDisplayList = false;
- else if (m_material->UsesObjectColor() && ms.m_bObjectColor)
- ms.m_bDisplayList = false;
- else
- ms.m_bDisplayList = true;
-
- if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT) {
- // for text drawing using faces
- rasty->IndexPrimitives_3DText(ms, m_material);
- }
- else {
- rasty->IndexPrimitives(ms);
- }
-
- rasty->PopMatrix();
-}
-
-void RAS_MaterialBucket::Optimize(MT_Scalar distance)
-{
- /* TODO: still have to check before this works correct:
- * - lightlayer, frontface, text, billboard
- * - make it work with physics */
-
-#if 0
- list<RAS_MeshSlot>::iterator it;
- list<RAS_MeshSlot>::iterator jt;
-
- // greed joining on all following buckets
- for (it=m_meshSlots.begin(); it!=m_meshSlots.end(); it++)
- for (jt=it, jt++; jt!=m_meshSlots.end(); jt++)
- jt->Join(&*it, distance);
-#endif
-}
-
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h
deleted file mode 100644
index 75cc382c78c..00000000000
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_MaterialBucket.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_MATERIALBUCKET_H__
-#define __RAS_MATERIALBUCKET_H__
-
-#include "RAS_TexVert.h"
-#include "CTR_Map.h"
-#include "SG_QList.h"
-
-#include "MT_Transform.h"
-#include "MT_Matrix4x4.h"
-
-#include <vector>
-#include <set>
-#include <list>
-
-class RAS_MaterialBucket;
-struct DerivedMesh;
-class CTR_HashedPtr;
-class RAS_Deformer;
-class RAS_IPolyMaterial;
-class RAS_IRasterizer;
-class RAS_MeshObject;
-
-using namespace std;
-
-/* Display List Slot */
-
-class KX_ListSlot
-{
-protected:
- int m_refcount;
-public:
- KX_ListSlot() { m_refcount = 1; }
- virtual ~KX_ListSlot() {}
- virtual int Release() {
- if (--m_refcount > 0)
- return m_refcount;
- delete this;
- return 0;
- }
- virtual KX_ListSlot* AddRef() {
- m_refcount++;
- return this;
- }
- virtual void SetModified(bool mod)=0;
-};
-
-/* An array with data used for OpenGL drawing */
-
-class RAS_DisplayArray
-{
-public:
- /** The offset relation to the previous RAS_DisplayArray.
- * For the user vertex are one big list but in C++ source
- * it's two different lists if we use quads and triangles.
- * So to fix that we add an offset.
- * This value is set in UpdateDisplayArraysOffset().
- */
- unsigned int m_offset;
- vector<RAS_TexVert> m_vertex;
- vector<unsigned short> m_index;
- /* LINE currently isn't used */
- enum { LINE = 2, TRIANGLE = 3, QUAD = 4 } m_type;
- //RAS_MeshSlot *m_origSlot;
-
- /* Number of RAS_MeshSlot using this array */
- int m_users;
-
- enum { BUCKET_MAX_INDEX = 65535 };
- enum { BUCKET_MAX_VERTEX = 65535 };
-};
-
-/* Entry of a RAS_MeshObject into RAS_MaterialBucket */
-typedef std::vector<RAS_DisplayArray*> RAS_DisplayArrayList;
-
-// The QList is used to link the mesh slots to the object
-// The DList is used to link the visible mesh slots to the material bucket
-class RAS_MeshSlot : public SG_QList
-{
- friend class RAS_ListRasterizer;
-private:
- // indices into display arrays
- int m_startarray;
- int m_endarray;
- int m_startindex;
- int m_endindex;
- int m_startvertex;
- int m_endvertex;
- RAS_DisplayArrayList m_displayArrays;
-
- // for construction only
- RAS_DisplayArray* m_currentArray;
-
-public:
- // for rendering
- RAS_MaterialBucket* m_bucket;
- RAS_MeshObject* m_mesh;
- void* m_clientObj;
- RAS_Deformer* m_pDeformer;
- DerivedMesh* m_pDerivedMesh;
- float* m_OpenGLMatrix;
- // visibility
- bool m_bVisible;
- bool m_bCulled;
- // object color
- bool m_bObjectColor;
- MT_Vector4 m_RGBAcolor;
- // display lists
- KX_ListSlot* m_DisplayList;
- bool m_bDisplayList;
- // joined mesh slots
- RAS_MeshSlot* m_joinSlot;
- MT_Matrix4x4 m_joinInvTransform;
- list<RAS_MeshSlot*> m_joinedSlots;
-
- RAS_MeshSlot();
- RAS_MeshSlot(const RAS_MeshSlot& slot);
- virtual ~RAS_MeshSlot();
-
- void init(RAS_MaterialBucket *bucket, int numverts);
-
- struct iterator {
- RAS_DisplayArray *array;
- RAS_TexVert *vertex;
- unsigned short *index;
- size_t startvertex;
- size_t endvertex;
- size_t totindex;
- size_t arraynum;
- };
-
- void begin(iterator& it);
- void next(iterator& it);
- bool end(iterator& it);
-
- /* used during construction */
- void SetDisplayArray(int numverts);
- RAS_DisplayArray *CurrentDisplayArray();
- void SetDeformer(RAS_Deformer* deformer);
-
- void AddPolygon(int numverts);
- int AddVertex(const RAS_TexVert& tv);
- void AddPolygonVertex(int offset);
-
- /// Update offset of each display array
- void UpdateDisplayArraysOffset();
-
- /* optimization */
- bool Split(bool force=false);
- bool Join(RAS_MeshSlot *target, MT_Scalar distance);
- bool Equals(RAS_MeshSlot *target);
-#ifdef USE_SPLIT
- bool IsCulled();
-#else
- bool IsCulled() { return m_bCulled; }
-#endif
- void SetCulled(bool culled) { m_bCulled = culled; }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_MeshSlot")
-#endif
-};
-
-/* Used by RAS_MeshObject, to point to it's slots in a bucket */
-
-class RAS_MeshMaterial
-{
-public:
- RAS_MeshSlot *m_baseslot;
- class RAS_MaterialBucket *m_bucket;
-
- /* the KX_GameObject is used as a key here */
- CTR_Map<CTR_HashedPtr,RAS_MeshSlot*> m_slots;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_MeshMaterial")
-#endif
-};
-
-/* Contains a list of display arrays with the same material,
- * and a mesh slot for each mesh that uses display arrays in
- * this bucket */
-
-class RAS_MaterialBucket
-{
-public:
- RAS_MaterialBucket(RAS_IPolyMaterial* mat);
- virtual ~RAS_MaterialBucket();
-
- /* Bucket Sorting */
- struct less;
- typedef set<RAS_MaterialBucket*, less> Set;
-
- /* Material Properties */
- RAS_IPolyMaterial* GetPolyMaterial() const;
- bool IsAlpha() const;
- bool IsZSort() const;
-
- /* Rendering */
- bool ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty);
- void RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_MeshSlot &ms);
-
- /* Mesh Slot Access */
- list<RAS_MeshSlot>::iterator msBegin();
- list<RAS_MeshSlot>::iterator msEnd();
-
- class RAS_MeshSlot* AddMesh(int numverts);
- class RAS_MeshSlot* CopyMesh(class RAS_MeshSlot *ms);
- void RemoveMesh(class RAS_MeshSlot* ms);
- void Optimize(MT_Scalar distance);
- void ActivateMesh(RAS_MeshSlot* slot)
- {
- m_activeMeshSlotsHead.AddBack(slot);
- }
- SG_DList& GetActiveMeshSlots()
- {
- return m_activeMeshSlotsHead;
- }
- RAS_MeshSlot* GetNextActiveMeshSlot()
- {
- return (RAS_MeshSlot*)m_activeMeshSlotsHead.Remove();
- }
-
-private:
- list<RAS_MeshSlot> m_meshSlots; // all the mesh slots
- RAS_IPolyMaterial* m_material;
- SG_DList m_activeMeshSlotsHead; // only those which must be rendered
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_MaterialBucket")
-#endif
-};
-
-#endif /* __RAS_MATERIAL_BUCKET */
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
deleted file mode 100644
index 4360464ed32..00000000000
--- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp
+++ /dev/null
@@ -1,573 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_MeshObject.cpp
- * \ingroup bgerast
- */
-
-#include "DNA_key_types.h"
-#include "DNA_mesh_types.h"
-
-#include "CTR_HashedPtr.h"
-
-#include "RAS_MeshObject.h"
-#include "RAS_Polygon.h"
-#include "RAS_IPolygonMaterial.h"
-#include "RAS_Deformer.h"
-#include "MT_Point3.h"
-
-#include <algorithm>
-
-
-/* polygon sorting */
-
-struct RAS_MeshObject::polygonSlot
-{
- float m_z;
- int m_index[4];
-
- polygonSlot() {}
-
- /* pnorm is the normal from the plane equation that the distance from is
- * used to sort again. */
- void get(const RAS_TexVert *vertexarray, const unsigned short *indexarray,
- int offset, int nvert, const MT_Vector3& pnorm)
- {
- MT_Vector3 center(0, 0, 0);
- int i;
-
- for (i=0; i<nvert; i++) {
- m_index[i] = indexarray[offset+i];
- center += vertexarray[m_index[i]].getXYZ();
- }
-
- /* note we don't divide center by the number of vertices, since all
- * polygons have the same number of vertices, and that we leave out
- * the 4-th component of the plane equation since it is constant. */
- m_z = MT_dot(pnorm, center);
- }
-
- void set(unsigned short *indexarray, int offset, int nvert)
- {
- int i;
-
- for (i=0; i<nvert; i++)
- indexarray[offset+i] = m_index[i];
- }
-};
-
-struct RAS_MeshObject::backtofront
-{
- bool operator()(const polygonSlot &a, const polygonSlot &b) const
- {
- return a.m_z < b.m_z;
- }
-};
-
-struct RAS_MeshObject::fronttoback
-{
- bool operator()(const polygonSlot &a, const polygonSlot &b) const
- {
- return a.m_z > b.m_z;
- }
-};
-
-/* mesh object */
-
-STR_String RAS_MeshObject::s_emptyname = "";
-
-RAS_MeshObject::RAS_MeshObject(Mesh* mesh)
- : m_bModified(true),
- m_bMeshModified(true),
- m_mesh(mesh)
-{
- if (m_mesh && m_mesh->key)
- {
- KeyBlock *kb;
- int count=0;
- // initialize weight cache for shape objects
- // count how many keys in this mesh
- for (kb= (KeyBlock *)m_mesh->key->block.first; kb; kb= (KeyBlock *)kb->next)
- count++;
- m_cacheWeightIndex.resize(count,-1);
- }
-}
-
-RAS_MeshObject::~RAS_MeshObject()
-{
- vector<RAS_Polygon*>::iterator it;
-
- for (it=m_Polygons.begin(); it!=m_Polygons.end(); it++)
- delete (*it);
-
- m_sharedvertex_map.clear();
- m_Polygons.clear();
- m_materials.clear();
-}
-
-bool RAS_MeshObject::MeshModified()
-{
- return m_bMeshModified;
-}
-
-//unsigned int RAS_MeshObject::GetLightLayer()
-//{
-// return m_lightlayer;
-//}
-
-
-
-int RAS_MeshObject::NumMaterials()
-{
- return m_materials.size();
-}
-
-const STR_String& RAS_MeshObject::GetMaterialName(unsigned int matid)
-{
- RAS_MeshMaterial* mmat = GetMeshMaterial(matid);
-
- if (mmat)
- return mmat->m_bucket->GetPolyMaterial()->GetMaterialName();
-
- return s_emptyname;
-}
-
-RAS_MeshMaterial* RAS_MeshObject::GetMeshMaterial(unsigned int matid)
-{
- if ((m_materials.empty() == false) && (matid < m_materials.size()))
- {
- list<RAS_MeshMaterial>::iterator it = m_materials.begin();
- while (matid--) ++it;
- return &*it;
- }
-
- return NULL;
-}
-
-
-
-int RAS_MeshObject::NumPolygons()
-{
- return m_Polygons.size();
-}
-
-
-
-RAS_Polygon* RAS_MeshObject::GetPolygon(int num) const
-{
- return m_Polygons[num];
-}
-
-
-
-
- list<RAS_MeshMaterial>::iterator GetFirstMaterial();
- list<RAS_MeshMaterial>::iterator GetLastMaterial();
-list<RAS_MeshMaterial>::iterator RAS_MeshObject::GetFirstMaterial()
-{
- return m_materials.begin();
-}
-
-
-
-list<RAS_MeshMaterial>::iterator RAS_MeshObject::GetLastMaterial()
-{
- return m_materials.end();
-}
-
-
-
-void RAS_MeshObject::SetName(const char *name)
-{
- m_name = name;
-}
-
-
-
-STR_String& RAS_MeshObject::GetName()
-{
- return m_name;
-}
-
-
-
-const STR_String& RAS_MeshObject::GetTextureName(unsigned int matid)
-{
- RAS_MeshMaterial* mmat = GetMeshMaterial(matid);
-
- if (mmat)
- return mmat->m_bucket->GetPolyMaterial()->GetTextureName();
-
- return s_emptyname;
-}
-
-RAS_MeshMaterial *RAS_MeshObject::GetMeshMaterial(RAS_IPolyMaterial *mat)
-{
- list<RAS_MeshMaterial>::iterator mit;
-
- /* find a mesh material */
- for (mit = m_materials.begin(); mit != m_materials.end(); mit++)
- if (mit->m_bucket->GetPolyMaterial() == mat)
- return &*mit;
-
- return NULL;
-}
-
-int RAS_MeshObject::GetMaterialId(RAS_IPolyMaterial *mat)
-{
- list<RAS_MeshMaterial>::iterator mit;
- int imat;
-
- /* find a mesh material */
- for (imat=0, mit = m_materials.begin(); mit != m_materials.end(); mit++, imat++)
- if (mit->m_bucket->GetPolyMaterial() == mat)
- return imat;
-
- return -1;
-}
-
-RAS_Polygon* RAS_MeshObject::AddPolygon(RAS_MaterialBucket *bucket, int numverts)
-{
- RAS_MeshMaterial *mmat;
- RAS_Polygon *poly;
- RAS_MeshSlot *slot;
-
- /* find a mesh material */
- mmat = GetMeshMaterial(bucket->GetPolyMaterial());
-
- /* none found, create a new one */
- if (!mmat) {
- RAS_MeshMaterial meshmat;
- meshmat.m_bucket = bucket;
- meshmat.m_baseslot = meshmat.m_bucket->AddMesh(numverts);
- meshmat.m_baseslot->m_mesh = this;
- m_materials.push_back(meshmat);
- mmat = &m_materials.back();
- }
-
- /* add it to the bucket, this also adds new display arrays */
- slot = mmat->m_baseslot;
- slot->AddPolygon(numverts);
-
- /* create a new polygon */
- RAS_DisplayArray *darray = slot->CurrentDisplayArray();
- poly = new RAS_Polygon(bucket, darray, numverts);
- m_Polygons.push_back(poly);
-
- return poly;
-}
-
-void RAS_MeshObject::DebugColor(unsigned int abgr)
-{
- /*int numpolys = NumPolygons();
-
- for (int i=0;i<numpolys;i++) {
- RAS_Polygon* poly = m_polygons[i];
- for (int v=0;v<poly->VertexCount();v++)
- RAS_TexVert* vtx = poly->GetVertex(v)->setDebugRGBA(abgr);
- }
- */
-
- /* m_debugcolor = abgr; */
-}
-
-void RAS_MeshObject::SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba)
-{
- RAS_MeshMaterial *mmat = GetMeshMaterial(mat);
- RAS_MeshSlot *slot = mmat->m_baseslot;
- RAS_MeshSlot::iterator it;
- size_t i;
-
- for (slot->begin(it); !slot->end(it); slot->next(it))
- for (i=it.startvertex; i<it.endvertex; i++)
- it.vertex[i].SetRGBA(rgba);
-}
-
-void RAS_MeshObject::AddVertex(RAS_Polygon *poly, int i,
- const MT_Point3& xyz,
- const MT_Point2 uvs[RAS_TexVert::MAX_UNIT],
- const MT_Vector4& tangent,
- const unsigned int rgba,
- const MT_Vector3& normal,
- bool flat,
- int origindex)
-{
- RAS_TexVert texvert(xyz, uvs, tangent, rgba, normal, flat, origindex);
- RAS_MeshMaterial *mmat;
- RAS_DisplayArray *darray;
- RAS_MeshSlot *slot;
- int offset;
-
- mmat = GetMeshMaterial(poly->GetMaterial()->GetPolyMaterial());
- slot = mmat->m_baseslot;
- darray = slot->CurrentDisplayArray();
-
- { /* Shared Vertex! */
- /* find vertices shared between faces, with the restriction
- * that they exist in the same display array, and have the
- * same uv coordinate etc */
- vector<SharedVertex>& sharedmap = m_sharedvertex_map[origindex];
- vector<SharedVertex>::iterator it;
-
- for (it = sharedmap.begin(); it != sharedmap.end(); it++)
- {
- if (it->m_darray != darray)
- continue;
- if (!it->m_darray->m_vertex[it->m_offset].closeTo(&texvert))
- continue;
-
- /* found one, add it and we're done */
- if (poly->IsVisible())
- slot->AddPolygonVertex(it->m_offset);
- poly->SetVertexOffset(i, it->m_offset);
- return;
- }
- }
-
- /* no shared vertex found, add a new one */
- offset = slot->AddVertex(texvert);
- if (poly->IsVisible())
- slot->AddPolygonVertex(offset);
- poly->SetVertexOffset(i, offset);
-
- { /* Shared Vertex! */
- SharedVertex shared;
- shared.m_darray = darray;
- shared.m_offset = offset;
- m_sharedvertex_map[origindex].push_back(shared);
- }
-}
-
-int RAS_MeshObject::NumVertices(RAS_IPolyMaterial* mat)
-{
- RAS_MeshMaterial *mmat;
- RAS_MeshSlot *slot;
- RAS_MeshSlot::iterator it;
- size_t len = 0;
-
- mmat = GetMeshMaterial(mat);
- slot = mmat->m_baseslot;
- for (slot->begin(it); !slot->end(it); slot->next(it))
- len += it.endvertex - it.startvertex;
-
- return len;
-}
-
-
-RAS_TexVert* RAS_MeshObject::GetVertex(unsigned int matid,
- unsigned int index)
-{
- RAS_MeshMaterial *mmat;
- RAS_MeshSlot *slot;
- RAS_MeshSlot::iterator it;
- size_t len;
-
- mmat = GetMeshMaterial(matid);
-
- if (!mmat)
- return NULL;
-
- slot = mmat->m_baseslot;
- len = 0;
- for (slot->begin(it); !slot->end(it); slot->next(it)) {
- if (index >= len + it.endvertex - it.startvertex)
- len += it.endvertex - it.startvertex;
- else
- return &it.vertex[index - len];
- }
-
- return NULL;
-}
-
-const float* RAS_MeshObject::GetVertexLocation(unsigned int orig_index)
-{
- vector<SharedVertex>& sharedmap = m_sharedvertex_map[orig_index];
- vector<SharedVertex>::iterator it= sharedmap.begin();
- return it->m_darray->m_vertex[it->m_offset].getXYZ();
-}
-
-void RAS_MeshObject::AddMeshUser(void *clientobj, SG_QList *head, RAS_Deformer* deformer)
-{
- list<RAS_MeshMaterial>::iterator it;
- list<RAS_MeshMaterial>::iterator mit;
-
- for (it = m_materials.begin();it!=m_materials.end();++it) {
- /* always copy from the base slot, which is never removed
- * since new objects can be created with the same mesh data */
- if (deformer && !deformer->UseVertexArray())
- {
- // HACK!
- // this deformer doesn't use vertex array => derive mesh
- // we must keep only the mesh slots that have unique material id
- // this is to match the derived mesh drawing function
- // Need a better solution in the future: scan the derive mesh and create vertex array
- RAS_IPolyMaterial* curmat = it->m_bucket->GetPolyMaterial();
- if (curmat->GetFlag() & RAS_BLENDERGLSL)
- {
- for (mit = m_materials.begin(); mit != it; ++mit)
- {
- RAS_IPolyMaterial* mat = mit->m_bucket->GetPolyMaterial();
- if ((mat->GetFlag() & RAS_BLENDERGLSL) &&
- mat->GetMaterialIndex() == curmat->GetMaterialIndex())
- // no need to convert current mesh slot
- break;
- }
- if (mit != it)
- continue;
- }
- }
- RAS_MeshSlot *ms = it->m_bucket->CopyMesh(it->m_baseslot);
- ms->m_clientObj = clientobj;
- ms->SetDeformer(deformer);
- it->m_slots.insert(clientobj, ms);
- head->QAddBack(ms);
- }
-}
-
-void RAS_MeshObject::RemoveFromBuckets(void *clientobj)
-{
- list<RAS_MeshMaterial>::iterator it;
-
- for (it = m_materials.begin();it!=m_materials.end();++it) {
- RAS_MeshSlot **msp = it->m_slots[clientobj];
-
- if (!msp)
- continue;
-
- RAS_MeshSlot *ms = *msp;
-
- it->m_bucket->RemoveMesh(ms);
- it->m_slots.remove(clientobj);
- }
-}
-
-void RAS_MeshObject::EndConversion()
-{
-#if 0
- m_sharedvertex_map.clear(); // SharedVertex
- vector<vector<SharedVertex> > shared_null(0);
- shared_null.swap( m_sharedvertex_map ); /* really free the memory */
-#endif
-
- for (std::list<RAS_MeshMaterial>::iterator it = m_materials.begin();
- it != m_materials.end();
- ++it)
- {
- RAS_MeshSlot *ms = it->m_baseslot;
- ms->UpdateDisplayArraysOffset();
- }
-}
-
-//void RAS_MeshObject::Transform(const MT_Transform& trans)
-//{
- //m_trans.translate(MT_Vector3(0,0,1));//.operator *=(trans);
-
-// for (int i=0;i<m_Polygons.size();i++)
-// {
-// m_Polygons[i]->Transform(trans);
-// }
-//}
-
-
-/*
-void RAS_MeshObject::RelativeTransform(const MT_Vector3& vec)
-{
- for (int i=0;i<m_Polygons.size();i++)
- {
- m_Polygons[i]->RelativeTransform(vec);
- }
-}
-*/
-
-void RAS_MeshObject::SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transform)
-{
- // Limitations: sorting is quite simple, and handles many
- // cases wrong, partially due to polygons being sorted per
- // bucket.
- //
- // a) mixed triangles/quads are sorted wrong
- // b) mixed materials are sorted wrong
- // c) more than 65k faces are sorted wrong
- // d) intersecting objects are sorted wrong
- // e) intersecting polygons are sorted wrong
- //
- // a) can be solved by making all faces either triangles or quads
- // if they need to be z-sorted. c) could be solved by allowing
- // larger buckets, b) and d) cannot be solved easily if we want
- // to avoid excessive state changes while drawing. e) would
- // require splitting polygons.
-
- RAS_MeshSlot::iterator it;
- size_t j;
-
- for (ms.begin(it); !ms.end(it); ms.next(it)) {
- unsigned int nvert = (int)it.array->m_type;
- unsigned int totpoly = it.totindex/nvert;
-
- if (totpoly <= 1)
- continue;
- if (it.array->m_type == RAS_DisplayArray::LINE)
- continue;
-
- // Extract camera Z plane...
- const MT_Vector3 pnorm(transform.getBasis()[2]);
- // unneeded: const MT_Scalar pval = transform.getOrigin()[2];
-
- vector<polygonSlot> poly_slots(totpoly);
-
- /* get indices and z into temporary array */
- for (j=0; j<totpoly; j++)
- poly_slots[j].get(it.vertex, it.index, j*nvert, nvert, pnorm);
-
- /* sort (stable_sort might be better, if flickering happens?) */
- std::sort(poly_slots.begin(), poly_slots.end(), backtofront());
-
- /* get indices from temporary array again */
- for (j=0; j<totpoly; j++)
- poly_slots[j].set(it.index, j*nvert, nvert);
- }
-}
-
-
-bool RAS_MeshObject::HasColliderPolygon()
-{
- int numpolys= NumPolygons();
- for (int p=0; p<numpolys; p++)
- if (m_Polygons[p]->IsCollider())
- return true;
-
- return false;
-}
-
-void RAS_MeshObject::SchedulePolygons(int drawingmode)
-{
- if (m_bModified)
- {
- m_bModified = false;
- m_bMeshModified = true;
- }
-}
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h
deleted file mode 100644
index a6f1a1cafc6..00000000000
--- a/source/gameengine/Rasterizer/RAS_MeshObject.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_MeshObject.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_MESHOBJECT_H__
-#define __RAS_MESHOBJECT_H__
-
-#ifdef _MSC_VER
- /* disable the STL warnings ("debug information length > 255") */
-# pragma warning (disable:4786)
-#endif
-
-#include <vector>
-#include <list>
-
-#include "RAS_MaterialBucket.h"
-#include "MT_Transform.h"
-#include "STR_String.h"
-
-struct Mesh;
-class RAS_Deformer;
-class RAS_Polygon;
-
-/* RAS_MeshObject is a mesh used for rendering. It stores polygons,
- * but the actual vertices and index arrays are stored in material
- * buckets, referenced by the list of RAS_MeshMaterials. */
-
-class RAS_MeshObject
-{
-private:
- /* unsigned int m_debugcolor; */ /* UNUSED */
-
- bool m_bModified;
- bool m_bMeshModified;
-
- STR_String m_name;
- static STR_String s_emptyname;
-
- vector<RAS_Polygon*> m_Polygons;
-
- /* polygon sorting */
- struct polygonSlot;
- struct backtofront;
- struct fronttoback;
-
-protected:
- vector<int> m_cacheWeightIndex;
- list<RAS_MeshMaterial> m_materials;
- Mesh* m_mesh;
-
-public:
- // for now, meshes need to be in a certain layer (to avoid sorting on lights in realtime)
- RAS_MeshObject(Mesh* mesh);
- virtual ~RAS_MeshObject();
-
-
- /* materials */
- int NumMaterials();
- const STR_String& GetMaterialName(unsigned int matid);
- const STR_String& GetTextureName(unsigned int matid);
-
- RAS_MeshMaterial* GetMeshMaterial(unsigned int matid);
- RAS_MeshMaterial* GetMeshMaterial(RAS_IPolyMaterial *mat);
- int GetMaterialId(RAS_IPolyMaterial *mat);
-
- list<RAS_MeshMaterial>::iterator GetFirstMaterial();
- list<RAS_MeshMaterial>::iterator GetLastMaterial();
-
- //unsigned int GetLightLayer();
-
- /* name */
- void SetName(const char *name);
- STR_String& GetName();
-
- /* modification state */
- bool MeshModified();
- void SetMeshModified(bool v) { m_bMeshModified = v; }
-
- /* original blender mesh */
- Mesh* GetMesh() { return m_mesh; }
-
- /* mesh construction */
-
- virtual RAS_Polygon* AddPolygon(RAS_MaterialBucket *bucket, int numverts);
- virtual void AddVertex(RAS_Polygon *poly, int i,
- const MT_Point3& xyz,
- const MT_Point2 uvs[RAS_TexVert::MAX_UNIT],
- const MT_Vector4& tangent,
- const unsigned int rgbacolor,
- const MT_Vector3& normal,
- bool flat,
- int origindex);
-
- void SchedulePolygons(int drawingmode);
-
- /* vertex and polygon acces */
- int NumVertices(RAS_IPolyMaterial* mat);
- RAS_TexVert* GetVertex(unsigned int matid, unsigned int index);
- const float* GetVertexLocation(unsigned int orig_index);
-
- int NumPolygons();
- RAS_Polygon* GetPolygon(int num) const;
-
- /* buckets */
- virtual void AddMeshUser(void *clientobj, SG_QList *head, RAS_Deformer* deformer);
-
- void RemoveFromBuckets(void *clientobj);
- void EndConversion();
-
- /* colors */
- void DebugColor(unsigned int abgr);
- void SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba);
-
- /* polygon sorting by Z for alpha */
- void SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transform);
-
-
- bool HasColliderPolygon();
-
- /* for construction to find shared vertices */
- struct SharedVertex {
- RAS_DisplayArray *m_darray;
- int m_offset;
- };
-
- vector<vector<SharedVertex> > m_sharedvertex_map;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_MeshObject")
-#endif
-};
-
-#endif /* __RAS_MESHOBJECT_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_ObjectColor.h b/source/gameengine/Rasterizer/RAS_ObjectColor.h
deleted file mode 100644
index 77feffccffc..00000000000
--- a/source/gameengine/Rasterizer/RAS_ObjectColor.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_ObjectColor.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_OBJECTCOLOR_H__
-#define __RAS_OBJECTCOLOR_H__
-
-struct RAS_ObjectColor {
- float m_red;
- float m_green;
- float m_blue;
-};
-
-#endif /* __RAS_OBJECTCOLOR_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h
deleted file mode 100644
index 3f1644a5c60..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_Blur2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_BLUR2DFILTER_H__
-#define __RAS_BLUR2DFILTER_H__
-
-static const char *BlurFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- }
-
- gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] +
- (2.0*sample[3]) + sample[4] + (2.0*sample[5]) +
- sample[6] + (2.0*sample[7]) + sample[8]) / 13.0;
-}
-);
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h
deleted file mode 100644
index 4e863cb6f8d..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_Dilation2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_DILATION2DFILTER_H__
-#define __RAS_DILATION2DFILTER_H__
-
-static const char *DilationFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
- vec4 maxValue = vec4(0.0);
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- maxValue = max(sample[i], maxValue);
- }
-
- gl_FragColor = maxValue;
-}
-);
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h
deleted file mode 100644
index 56e2c22fe2e..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_Erosion2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_EROSION2DFILTER_H__
-#define __RAS_EROSION2DFILTER_H__
-
-static const char *ErosionFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
- vec4 minValue = vec4(1.0);
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- minValue = min(sample[i], minValue);
- }
-
- gl_FragColor = minValue;
-}
-);
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h
deleted file mode 100644
index 932d5b16fed..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_GrayScale2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_GRAYSCALE2DFILTER_H__
-#define __RAS_GRAYSCALE2DFILTER_H__
-
-static const char *GrayScaleFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-
-void main(void)
-{
- vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
- float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114));
- gl_FragColor = vec4(gray, gray, gray, texcolor.a);
-}
-);
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h
deleted file mode 100644
index dce303916ea..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_Invert2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_INVERT2DFILTER_H__
-#define __RAS_INVERT2DFILTER_H__
-
-static const char *InvertFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-
-void main(void)
-{
- vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
- gl_FragColor.rgb = 1.0 - texcolor.rgb;
- gl_FragColor.a = texcolor.a;
-}
-);
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h
deleted file mode 100644
index 9ec5092817d..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_Laplacian2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_LAPLACIAN2DFILTER_H__
-#define __RAS_LAPLACIAN2DFILTER_H__
-
-static const char *LaplacionFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- }
-
- gl_FragColor = (sample[4] * 8.0) -
- (sample[0] + sample[1] + sample[2] +
- sample[3] + sample[5] +
- sample[6] + sample[7] + sample[8]);
- gl_FragColor = vec4(gl_FragColor.rgb, 1.0);
-}
-);
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h
deleted file mode 100644
index 4ae6009fdeb..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_Prewitt2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_PREWITT2DFILTER_H__
-#define __RAS_PREWITT2DFILTER_H__
-
-static const char *PrewittFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- }
-
- vec4 horizEdge = sample[2] + sample[5] + sample[8] -
- (sample[0] + sample[3] + sample[6]);
-
- vec4 vertEdge = sample[0] + sample[1] + sample[2] -
- (sample[6] + sample[7] + sample[8]);
-
- gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) +
- (vertEdge.rgb * vertEdge.rgb));
- gl_FragColor.a = 1.0;
-}
-
-);
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h
deleted file mode 100644
index 16b4e71dfdb..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_Sepia2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_SEPIA2DFILTER_H__
-#define __RAS_SEPIA2DFILTER_H__
-
-static const char *SepiaFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-
-void main(void)
-{
- vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
- float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114));
- gl_FragColor = vec4(gray * vec3(1.2, 1.0, 0.8), texcolor.a);
-}
-);
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h
deleted file mode 100644
index 7512393815b..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_Sharpen2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_SHARPEN2DFILTER_H__
-#define __RAS_SHARPEN2DFILTER_H__
-
-static const char *SharpenFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- }
-
- gl_FragColor = (sample[4] * 9.0) -
- (sample[0] + sample[1] + sample[2] +
- sample[3] + sample[5] +
- sample[6] + sample[7] + sample[8]);
-}
-);
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h
deleted file mode 100644
index 088ac10a56a..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_Sobel2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_SOBEL2DFILTER_H__
-#define __RAS_SOBEL2DFILTER_H__
-
-static const char *SobelFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- }
-
- vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] -
- (sample[0] + (2.0*sample[3]) + sample[6]);
-
- vec4 vertEdge = sample[0] + (2.0*sample[1]) + sample[2] -
- (sample[6] + (2.0*sample[7]) + sample[8]);
-
- gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) +
- (vertEdge.rgb * vertEdge.rgb));
- gl_FragColor.a = 1.0;
-}
-);
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
deleted file mode 100644
index 89e31b62b41..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
+++ /dev/null
@@ -1,72 +0,0 @@
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# The Original Code is Copyright (C) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- ..
- # XXX Remove these <<<
- ../../BlenderRoutines
- ../../Expressions
- ../../GameLogic
- ../../Ketsji
- ../../Physics/common
- # >>>
- ../../SceneGraph
- ../../../blender/blenfont
- ../../../blender/blenkernel
- ../../../blender/blenlib
- ../../../blender/gpu
- ../../../blender/makesdna
- ../../../../intern/container
- ../../../../intern/glew-mx
- ../../../../intern/string
-)
-
-set(INC_SYS
- ../../../../intern/moto/include
- ${GLEW_INCLUDE_PATH}
-)
-
-set(SRC
- RAS_ListRasterizer.cpp
- RAS_OpenGLLight.cpp
- RAS_OpenGLOffScreen.cpp
- RAS_OpenGLSync.cpp
- RAS_OpenGLRasterizer.cpp
- RAS_StorageVA.cpp
- RAS_StorageVBO.cpp
-
- RAS_IStorage.h
- RAS_ListRasterizer.h
- RAS_OpenGLLight.h
- RAS_OpenGLOffScreen.h
- RAS_OpenGLSync.h
- RAS_OpenGLRasterizer.h
- RAS_StorageVA.h
- RAS_StorageVBO.h
-)
-
-add_definitions(${GL_DEFINITIONS})
-
-blender_add_lib(ge_oglrasterizer "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h
deleted file mode 100644
index ae0cdcd84af..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __KX_STORAGE
-#define __KX_STORAGE
-
-#ifdef WITH_CXX_GUARDEDALLOC
- #include "MEM_guardedalloc.h"
-#endif
-
-class RAS_MeshSlot;
-
-class RAS_IStorage
-{
-
-public:
- virtual ~RAS_IStorage() {};
-
- virtual bool Init()=0;
- virtual void Exit()=0;
-
- virtual void IndexPrimitives(RAS_MeshSlot& ms)=0;
-
- virtual void SetDrawingMode(int drawingmode)=0;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IStorage")
-#endif
-};
-
-#endif //__KX_STORAGE
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
deleted file mode 100644
index 71c8cfe745f..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
- * \ingroup bgerastogl
- */
-
-#include <iostream>
-
-#include "RAS_ListRasterizer.h"
-
-#ifdef WIN32
-#include <windows.h>
-#endif // WIN32
-
-#include "GPU_glew.h"
-
-#include "RAS_MaterialBucket.h"
-#include "RAS_TexVert.h"
-#include "MT_assert.h"
-
-//#if defined(DEBUG)
-//#ifdef WIN32
-//#define spit(x) std::cout << x << std::endl;
-//#endif //WIN32
-//#else
-#define spit(x)
-//#endif
-
-RAS_ListSlot::RAS_ListSlot(RAS_ListRasterizer* rasty)
-: KX_ListSlot(),
- m_list(0),
- m_flag(LIST_MODIFY|LIST_CREATE),
- m_matnr(0),
- m_rasty(rasty)
-{
-}
-
-int RAS_ListSlot::Release()
-{
- if (--m_refcount > 0)
- return m_refcount;
- m_rasty->RemoveListSlot(this);
- delete this;
- return 0;
-}
-
-RAS_ListSlot::~RAS_ListSlot()
-{
- RemoveList();
-}
-
-
-void RAS_ListSlot::RemoveList()
-{
- if (m_list != 0) {
- spit("Releasing display list (" << m_list << ")");
- glDeleteLists((GLuint)m_list, 1);
- m_list =0;
- }
-}
-
-void RAS_ListSlot::DrawList()
-{
- if (m_flag &LIST_MODIFY) {
- if (m_flag &LIST_CREATE) {
- if (m_list == 0) {
- m_list = (unsigned int)glGenLists(1);
- m_flag = m_flag &~ LIST_CREATE;
- spit("Created display list (" << m_list << ")");
- }
- }
- if (m_list != 0)
- glNewList((GLuint)m_list, GL_COMPILE);
-
- m_flag |= LIST_BEGIN;
- return;
- }
- glCallList(m_list);
-}
-
-void RAS_ListSlot::EndList()
-{
- if (m_flag & LIST_BEGIN) {
- glEndList();
- m_flag = m_flag &~(LIST_BEGIN|LIST_MODIFY);
- m_flag |= LIST_END;
- glCallList(m_list);
- }
-}
-
-void RAS_ListSlot::SetModified(bool mod)
-{
- if (mod && !(m_flag & LIST_MODIFY)) {
- spit("Modifying list (" << m_list << ")");
- m_flag = m_flag &~ LIST_END;
- m_flag |= LIST_MODIFY;
- }
-}
-
-bool RAS_ListSlot::End()
-{
- return (m_flag &LIST_END)!=0;
-}
-
-
-
-RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas, bool lock, RAS_STORAGE_TYPE storage)
-: RAS_OpenGLRasterizer(canvas, storage)
-{
-}
-
-RAS_ListRasterizer::~RAS_ListRasterizer()
-{
- ReleaseAlloc();
-}
-
-void RAS_ListRasterizer::RemoveListSlot(RAS_ListSlot* list)
-{
- if (list->m_flag & LIST_DERIVEDMESH) {
- RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.begin();
- while (it != mDerivedMeshLists.end()) {
- RAS_ListSlots *slots = it->second;
- if (slots->size() > list->m_matnr && slots->at(list->m_matnr) == list) {
- (*slots)[list->m_matnr] = NULL;
- // check if all slots are NULL and if yes, delete the entry
- int i;
- for (i=slots->size(); i-- > 0; ) {
- if (slots->at(i) != NULL)
- break;
- }
- if (i < 0) {
- slots->clear();
- delete slots;
- mDerivedMeshLists.erase(it);
- }
- break;
- }
- ++it;
- }
- } else {
- RAS_ArrayLists::iterator it = mArrayLists.begin();
- while (it != mArrayLists.end()) {
- if (it->second == list) {
- mArrayLists.erase(it);
- break;
- }
- it++;
- }
- }
-}
-
-RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(RAS_MeshSlot& ms)
-{
- /*
- * Keep a copy of constant lists submitted for rendering,
- * this guards against (replicated)new...delete every frame,
- * and we can reuse lists!
- * :: sorted by mesh slot
- */
- RAS_ListSlot* localSlot = (RAS_ListSlot*)ms.m_DisplayList;
- if (!localSlot) {
- if (ms.m_pDerivedMesh) {
- // that means that we draw based on derived mesh, a display list is possible
- // Note that we come here only for static derived mesh
- int matnr = ms.m_bucket->GetPolyMaterial()->GetMaterialIndex();
- RAS_ListSlot* nullSlot = NULL;
- RAS_ListSlots *listVector;
- RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.find(ms.m_pDerivedMesh);
- if (it == mDerivedMeshLists.end()) {
- listVector = new RAS_ListSlots(matnr+4, nullSlot);
- localSlot = new RAS_ListSlot(this);
- localSlot->m_flag |= LIST_DERIVEDMESH;
- localSlot->m_matnr = matnr;
- listVector->at(matnr) = localSlot;
- mDerivedMeshLists.insert(std::pair<DerivedMesh*, RAS_ListSlots*>(ms.m_pDerivedMesh, listVector));
- } else {
- listVector = it->second;
- if (listVector->size() <= matnr)
- listVector->resize(matnr+4, nullSlot);
- if ((localSlot = listVector->at(matnr)) == NULL) {
- localSlot = new RAS_ListSlot(this);
- localSlot->m_flag |= LIST_DERIVEDMESH;
- localSlot->m_matnr = matnr;
- listVector->at(matnr) = localSlot;
- } else {
- localSlot->AddRef();
- }
- }
- } else {
- RAS_ArrayLists::iterator it = mArrayLists.find(ms.m_displayArrays);
- if (it == mArrayLists.end()) {
- localSlot = new RAS_ListSlot(this);
- mArrayLists.insert(std::pair<RAS_DisplayArrayList, RAS_ListSlot*>(ms.m_displayArrays, localSlot));
- } else {
- localSlot = static_cast<RAS_ListSlot*>(it->second->AddRef());
- }
- }
- }
- MT_assert(localSlot);
- return localSlot;
-}
-
-void RAS_ListRasterizer::ReleaseAlloc()
-{
- for (RAS_ArrayLists::iterator it = mArrayLists.begin();it != mArrayLists.end();++it)
- delete it->second;
- mArrayLists.clear();
- for (RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.begin();it != mDerivedMeshLists.end();++it) {
- RAS_ListSlots* slots = it->second;
- for (int i=slots->size(); i-- > 0; ) {
- RAS_ListSlot* slot = slots->at(i);
- if (slot)
- delete slot;
- }
- slots->clear();
- delete slots;
- }
- mDerivedMeshLists.clear();
-}
-
-void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
-{
- RAS_ListSlot* localSlot =0;
-
- if (ms.m_bDisplayList) {
- localSlot = FindOrAdd(ms);
- localSlot->DrawList();
-
- if (localSlot->End()) {
- // save slot here too, needed for replicas and object using same mesh
- // => they have the same vertexarray but different mesh slot
- ms.m_DisplayList = localSlot;
- return;
- }
- }
-
- RAS_OpenGLRasterizer::IndexPrimitives(ms);
-
- if (ms.m_bDisplayList) {
- localSlot->EndList();
- ms.m_DisplayList = localSlot;
- }
-}
-
-bool RAS_ListRasterizer::Init(void)
-{
- return RAS_OpenGLRasterizer::Init();
-}
-
-void RAS_ListRasterizer::SetDrawingMode(int drawingmode)
-{
- RAS_OpenGLRasterizer::SetDrawingMode(drawingmode);
-}
-
-void RAS_ListRasterizer::Exit()
-{
- RAS_OpenGLRasterizer::Exit();
-}
-
-// eof
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
deleted file mode 100644
index e3e6931311b..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
+++ /dev/null
@@ -1,77 +0,0 @@
-
-/** \file RAS_ListRasterizer.h
- * \ingroup bgerastogl
- */
-
-#ifndef __RAS_LISTRASTERIZER_H__
-#define __RAS_LISTRASTERIZER_H__
-
-#include "RAS_MaterialBucket.h"
-#include "RAS_OpenGLRasterizer.h"
-#include <vector>
-#include <map>
-
-class RAS_ListRasterizer;
-class RAS_ListSlot : public KX_ListSlot
-{
- friend class RAS_ListRasterizer;
- unsigned int m_list;
- unsigned int m_flag;
- unsigned int m_matnr;
- RAS_ListRasterizer* m_rasty;
-public:
- RAS_ListSlot(RAS_ListRasterizer* rasty);
- virtual ~RAS_ListSlot();
- virtual void SetModified(bool mod);
- virtual int Release();
-
- void RemoveList();
- void DrawList();
- void EndList();
- bool End();
-
-};
-
-enum RAS_ListSlotFlags {
- LIST_CREATE =1,
- LIST_MODIFY =2,
- LIST_BEGIN =4,
- LIST_END =8,
- LIST_DERIVEDMESH=16,
-};
-
-struct DerivedMesh;
-
-typedef std::map<RAS_DisplayArrayList, RAS_ListSlot*> RAS_ArrayLists;
-typedef std::vector<RAS_ListSlot*> RAS_ListSlots; // indexed by material slot number
-typedef std::map<DerivedMesh*, RAS_ListSlots*> RAS_DerivedMeshLists;
-
-class RAS_ListRasterizer : public RAS_OpenGLRasterizer
-{
- RAS_ArrayLists mArrayLists;
- RAS_DerivedMeshLists mDerivedMeshLists;
-
- RAS_ListSlot* FindOrAdd(class RAS_MeshSlot& ms);
- void ReleaseAlloc();
-
-public:
- void RemoveListSlot(RAS_ListSlot* list);
- RAS_ListRasterizer(RAS_ICanvas* canvas, bool lock, RAS_STORAGE_TYPE storage);
- virtual ~RAS_ListRasterizer();
-
- virtual void IndexPrimitives(class RAS_MeshSlot& ms);
-
- virtual bool Init();
- virtual void Exit();
-
- virtual void SetDrawingMode(int drawingmode);
-
- virtual bool QueryLists() {return true;}
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_ListRasterizer")
-#endif
-};
-
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp
deleted file mode 100644
index 18254357f85..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Mitchell Stokes
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "GPU_glew.h"
-
-#include <stdio.h>
-
-
-#include "RAS_OpenGLLight.h"
-#include "RAS_OpenGLRasterizer.h"
-#include "RAS_ICanvas.h"
-
-#include "MT_CmMatrix4x4.h"
-
-#include "KX_Camera.h"
-#include "KX_Light.h"
-#include "KX_Scene.h"
-
-#include "DNA_lamp_types.h"
-#include "DNA_scene_types.h"
-
-#include "GPU_lamp.h"
-#include "GPU_material.h"
-
-RAS_OpenGLLight::RAS_OpenGLLight(RAS_OpenGLRasterizer *ras)
- :m_rasterizer(ras)
-{
-}
-
-RAS_OpenGLLight::~RAS_OpenGLLight()
-{
- GPULamp *lamp;
- KX_LightObject* kxlight = (KX_LightObject*)m_light;
- Lamp *la = (Lamp*)kxlight->GetBlenderObject()->data;
-
- if ((lamp = GetGPULamp())) {
- float obmat[4][4] = {{0}};
- GPU_lamp_update(lamp, 0, 0, obmat);
- GPU_lamp_update_distance(lamp, la->dist, la->att1, la->att2, la->coeff_const, la->coeff_lin, la->coeff_quad);
- GPU_lamp_update_spot(lamp, la->spotsize, la->spotblend);
- }
-}
-
-bool RAS_OpenGLLight::ApplyFixedFunctionLighting(KX_Scene *kxscene, int oblayer, int slot)
-{
- KX_Scene* lightscene = (KX_Scene*)m_scene;
- KX_LightObject* kxlight = (KX_LightObject*)m_light;
- float vec[4];
- int scenelayer = ~0;
-
- if (kxscene && kxscene->GetBlenderScene())
- scenelayer = kxscene->GetBlenderScene()->lay;
-
- /* only use lights in the same layer as the object */
- if (!(m_layer & oblayer))
- return false;
- /* only use lights in the same scene, and in a visible layer */
- if (kxscene != lightscene || !(m_layer & scenelayer))
- return false;
-
- // lights don't get their openGL matrix updated, do it now
- if (kxlight->GetSGNode()->IsDirty())
- kxlight->GetOpenGLMatrix();
-
- MT_CmMatrix4x4& worldmatrix= *kxlight->GetOpenGLMatrixPtr();
-
- vec[0] = worldmatrix(0,3);
- vec[1] = worldmatrix(1,3);
- vec[2] = worldmatrix(2,3);
- vec[3] = 1.0f;
-
- if (m_type==RAS_ILightObject::LIGHT_SUN) {
-
- vec[0] = worldmatrix(0,2);
- vec[1] = worldmatrix(1,2);
- vec[2] = worldmatrix(2,2);
- //vec[0] = base->object->obmat[2][0];
- //vec[1] = base->object->obmat[2][1];
- //vec[2] = base->object->obmat[2][2];
- vec[3] = 0.0f;
- glLightfv((GLenum)(GL_LIGHT0+slot), GL_POSITION, vec);
- }
- else {
- //vec[3] = 1.0f;
- glLightfv((GLenum)(GL_LIGHT0+slot), GL_POSITION, vec);
- glLightf((GLenum)(GL_LIGHT0+slot), GL_CONSTANT_ATTENUATION, 1.0f);
- glLightf((GLenum)(GL_LIGHT0+slot), GL_LINEAR_ATTENUATION, m_att1/m_distance);
- // without this next line it looks backward compatible.
- //attennuation still is acceptable
- glLightf((GLenum)(GL_LIGHT0+slot), GL_QUADRATIC_ATTENUATION, m_att2/(m_distance*m_distance));
-
- if (m_type==RAS_ILightObject::LIGHT_SPOT) {
- vec[0] = -worldmatrix(0,2);
- vec[1] = -worldmatrix(1,2);
- vec[2] = -worldmatrix(2,2);
- //vec[0] = -base->object->obmat[2][0];
- //vec[1] = -base->object->obmat[2][1];
- //vec[2] = -base->object->obmat[2][2];
- glLightfv((GLenum)(GL_LIGHT0+slot), GL_SPOT_DIRECTION, vec);
- glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_CUTOFF, m_spotsize / 2.0f);
- glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_EXPONENT, 128.0f * m_spotblend);
- }
- else {
- glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_CUTOFF, 180.0f);
- }
- }
-
- if (m_nodiffuse) {
- vec[0] = vec[1] = vec[2] = vec[3] = 0.0f;
- }
- else {
- vec[0] = m_energy*m_color[0];
- vec[1] = m_energy*m_color[1];
- vec[2] = m_energy*m_color[2];
- vec[3] = 1.0f;
- }
-
- glLightfv((GLenum)(GL_LIGHT0+slot), GL_DIFFUSE, vec);
- if (m_nospecular)
- {
- vec[0] = vec[1] = vec[2] = vec[3] = 0.0f;
- }
- else if (m_nodiffuse) {
- vec[0] = m_energy*m_color[0];
- vec[1] = m_energy*m_color[1];
- vec[2] = m_energy*m_color[2];
- vec[3] = 1.0f;
- }
-
- glLightfv((GLenum)(GL_LIGHT0+slot), GL_SPECULAR, vec);
- glEnable((GLenum)(GL_LIGHT0+slot));
-
- return true;
-}
-
-GPULamp *RAS_OpenGLLight::GetGPULamp()
-{
- KX_LightObject* kxlight = (KX_LightObject*)m_light;
-
- if (m_glsl)
- return GPU_lamp_from_blender(kxlight->GetScene()->GetBlenderScene(), kxlight->GetBlenderObject(), kxlight->GetBlenderGroupObject());
- else
- return NULL;
-}
-
-
-bool RAS_OpenGLLight::HasShadowBuffer()
-{
- GPULamp *lamp;
-
- if ((lamp = GetGPULamp()))
- return GPU_lamp_has_shadow_buffer(lamp);
- else
- return false;
-}
-
-int RAS_OpenGLLight::GetShadowBindCode()
-{
- GPULamp *lamp;
-
- if ((lamp = GetGPULamp()))
- return GPU_lamp_shadow_bind_code(lamp);
- return -1;
-}
-
-MT_Matrix4x4 RAS_OpenGLLight::GetShadowMatrix()
-{
- GPULamp *lamp;
-
- if ((lamp = GetGPULamp()))
- return MT_Matrix4x4(GPU_lamp_dynpersmat(lamp));
- MT_Matrix4x4 mat;
- mat.setIdentity();
- return mat;
-}
-
-int RAS_OpenGLLight::GetShadowLayer()
-{
- GPULamp *lamp;
-
- if ((lamp = GetGPULamp()))
- return GPU_lamp_shadow_layer(lamp);
- else
- return 0;
-}
-
-void RAS_OpenGLLight::BindShadowBuffer(RAS_ICanvas *canvas, KX_Camera *cam, MT_Transform& camtrans)
-{
- GPULamp *lamp;
- float viewmat[4][4], winmat[4][4];
- int winsize;
-
- /* bind framebuffer */
- lamp = GetGPULamp();
- GPU_lamp_shadow_buffer_bind(lamp, viewmat, &winsize, winmat);
-
- if (GPU_lamp_shadow_buffer_type(lamp) == LA_SHADMAP_VARIANCE)
- m_rasterizer->SetUsingOverrideShader(true);
-
- /* GPU_lamp_shadow_buffer_bind() changes the viewport, so update the canvas */
- canvas->UpdateViewPort(0, 0, winsize, winsize);
-
- /* setup camera transformation */
- MT_Matrix4x4 modelviewmat((float*)viewmat);
- MT_Matrix4x4 projectionmat((float*)winmat);
-
- MT_Transform trans = MT_Transform((float*)viewmat);
- camtrans.invert(trans);
-
- cam->SetModelviewMatrix(modelviewmat);
- cam->SetProjectionMatrix(projectionmat);
-
- cam->NodeSetLocalPosition(camtrans.getOrigin());
- cam->NodeSetLocalOrientation(camtrans.getBasis());
- cam->NodeUpdateGS(0);
-
- /* setup rasterizer transformations */
- /* SetViewMatrix may use stereomode which we temporarily disable here */
- RAS_IRasterizer::StereoMode stereomode = m_rasterizer->GetStereoMode();
- m_rasterizer->SetStereoMode(RAS_IRasterizer::RAS_STEREO_NOSTEREO);
- m_rasterizer->SetProjectionMatrix(projectionmat);
- m_rasterizer->SetViewMatrix(modelviewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), cam->NodeGetLocalScaling(), cam->GetCameraData()->m_perspective);
- m_rasterizer->SetStereoMode(stereomode);
-}
-
-void RAS_OpenGLLight::UnbindShadowBuffer()
-{
- GPULamp *lamp = GetGPULamp();
- GPU_lamp_shadow_buffer_unbind(lamp);
-
- if (GPU_lamp_shadow_buffer_type(lamp) == LA_SHADMAP_VARIANCE)
- m_rasterizer->SetUsingOverrideShader(false);
-}
-
-Image *RAS_OpenGLLight::GetTextureImage(short texslot)
-{
- KX_LightObject* kxlight = (KX_LightObject*)m_light;
- Lamp *la = (Lamp*)kxlight->GetBlenderObject()->data;
-
- if (texslot >= MAX_MTEX || texslot < 0)
- {
- printf("KX_LightObject::GetTextureImage(): texslot exceeds slot bounds (0-%d)\n", MAX_MTEX-1);
- return NULL;
- }
-
- if (la->mtex[texslot])
- return la->mtex[texslot]->tex->ima;
-
- return NULL;
-}
-
-void RAS_OpenGLLight::Update()
-{
- GPULamp *lamp;
- KX_LightObject* kxlight = (KX_LightObject*)m_light;
-
- if ((lamp = GetGPULamp()) != NULL && kxlight->GetSGNode()) {
- float obmat[4][4];
- // lights don't get their openGL matrix updated, do it now
- if (kxlight->GetSGNode()->IsDirty())
- kxlight->GetOpenGLMatrix();
- float *dobmat = kxlight->GetOpenGLMatrixPtr()->getPointer();
-
- for (int i=0; i<4; i++)
- for (int j=0; j<4; j++, dobmat++)
- obmat[i][j] = (float)*dobmat;
- int hide = kxlight->GetVisible() ? 0 : 1;
- GPU_lamp_update(lamp, m_layer, hide, obmat);
- GPU_lamp_update_colors(lamp, m_color[0], m_color[1],
- m_color[2], m_energy);
- GPU_lamp_update_distance(lamp, m_distance, m_att1, m_att2, m_coeff_const, m_coeff_lin, m_coeff_quad);
- GPU_lamp_update_spot(lamp, m_spotsize, m_spotblend);
- }
-}
-
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.h
deleted file mode 100644
index a520b18c434..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Mitchell Stokes
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "RAS_ILightObject.h"
-
-class RAS_OpenGLRasterizer;
-struct GPULamp;
-struct Image;
-
-class RAS_OpenGLLight : public RAS_ILightObject
-{
-
- RAS_OpenGLRasterizer *m_rasterizer;
-
- GPULamp *GetGPULamp();
-public:
- RAS_OpenGLLight(RAS_OpenGLRasterizer *ras);
- ~RAS_OpenGLLight();
-
- bool ApplyFixedFunctionLighting(KX_Scene *kxscene, int oblayer, int slot);
-
- RAS_OpenGLLight* Clone() { return new RAS_OpenGLLight(*this); }
-
- bool HasShadowBuffer();
- int GetShadowBindCode();
- MT_Matrix4x4 GetShadowMatrix();
- int GetShadowLayer();
- void BindShadowBuffer(RAS_ICanvas *canvas, KX_Camera *cam, MT_Transform& camtrans);
- void UnbindShadowBuffer();
- Image *GetTextureImage(short texslot);
- void Update();
-};
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.cpp
deleted file mode 100644
index 58b3c61bd05..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.cpp
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "GPU_glew.h"
-
-#include <stdio.h>
-
-#include "RAS_OpenGLOffScreen.h"
-#include "RAS_ICanvas.h"
-
-RAS_OpenGLOffScreen::RAS_OpenGLOffScreen(RAS_ICanvas *canvas)
- :m_canvas(canvas), m_depthrb(0), m_colorrb(0), m_depthtx(0), m_colortx(0),
- m_fbo(0), m_blitfbo(0), m_blitrbo(0), m_blittex(0), m_target(RAS_OFS_RENDER_BUFFER), m_bound(false)
-{
- m_width = 0;
- m_height = 0;
- m_samples = 0;
- m_color = 0;
-}
-
-RAS_OpenGLOffScreen::~RAS_OpenGLOffScreen()
-{
- Destroy();
-}
-
-bool RAS_OpenGLOffScreen::Create(int width, int height, int samples, RAS_OFS_RENDER_TARGET target)
-{
- GLenum status;
- GLuint glo[2], fbo;
- GLint max_samples;
- GLenum textarget;
-
- if (m_fbo) {
- printf("RAS_OpenGLOffScreen::Create(): buffer exists already, destroy first\n");
- return false;
- }
- if (target != RAS_IOffScreen::RAS_OFS_RENDER_BUFFER &&
- target != RAS_IOffScreen::RAS_OFS_RENDER_TEXTURE)
- {
- printf("RAS_OpenGLOffScreen::Create(): invalid offscren target\n");
- return false;
- }
- if (!GLEW_EXT_framebuffer_object) {
- printf("RAS_OpenGLOffScreen::Create(): frame buffer not supported\n");
- return false;
- }
- if (samples) {
- if (!GLEW_EXT_framebuffer_multisample ||
- !GLEW_EXT_framebuffer_blit)
- {
- samples = 0;
- }
- }
- if (samples && target == RAS_OFS_RENDER_TEXTURE) {
- // we need this in addition if we use multisample textures
- if (!GLEW_ARB_texture_multisample ||
- !GLEW_EXT_framebuffer_multisample_blit_scaled)
- {
- samples = 0;
- }
- }
- if (samples) {
- max_samples = 0;
- glGetIntegerv(GL_MAX_SAMPLES_EXT , &max_samples);
- if (samples > max_samples)
- samples = max_samples;
- }
- m_target = target;
- fbo = 0;
- glGenFramebuffersEXT(1, &fbo);
- if (fbo == 0) {
- printf("RAS_OpenGLOffScreen::Create(): frame buffer creation failed: %d\n", (int)glGetError());
- return false;
- }
- m_fbo = fbo;
- glo[0] = glo[1] = 0;
- if (target == RAS_OFS_RENDER_TEXTURE) {
- glGenTextures(2, glo);
- if (glo[0] == 0 || glo[1] == 0) {
- printf("RAS_OpenGLOffScreen::Create(): texture creation failed: %d\n", (int)glGetError());
- goto L_ERROR;
- }
- m_depthtx = glo[0];
- m_color = m_colortx = glo[1];
- if (samples) {
- textarget = GL_TEXTURE_2D_MULTISAMPLE;
- glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_depthtx);
- glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, GL_DEPTH_COMPONENT, width, height, true);
- glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_colortx);
- glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, GL_RGBA8, width, height, true);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
- }
- else {
- textarget = GL_TEXTURE_2D;
- glBindTexture(GL_TEXTURE_2D, m_depthtx);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
- glBindTexture(GL_TEXTURE_2D, m_colortx);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glBindTexture(GL_TEXTURE_2D, 0);
- }
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, textarget, m_depthtx, 0);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, textarget, m_colortx, 0);
- }
- else {
- glGenRenderbuffersEXT(2, glo);
- if (glo[0] == 0 || glo[1] == 0) {
- printf("RAS_OpenGLOffScreen::Create(): render buffer creation failed: %d\n", (int)glGetError());
- goto L_ERROR;
- }
- m_depthrb = glo[0];
- m_colorrb = glo[1];
- glBindRenderbufferEXT(GL_RENDERBUFFER, m_depthrb);
- glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, samples, GL_DEPTH_COMPONENT, width, height);
- glBindRenderbufferEXT(GL_RENDERBUFFER, m_colorrb);
- glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, samples, GL_RGBA8, width, height);
- glBindRenderbufferEXT(GL_RENDERBUFFER, 0);
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER, m_depthrb);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER, m_colorrb);
- }
- status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-
- if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- printf("RAS_OpenGLOffScreen::Create(): frame buffer incomplete: %d\n", (int)status);
- goto L_ERROR;
- }
- m_width = width;
- m_height = height;
-
- if (samples > 0) {
- GLuint blit_tex;
- GLuint blit_fbo;
- // create a secondary FBO to blit to before the pixel can be read
-
- /* write into new single-sample buffer */
- glGenFramebuffersEXT(1, &blit_fbo);
- if (!blit_fbo) {
- printf("RAS_OpenGLOffScreen::Create(): failed creating a FBO for multi-sample offscreen buffer\n");
- goto L_ERROR;
- }
- m_blitfbo = blit_fbo;
- blit_tex = 0;
- if (target == RAS_OFS_RENDER_TEXTURE) {
- glGenTextures(1, &blit_tex);
- if (!blit_tex) {
- printf("RAS_OpenGLOffScreen::Create(): failed creating a texture for multi-sample offscreen buffer\n");
- goto L_ERROR;
- }
- // m_color is the texture where the final render goes, the blit texture in this case
- m_color = m_blittex = blit_tex;
- glBindTexture(GL_TEXTURE_2D, m_blittex);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glBindTexture(GL_TEXTURE_2D, 0);
- glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_blitfbo);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_blittex, 0);
- }
- else {
- /* create render buffer for new 'fbo_blit' */
- glGenRenderbuffersEXT(1, &blit_tex);
- if (!blit_tex) {
- printf("RAS_OpenGLOffScreen::Create(): failed creating a render buffer for multi-sample offscreen buffer\n");
- goto L_ERROR;
- }
- m_blitrbo = blit_tex;
- glBindRenderbufferEXT(GL_RENDERBUFFER, m_blitrbo);
- glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 0, GL_RGBA8, width, height);
- glBindRenderbufferEXT(GL_RENDERBUFFER, 0);
- glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_blitfbo);
- glFramebufferRenderbufferEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER, m_blitrbo);
- }
- status = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER_EXT);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0);
- if (status != GL_FRAMEBUFFER_COMPLETE) {
- printf("RAS_OpenGLOffScreen::Create(): frame buffer for multi-sample offscreen buffer incomplete: %d\n", (int)status);
- goto L_ERROR;
- }
- // remember that multisample is enabled
- m_samples = 1;
- }
- return true;
-
-L_ERROR:
- Destroy();
- return false;
-}
-
-void RAS_OpenGLOffScreen::Destroy()
-{
- GLuint globj;
- Unbind();
- if (m_fbo) {
- globj = m_fbo;
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- if (m_target == RAS_OFS_RENDER_TEXTURE) {
- GLenum textarget = (m_samples) ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, textarget, 0, 0);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, textarget, 0, 0);
- }
- else {
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, 0);
- }
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glDeleteFramebuffersEXT(1, &globj);
- m_fbo = 0;
- }
- if (m_depthrb) {
- globj = m_depthrb;
- glDeleteRenderbuffers(1, &globj);
- m_depthrb = 0;
- }
- if (m_colorrb) {
- globj = m_colorrb;
- glDeleteRenderbuffers(1, &globj);
- m_colorrb = 0;
- }
- if (m_depthtx) {
- globj = m_depthtx;
- glDeleteTextures(1, &globj);
- m_depthtx = 0;
- }
- if (m_colortx) {
- globj = m_colortx;
- glDeleteTextures(1, &globj);
- m_colortx = 0;
- }
- if (m_blitfbo) {
- globj = m_blitfbo;
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_blitfbo);
- if (m_target == RAS_OFS_RENDER_TEXTURE) {
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, 0, 0);
- }
- else {
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, 0);
- }
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glDeleteFramebuffersEXT(1, &globj);
- m_blitfbo = 0;
- }
- if (m_blitrbo) {
- globj = m_blitrbo;
- glDeleteRenderbuffers(1, &globj);
- m_blitrbo = 0;
- }
- if (m_blittex) {
- globj = m_blittex;
- glDeleteTextures(1, &globj);
- m_blittex = 0;
- }
- m_width = 0;
- m_height = 0;
- m_samples = 0;
- m_color = 0;
- m_target = RAS_OFS_RENDER_BUFFER;
-}
-
-void RAS_OpenGLOffScreen::Bind(RAS_OFS_BIND_MODE mode)
-{
- if (m_fbo) {
- if (mode == RAS_OFS_BIND_RENDER) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
- glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
- glViewport(0, 0, m_width, m_height);
- glDisable(GL_SCISSOR_TEST);
- }
- else if (!m_blitfbo) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
- }
- else {
- glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_blitfbo);
- glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
- }
- m_bound = true;
- }
-}
-
-void RAS_OpenGLOffScreen::Unbind()
-{
- if (!m_bound)
- return;
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glEnable(GL_SCISSOR_TEST);
- glReadBuffer(GL_BACK);
- glDrawBuffer(GL_BACK);
- m_bound = false;
-}
-
-void RAS_OpenGLOffScreen::MipMap()
-{
- if (m_color) {
- glBindTexture(GL_TEXTURE_2D, m_color);
- glGenerateMipmap(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, 0);
- }
-}
-
-void RAS_OpenGLOffScreen::Blit()
-{
- if (m_bound && m_blitfbo) {
- // set the draw target to the secondary FBO, the read target is still the multisample FBO
- glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, m_blitfbo);
-
- // sample the primary
- glBlitFramebufferEXT(0, 0, m_width, m_height, 0, 0, m_width, m_height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
-
- // make sure the next glReadPixels will read from the secondary buffer
- glBindFramebufferEXT(GL_READ_FRAMEBUFFER, m_blitfbo);
- }
-}
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.h
deleted file mode 100644
index 3f6845f1e21..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __RAS_OPENGLOFFSCREEN__
-#define __RAS_OPENGLOFFSCREEN__
-
-#include "RAS_IOffScreen.h"
-#include "GPU_extensions.h"
-
-class RAS_ICanvas;
-
-class RAS_OpenGLOffScreen : public RAS_IOffScreen
-{
- RAS_ICanvas *m_canvas;
- // these are GL objects
- unsigned int m_depthrb;
- unsigned int m_colorrb;
- unsigned int m_depthtx;
- unsigned int m_colortx;
- unsigned int m_fbo;
- unsigned int m_blitfbo;
- unsigned int m_blitrbo;
- unsigned int m_blittex;
- RAS_OFS_RENDER_TARGET m_target;
- bool m_bound;
-
-
-public:
- RAS_OpenGLOffScreen(RAS_ICanvas *canvas);
- ~RAS_OpenGLOffScreen();
-
- bool Create(int width, int height, int samples, RAS_OFS_RENDER_TARGET target);
- void Destroy();
- void Bind(RAS_OFS_BIND_MODE mode);
- void Blit();
- void Unbind();
- void MipMap();
-};
-
-#endif /* __RAS_OPENGLOFFSCREEN__ */
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
deleted file mode 100644
index d1c3162f752..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ /dev/null
@@ -1,1694 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
- * \ingroup bgerastogl
- */
-
-
-#include <math.h>
-#include <stdlib.h>
-
-#include "RAS_OpenGLRasterizer.h"
-
-#include "GPU_glew.h"
-
-#include "RAS_ICanvas.h"
-#include "RAS_Rect.h"
-#include "RAS_TexVert.h"
-#include "RAS_MeshObject.h"
-#include "RAS_Polygon.h"
-#include "RAS_ILightObject.h"
-#include "MT_CmMatrix4x4.h"
-
-#include "RAS_OpenGLLight.h"
-#include "RAS_OpenGLOffScreen.h"
-#include "RAS_OpenGLSync.h"
-
-#include "RAS_StorageVA.h"
-#include "RAS_StorageVBO.h"
-
-#include "GPU_draw.h"
-#include "GPU_extensions.h"
-#include "GPU_material.h"
-#include "GPU_shader.h"
-
-extern "C"{
- #include "BLF_api.h"
- #include "BKE_DerivedMesh.h"
- #include "DNA_material_types.h"
-}
-
-
-// XXX Clean these up <<<
-#include "EXP_Value.h"
-#include "KX_Scene.h"
-#include "KX_RayCast.h"
-#include "KX_GameObject.h"
-// >>>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-/**
- * 32x32 bit masks for vinterlace stereo mode
- */
-static GLuint left_eye_vinterlace_mask[32];
-static GLuint right_eye_vinterlace_mask[32];
-
-/**
- * 32x32 bit masks for hinterlace stereo mode.
- * Left eye = &hinterlace_mask[0]
- * Right eye = &hinterlace_mask[1]
- */
-static GLuint hinterlace_mask[33];
-
-RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, RAS_STORAGE_TYPE storage)
- :RAS_IRasterizer(canvas),
- m_2DCanvas(canvas),
- m_fogenabled(false),
- m_time(0.0f),
- m_campos(0.0f, 0.0f, 0.0f),
- m_camortho(false),
- m_camnegscale(false),
- m_stereomode(RAS_STEREO_NOSTEREO),
- m_curreye(RAS_STEREO_LEFTEYE),
- m_eyeseparation(0.0f),
- m_focallength(0.0f),
- m_setfocallength(false),
- m_noOfScanlines(32),
- m_motionblur(0),
- m_motionblurvalue(-1.0f),
- m_usingoverrideshader(false),
- m_clientobject(NULL),
- m_auxilaryClientInfo(NULL),
- m_drawingmode(KX_TEXTURED),
- m_texco_num(0),
- m_attrib_num(0),
- //m_last_alphablend(GPU_BLEND_SOLID),
- m_last_frontface(true),
- m_materialCachingInfo(0),
- m_storage_type(storage)
-{
- m_viewmatrix.setIdentity();
- m_viewinvmatrix.setIdentity();
-
- for (int i = 0; i < 32; i++)
- {
- left_eye_vinterlace_mask[i] = 0x55555555;
- right_eye_vinterlace_mask[i] = 0xAAAAAAAA;
- hinterlace_mask[i] = (i&1)*0xFFFFFFFF;
- }
- hinterlace_mask[32] = 0;
-
- m_prevafvalue = GPU_get_anisotropic();
-
- if (m_storage_type == RAS_VBO /*|| m_storage_type == RAS_AUTO_STORAGE && GLEW_ARB_vertex_buffer_object*/) {
- m_storage = new RAS_StorageVBO(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer);
- }
- else if ((m_storage_type == RAS_VA) || (m_storage_type == RAS_AUTO_STORAGE)) {
- m_storage = new RAS_StorageVA(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer);
- }
- else {
- printf("Unknown rasterizer storage type, falling back to vertex arrays\n");
- m_storage = new RAS_StorageVA(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer);
- }
-
- glGetIntegerv(GL_MAX_LIGHTS, (GLint *) &m_numgllights);
- if (m_numgllights < 8)
- m_numgllights = 8;
-}
-
-
-
-RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer()
-{
- // Restore the previous AF value
- GPU_set_anisotropic(m_prevafvalue);
-
- if (m_storage)
- delete m_storage;
-}
-
-bool RAS_OpenGLRasterizer::Init()
-{
- bool storage_init;
- GPU_state_init();
-
-
- m_ambr = 0.0f;
- m_ambg = 0.0f;
- m_ambb = 0.0f;
-
- glDisable(GL_BLEND);
- glDisable(GL_ALPHA_TEST);
- //m_last_alphablend = GPU_BLEND_SOLID;
- GPU_set_material_alpha_blend(GPU_BLEND_SOLID);
-
- glFrontFace(GL_CCW);
- m_last_frontface = true;
-
- m_redback = 0.4375f;
- m_greenback = 0.4375f;
- m_blueback = 0.4375f;
- m_alphaback = 0.0f;
-
- glClearColor(m_redback,m_greenback,m_blueback,m_alphaback);
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-
- glShadeModel(GL_SMOOTH);
-
- storage_init = m_storage->Init();
-
- return true && storage_init;
-}
-
-
-void RAS_OpenGLRasterizer::SetAmbientColor(float color[3])
-{
- m_ambr = color[0];
- m_ambg = color[1];
- m_ambb = color[2];
-}
-
-void RAS_OpenGLRasterizer::SetAmbient(float factor)
-{
- float ambient[] = {m_ambr * factor, m_ambg * factor, m_ambb * factor, 1.0f};
- glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
-}
-
-void RAS_OpenGLRasterizer::SetBackColor(float color[3])
-{
- m_redback = color[0];
- m_greenback = color[1];
- m_blueback = color[2];
- m_alphaback = 0.0f;
-}
-
-void RAS_OpenGLRasterizer::SetFog(short type, float start, float dist, float intensity, float color[3])
-{
- float params[4] = {color[0], color[1], color[2], 1.0f};
- glFogi(GL_FOG_MODE, GL_LINEAR);
- glFogf(GL_FOG_DENSITY, intensity / 10.0f);
- glFogf(GL_FOG_START, start);
- glFogf(GL_FOG_END, start + dist);
- glFogfv(GL_FOG_COLOR, params);
-}
-
-void RAS_OpenGLRasterizer::EnableFog(bool enable)
-{
- m_fogenabled = enable;
-}
-
-void RAS_OpenGLRasterizer::DisplayFog()
-{
- if ((m_drawingmode >= KX_SOLID) && m_fogenabled) {
- glEnable(GL_FOG);
- }
- else {
- glDisable(GL_FOG);
- }
-}
-
-bool RAS_OpenGLRasterizer::SetMaterial(const RAS_IPolyMaterial& mat)
-{
- return mat.Activate(this, m_materialCachingInfo);
-}
-
-
-
-void RAS_OpenGLRasterizer::Exit()
-{
- m_storage->Exit();
-
- glEnable(GL_CULL_FACE);
- glEnable(GL_DEPTH_TEST);
- glClearDepth(1.0f);
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glClearColor(m_redback, m_greenback, m_blueback, m_alphaback);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glDepthMask (GL_TRUE);
- glDepthFunc(GL_LEQUAL);
- glBlendFunc(GL_ONE, GL_ZERO);
-
- glDisable(GL_POLYGON_STIPPLE);
-
- glDisable(GL_LIGHTING);
- if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2)
- glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
-
- EndFrame();
-}
-
-bool RAS_OpenGLRasterizer::BeginFrame(double time)
-{
- m_time = time;
-
- // Blender camera routine destroys the settings
- if (m_drawingmode < KX_SOLID)
- {
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- }
- else
- {
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_CULL_FACE);
- }
-
- glDisable(GL_BLEND);
- glDisable(GL_ALPHA_TEST);
- //m_last_alphablend = GPU_BLEND_SOLID;
- GPU_set_material_alpha_blend(GPU_BLEND_SOLID);
-
- glFrontFace(GL_CCW);
- m_last_frontface = true;
-
- glShadeModel(GL_SMOOTH);
-
- glEnable(GL_MULTISAMPLE_ARB);
-
- m_2DCanvas->BeginFrame();
-
- // Render Tools
- m_clientobject = NULL;
- m_lastlightlayer = -1;
- m_lastauxinfo = NULL;
- m_lastlighting = true; /* force disable in DisableOpenGLLights() */
- DisableOpenGLLights();
-
- return true;
-}
-
-
-
-void RAS_OpenGLRasterizer::SetDrawingMode(int drawingmode)
-{
- m_drawingmode = drawingmode;
-
- if (m_drawingmode == KX_WIREFRAME)
- glDisable(GL_CULL_FACE);
-
- m_storage->SetDrawingMode(drawingmode);
-}
-
-int RAS_OpenGLRasterizer::GetDrawingMode()
-{
- return m_drawingmode;
-}
-
-
-void RAS_OpenGLRasterizer::SetDepthMask(DepthMask depthmask)
-{
- glDepthMask(depthmask == KX_DEPTHMASK_DISABLED ? GL_FALSE : GL_TRUE);
-}
-
-
-void RAS_OpenGLRasterizer::ClearColorBuffer()
-{
- m_2DCanvas->ClearColor(m_redback,m_greenback,m_blueback,m_alphaback);
- m_2DCanvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER);
-}
-
-
-void RAS_OpenGLRasterizer::ClearDepthBuffer()
-{
- m_2DCanvas->ClearBuffer(RAS_ICanvas::DEPTH_BUFFER);
-}
-
-
-void RAS_OpenGLRasterizer::ClearCachingInfo(void)
-{
- m_materialCachingInfo = 0;
-}
-
-void RAS_OpenGLRasterizer::FlushDebugShapes(SCA_IScene *scene)
-{
- std::vector<OglDebugShape> &debugShapes = m_debugShapes[scene];
- if (debugShapes.empty())
- return;
-
- // DrawDebugLines
- GLboolean light, tex;
-
- light= glIsEnabled(GL_LIGHTING);
- tex= glIsEnabled(GL_TEXTURE_2D);
-
- if (light) glDisable(GL_LIGHTING);
- if (tex) glDisable(GL_TEXTURE_2D);
-
- // draw lines
- glBegin(GL_LINES);
- for (unsigned int i = 0; i < debugShapes.size(); i++) {
- if (debugShapes[i].m_type != OglDebugShape::LINE)
- continue;
- glColor4f(debugShapes[i].m_color[0], debugShapes[i].m_color[1], debugShapes[i].m_color[2], 1.0f);
- const MT_Scalar *fromPtr = &debugShapes[i].m_pos.x();
- const MT_Scalar *toPtr= &debugShapes[i].m_param.x();
- glVertex3fv(fromPtr);
- glVertex3fv(toPtr);
- }
- glEnd();
-
- // draw circles
- for (unsigned int i = 0; i < debugShapes.size(); i++) {
- if (debugShapes[i].m_type != OglDebugShape::CIRCLE)
- continue;
- glBegin(GL_LINE_LOOP);
- glColor4f(debugShapes[i].m_color[0], debugShapes[i].m_color[1], debugShapes[i].m_color[2], 1.0f);
-
- static const MT_Vector3 worldUp(0.0f, 0.0f, 1.0f);
- MT_Vector3 norm = debugShapes[i].m_param;
- MT_Matrix3x3 tr;
- if (norm.fuzzyZero() || norm == worldUp)
- {
- tr.setIdentity();
- }
- else
- {
- MT_Vector3 xaxis, yaxis;
- xaxis = MT_cross(norm, worldUp);
- yaxis = MT_cross(xaxis, norm);
- tr.setValue(xaxis.x(), xaxis.y(), xaxis.z(),
- yaxis.x(), yaxis.y(), yaxis.z(),
- norm.x(), norm.y(), norm.z());
- }
- MT_Scalar rad = debugShapes[i].m_param2.x();
- int n = (int)debugShapes[i].m_param2.y();
- for (int j = 0; j<n; j++)
- {
- MT_Scalar theta = j*(float)M_PI*2/n;
- MT_Vector3 pos(cosf(theta) * rad, sinf(theta) * rad, 0.0f);
- pos = pos*tr;
- pos += debugShapes[i].m_pos;
- const MT_Scalar* posPtr = &pos.x();
- glVertex3fv(posPtr);
- }
- glEnd();
- }
-
- if (light) glEnable(GL_LIGHTING);
- if (tex) glEnable(GL_TEXTURE_2D);
-
- debugShapes.clear();
-}
-
-void RAS_OpenGLRasterizer::EndFrame()
-{
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-
- glDisable(GL_MULTISAMPLE_ARB);
-
- m_2DCanvas->EndFrame();
-}
-
-void RAS_OpenGLRasterizer::SetRenderArea()
-{
- RAS_Rect area;
- // only above/below stereo method needs viewport adjustment
- switch (m_stereomode)
- {
- case RAS_STEREO_ABOVEBELOW:
- switch (m_curreye) {
- case RAS_STEREO_LEFTEYE:
- // upper half of window
- area.SetLeft(0);
- area.SetBottom(m_2DCanvas->GetHeight() -
- int(m_2DCanvas->GetHeight() - m_noOfScanlines) / 2);
-
- area.SetRight(int(m_2DCanvas->GetWidth()));
- area.SetTop(int(m_2DCanvas->GetHeight()));
- m_2DCanvas->SetDisplayArea(&area);
- break;
- case RAS_STEREO_RIGHTEYE:
- // lower half of window
- area.SetLeft(0);
- area.SetBottom(0);
- area.SetRight(int(m_2DCanvas->GetWidth()));
- area.SetTop(int(m_2DCanvas->GetHeight() - m_noOfScanlines) / 2);
- m_2DCanvas->SetDisplayArea(&area);
- break;
- }
- break;
- case RAS_STEREO_3DTVTOPBOTTOM:
- switch (m_curreye) {
- case RAS_STEREO_LEFTEYE:
- // upper half of window
- area.SetLeft(0);
- area.SetBottom(m_2DCanvas->GetHeight() -
- m_2DCanvas->GetHeight() / 2);
-
- area.SetRight(m_2DCanvas->GetWidth());
- area.SetTop(m_2DCanvas->GetHeight());
- m_2DCanvas->SetDisplayArea(&area);
- break;
- case RAS_STEREO_RIGHTEYE:
- // lower half of window
- area.SetLeft(0);
- area.SetBottom(0);
- area.SetRight(m_2DCanvas->GetWidth());
- area.SetTop(m_2DCanvas->GetHeight() / 2);
- m_2DCanvas->SetDisplayArea(&area);
- break;
- }
- break;
- case RAS_STEREO_SIDEBYSIDE:
- switch (m_curreye)
- {
- case RAS_STEREO_LEFTEYE:
- // Left half of window
- area.SetLeft(0);
- area.SetBottom(0);
- area.SetRight(m_2DCanvas->GetWidth()/2);
- area.SetTop(m_2DCanvas->GetHeight());
- m_2DCanvas->SetDisplayArea(&area);
- break;
- case RAS_STEREO_RIGHTEYE:
- // Right half of window
- area.SetLeft(m_2DCanvas->GetWidth()/2);
- area.SetBottom(0);
- area.SetRight(m_2DCanvas->GetWidth());
- area.SetTop(m_2DCanvas->GetHeight());
- m_2DCanvas->SetDisplayArea(&area);
- break;
- }
- break;
- default:
- // every available pixel
- area.SetLeft(0);
- area.SetBottom(0);
- area.SetRight(int(m_2DCanvas->GetWidth()));
- area.SetTop(int(m_2DCanvas->GetHeight()));
- m_2DCanvas->SetDisplayArea(&area);
- break;
- }
-}
-
-void RAS_OpenGLRasterizer::SetStereoMode(const StereoMode stereomode)
-{
- m_stereomode = stereomode;
-}
-
-RAS_IRasterizer::StereoMode RAS_OpenGLRasterizer::GetStereoMode()
-{
- return m_stereomode;
-}
-
-bool RAS_OpenGLRasterizer::Stereo()
-{
- if (m_stereomode > RAS_STEREO_NOSTEREO) // > 0
- return true;
- else
- return false;
-}
-
-bool RAS_OpenGLRasterizer::InterlacedStereo()
-{
- return m_stereomode == RAS_STEREO_VINTERLACE || m_stereomode == RAS_STEREO_INTERLACED;
-}
-
-void RAS_OpenGLRasterizer::SetEye(const StereoEye eye)
-{
- m_curreye = eye;
- switch (m_stereomode)
- {
- case RAS_STEREO_QUADBUFFERED:
- glDrawBuffer(m_curreye == RAS_STEREO_LEFTEYE ? GL_BACK_LEFT : GL_BACK_RIGHT);
- break;
- case RAS_STEREO_ANAGLYPH:
- if (m_curreye == RAS_STEREO_LEFTEYE) {
- glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
- }
- else {
- //glAccum(GL_LOAD, 1.0f);
- glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE);
- ClearDepthBuffer();
- }
- break;
- case RAS_STEREO_VINTERLACE:
- {
- // OpenGL stippling is deprecated, it is no longer possible to affect all shaders
- // this way, offscreen rendering and then compositing may be the better solution
- glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple((const GLubyte*) ((m_curreye == RAS_STEREO_LEFTEYE) ? left_eye_vinterlace_mask : right_eye_vinterlace_mask));
- if (m_curreye == RAS_STEREO_RIGHTEYE)
- ClearDepthBuffer();
- break;
- }
- case RAS_STEREO_INTERLACED:
- {
- glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple((const GLubyte*) &hinterlace_mask[m_curreye == RAS_STEREO_LEFTEYE?0:1]);
- if (m_curreye == RAS_STEREO_RIGHTEYE)
- ClearDepthBuffer();
- break;
- }
- default:
- break;
- }
-}
-
-RAS_IRasterizer::StereoEye RAS_OpenGLRasterizer::GetEye()
-{
- return m_curreye;
-}
-
-
-void RAS_OpenGLRasterizer::SetEyeSeparation(const float eyeseparation)
-{
- m_eyeseparation = eyeseparation;
-}
-
-float RAS_OpenGLRasterizer::GetEyeSeparation()
-{
- return m_eyeseparation;
-}
-
-void RAS_OpenGLRasterizer::SetFocalLength(const float focallength)
-{
- m_focallength = focallength;
- m_setfocallength = true;
-}
-
-float RAS_OpenGLRasterizer::GetFocalLength()
-{
- return m_focallength;
-}
-
-RAS_IOffScreen *RAS_OpenGLRasterizer::CreateOffScreen(int width, int height, int samples, int target)
-{
- RAS_IOffScreen *ofs;
-
- ofs = new RAS_OpenGLOffScreen(m_2DCanvas);
-
- if (!ofs->Create(width, height, samples, (RAS_IOffScreen::RAS_OFS_RENDER_TARGET)target)) {
- delete ofs;
- return NULL;
- }
- return ofs;
-}
-
-RAS_ISync *RAS_OpenGLRasterizer::CreateSync(int type)
-{
- RAS_ISync *sync;
-
- sync = new RAS_OpenGLSync();
-
- if (!sync->Create((RAS_ISync::RAS_SYNC_TYPE)type)) {
- delete sync;
- return NULL;
- }
- return sync;
-}
-
-void RAS_OpenGLRasterizer::SwapBuffers()
-{
- m_2DCanvas->SwapBuffers();
-}
-
-
-
-const MT_Matrix4x4& RAS_OpenGLRasterizer::GetViewMatrix() const
-{
- return m_viewmatrix;
-}
-
-const MT_Matrix4x4& RAS_OpenGLRasterizer::GetViewInvMatrix() const
-{
- return m_viewinvmatrix;
-}
-
-void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms,
- class RAS_IPolyMaterial* polymat)
-{
- bool obcolor = ms.m_bObjectColor;
- MT_Vector4& rgba = ms.m_RGBAcolor;
- RAS_MeshSlot::iterator it;
-
- const STR_String& mytext = ((CValue*)m_clientobject)->GetPropertyText("Text");
-
- // handle object color
- if (obcolor) {
- glDisableClientState(GL_COLOR_ARRAY);
- glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
- }
- else
- glEnableClientState(GL_COLOR_ARRAY);
-
- for (ms.begin(it); !ms.end(it); ms.next(it)) {
- RAS_TexVert *vertex;
- size_t i, j, numvert;
-
- numvert = it.array->m_type;
-
- if (it.array->m_type == RAS_DisplayArray::LINE) {
- // line drawing, no text
- glBegin(GL_LINES);
-
- for (i=0; i<it.totindex; i+=2)
- {
- vertex = &it.vertex[it.index[i]];
- glVertex3fv(vertex->getXYZ());
-
- vertex = &it.vertex[it.index[i+1]];
- glVertex3fv(vertex->getXYZ());
- }
-
- glEnd();
- }
- else {
- // triangle and quad text drawing
- for (i=0; i<it.totindex; i+=numvert)
- {
- float v[4][3];
- const float *v_ptr[4] = {NULL};
- const float *uv_ptr[4] = {NULL};
- int glattrib, unit;
-
- for (j=0; j<numvert; j++) {
- vertex = &it.vertex[it.index[i+j]];
-
- v[j][0] = vertex->getXYZ()[0];
- v[j][1] = vertex->getXYZ()[1];
- v[j][2] = vertex->getXYZ()[2];
- v_ptr[j] = v[j];
-
- uv_ptr[j] = vertex->getUV(0);
- }
-
- // find the right opengl attribute
- glattrib = -1;
- if (GLEW_ARB_vertex_program)
- for (unit=0; unit<m_attrib_num; unit++)
- if (m_attrib[unit] == RAS_TEXCO_UV)
- glattrib = unit;
-
- GPU_render_text(
- polymat->GetDrawingMode(), mytext, mytext.Length(), polymat->GetMCol(),
- v_ptr, uv_ptr, glattrib);
-
- ClearCachingInfo();
- }
- }
- }
-
- glDisableClientState(GL_COLOR_ARRAY);
-}
-
-void RAS_OpenGLRasterizer::SetTexCoordNum(int num)
-{
- m_texco_num = num;
- if (m_texco_num > RAS_MAX_TEXCO)
- m_texco_num = RAS_MAX_TEXCO;
-}
-
-void RAS_OpenGLRasterizer::SetAttribNum(int num)
-{
- m_attrib_num = num;
- if (m_attrib_num > RAS_MAX_ATTRIB)
- m_attrib_num = RAS_MAX_ATTRIB;
-}
-
-void RAS_OpenGLRasterizer::SetTexCoord(TexCoGen coords, int unit)
-{
- // this changes from material to material
- if (unit < RAS_MAX_TEXCO)
- m_texco[unit] = coords;
-}
-
-void RAS_OpenGLRasterizer::SetAttrib(TexCoGen coords, int unit, int layer)
-{
- // this changes from material to material
- if (unit < RAS_MAX_ATTRIB) {
- m_attrib[unit] = coords;
- m_attrib_layer[unit] = layer;
- }
-}
-
-void RAS_OpenGLRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
-{
- if (ms.m_pDerivedMesh)
- DrawDerivedMesh(ms);
- else
- m_storage->IndexPrimitives(ms);
-}
-
-// Code for hooking into Blender's mesh drawing for derived meshes.
-// If/when we use more of Blender's drawing code, we may be able to
-// clean this up
-static bool current_wireframe;
-static RAS_MaterialBucket *current_bucket;
-static RAS_IPolyMaterial *current_polymat;
-static RAS_MeshSlot *current_ms;
-static RAS_MeshObject *current_mesh;
-static int current_blmat_nr;
-static GPUVertexAttribs current_gpu_attribs;
-static int CheckMaterialDM(int matnr, void *attribs)
-{
- // only draw the current material
- if (matnr != current_blmat_nr)
- return 0;
- GPUVertexAttribs *gattribs = (GPUVertexAttribs *)attribs;
- if (gattribs)
- memcpy(gattribs, &current_gpu_attribs, sizeof(GPUVertexAttribs));
- return 1;
-}
-
-void RAS_OpenGLRasterizer::DrawDerivedMesh(class RAS_MeshSlot &ms)
-{
- // mesh data is in derived mesh
- current_bucket = ms.m_bucket;
- current_polymat = current_bucket->GetPolyMaterial();
- current_ms = &ms;
- current_mesh = ms.m_mesh;
- current_wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME;
- // MCol *mcol = (MCol*)ms.m_pDerivedMesh->getFaceDataArray(ms.m_pDerivedMesh, CD_MCOL); /* UNUSED */
-
- // handle two-side
- if (current_polymat->GetDrawingMode() & RAS_IRasterizer::KX_BACKCULL)
- this->SetCullFace(true);
- else
- this->SetCullFace(false);
-
-#if 0
- if (current_polymat->GetFlag() & RAS_BLENDERGLSL)
-#endif
- {
- // GetMaterialIndex return the original mface material index,
- // increment by 1 to match what derived mesh is doing
- current_blmat_nr = current_polymat->GetMaterialIndex()+1;
- // For GLSL we need to retrieve the GPU material attribute
- Material* blmat = current_polymat->GetBlenderMaterial();
- Scene* blscene = current_polymat->GetBlenderScene();
- if (!current_wireframe && blscene && blmat)
- GPU_material_vertex_attributes(GPU_material_from_blender(blscene, blmat, false), &current_gpu_attribs);
- else
- memset(&current_gpu_attribs, 0, sizeof(current_gpu_attribs));
- // DM draw can mess up blending mode, restore at the end
- int current_blend_mode = GPU_get_material_alpha_blend();
- ms.m_pDerivedMesh->drawFacesGLSL(ms.m_pDerivedMesh, CheckMaterialDM);
- GPU_set_material_alpha_blend(current_blend_mode);
- }
-}
-
-void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat)
-{
- glMatrixMode(GL_PROJECTION);
- float* matrix = &mat(0, 0);
- glLoadMatrixf(matrix);
-
- m_camortho = (mat(3, 3) != 0.0f);
-}
-
-void RAS_OpenGLRasterizer::SetProjectionMatrix(const MT_Matrix4x4 & mat)
-{
- glMatrixMode(GL_PROJECTION);
- float matrix[16];
- /* Get into argument. Looks a bit dodgy, but it's ok. */
- mat.getValue(matrix);
- glLoadMatrixf(matrix);
-
- m_camortho = (mat[3][3] != 0.0f);
-}
-
-MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
- float left,
- float right,
- float bottom,
- float top,
- float frustnear,
- float frustfar,
- float focallength,
- bool
-) {
- MT_Matrix4x4 result;
- float mat[16];
-
- // correction for stereo
- if (Stereo())
- {
- float near_div_focallength;
- float offset;
-
- // if Rasterizer.setFocalLength is not called we use the camera focallength
- if (!m_setfocallength)
- // if focallength is null we use a value known to be reasonable
- m_focallength = (focallength == 0.f) ? m_eyeseparation * 30.0f
- : focallength;
-
- near_div_focallength = frustnear / m_focallength;
- offset = 0.5f * m_eyeseparation * near_div_focallength;
- switch (m_curreye) {
- case RAS_STEREO_LEFTEYE:
- left += offset;
- right += offset;
- break;
- case RAS_STEREO_RIGHTEYE:
- left -= offset;
- right -= offset;
- break;
- }
- // leave bottom and top untouched
- if (m_stereomode == RAS_STEREO_3DTVTOPBOTTOM) {
- // restore the vertical frustum because the 3DTV will
- // expand the top and bottom part to the full size of the screen
- bottom *= 2.0f;
- top *= 2.0f;
- }
- }
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(left, right, bottom, top, frustnear, frustfar);
-
- glGetFloatv(GL_PROJECTION_MATRIX, mat);
- result.setValue(mat);
-
- return result;
-}
-
-MT_Matrix4x4 RAS_OpenGLRasterizer::GetOrthoMatrix(
- float left,
- float right,
- float bottom,
- float top,
- float frustnear,
- float frustfar
-) {
- MT_Matrix4x4 result;
- float mat[16];
-
- // stereo is meaningless for orthographic, disable it
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(left, right, bottom, top, frustnear, frustfar);
-
- glGetFloatv(GL_PROJECTION_MATRIX, mat);
- result.setValue(mat);
-
- return result;
-}
-
-
-// next arguments probably contain redundant info, for later...
-void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat,
- const MT_Matrix3x3 & camOrientMat3x3,
- const MT_Point3 & pos,
- const MT_Vector3 &scale,
- bool perspective)
-{
- m_viewmatrix = mat;
-
- // correction for stereo
- if (Stereo() && perspective)
- {
- MT_Vector3 unitViewDir(0.0f, -1.0f, 0.0f); // minus y direction, Blender convention
- MT_Vector3 unitViewupVec(0.0f, 0.0f, 1.0f);
- MT_Vector3 viewDir, viewupVec;
- MT_Vector3 eyeline;
-
- // actual viewDir
- viewDir = camOrientMat3x3 * unitViewDir; // this is the moto convention, vector on right hand side
- // actual viewup vec
- viewupVec = camOrientMat3x3 * unitViewupVec;
-
- // vector between eyes
- eyeline = viewDir.cross(viewupVec);
-
- switch (m_curreye) {
- case RAS_STEREO_LEFTEYE:
- {
- // translate to left by half the eye distance
- MT_Transform transform;
- transform.setIdentity();
- transform.translate(-(eyeline * m_eyeseparation / 2.0f));
- m_viewmatrix *= transform;
- }
- break;
- case RAS_STEREO_RIGHTEYE:
- {
- // translate to right by half the eye distance
- MT_Transform transform;
- transform.setIdentity();
- transform.translate(eyeline * m_eyeseparation / 2.0f);
- m_viewmatrix *= transform;
- }
- break;
- }
- }
-
- bool negX = (scale[0] < 0.0f);
- bool negY = (scale[1] < 0.0f);
- bool negZ = (scale[2] < 0.0f);
- if (negX || negY || negZ) {
- m_viewmatrix.tscale((negX)?-1.0f:1.0f, (negY)?-1.0f:1.0f, (negZ)?-1.0f:1.0f, 1.0);
- }
- m_viewinvmatrix = m_viewmatrix;
- m_viewinvmatrix.invert();
-
- // note: getValue gives back column major as needed by OpenGL
- MT_Scalar glviewmat[16];
- m_viewmatrix.getValue(glviewmat);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadMatrixf(glviewmat);
- m_campos = pos;
- m_camnegscale = negX ^ negY ^ negZ;
-}
-
-
-const MT_Point3& RAS_OpenGLRasterizer::GetCameraPosition()
-{
- return m_campos;
-}
-
-bool RAS_OpenGLRasterizer::GetCameraOrtho()
-{
- return m_camortho;
-}
-
-void RAS_OpenGLRasterizer::SetCullFace(bool enable)
-{
- if (enable)
- glEnable(GL_CULL_FACE);
- else
- glDisable(GL_CULL_FACE);
-}
-
-void RAS_OpenGLRasterizer::SetLines(bool enable)
-{
- if (enable)
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- else
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-}
-
-void RAS_OpenGLRasterizer::SetSpecularity(float specX,
- float specY,
- float specZ,
- float specval)
-{
- GLfloat mat_specular[] = {specX, specY, specZ, specval};
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
-}
-
-
-
-void RAS_OpenGLRasterizer::SetShinyness(float shiny)
-{
- GLfloat mat_shininess[] = { shiny };
- glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
-}
-
-
-
-void RAS_OpenGLRasterizer::SetDiffuse(float difX,float difY,float difZ,float diffuse)
-{
- GLfloat mat_diffuse [] = {difX, difY,difZ, diffuse};
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
-}
-
-void RAS_OpenGLRasterizer::SetEmissive(float eX, float eY, float eZ, float e)
-{
- GLfloat mat_emit [] = {eX,eY,eZ,e};
- glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mat_emit);
-}
-
-
-double RAS_OpenGLRasterizer::GetTime()
-{
- return m_time;
-}
-
-void RAS_OpenGLRasterizer::SetPolygonOffset(float mult, float add)
-{
- glPolygonOffset(mult, add);
- GLint mode = GL_POLYGON_OFFSET_FILL;
- if (m_drawingmode < KX_SHADED)
- mode = GL_POLYGON_OFFSET_LINE;
- if (mult != 0.0f || add != 0.0f)
- glEnable(mode);
- else
- glDisable(mode);
-}
-
-void RAS_OpenGLRasterizer::EnableMotionBlur(float motionblurvalue)
-{
- /* don't just set m_motionblur to 1, but check if it is 0 so
- * we don't reset a motion blur that is already enabled */
- if (m_motionblur == 0)
- m_motionblur = 1;
- m_motionblurvalue = motionblurvalue;
-}
-
-void RAS_OpenGLRasterizer::DisableMotionBlur()
-{
- m_motionblur = 0;
- m_motionblurvalue = -1.0f;
-}
-
-void RAS_OpenGLRasterizer::SetAlphaBlend(int alphablend)
-{
- /* Variance shadow maps don't handle alpha well, best to not allow it for now */
- if (m_drawingmode == KX_SHADOW && m_usingoverrideshader)
- GPU_set_material_alpha_blend(GPU_BLEND_SOLID);
- else
- GPU_set_material_alpha_blend(alphablend);
-/*
- if (alphablend == m_last_alphablend)
- return;
-
- if (alphablend == GPU_BLEND_SOLID) {
- glDisable(GL_BLEND);
- glDisable(GL_ALPHA_TEST);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
- else if (alphablend == GPU_BLEND_ADD) {
- glBlendFunc(GL_ONE, GL_ONE);
- glEnable(GL_BLEND);
- glDisable(GL_ALPHA_TEST);
- }
- else if (alphablend == GPU_BLEND_ALPHA) {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- glEnable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, 0.0f);
- }
- else if (alphablend == GPU_BLEND_CLIP) {
- glDisable(GL_BLEND);
- glEnable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, 0.5f);
- }
-
- m_last_alphablend = alphablend;
-*/
-}
-
-void RAS_OpenGLRasterizer::SetFrontFace(bool ccw)
-{
- if (m_camnegscale)
- ccw = !ccw;
-
- if (m_last_frontface == ccw)
- return;
-
- if (ccw)
- glFrontFace(GL_CCW);
- else
- glFrontFace(GL_CW);
-
- m_last_frontface = ccw;
-}
-
-void RAS_OpenGLRasterizer::SetAnisotropicFiltering(short level)
-{
- GPU_set_anisotropic((float)level);
-}
-
-short RAS_OpenGLRasterizer::GetAnisotropicFiltering()
-{
- return (short)GPU_get_anisotropic();
-}
-
-void RAS_OpenGLRasterizer::SetMipmapping(MipmapOption val)
-{
- if (val == RAS_IRasterizer::RAS_MIPMAP_LINEAR)
- {
- GPU_set_linear_mipmap(1);
- GPU_set_mipmap(1);
- }
- else if (val == RAS_IRasterizer::RAS_MIPMAP_NEAREST)
- {
- GPU_set_linear_mipmap(0);
- GPU_set_mipmap(1);
- }
- else
- {
- GPU_set_linear_mipmap(0);
- GPU_set_mipmap(0);
- }
-}
-
-RAS_IRasterizer::MipmapOption RAS_OpenGLRasterizer::GetMipmapping()
-{
- if (GPU_get_mipmap()) {
- if (GPU_get_linear_mipmap()) {
- return RAS_IRasterizer::RAS_MIPMAP_LINEAR;
- }
- else {
- return RAS_IRasterizer::RAS_MIPMAP_NEAREST;
- }
- }
- else {
- return RAS_IRasterizer::RAS_MIPMAP_NONE;
- }
-}
-
-void RAS_OpenGLRasterizer::SetUsingOverrideShader(bool val)
-{
- m_usingoverrideshader = val;
-}
-
-bool RAS_OpenGLRasterizer::GetUsingOverrideShader()
-{
- return m_usingoverrideshader;
-}
-
-/**
- * Render Tools
- */
-
-/* ProcessLighting performs lighting on objects. the layer is a bitfield that
- * contains layer information. There are 20 'official' layers in blender. A
- * light is applied on an object only when they are in the same layer. OpenGL
- * has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in
- * a scene. */
-
-void RAS_OpenGLRasterizer::ProcessLighting(bool uselights, const MT_Transform& viewmat)
-{
- bool enable = false;
- int layer= -1;
-
- /* find the layer */
- if (uselights) {
- if (m_clientobject)
- layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer();
- }
-
- /* avoid state switching */
- if (m_lastlightlayer == layer && m_lastauxinfo == m_auxilaryClientInfo)
- return;
-
- m_lastlightlayer = layer;
- m_lastauxinfo = m_auxilaryClientInfo;
-
- /* enable/disable lights as needed */
- if (layer >= 0) {
- //enable = ApplyLights(layer, viewmat);
- // taken from blender source, incompatibility between Blender Object / GameObject
- KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo;
- float glviewmat[16];
- unsigned int count;
- std::vector<RAS_OpenGLLight*>::iterator lit = m_lights.begin();
-
- for (count=0; count<m_numgllights; count++)
- glDisable((GLenum)(GL_LIGHT0+count));
-
- viewmat.getValue(glviewmat);
-
- glPushMatrix();
- glLoadMatrixf(glviewmat);
- for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit)
- {
- RAS_OpenGLLight* light = (*lit);
-
- if (light->ApplyFixedFunctionLighting(kxscene, layer, count))
- count++;
- }
- glPopMatrix();
-
- enable = count > 0;
- }
-
- if (enable)
- EnableOpenGLLights();
- else
- DisableOpenGLLights();
-}
-
-void RAS_OpenGLRasterizer::EnableOpenGLLights()
-{
- if (m_lastlighting == true)
- return;
-
- glEnable(GL_LIGHTING);
- glEnable(GL_COLOR_MATERIAL);
-
- glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
- glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (GetCameraOrtho())? GL_FALSE: GL_TRUE);
- if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2)
- glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
-
- m_lastlighting = true;
-}
-
-void RAS_OpenGLRasterizer::DisableOpenGLLights()
-{
- if (m_lastlighting == false)
- return;
-
- glDisable(GL_LIGHTING);
- glDisable(GL_COLOR_MATERIAL);
-
- m_lastlighting = false;
-}
-
-RAS_ILightObject *RAS_OpenGLRasterizer::CreateLight()
-{
- return new RAS_OpenGLLight(this);
-}
-
-void RAS_OpenGLRasterizer::AddLight(RAS_ILightObject* lightobject)
-{
- RAS_OpenGLLight* gllight = dynamic_cast<RAS_OpenGLLight*>(lightobject);
- assert(gllight);
- m_lights.push_back(gllight);
-}
-
-void RAS_OpenGLRasterizer::RemoveLight(RAS_ILightObject* lightobject)
-{
- RAS_OpenGLLight* gllight = dynamic_cast<RAS_OpenGLLight*>(lightobject);
- assert(gllight);
-
- std::vector<RAS_OpenGLLight*>::iterator lit =
- std::find(m_lights.begin(),m_lights.end(),gllight);
-
- if (!(lit==m_lights.end()))
- m_lights.erase(lit);
-}
-
-bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast *result, float *oglmatrix)
-{
- if (result->m_hitMesh) {
-
- RAS_Polygon* poly = result->m_hitMesh->GetPolygon(result->m_hitPolygon);
- if (!poly->IsVisible())
- return false;
-
- MT_Vector3 resultnormal(result->m_hitNormal);
- MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
- MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized();
- left = (dir.cross(resultnormal)).safe_normalized();
- // for the up vector, we take the 'resultnormal' returned by the physics
-
- float maat[16] = {left[0], left[1], left[2], 0,
- dir[0], dir[1], dir[2], 0,
- resultnormal[0], resultnormal[1], resultnormal[2], 0,
- 0, 0, 0, 1};
-
- glTranslatef(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
- //glMultMatrixd(oglmatrix);
- glMultMatrixf(maat);
- return true;
- }
- else {
- return false;
- }
-}
-
-void RAS_OpenGLRasterizer::applyTransform(float* oglmatrix,int objectdrawmode )
-{
- /* FIXME:
- blender: intern/moto/include/MT_Vector3.inl:42: MT_Vector3 operator/(const
- MT_Vector3&, double): Assertion `!MT_fuzzyZero(s)' failed.
-
- Program received signal SIGABRT, Aborted.
- [Switching to Thread 16384 (LWP 1519)]
- 0x40477571 in kill () from /lib/libc.so.6
- (gdb) bt
- #7 0x08334368 in MT_Vector3::normalized() const ()
- #8 0x0833e6ec in RAS_OpenGLRasterizer::applyTransform(RAS_IRasterizer*, double*, int) ()
- */
-
- if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED ||
- objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED)
- {
- // rotate the billboard/halo
- //page 360/361 3D Game Engine Design, David Eberly for a discussion
- // on screen aligned and axis aligned billboards
- // assumed is that the preprocessor transformed all billboard polygons
- // so that their normal points into the positive x direction (1.0f, 0.0f, 0.0f)
- // when new parenting for objects is done, this rotation
- // will be moved into the object
-
- MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]);
- MT_Point3 campos = GetCameraPosition();
- MT_Vector3 dir = (campos - objpos).safe_normalized();
- MT_Vector3 up(0,0,1.0f);
-
- KX_GameObject* gameobj = (KX_GameObject*)m_clientobject;
- // get scaling of halo object
- MT_Vector3 size = gameobj->GetSGNode()->GetWorldScaling();
-
- bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned
- if (screenaligned)
- {
- up = (up - up.dot(dir) * dir).safe_normalized();
- } else
- {
- dir = (dir - up.dot(dir)*up).safe_normalized();
- }
-
- MT_Vector3 left = dir.normalized();
- dir = (up.cross(left)).normalized();
-
- // we have calculated the row vectors, now we keep
- // local scaling into account:
-
- left *= size[0];
- dir *= size[1];
- up *= size[2];
-
- float maat[16] = {left[0], left[1], left[2], 0,
- dir[0], dir[1], dir[2], 0,
- up[0], up[1], up[2], 0,
- 0, 0, 0, 1};
-
- glTranslatef(objpos[0],objpos[1],objpos[2]);
- glMultMatrixf(maat);
-
- }
- else {
- if (objectdrawmode & RAS_IPolyMaterial::SHADOW)
- {
- // shadow must be cast to the ground, physics system needed here!
- MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
- KX_GameObject *gameobj = (KX_GameObject*)m_clientobject;
- MT_Vector3 direction = MT_Vector3(0,0,-1);
-
- direction.normalize();
- direction *= 100000;
-
- MT_Point3 topoint = frompoint + direction;
-
- KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo;
- PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment();
- PHY_IPhysicsController* physics_controller = gameobj->GetPhysicsController();
-
- KX_GameObject *parent = gameobj->GetParent();
- if (!physics_controller && parent)
- physics_controller = parent->GetPhysicsController();
-
- KX_RayCast::Callback<RAS_OpenGLRasterizer, float> callback(this, physics_controller, oglmatrix);
- if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))
- {
- // couldn't find something to cast the shadow on...
- glMultMatrixf(oglmatrix);
- }
- else
- { // we found the "ground", but the cast matrix doesn't take
- // scaling in consideration, so we must apply the object scale
- MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale();
- glScalef(size[0], size[1], size[2]);
- }
- } else
- {
-
- // 'normal' object
- glMultMatrixf(oglmatrix);
- }
- }
-}
-
-static void DisableForText()
-{
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* needed for texture fonts otherwise they render as wireframe */
-
- glDisable(GL_BLEND);
- glDisable(GL_ALPHA_TEST);
-
- glDisable(GL_LIGHTING);
- glDisable(GL_COLOR_MATERIAL);
-
- if (GLEW_ARB_multitexture) {
- for (int i=0; i<RAS_MAX_TEXCO; i++) {
- glActiveTextureARB(GL_TEXTURE0_ARB+i);
-
- if (GLEW_ARB_texture_cube_map) {
- glDisable(GL_TEXTURE_CUBE_MAP_ARB);
- glDisable(GL_TEXTURE_GEN_S);
- glDisable(GL_TEXTURE_GEN_T);
- glDisable(GL_TEXTURE_GEN_Q);
- glDisable(GL_TEXTURE_GEN_R);
- }
- glDisable(GL_TEXTURE_2D);
- }
-
- glActiveTextureARB(GL_TEXTURE0_ARB);
- }
- else {
- if (GLEW_ARB_texture_cube_map)
- glDisable(GL_TEXTURE_CUBE_MAP_ARB);
-
- glDisable(GL_TEXTURE_2D);
- }
-}
-
-void RAS_OpenGLRasterizer::RenderBox2D(int xco,
- int yco,
- int width,
- int height,
- float percentage)
-{
- /* This is a rather important line :( The gl-mode hasn't been left
- * behind quite as neatly as we'd have wanted to. I don't know
- * what cause it, though :/ .*/
- glDisable(GL_DEPTH_TEST);
-
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
-
- glOrtho(0, width, 0, height, -100, 100);
-
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- yco = height - yco;
- int barsize = 50;
-
- /* draw in black first */
- glColor3ub(0, 0, 0);
- glBegin(GL_QUADS);
- glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1 + 10);
- glVertex2f(xco + 1, yco - 1 + 10);
- glVertex2f(xco + 1, yco - 1);
- glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1);
- glEnd();
-
- glColor3ub(255, 255, 255);
- glBegin(GL_QUADS);
- glVertex2f(xco + 1 + barsize * percentage, yco + 10);
- glVertex2f(xco, yco + 10);
- glVertex2f(xco, yco);
- glVertex2f(xco + 1 + barsize * percentage, yco);
- glEnd();
-
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glEnable(GL_DEPTH_TEST);
-}
-
-void RAS_OpenGLRasterizer::RenderText3D(
- int fontid, const char *text, int size, int dpi,
- const float color[4], const float mat[16], float aspect)
-{
- /* gl prepping */
- DisableForText();
-
- /* the actual drawing */
- glColor4fv(color);
-
- /* multiply the text matrix by the object matrix */
- BLF_enable(fontid, BLF_MATRIX|BLF_ASPECT);
- BLF_matrix(fontid, mat);
-
- /* aspect is the inverse scale that allows you to increase
- * your resolution without sizing the final text size
- * the bigger the size, the smaller the aspect */
- BLF_aspect(fontid, aspect, aspect, aspect);
-
- BLF_size(fontid, size, dpi);
- BLF_position(fontid, 0, 0, 0);
- BLF_draw(fontid, text, 65535);
-
- BLF_disable(fontid, BLF_MATRIX|BLF_ASPECT);
-}
-
-void RAS_OpenGLRasterizer::RenderText2D(
- RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco, int yco,
- int width, int height)
-{
- /* This is a rather important line :( The gl-mode hasn't been left
- * behind quite as neatly as we'd have wanted to. I don't know
- * what cause it, though :/ .*/
- DisableForText();
- glDisable(GL_DEPTH_TEST);
-
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
-
- glOrtho(0, width, 0, height, -100, 100);
-
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- if (mode == RAS_TEXT_PADDED) {
- /* draw in black first */
- glColor3ub(0, 0, 0);
- BLF_size(blf_mono_font, 11, 72);
- BLF_position(blf_mono_font, (float)xco+1, (float)(height-yco-1), 0.0f);
- BLF_draw(blf_mono_font, text, 65535); /* XXX, use real len */
- }
-
- /* the actual drawing */
- glColor3ub(255, 255, 255);
- BLF_size(blf_mono_font, 11, 72);
- BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f);
- BLF_draw(blf_mono_font, text, 65535); /* XXX, use real len */
-
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glEnable(GL_DEPTH_TEST);
-}
-
-void RAS_OpenGLRasterizer::PushMatrix()
-{
- glPushMatrix();
-}
-
-void RAS_OpenGLRasterizer::PopMatrix()
-{
- glPopMatrix();
-}
-
-void RAS_OpenGLRasterizer::MotionBlur()
-{
- int state = GetMotionBlurState();
- float motionblurvalue;
- if (state)
- {
- motionblurvalue = GetMotionBlurValue();
- if (state==1)
- {
- // bugfix:load color buffer into accum buffer for the first time(state=1)
- glAccum(GL_LOAD, 1.0f);
- SetMotionBlurState(2);
- }
- else if (motionblurvalue >= 0.0f && motionblurvalue <= 1.0f) {
- glAccum(GL_MULT, motionblurvalue);
- glAccum(GL_ACCUM, 1-motionblurvalue);
- glAccum(GL_RETURN, 1.0f);
- glFlush();
- }
- }
-}
-
-void RAS_OpenGLRasterizer::SetClientObject(void* obj)
-{
- if (m_clientobject != obj)
- {
- bool ccw = (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling());
- SetFrontFace(ccw);
-
- m_clientobject = obj;
- }
-}
-
-void RAS_OpenGLRasterizer::SetAuxilaryClientInfo(void* inf)
-{
- m_auxilaryClientInfo = inf;
-}
-
-void RAS_OpenGLRasterizer::PrintHardwareInfo()
-{
- #define pprint(x) std::cout << x << std::endl;
-
- pprint("GL_VENDOR: " << glGetString(GL_VENDOR));
- pprint("GL_RENDERER: " << glGetString(GL_RENDERER));
- pprint("GL_VERSION: " << glGetString(GL_VERSION));
- bool support=0;
- pprint("Supported Extensions...");
- pprint(" GL_ARB_shader_objects supported? "<< (GLEW_ARB_shader_objects?"yes.":"no."));
-
- support= GLEW_ARB_vertex_shader;
- pprint(" GL_ARB_vertex_shader supported? "<< (support?"yes.":"no."));
- if (support) {
- pprint(" ----------Details----------");
- int max=0;
- glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, (GLint*)&max);
- pprint(" Max uniform components." << max);
-
- glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, (GLint*)&max);
- pprint(" Max varying floats." << max);
-
- glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max);
- pprint(" Max vertex texture units." << max);
-
- glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max);
- pprint(" Max combined texture units." << max);
- pprint("");
- }
-
- support=GLEW_ARB_fragment_shader;
- pprint(" GL_ARB_fragment_shader supported? "<< (support?"yes.":"no."));
- if (support) {
- pprint(" ----------Details----------");
- int max=0;
- glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, (GLint*)&max);
- pprint(" Max uniform components." << max);
- pprint("");
- }
-
- support = GLEW_ARB_texture_cube_map;
- pprint(" GL_ARB_texture_cube_map supported? "<< (support?"yes.":"no."));
- if (support) {
- pprint(" ----------Details----------");
- int size=0;
- glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, (GLint*)&size);
- pprint(" Max cubemap size." << size);
- pprint("");
- }
-
- support = GLEW_ARB_multitexture;
- pprint(" GL_ARB_multitexture supported? "<< (support?"yes.":"no."));
- if (support) {
- pprint(" ----------Details----------");
- int units=0;
- glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&units);
- pprint(" Max texture units available. " << units);
- pprint("");
- }
-
- pprint(" GL_ARB_texture_env_combine supported? "<< (GLEW_ARB_texture_env_combine?"yes.":"no."));
-
- pprint(" GL_ARB_texture_non_power_of_two supported " << (GPU_full_non_power_of_two_support()?"yes.":"no."));
-}
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
deleted file mode 100644
index 9561e207dba..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_OpenGLRasterizer.h
- * \ingroup bgerastogl
- */
-
-#ifndef __RAS_OPENGLRASTERIZER_H__
-#define __RAS_OPENGLRASTERIZER_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include "MT_CmMatrix4x4.h"
-#include <vector>
-#include <map>
-using namespace std;
-
-#include "RAS_IRasterizer.h"
-#include "RAS_MaterialBucket.h"
-#include "RAS_IPolygonMaterial.h"
-
-#include "BLI_utildefines.h"
-
-class RAS_IStorage;
-class RAS_ICanvas;
-class RAS_OpenGLLight;
-
-#define RAS_MAX_TEXCO 8 /* match in BL_Material */
-#define RAS_MAX_ATTRIB 16 /* match in BL_BlenderShader */
-
-enum RAS_STORAGE_TYPE {
- RAS_AUTO_STORAGE,
- RAS_VA,
- RAS_VBO,
-};
-
-struct OglDebugShape
-{
- enum SHAPE_TYPE{
- LINE,
- CIRCLE,
- };
- SHAPE_TYPE m_type;
- MT_Vector3 m_pos;
- MT_Vector3 m_param;
- MT_Vector3 m_param2;
- MT_Vector3 m_color;
-};
-
-/**
- * 3D rendering device context.
- */
-class RAS_OpenGLRasterizer : public RAS_IRasterizer
-{
- RAS_ICanvas *m_2DCanvas;
-
- /* fogging vars */
- bool m_fogenabled;
-
- float m_redback;
- float m_greenback;
- float m_blueback;
- float m_alphaback;
-
- float m_ambr;
- float m_ambg;
- float m_ambb;
- double m_time;
- MT_Matrix4x4 m_viewmatrix;
- MT_Matrix4x4 m_viewinvmatrix;
- MT_Point3 m_campos;
- bool m_camortho;
- bool m_camnegscale;
-
- StereoMode m_stereomode;
- StereoEye m_curreye;
- float m_eyeseparation;
- float m_focallength;
- bool m_setfocallength;
- int m_noOfScanlines;
-
- short m_prevafvalue;
-
- /* motion blur */
- int m_motionblur;
- float m_motionblurvalue;
-
- bool m_usingoverrideshader;
-
- /* Render tools */
- void *m_clientobject;
- void *m_auxilaryClientInfo;
- std::vector<RAS_OpenGLLight *> m_lights;
- int m_lastlightlayer;
- bool m_lastlighting;
- void *m_lastauxinfo;
- unsigned int m_numgllights;
-
-protected:
- int m_drawingmode;
- TexCoGen m_texco[RAS_MAX_TEXCO];
- TexCoGen m_attrib[RAS_MAX_ATTRIB];
- int m_attrib_layer[RAS_MAX_ATTRIB];
- int m_texco_num;
- int m_attrib_num;
- /* int m_last_alphablend; */
- bool m_last_frontface;
-
- /* Stores the caching information for the last material activated. */
- RAS_IPolyMaterial::TCachingInfo m_materialCachingInfo;
-
- /* Making use of a Strategy design pattern for storage behavior.
- * Examples of concrete strategies: Vertex Arrays, VBOs, Immediate Mode*/
- int m_storage_type;
- RAS_IStorage *m_storage;
-
-public:
- double GetTime();
- RAS_OpenGLRasterizer(RAS_ICanvas *canv, RAS_STORAGE_TYPE storage);
- virtual ~RAS_OpenGLRasterizer();
-
- /*enum DrawType
- {
- KX_BOUNDINGBOX = 1,
- KX_WIREFRAME,
- KX_SOLID,
- KX_SHADED,
- KX_TEXTURED
- };
-
- enum DepthMask
- {
- KX_DEPTHMASK_ENABLED =1,
- KX_DEPTHMASK_DISABLED,
- };*/
- virtual void SetDepthMask(DepthMask depthmask);
-
- virtual bool SetMaterial(const RAS_IPolyMaterial &mat);
- virtual bool Init();
- virtual void Exit();
- virtual bool BeginFrame(double time);
- virtual void ClearColorBuffer();
- virtual void ClearDepthBuffer();
- virtual void ClearCachingInfo(void);
- virtual void EndFrame();
- virtual void SetRenderArea();
-
- virtual void SetStereoMode(const StereoMode stereomode);
- virtual RAS_IRasterizer::StereoMode GetStereoMode();
- virtual bool Stereo();
- virtual bool InterlacedStereo();
- virtual void SetEye(const StereoEye eye);
- virtual StereoEye GetEye();
- virtual void SetEyeSeparation(const float eyeseparation);
- virtual float GetEyeSeparation();
- virtual void SetFocalLength(const float focallength);
- virtual float GetFocalLength();
- virtual RAS_IOffScreen *CreateOffScreen(int width, int height, int samples, int target);
- virtual RAS_ISync *CreateSync(int type);
- virtual void SwapBuffers();
-
- virtual void IndexPrimitives(class RAS_MeshSlot &ms);
- virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat);
- virtual void DrawDerivedMesh(class RAS_MeshSlot &ms);
-
- virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat);
- virtual void SetProjectionMatrix(const MT_Matrix4x4 &mat);
- virtual void SetViewMatrix(
- const MT_Matrix4x4 &mat,
- const MT_Matrix3x3 &ori,
- const MT_Point3 &pos,
- const MT_Vector3 &scale,
- bool perspective);
-
- virtual const MT_Point3& GetCameraPosition();
- virtual bool GetCameraOrtho();
-
- virtual void SetFog(short type, float start, float dist, float intensity, float color[3]);
- virtual void EnableFog(bool enable);
- virtual void DisplayFog();
-
- virtual void SetBackColor(float color[3]);
-
- virtual void SetDrawingMode(int drawingmode);
- virtual int GetDrawingMode();
-
- virtual void SetCullFace(bool enable);
- virtual void SetLines(bool enable);
-
- virtual MT_Matrix4x4 GetFrustumMatrix(
- float left, float right, float bottom, float top,
- float frustnear, float frustfar,
- float focallength, bool perspective);
- virtual MT_Matrix4x4 GetOrthoMatrix(
- float left, float right, float bottom, float top,
- float frustnear, float frustfar);
-
- virtual void SetSpecularity(float specX, float specY, float specZ, float specval);
- virtual void SetShinyness(float shiny);
- virtual void SetDiffuse(float difX, float difY, float difZ, float diffuse);
- virtual void SetEmissive(float eX, float eY, float eZ, float e);
-
- virtual void SetAmbientColor(float color[3]);
- virtual void SetAmbient(float factor);
-
- virtual void SetPolygonOffset(float mult, float add);
-
- virtual void FlushDebugShapes(SCA_IScene *scene);
-
- virtual void DrawDebugLine(SCA_IScene *scene, const MT_Vector3 &from,const MT_Vector3 &to, const MT_Vector3 &color)
- {
- OglDebugShape line;
- line.m_type = OglDebugShape::LINE;
- line.m_pos= from;
- line.m_param = to;
- line.m_color = color;
- m_debugShapes[scene].push_back(line);
- }
-
- virtual void DrawDebugCircle(SCA_IScene *scene, const MT_Vector3 &center, const MT_Scalar radius,
- const MT_Vector3 &color, const MT_Vector3 &normal, int nsector)
- {
- OglDebugShape line;
- line.m_type = OglDebugShape::CIRCLE;
- line.m_pos= center;
- line.m_param = normal;
- line.m_color = color;
- line.m_param2.x() = radius;
- line.m_param2.y() = (float) nsector;
- m_debugShapes[scene].push_back(line);
- }
-
- // We store each debug shape by scene.
- std::map<SCA_IScene *, std::vector<OglDebugShape> > m_debugShapes;
-
- virtual void SetTexCoordNum(int num);
- virtual void SetAttribNum(int num);
- virtual void SetTexCoord(TexCoGen coords, int unit);
- virtual void SetAttrib(TexCoGen coords, int unit, int layer = 0);
-
- void TexCoord(const RAS_TexVert &tv);
-
- const MT_Matrix4x4 &GetViewMatrix() const;
- const MT_Matrix4x4 &GetViewInvMatrix() const;
-
- virtual void EnableMotionBlur(float motionblurvalue);
- virtual void DisableMotionBlur();
- virtual float GetMotionBlurValue() { return m_motionblurvalue; }
- virtual int GetMotionBlurState() { return m_motionblur; }
- virtual void SetMotionBlurState(int newstate)
- {
- if (newstate < 0)
- m_motionblur = 0;
- else if (newstate > 2)
- m_motionblur = 2;
- else
- m_motionblur = newstate;
- }
-
- virtual void SetAlphaBlend(int alphablend);
- virtual void SetFrontFace(bool ccw);
-
- virtual void SetAnisotropicFiltering(short level);
- virtual short GetAnisotropicFiltering();
-
- virtual void SetMipmapping(MipmapOption val);
- virtual MipmapOption GetMipmapping();
-
- virtual void SetUsingOverrideShader(bool val);
- virtual bool GetUsingOverrideShader();
-
- /**
- * Render Tools
- */
- void EnableOpenGLLights();
- void DisableOpenGLLights();
- void ProcessLighting(bool uselights, const MT_Transform &viewmat);
-
- void RenderBox2D(int xco, int yco, int width, int height, float percentage);
- void RenderText3D(int fontid, const char *text, int size, int dpi,
- const float color[4], const float mat[16], float aspect);
- void RenderText2D(RAS_TEXT_RENDER_MODE mode, const char *text,
- int xco, int yco, int width, int height);
-
- void applyTransform(float *oglmatrix, int objectdrawmode);
-
- void PushMatrix();
- void PopMatrix();
-
- /// \see KX_RayCast
- bool RayHit(struct KX_ClientObjectInfo *client, class KX_RayCast *result, float *oglmatrix);
- /// \see KX_RayCast
- bool NeedRayCast(struct KX_ClientObjectInfo *, void *UNUSED(data)) { return true; }
-
- RAS_ILightObject* CreateLight();
- void AddLight(RAS_ILightObject* lightobject);
-
- void RemoveLight(RAS_ILightObject* lightobject);
- int ApplyLights(int objectlayer, const MT_Transform& viewmat);
-
- void MotionBlur();
-
- void SetClientObject(void *obj);
-
- void SetAuxilaryClientInfo(void *inf);
-
- /**
- * Prints information about what the hardware supports.
- */
- virtual void PrintHardwareInfo();
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_OpenGLRasterizer")
-#endif
-};
-
-#endif /* __RAS_OPENGLRASTERIZER_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.cpp
deleted file mode 100644
index 26b956cd74e..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "GPU_glew.h"
-
-#include <stdio.h>
-
-#include "RAS_OpenGLSync.h"
-
-RAS_OpenGLSync::RAS_OpenGLSync()
- :m_sync(NULL)
-{
-}
-
-RAS_OpenGLSync::~RAS_OpenGLSync()
-{
- Destroy();
-}
-
-bool RAS_OpenGLSync::Create(RAS_SYNC_TYPE type)
-{
- if (m_sync) {
- printf("RAS_OpenGLSync::Create(): sync already exists, destroy first\n");
- return false;
- }
- if (type != RAS_SYNC_TYPE_FENCE) {
- printf("RAS_OpenGLSync::Create(): only RAS_SYNC_TYPE_FENCE are currently supported\n");
- return false;
- }
- if (!GLEW_ARB_sync) {
- printf("RAS_OpenGLSync::Create(): ARB_sync extension is needed to create sync object\n");
- return false;
- }
- m_sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
- if (!m_sync) {
- printf("RAS_OpenGLSync::Create(): glFenceSync() failed");
- return false;
- }
- return true;
-}
-
-void RAS_OpenGLSync::Destroy()
-{
- if (m_sync) {
- glDeleteSync(m_sync);
- m_sync = NULL;
- }
-}
-
-void RAS_OpenGLSync::Wait()
-{
- if (m_sync) {
- // this is needed to ensure that the sync is in the GPU
- glFlush();
- // block until the operation have completed
- glWaitSync(m_sync, 0, GL_TIMEOUT_IGNORED);
- }
-}
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.h
deleted file mode 100644
index 4ba96903856..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __RAS_OPENGLSYNC__
-#define __RAS_OPENGLSYNC__
-
-
-#include "RAS_ISync.h"
-
-struct __GLsync;
-
-class RAS_OpenGLSync : public RAS_ISync
-{
-private:
- struct __GLsync *m_sync;
-
-public:
- RAS_OpenGLSync();
- ~RAS_OpenGLSync();
-
- virtual bool Create(RAS_SYNC_TYPE type);
- virtual void Destroy();
- virtual void Wait();
-};
-
-#endif /* __RAS_OPENGLSYNC__ */
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp
deleted file mode 100644
index f980116f5f8..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "RAS_StorageVA.h"
-
-#include "GPU_glew.h"
-
-RAS_StorageVA::RAS_StorageVA(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer) :
- m_drawingmode(RAS_IRasterizer::KX_TEXTURED),
- m_texco_num(texco_num),
- m_attrib_num(attrib_num),
- m_last_texco_num(0),
- m_last_attrib_num(0),
- m_texco(texco),
- m_attrib(attrib),
- m_attrib_layer(attrib_layer)
-{
-}
-
-RAS_StorageVA::~RAS_StorageVA()
-{
-}
-
-bool RAS_StorageVA::Init()
-{
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- return true;
-}
-
-void RAS_StorageVA::Exit()
-{
-}
-
-void RAS_StorageVA::IndexPrimitives(class RAS_MeshSlot& ms)
-{
- static const GLsizei stride = sizeof(RAS_TexVert);
- bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME, use_color_array = true;
- RAS_MeshSlot::iterator it;
- GLenum drawmode;
-
- if (!wireframe)
- EnableTextures(true);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
-
- // use glDrawElements to draw each vertexarray
- for (ms.begin(it); !ms.end(it); ms.next(it)) {
- if (it.totindex == 0)
- continue;
-
- // drawing mode
- if (it.array->m_type == RAS_DisplayArray::TRIANGLE)
- drawmode = GL_TRIANGLES;
- else if (it.array->m_type == RAS_DisplayArray::QUAD)
- drawmode = GL_QUADS;
- else
- drawmode = GL_LINES;
-
- // colors
- if (drawmode != GL_LINES && !wireframe) {
- if (ms.m_bObjectColor) {
- const MT_Vector4& rgba = ms.m_RGBAcolor;
-
- glDisableClientState(GL_COLOR_ARRAY);
- glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
- use_color_array = false;
- }
- else {
- glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
- glEnableClientState(GL_COLOR_ARRAY);
- use_color_array = true;
- }
- }
- else
- glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
-
- glVertexPointer(3, GL_FLOAT, stride, it.vertex->getXYZ());
- glNormalPointer(GL_FLOAT, stride, it.vertex->getNormal());
-
- if (!wireframe) {
- TexCoordPtr(it.vertex);
- if (use_color_array)
- glColorPointer(4, GL_UNSIGNED_BYTE, stride, it.vertex->getRGBA());
- }
-
- // here the actual drawing takes places
- glDrawElements(drawmode, it.totindex, GL_UNSIGNED_SHORT, it.index);
- }
-
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- if (!wireframe) {
- glDisableClientState(GL_COLOR_ARRAY);
- EnableTextures(false);
- }
-}
-
-void RAS_StorageVA::TexCoordPtr(const RAS_TexVert *tv)
-{
- /* note: this function must closely match EnableTextures to enable/disable
- * the right arrays, otherwise coordinate and attribute pointers from other
- * materials can still be used and cause crashes */
- int unit;
-
- if (GLEW_ARB_multitexture)
- {
- for (unit = 0; unit < *m_texco_num; unit++)
- {
- glClientActiveTextureARB(GL_TEXTURE0_ARB+unit);
- switch (m_texco[unit]) {
- case RAS_IRasterizer::RAS_TEXCO_ORCO:
- case RAS_IRasterizer::RAS_TEXCO_GLOB:
- glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getXYZ());
- break;
- case RAS_IRasterizer::RAS_TEXCO_UV:
- glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV(unit));
- break;
- case RAS_IRasterizer::RAS_TEXCO_NORM:
- glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getNormal());
- break;
- case RAS_IRasterizer::RAS_TEXTANGENT:
- glTexCoordPointer(4, GL_FLOAT, sizeof(RAS_TexVert),tv->getTangent());
- break;
- default:
- break;
- }
- }
-
- glClientActiveTextureARB(GL_TEXTURE0_ARB);
- }
-
- if (GLEW_ARB_vertex_program) {
- for (unit = 0; unit < *m_attrib_num; unit++) {
- switch (m_attrib[unit]) {
- case RAS_IRasterizer::RAS_TEXCO_ORCO:
- case RAS_IRasterizer::RAS_TEXCO_GLOB:
- glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getXYZ());
- break;
- case RAS_IRasterizer::RAS_TEXCO_UV:
- glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV(m_attrib_layer[unit]));
- break;
- case RAS_IRasterizer::RAS_TEXCO_NORM:
- glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getNormal());
- break;
- case RAS_IRasterizer::RAS_TEXTANGENT:
- glVertexAttribPointerARB(unit, 4, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getTangent());
- break;
- case RAS_IRasterizer::RAS_TEXCO_VCOL:
- glVertexAttribPointerARB(unit, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(RAS_TexVert), tv->getRGBA());
- break;
- default:
- break;
- }
- }
- }
-}
-
-void RAS_StorageVA::EnableTextures(bool enable)
-{
- RAS_IRasterizer::TexCoGen *texco, *attrib;
- int unit, texco_num, attrib_num;
-
- /* we cache last texcoords and attribs to ensure we disable the ones that
- * were actually last set */
- if (enable) {
- texco = m_texco;
- texco_num = *m_texco_num;
- attrib = m_attrib;
- attrib_num = *m_attrib_num;
-
- memcpy(m_last_texco, m_texco, sizeof(RAS_IRasterizer::TexCoGen)*(*m_texco_num));
- m_last_texco_num = *m_texco_num;
- memcpy(m_last_attrib, m_attrib, sizeof(RAS_IRasterizer::TexCoGen)*(*m_attrib_num));
- m_last_attrib_num = *m_attrib_num;
- }
- else {
- texco = m_last_texco;
- texco_num = m_last_texco_num;
- attrib = m_last_attrib;
- attrib_num = m_last_attrib_num;
- }
-
- if (GLEW_ARB_multitexture) {
- for (unit = 0; unit < texco_num; unit++) {
- glClientActiveTextureARB(GL_TEXTURE0_ARB + unit);
-
- switch (texco[unit]) {
- case RAS_IRasterizer::RAS_TEXCO_ORCO:
- case RAS_IRasterizer::RAS_TEXCO_GLOB:
- case RAS_IRasterizer::RAS_TEXCO_UV:
- case RAS_IRasterizer::RAS_TEXCO_NORM:
- case RAS_IRasterizer::RAS_TEXTANGENT:
- if (enable) glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- else glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- break;
- default:
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- break;
- }
- }
-
- glClientActiveTextureARB(GL_TEXTURE0_ARB);
- }
- else {
- if (texco_num) {
- if (enable) glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- else glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- }
- }
-
- if (GLEW_ARB_vertex_program) {
- for (unit = 0; unit < attrib_num; unit++) {
- switch (attrib[unit]) {
- case RAS_IRasterizer::RAS_TEXCO_ORCO:
- case RAS_IRasterizer::RAS_TEXCO_GLOB:
- case RAS_IRasterizer::RAS_TEXCO_UV:
- case RAS_IRasterizer::RAS_TEXCO_NORM:
- case RAS_IRasterizer::RAS_TEXTANGENT:
- case RAS_IRasterizer::RAS_TEXCO_VCOL:
- if (enable) glEnableVertexAttribArrayARB(unit);
- else glDisableVertexAttribArrayARB(unit);
- break;
- default:
- glDisableVertexAttribArrayARB(unit);
- break;
- }
- }
- }
-
- if (!enable) {
- m_last_texco_num = 0;
- m_last_attrib_num = 0;
- }
-}
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h
deleted file mode 100644
index a5a3170ed77..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __KX_VERTEXARRAYSTORAGE
-#define __KX_VERTEXARRAYSTORAGE
-
-#include "RAS_IStorage.h"
-#include "RAS_IRasterizer.h"
-
-#include "RAS_OpenGLRasterizer.h"
-
-class RAS_StorageVA : public RAS_IStorage
-{
-
-public:
- RAS_StorageVA(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer);
- virtual ~RAS_StorageVA();
-
- virtual bool Init();
- virtual void Exit();
-
- virtual void IndexPrimitives(RAS_MeshSlot& ms);
-
- virtual void SetDrawingMode(int drawingmode) {m_drawingmode = drawingmode;};
-
-protected:
- int m_drawingmode;
-
- int* m_texco_num;
- int* m_attrib_num;
-
- int m_last_texco_num;
- int m_last_attrib_num;
-
- RAS_IRasterizer::TexCoGen* m_texco;
- RAS_IRasterizer::TexCoGen* m_attrib;
- int* m_attrib_layer;
-
- RAS_IRasterizer::TexCoGen m_last_texco[RAS_MAX_TEXCO];
- RAS_IRasterizer::TexCoGen m_last_attrib[RAS_MAX_ATTRIB];
-
- virtual void EnableTextures(bool enable);
- virtual void TexCoordPtr(const RAS_TexVert *tv);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
-public:
- void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_StorageVA"); }
- void operator delete( void *mem ) { MEM_freeN(mem); }
-#endif
-};
-
-#endif //__KX_VERTEXARRAYSTORAGE
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp
deleted file mode 100644
index 4ba5882a46e..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "RAS_StorageVBO.h"
-#include "RAS_MeshObject.h"
-
-#include "GPU_glew.h"
-
-VBO::VBO(RAS_DisplayArray *data, unsigned int indices)
-{
- this->data = data;
- this->size = data->m_vertex.size();
- this->indices = indices;
- this->stride = sizeof(RAS_TexVert);
-
- // Determine drawmode
- if (data->m_type == data->QUAD)
- this->mode = GL_QUADS;
- else if (data->m_type == data->TRIANGLE)
- this->mode = GL_TRIANGLES;
- else
- this->mode = GL_LINE;
-
- // Generate Buffers
- glGenBuffersARB(1, &this->ibo);
- glGenBuffersARB(1, &this->vbo_id);
-
- // Fill the buffers with initial data
- UpdateIndices();
- UpdateData();
-
- // Establish offsets
- this->vertex_offset = (void*)(((RAS_TexVert*)0)->getXYZ());
- this->normal_offset = (void*)(((RAS_TexVert*)0)->getNormal());
- this->tangent_offset = (void*)(((RAS_TexVert*)0)->getTangent());
- this->color_offset = (void*)(((RAS_TexVert*)0)->getRGBA());
- this->uv_offset = (void*)(((RAS_TexVert*)0)->getUV(0));
-}
-
-VBO::~VBO()
-{
- glDeleteBuffersARB(1, &this->ibo);
- glDeleteBuffersARB(1, &this->vbo_id);
-}
-
-void VBO::UpdateData()
-{
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, this->vbo_id);
- glBufferData(GL_ARRAY_BUFFER, this->stride*this->size, &this->data->m_vertex[0], GL_STATIC_DRAW);
-}
-
-void VBO::UpdateIndices()
-{
- glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, this->ibo);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, data->m_index.size() * sizeof(GLushort),
- &data->m_index[0], GL_STATIC_DRAW);
-}
-
-void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer)
-{
- int unit;
-
- // Bind buffers
- glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, this->ibo);
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, this->vbo_id);
-
- // Vertexes
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, this->stride, this->vertex_offset);
-
- // Normals
- glEnableClientState(GL_NORMAL_ARRAY);
- glNormalPointer(GL_FLOAT, this->stride, this->normal_offset);
-
- // Colors
- glEnableClientState(GL_COLOR_ARRAY);
- glColorPointer(4, GL_UNSIGNED_BYTE, this->stride, this->color_offset);
-
- for (unit = 0; unit < texco_num; ++unit)
- {
- glClientActiveTexture(GL_TEXTURE0_ARB + unit);
- switch (texco[unit]) {
- case RAS_IRasterizer::RAS_TEXCO_ORCO:
- case RAS_IRasterizer::RAS_TEXCO_GLOB:
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(3, GL_FLOAT, this->stride, this->vertex_offset);
- break;
- case RAS_IRasterizer::RAS_TEXCO_UV:
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, this->stride, (void*)((intptr_t)this->uv_offset+(sizeof(GLfloat)*2*unit)));
- break;
- case RAS_IRasterizer::RAS_TEXCO_NORM:
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(3, GL_FLOAT, this->stride, this->normal_offset);
- break;
- case RAS_IRasterizer::RAS_TEXTANGENT:
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(4, GL_FLOAT, this->stride, this->tangent_offset);
- break;
- default:
- break;
- }
- }
- glClientActiveTextureARB(GL_TEXTURE0_ARB);
-
- if (GLEW_ARB_vertex_program)
- {
- for (unit = 0; unit < attrib_num; ++unit)
- {
- switch (attrib[unit]) {
- case RAS_IRasterizer::RAS_TEXCO_ORCO:
- case RAS_IRasterizer::RAS_TEXCO_GLOB:
- glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, this->stride, this->vertex_offset);
- glEnableVertexAttribArrayARB(unit);
- break;
- case RAS_IRasterizer::RAS_TEXCO_UV:
- glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, this->stride, (void*)((intptr_t)this->uv_offset+attrib_layer[unit]*sizeof(GLfloat)*2));
- glEnableVertexAttribArrayARB(unit);
- break;
- case RAS_IRasterizer::RAS_TEXCO_NORM:
- glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, stride, this->normal_offset);
- glEnableVertexAttribArrayARB(unit);
- break;
- case RAS_IRasterizer::RAS_TEXTANGENT:
- glVertexAttribPointerARB(unit, 4, GL_FLOAT, GL_FALSE, this->stride, this->tangent_offset);
- glEnableVertexAttribArrayARB(unit);
- break;
- case RAS_IRasterizer::RAS_TEXCO_VCOL:
- glVertexAttribPointerARB(unit, 4, GL_UNSIGNED_BYTE, GL_TRUE, this->stride, this->color_offset);
- glEnableVertexAttribArrayARB(unit);
- default:
- break;
- }
- }
- }
-
- glDrawElements(this->mode, this->indices, GL_UNSIGNED_SHORT, 0);
-
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-
- if (GLEW_ARB_vertex_program)
- {
- for (int i = 0; i < attrib_num; ++i)
- glDisableVertexAttribArrayARB(i);
- }
-
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
- glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
-}
-
-RAS_StorageVBO::RAS_StorageVBO(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer):
- m_drawingmode(RAS_IRasterizer::KX_TEXTURED),
- m_texco_num(texco_num),
- m_attrib_num(attrib_num),
- m_texco(texco),
- m_attrib(attrib),
- m_attrib_layer(attrib_layer)
-{
-}
-
-RAS_StorageVBO::~RAS_StorageVBO()
-{
-}
-
-bool RAS_StorageVBO::Init()
-{
- return true;
-}
-
-void RAS_StorageVBO::Exit()
-{
- VBOMap::iterator it = m_vbo_lookup.begin();
- while (it != m_vbo_lookup.end()) {
- delete it->second;
- ++it;
- }
- m_vbo_lookup.clear();
-}
-
-void RAS_StorageVBO::IndexPrimitives(RAS_MeshSlot& ms)
-{
- RAS_MeshSlot::iterator it;
- VBO *vbo;
-
- for (ms.begin(it); !ms.end(it); ms.next(it))
- {
- vbo = m_vbo_lookup[it.array];
-
- if (vbo == 0)
- m_vbo_lookup[it.array] = vbo = new VBO(it.array, it.totindex);
-
- // Update the vbo
- if (ms.m_mesh->MeshModified())
- {
- vbo->UpdateData();
- }
-
- vbo->Draw(*m_texco_num, m_texco, *m_attrib_num, m_attrib, m_attrib_layer);
- }
-}
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h
deleted file mode 100644
index c82b6a3206d..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __KX_VERTEXBUFFEROBJECTSTORAGE
-#define __KX_VERTEXBUFFEROBJECTSTORAGE
-
-#include <map>
-#include "GPU_glew.h"
-
-#include "RAS_IStorage.h"
-#include "RAS_IRasterizer.h"
-
-#include "RAS_OpenGLRasterizer.h"
-
-class VBO
-{
-public:
- VBO(RAS_DisplayArray *data, unsigned int indices);
- ~VBO();
-
- void Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer);
-
- void UpdateData();
- void UpdateIndices();
-private:
- RAS_DisplayArray* data;
- GLuint size;
- GLuint stride;
- GLuint indices;
- GLenum mode;
- GLuint ibo;
- GLuint vbo_id;
-
- void* vertex_offset;
- void* normal_offset;
- void* color_offset;
- void* tangent_offset;
- void* uv_offset;
-};
-
-typedef std::map<RAS_DisplayArray*, VBO*> VBOMap;
-
-class RAS_StorageVBO : public RAS_IStorage
-{
-
-public:
- RAS_StorageVBO(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer);
- virtual ~RAS_StorageVBO();
-
- virtual bool Init();
- virtual void Exit();
-
- virtual void IndexPrimitives(RAS_MeshSlot& ms);
-
- virtual void SetDrawingMode(int drawingmode) {m_drawingmode = drawingmode;};
-
-protected:
- int m_drawingmode;
-
- int* m_texco_num;
- int* m_attrib_num;
-
- RAS_IRasterizer::TexCoGen* m_texco;
- RAS_IRasterizer::TexCoGen* m_attrib;
- int* m_attrib_layer;
-
- VBOMap m_vbo_lookup;
-
-#ifdef WITH_CXX_GUARDEDALLOC
-public:
- void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_StorageVA"); }
- void operator delete( void *mem ) { MEM_freeN(mem); }
-#endif
-};
-
-#endif //__KX_VERTEXBUFFEROBJECTSTORAGE
diff --git a/source/gameengine/Rasterizer/RAS_Polygon.cpp b/source/gameengine/Rasterizer/RAS_Polygon.cpp
deleted file mode 100644
index 3274ded4406..00000000000
--- a/source/gameengine/Rasterizer/RAS_Polygon.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_Polygon.cpp
- * \ingroup bgerast
- */
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include "RAS_Polygon.h"
-#include "RAS_MaterialBucket.h"
-
-RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray *darray, int numvert)
-{
- m_bucket = bucket;
- m_darray = darray;
- m_offset[0] = m_offset[1] = m_offset[2] = m_offset[3] = 0;
- m_numvert = numvert;
-
-// m_edgecode = 255;
- m_polyflags = 0;
-}
-
-int RAS_Polygon::VertexCount()
-{
- return m_numvert;
-}
-
-void RAS_Polygon::SetVertexOffset(int i, unsigned short offset)
-{
- m_offset[i] = offset;
-}
-
-RAS_TexVert *RAS_Polygon::GetVertex(int i)
-{
- return &m_darray->m_vertex[m_offset[i]];
-}
-
-unsigned int RAS_Polygon::GetVertexOffsetAbsolute(unsigned short i)
-{
- return m_offset[i] + m_darray->m_offset;
-}
-
-/*
-int RAS_Polygon::GetEdgeCode()
-{
- return m_edgecode;
-}
-
-void RAS_Polygon::SetEdgeCode(int edgecode)
-{
- m_edgecode = edgecode;
-}*/
-
-
-bool RAS_Polygon::IsVisible()
-{
- return (m_polyflags & VISIBLE) != 0;
-}
-
-void RAS_Polygon::SetVisible(bool visible)
-{
- if (visible) m_polyflags |= VISIBLE;
- else m_polyflags &= ~VISIBLE;
-}
-
-bool RAS_Polygon::IsCollider()
-{
- return (m_polyflags & COLLIDER) != 0;
-}
-
-void RAS_Polygon::SetCollider(bool visible)
-{
- if (visible) m_polyflags |= COLLIDER;
- else m_polyflags &= ~COLLIDER;
-}
-
-bool RAS_Polygon::IsTwoside()
-{
- return (m_polyflags & TWOSIDE) != 0;
-}
-
-void RAS_Polygon::SetTwoside(bool twoside)
-{
- if (twoside) m_polyflags |= TWOSIDE;
- else m_polyflags &= ~TWOSIDE;
-}
-
-RAS_MaterialBucket* RAS_Polygon::GetMaterial()
-{
- return m_bucket;
-}
-
-RAS_DisplayArray* RAS_Polygon::GetDisplayArray()
-{
- return m_darray;
-}
diff --git a/source/gameengine/Rasterizer/RAS_Polygon.h b/source/gameengine/Rasterizer/RAS_Polygon.h
deleted file mode 100644
index 597e80ffdfb..00000000000
--- a/source/gameengine/Rasterizer/RAS_Polygon.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_Polygon.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_POLYGON_H__
-#define __RAS_POLYGON_H__
-
-class RAS_DisplayArray;
-class RAS_MaterialBucket;
-class RAS_TexVert;
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-/* polygon flags */
-
-class RAS_Polygon
-{
- /* location */
- RAS_MaterialBucket* m_bucket;
- RAS_DisplayArray* m_darray;
- unsigned short m_offset[4];
- unsigned short m_numvert;
-
- /* flags */
-#if 1
- unsigned short m_polyflags;
-#else
- unsigned char m_edgecode;
- unsigned char m_polyflags;
-#endif
-
-public:
- enum {
- VISIBLE = 1,
- COLLIDER = 2,
- TWOSIDE = 4
- };
-
- RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray* darray, int numvert);
- virtual ~RAS_Polygon() {};
-
- int VertexCount();
- RAS_TexVert* GetVertex(int i);
-
- void SetVertexOffset(int i, unsigned short offset);
- unsigned int GetVertexOffsetAbsolute(unsigned short i);
-
- // each bit is for a visible edge, starting with bit 1 for the first edge, bit 2 for second etc.
- // - Not used yet!
-/* int GetEdgeCode();
- void SetEdgeCode(int edgecode); */
-
- bool IsVisible();
- void SetVisible(bool visible);
-
- bool IsCollider();
- void SetCollider(bool collider);
-
- bool IsTwoside();
- void SetTwoside(bool twoside);
-
- RAS_MaterialBucket* GetMaterial();
- RAS_DisplayArray* GetDisplayArray();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_Polygon")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_Rect.h b/source/gameengine/Rasterizer/RAS_Rect.h
deleted file mode 100644
index fc99c9159db..00000000000
--- a/source/gameengine/Rasterizer/RAS_Rect.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_Rect.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_RECT_H__
-#define __RAS_RECT_H__
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-/**
- * \section interface class.
- * RAS_Rect just encodes a simple rectangle.
- * \note Should be part of a generic library
- */
-class RAS_Rect
-{
-public: // todo: make a decent class, and make private
- int m_x1, m_y1;
- int m_x2, m_y2;
-
-public:
- RAS_Rect() : m_x1(0), m_y1(0), m_x2(0), m_y2(0) {}
- int GetWidth(
- ) const {
- return m_x2 - m_x1;
- }
- int GetHeight(
- ) const {
- return m_y2 - m_y1;
- }
- int GetLeft(
- ) const {
- return m_x1;
- }
- int GetRight(
- ) const {
- return m_x2;
- }
- int GetBottom(
- ) const {
- return m_y1;
- }
- int GetTop(
- ) const {
- return m_y2;
- }
-
- void SetLeft(
- int x1)
- {
- m_x1 = x1;
- }
- void SetBottom(
- int y1)
- {
- m_y1 = y1;
- }
- void SetRight(
- int x2)
- {
- m_x2 = x2;
- }
- void SetTop(
- int y2)
- {
- m_y2 = y2;
- }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_Rect")
-#endif
-};
-
-#endif /* __RAS_RECT_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_TexMatrix.h b/source/gameengine/Rasterizer/RAS_TexMatrix.h
deleted file mode 100644
index a2dd291d016..00000000000
--- a/source/gameengine/Rasterizer/RAS_TexMatrix.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_TexMatrix.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_TEXMATRIX_H__
-#define __RAS_TEXMATRIX_H__
-
-#include "MT_Matrix3x3.h"
-#include "MT_Point3.h"
-#include "MT_Point2.h"
-#include "RAS_TexVert.h"
-
-void RAS_CalcTexMatrix(RAS_TexVert p[3],MT_Point3& origin,MT_Vector3& udir,MT_Vector3& vdir);
-
-#endif /* __RAS_TEXMATRIX_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_TexVert.cpp b/source/gameengine/Rasterizer/RAS_TexVert.cpp
deleted file mode 100644
index 2e176360d61..00000000000
--- a/source/gameengine/Rasterizer/RAS_TexVert.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_TexVert.cpp
- * \ingroup bgerast
- */
-
-
-#include "RAS_TexVert.h"
-#include "MT_Matrix4x4.h"
-#include "BLI_math.h"
-
-RAS_TexVert::RAS_TexVert(const MT_Point3& xyz,
- const MT_Point2 uvs[MAX_UNIT],
- const MT_Vector4& tangent,
- const unsigned int rgba,
- const MT_Vector3& normal,
- const bool flat,
- const unsigned int origindex)
-{
- xyz.getValue(m_localxyz);
- SetRGBA(rgba);
- SetNormal(normal);
- tangent.getValue(m_tangent);
- m_flag = (flat) ? FLAT: 0;
- m_origindex = origindex;
- m_unit = 2;
- m_softBodyIndex = -1;
-
- for (int i = 0; i < MAX_UNIT; ++i)
- {
- uvs[i].getValue(m_uvs[i]);
- }
-}
-
-const MT_Point3& RAS_TexVert::xyz()
-{
- g_pt3.setValue(m_localxyz);
- return g_pt3;
-}
-
-void RAS_TexVert::SetRGBA(const MT_Vector4& rgba)
-{
- unsigned char *colp = (unsigned char*) &m_rgba;
- colp[0] = (unsigned char) (rgba[0] * 255.0f);
- colp[1] = (unsigned char) (rgba[1] * 255.0f);
- colp[2] = (unsigned char) (rgba[2] * 255.0f);
- colp[3] = (unsigned char) (rgba[3] * 255.0f);
-}
-
-
-void RAS_TexVert::SetXYZ(const MT_Point3& xyz)
-{
- xyz.getValue(m_localxyz);
-}
-
-void RAS_TexVert::SetXYZ(const float xyz[3])
-{
- copy_v3_v3(m_localxyz, xyz);
-}
-
-void RAS_TexVert::SetUV(int index, const MT_Point2& uv)
-{
- uv.getValue(m_uvs[index]);
-}
-
-void RAS_TexVert::SetUV(int index, const float uv[2])
-{
- copy_v2_v2(m_uvs[index], uv);
-}
-
-void RAS_TexVert::SetRGBA(const unsigned int rgba)
-{
- m_rgba = rgba;
-}
-
-
-void RAS_TexVert::SetFlag(const short flag)
-{
- m_flag = flag;
-}
-
-void RAS_TexVert::SetUnit(const unsigned int u)
-{
- m_unit = (u <= (unsigned int) MAX_UNIT) ? u: (unsigned int)MAX_UNIT;
-}
-
-void RAS_TexVert::SetNormal(const MT_Vector3& normal)
-{
- normal.getValue(m_normal);
-}
-
-void RAS_TexVert::SetTangent(const MT_Vector3& tangent)
-{
- tangent.getValue(m_tangent);
-}
-
-
-// compare two vertices, and return true if both are almost identical (they can be shared)
-bool RAS_TexVert::closeTo(const RAS_TexVert* other)
-{
- const float eps = FLT_EPSILON;
- for (int i = 0; i < MAX_UNIT; i++) {
- if (!compare_v2v2(m_uvs[i], other->m_uvs[i], eps)) {
- return false;
- }
- }
-
- return (/* m_flag == other->m_flag && */
- /* at the moment the face only stores the smooth/flat setting so don't bother comparing it */
- (m_rgba == other->m_rgba) &&
- compare_v3v3(m_normal, other->m_normal, eps) &&
- compare_v3v3(m_tangent, other->m_tangent, eps)
- /* don't bother comparing m_localxyz since we know there from the same vert */
- /* && compare_v3v3(m_localxyz, other->m_localxyz, eps))*/
- );
-}
-
-short RAS_TexVert::getFlag() const
-{
- return m_flag;
-}
-
-
-unsigned int RAS_TexVert::getUnit() const
-{
- return m_unit;
-}
-
-void RAS_TexVert::Transform(const MT_Matrix4x4& mat, const MT_Matrix4x4& nmat)
-{
- SetXYZ((mat * MT_Vector4(m_localxyz[0], m_localxyz[1], m_localxyz[2], 1.0f)).getValue());
- SetNormal((nmat * MT_Vector4(m_normal[0], m_normal[1], m_normal[2], 1.0f)).getValue());
- SetTangent((nmat * MT_Vector4(m_tangent[0], m_tangent[1], m_tangent[2], 1.0f)).getValue());
-}
-
-void RAS_TexVert::TransformUV(int index, const MT_Matrix4x4& mat)
-{
- SetUV(index, (mat * MT_Vector4(m_uvs[index][0], m_uvs[index][1], 0.0f, 1.0f)).getValue());
-}
diff --git a/source/gameengine/Rasterizer/RAS_TexVert.h b/source/gameengine/Rasterizer/RAS_TexVert.h
deleted file mode 100644
index 8d08549d97e..00000000000
--- a/source/gameengine/Rasterizer/RAS_TexVert.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_TexVert.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_TEXVERT_H__
-#define __RAS_TEXVERT_H__
-
-
-#include "MT_Point3.h"
-#include "MT_Point2.h"
-#include "MT_Transform.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-static MT_Point3 g_pt3;
-static MT_Point2 g_pt2;
-
-class RAS_TexVert
-{
-
- float m_localxyz[3]; // 3*4 = 12
- float m_uvs[8][2]; // 8*2*4=64 //8 = MAX_UNIT
- unsigned int m_rgba; // 4
- float m_tangent[4]; // 4*4 = 16
- float m_normal[3]; // 3*4 = 12
- short m_flag; // 2
- short m_softBodyIndex; //2
- unsigned int m_unit; // 4
- unsigned int m_origindex; // 4
- char m_padding[8]; // 8
- //---------
- // 128
- // 32 bytes alignment improves performance on ATI cards.
-
-public:
- enum {
- FLAT = 1,
- MAX_UNIT = 8
- };
-
- short getFlag() const;
- unsigned int getUnit() const;
-
- RAS_TexVert()// :m_xyz(0,0,0),m_uv(0,0),m_rgba(0)
- {}
- RAS_TexVert(const MT_Point3& xyz,
- const MT_Point2 uvs[MAX_UNIT],
- const MT_Vector4& tangent,
- const unsigned int rgba,
- const MT_Vector3& normal,
- const bool flat,
- const unsigned int origindex);
- ~RAS_TexVert() {};
-
- const float* getUV (int unit) const {
- return m_uvs[unit];
- };
-
- const float* getXYZ() const {
- return m_localxyz;
- };
-
- const float* getNormal() const {
- return m_normal;
- }
-
- short int getSoftBodyIndex() const
- {
- return m_softBodyIndex;
- }
-
- void setSoftBodyIndex(short int sbIndex)
- {
- m_softBodyIndex = sbIndex;
- }
-
- const float* getTangent() const {
- return m_tangent;
- }
-
- const unsigned char* getRGBA() const {
- return (unsigned char *) &m_rgba;
- }
-
- unsigned int getOrigIndex() const {
- return m_origindex;
- }
-
- void SetXYZ(const MT_Point3& xyz);
- void SetXYZ(const float xyz[3]);
- void SetUV(int index, const MT_Point2& uv);
- void SetUV(int index, const float uv[2]);
-
- void SetRGBA(const unsigned int rgba);
- void SetNormal(const MT_Vector3& normal);
- void SetTangent(const MT_Vector3& tangent);
- void SetFlag(const short flag);
- void SetUnit(const unsigned u);
-
- void SetRGBA(const MT_Vector4& rgba);
- const MT_Point3& xyz();
-
- void Transform(const class MT_Matrix4x4& mat,
- const class MT_Matrix4x4& nmat);
- void TransformUV(int index, const MT_Matrix4x4& mat);
-
- // compare two vertices, to test if they can be shared, used for
- // splitting up based on uv's, colors, etc
- bool closeTo(const RAS_TexVert* other);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_TexVert")
-#endif
-};
-
-#endif /* __RAS_TEXVERT_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_texmatrix.cpp b/source/gameengine/Rasterizer/RAS_texmatrix.cpp
deleted file mode 100644
index d30a3d3a75d..00000000000
--- a/source/gameengine/Rasterizer/RAS_texmatrix.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_texmatrix.cpp
- * \ingroup bgerast
- */
-
-
-#include "RAS_TexMatrix.h"
-
-void RAS_CalcTexMatrix(RAS_TexVert p[3],MT_Point3& origin,MT_Vector3& udir,MT_Vector3& vdir)
-{
-// precondition: 3 vertices are non-collinear
-
- MT_Vector3 vec1 = p[1].xyz()-p[0].xyz();
- MT_Vector3 vec2 = p[2].xyz()-p[0].xyz();
- MT_Vector3 normal = vec1.cross(vec2);
- normal.normalize();
-
- // determine which coordinate we drop, ie. max coordinate in the normal
-
-
- int ZCOORD = normal.closestAxis();
- int XCOORD = (ZCOORD+1)%3;
- int YCOORD = (ZCOORD+2)%3;
-
- // ax+by+cz+d=0
- MT_Scalar d = -p[0].xyz().dot(normal);
-
-
- MT_Matrix3x3 mat3( p[0].getUV(0)[0],p[0].getUV(0)[1], 1,
- p[1].getUV(0)[0],p[1].getUV(0)[1], 1,
- p[2].getUV(0)[0],p[2].getUV(0)[1], 1);
-
-
- MT_Matrix3x3 mat3inv = mat3.inverse();
-
- MT_Vector3 p123x(p[0].xyz()[XCOORD],p[1].xyz()[XCOORD],p[2].xyz()[XCOORD]);
- MT_Vector3 resultx = mat3inv*p123x;
- MT_Vector3 p123y(p[0].xyz()[YCOORD],p[1].xyz()[YCOORD],p[2].xyz()[YCOORD]);
- MT_Vector3 resulty = mat3inv*p123y;
-
- // normal[ZCOORD] is not zero, because it's chosen to be maximal (absolute), and normal has length 1,
- // so at least on of the coords is <> 0
-
- //droppedvalue udir.dot(normal) =0
- MT_Scalar droppedu = -(resultx.x()*normal[XCOORD]+resulty.x()*normal[YCOORD])/normal[ZCOORD];
- udir[XCOORD] = resultx.x();
- udir[YCOORD] = resulty.x();
- udir[ZCOORD] = droppedu;
- MT_Scalar droppedv = -(resultx.y()*normal[XCOORD]+resulty.y()*normal[YCOORD])/normal[ZCOORD];
- vdir[XCOORD] = resultx.y();
- vdir[YCOORD] = resulty.y();
- vdir[ZCOORD] = droppedv;
- // droppedvalue b = -(ax+cz+d)/y;
- MT_Scalar droppedvalue = -((resultx.z()*normal[XCOORD] + resulty.z()*normal[YCOORD]+d))/normal[ZCOORD];
- origin[XCOORD] = resultx.z();
- origin[YCOORD] = resulty.z();
- origin[ZCOORD] = droppedvalue;
-
-
-}
-
-#ifdef _TEXOWNMAIN
-
-int main()
-{
-
- MT_Point2 puv0={0,0};
- MT_Point3 pxyz0 (0,0,128);
-
- MT_Scalar puv1[2] = {1,0};
- MT_Point3 pxyz1(128,0,128);
-
- MT_Scalar puv2[2] = {1,1};
- MT_Point3 pxyz2(128,0,0);
-
- RAS_TexVert p0(pxyz0,puv0);
- RAS_TexVert p1(pxyz1,puv1);
- RAS_TexVert p2(pxyz2,puv2);
-
- RAS_TexVert vertices[3] =
- {
- p0,
- p1,
- p2
- };
-
- MT_Vector3 udir,vdir;
- MT_Point3 origin;
- CalcTexMatrix(vertices,origin,udir,vdir);
-
- MT_Point3 testpoint(128,32,64);
-
- MT_Scalar lenu = udir.length2();
- MT_Scalar lenv = vdir.length2();
-
- MT_Scalar testu=((pxyz2-origin).dot(udir))/lenu;
- MT_Scalar testv=((pxyz2-origin).dot(vdir))/lenv;
-
-
-
-
- return 0;
-}
-
-#endif // _TEXOWNMAIN