This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/gameengine/GamePlayer/common/GPC_RenderTools.h

177 lines
3.8 KiB
C++
Raw Normal View History

2002-10-12 11:37:38 +00:00
/**
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
2002-10-12 11:37:38 +00:00
*
* 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.
2002-10-12 11:37:38 +00:00
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 *****
2002-10-12 11:37:38 +00:00
*/
#ifndef __GPC_RENDERTOOLS_H
#define __GPC_RENDERTOOLS_H
Merge of apricot branch game engine changes into trunk, excluding GLSL. GLEW ==== Added the GLEW opengl extension library into extern/, always compiled into Blender now. This is much nicer than doing this kind of extension management manually, and will be used in the game engine, for GLSL, and other opengl extensions. * According to the GLEW website it works on Windows, Linux, Mac OS X, FreeBSD, Irix, and Solaris. There might still be platform specific issues due to this commit, so let me know and I'll look into it. * This means also that all extensions will now always be compiled in, regardless of the glext.h on the platform where compilation happens. Game Engine =========== Refactoring of the use of opengl extensions and other drawing code in the game engine, and cleaning up some hacks related to GLSL integration. These changes will be merged into trunk too after this. The game engine graphics demos & apricot level survived my tests, but this could use some good testing of course. For users: please test with the options "Generate Display Lists" and "Vertex Arrays" enabled, these should be the fastest and are supposed to be "unreliable", but if that's the case that's probably due to bugs that can be fixed. * The game engine now also uses GLEW for extensions, replacing the custom opengl extensions code that was there. Removes a lot of #ifdef's, but the runtime checks stay of course. * Removed the WITHOUT_GLEXT environment variable. This was added to work around a specific bug and only disabled multitexturing anyway. It might also have caused a slowdown since it was retrieving the environment variable for every vertex in immediate mode (bug #13680). * Refactored the code to allow drawing skinned meshes with vertex arrays too, removing some specific immediate mode drawing functions for this that only did extra normal calculation. Now it always splits vertices of flat faces instead. * Refactored normal recalculation with some minor optimizations, required for the above change. * Removed some outdated code behind the __NLA_OLDDEFORM #ifdef. * Fixed various bugs in setting of multitexture coordinates and vertex attributes for vertex arrays. These were not being enabled/disabled correct according to the opengl spec, leading to crashes. Also tangent attributes used an immediate mode call for vertex arrays, which can't work. * Fixed use of uninitialized variable in RAS_TexVert. * Exporting skinned meshes was doing O(n^2) lookups for vertices and deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
#ifdef WIN32
#include <windows.h>
#endif // WIN32
2002-10-12 11:37:38 +00:00
Merge of apricot branch game engine changes into trunk, excluding GLSL. GLEW ==== Added the GLEW opengl extension library into extern/, always compiled into Blender now. This is much nicer than doing this kind of extension management manually, and will be used in the game engine, for GLSL, and other opengl extensions. * According to the GLEW website it works on Windows, Linux, Mac OS X, FreeBSD, Irix, and Solaris. There might still be platform specific issues due to this commit, so let me know and I'll look into it. * This means also that all extensions will now always be compiled in, regardless of the glext.h on the platform where compilation happens. Game Engine =========== Refactoring of the use of opengl extensions and other drawing code in the game engine, and cleaning up some hacks related to GLSL integration. These changes will be merged into trunk too after this. The game engine graphics demos & apricot level survived my tests, but this could use some good testing of course. For users: please test with the options "Generate Display Lists" and "Vertex Arrays" enabled, these should be the fastest and are supposed to be "unreliable", but if that's the case that's probably due to bugs that can be fixed. * The game engine now also uses GLEW for extensions, replacing the custom opengl extensions code that was there. Removes a lot of #ifdef's, but the runtime checks stay of course. * Removed the WITHOUT_GLEXT environment variable. This was added to work around a specific bug and only disabled multitexturing anyway. It might also have caused a slowdown since it was retrieving the environment variable for every vertex in immediate mode (bug #13680). * Refactored the code to allow drawing skinned meshes with vertex arrays too, removing some specific immediate mode drawing functions for this that only did extra normal calculation. Now it always splits vertices of flat faces instead. * Refactored normal recalculation with some minor optimizations, required for the above change. * Removed some outdated code behind the __NLA_OLDDEFORM #ifdef. * Fixed various bugs in setting of multitexture coordinates and vertex attributes for vertex arrays. These were not being enabled/disabled correct according to the opengl spec, leading to crashes. Also tangent attributes used an immediate mode call for vertex arrays, which can't work. * Fixed use of uninitialized variable in RAS_TexVert. * Exporting skinned meshes was doing O(n^2) lookups for vertices and deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
#include "GL/glew.h"
2002-10-12 11:37:38 +00:00
#include "RAS_IRenderTools.h"
#include "BMF_Api.h"
struct KX_ClientObjectInfo;
2002-10-12 11:37:38 +00:00
class GPC_RenderTools : public RAS_IRenderTools
{
public:
GPC_RenderTools();
virtual ~GPC_RenderTools();
virtual void EndFrame(RAS_IRasterizer* rasty);
virtual void BeginFrame(RAS_IRasterizer* rasty);
void DisableOpenGLLights()
{
glDisable(GL_LIGHTING);
glDisable(GL_COLOR_MATERIAL);
}
void EnableOpenGLLights();
2002-10-12 11:37:38 +00:00
int ProcessLighting(int layer);
void Perspective(int a, int width, int height, float mat[4][4], float viewmat[4][4])
{
if(a== 0)
{
glMatrixMode(GL_PROJECTION);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
else
{
if(a== 1)
{
glMatrixMode(GL_PROJECTION);
glMatrixMode(GL_MODELVIEW);
}
}
}
/**
* @attention mode is ignored here
*/
virtual void RenderText2D(
RAS_TEXT_RENDER_MODE mode,
const char* text,
int xco,
int yco,
int width,
int height);
/**
* Renders text into a (series of) polygon(s), using a texture font,
* Each character consists of one polygon (one quad or two triangles)
*/
virtual void RenderText(
int mode,
RAS_IPolyMaterial* polymat,
float v1[3],
float v2[3],
float v3[3],
float v4[3]);
void Render(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode)
{
glPopMatrix();
glPushMatrix();
glMultMatrixd(oglmatrix);
}
void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode);
virtual void PushMatrix()
{
glPushMatrix();
}
virtual void PopMatrix()
{
glPopMatrix();
}
virtual class RAS_IPolyMaterial* CreateBlenderPolyMaterial(
const STR_String &texname,
bool ba,
const STR_String& matname,
int tile,
int tilexrep,int tileyrep,
int mode,
bool transparant,
bool zsort,
2002-10-12 11:37:38 +00:00
int lightlayer,
bool bIsTriangle,
void* clientobject,
void* tface);
int applyLights(int objectlayer);
bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data);
virtual void MotionBlur(RAS_IRasterizer* rasterizer);
2007-10-22 20:24:26 +00:00
virtual void Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text);
2007-10-22 20:24:26 +00:00
virtual void Render2DFilters(RAS_ICanvas* canvas);
virtual void SetClientObject(void* obj);
2002-10-12 11:37:38 +00:00
protected:
/**
* Copied from KX_BlenderGL.cpp in KX_blenderhook
*/
void BL_RenderText(
int mode,
const char* textstr,
int textlen,
Added custom vertex/edge/face data for meshes: All data layers, including MVert/MEdge/MFace, are now managed as custom data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are still used of course, but allocating, copying or freeing these arrays should be done through the CustomData API. Work in progress documentation on this is here: http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData Replaced TFace by MTFace: This is the same struct, except that it does not contain color, that now always stays separated in MCol. This was not a good design decision to begin with, and it is needed for adding multiple color layers later. Note that this does mean older Blender versions will not be able to read UV coordinates from the next release, due to an SDNA limitation. Removed DispListMesh: This now fully replaced by DerivedMesh. To provide access to arrays of vertices, edges and faces, like DispListMesh does. The semantics of the DerivedMesh.getVertArray() and similar functions were changed to return a pointer to an array if one exists, or otherwise allocate a temporary one. On releasing the DerivedMesh, this temporary array will be removed automatically. Removed ssDM and meshDM DerivedMesh backends: The ssDM backend was for DispListMesh, so that became obsolete automatically. The meshDM backend was replaced by the custom data backend, that now figures out which layers need to be modified, and only duplicates those. This changes code in many places, and overall removes 2514 lines of code. So, there's a good chance this might break some stuff, although I've been testing it for a few days now. The good news is, adding multiple color and uv layers should now become easy.
2006-11-20 04:28:02 +00:00
struct MTFace* tface,
unsigned int* col,
2002-10-12 11:37:38 +00:00
float v1[3],float v2[3],float v3[3],float v4[3]);
void BL_spack(unsigned int ucol)
{
char *cp = (char *)&ucol;
glColor3ub(cp[3], cp[2], cp[1]);
}
BMF_Font* m_font;
static unsigned int m_numgllights;
2002-10-12 11:37:38 +00:00
};
#endif // __GPC_RENDERTOOLS_H
2007-10-22 20:24:26 +00:00