moved files around
This commit is contained in:
162
Demos/OpenGL/BMF_Api.cpp
Normal file
162
Demos/OpenGL/BMF_Api.cpp
Normal file
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* ***** BEGIN GPL/BL DUAL 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. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* 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/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* Copyright (C) 2001 NaN Technologies B.V.
|
||||
*
|
||||
* Implementation of the API of the OpenGL bitmap font library.
|
||||
*/
|
||||
|
||||
#include "BMF_Api.h"
|
||||
|
||||
#include "BMF_BitmapFont.h"
|
||||
|
||||
|
||||
#if BMF_INCLUDE_HELV10
|
||||
extern BMF_FontData BMF_font_helv10;
|
||||
static BMF_BitmapFont bmfHelv10(&BMF_font_helv10);
|
||||
#endif // BMF_INCLUDE_HELV10
|
||||
#if BMF_INCLUDE_HELV12
|
||||
extern BMF_FontData BMF_font_helv12;
|
||||
static BMF_BitmapFont bmfHelv12(&BMF_font_helv12);
|
||||
#endif // BMF_INCLUDE_HELV12
|
||||
#if BMF_INCLUDE_HELVB8
|
||||
extern BMF_FontData BMF_font_helvb8;
|
||||
static BMF_BitmapFont bmfHelvb8(&BMF_font_helvb8);
|
||||
#endif // BMF_INCLUDE_HELVB8
|
||||
#if BMF_INCLUDE_HELVB10
|
||||
extern BMF_FontData BMF_font_helvb10;
|
||||
static BMF_BitmapFont bmfHelvb10(&BMF_font_helvb10);
|
||||
#endif // BMF_INCLUDE_HELVB10
|
||||
#if BMF_INCLUDE_HELVB12
|
||||
extern BMF_FontData BMF_font_helvb12;
|
||||
static BMF_BitmapFont bmfHelvb12(&BMF_font_helvb12);
|
||||
#endif // BMF_INCLUDE_HELVB12
|
||||
#if BMF_INCLUDE_HELVB14
|
||||
extern BMF_FontData BMF_font_helvb14;
|
||||
static BMF_BitmapFont bmfHelvb14(&BMF_font_helvb14);
|
||||
#endif // BMF_INCLUDE_HELVB14
|
||||
#if BMF_INCLUDE_SCR12
|
||||
extern BMF_FontData BMF_font_scr12;
|
||||
static BMF_BitmapFont bmfScreen12(&BMF_font_scr12);
|
||||
#endif // BMF_INCLUDE_SCR12
|
||||
#if BMF_INCLUDE_SCR14
|
||||
extern BMF_FontData BMF_font_scr14;
|
||||
static BMF_BitmapFont bmfScreen14(&BMF_font_scr14);
|
||||
#endif // BMF_INCLUDE_SCR14
|
||||
#if BMF_INCLUDE_SCR15
|
||||
extern BMF_FontData BMF_font_scr15;
|
||||
static BMF_BitmapFont bmfScreen15(&BMF_font_scr15);
|
||||
#endif // BMF_INCLUDE_SCR15
|
||||
|
||||
|
||||
BMF_Font* BMF_GetFont(BMF_FontType font)
|
||||
{
|
||||
switch (font)
|
||||
{
|
||||
#if BMF_INCLUDE_HELV10
|
||||
case BMF_kHelvetica10: return (BMF_Font*) &bmfHelv10;
|
||||
#endif // BMF_INCLUDE_HELV10
|
||||
#if BMF_INCLUDE_HELV12
|
||||
case BMF_kHelvetica12: return (BMF_Font*) &bmfHelv12;
|
||||
#endif // BMF_INCLUDE_HELV12
|
||||
#if BMF_INCLUDE_HELVB8
|
||||
case BMF_kHelveticaBold8: return (BMF_Font*) &bmfHelvb8;
|
||||
#endif // BMF_INCLUDE_HELVB8
|
||||
#if BMF_INCLUDE_HELVB10
|
||||
case BMF_kHelveticaBold10: return (BMF_Font*) &bmfHelvb10;
|
||||
#endif // BMF_INCLUDE_HELVB10
|
||||
#if BMF_INCLUDE_HELVB12
|
||||
case BMF_kHelveticaBold12: return (BMF_Font*) &bmfHelvb12;
|
||||
#endif // BMF_INCLUDE_HELVB12
|
||||
#if BMF_INCLUDE_HELVB14
|
||||
case BMF_kHelveticaBold14: return (BMF_Font*) &bmfHelvb14;
|
||||
#endif // BMF_INCLUDE_HELVB12
|
||||
#if BMF_INCLUDE_SCR12
|
||||
case BMF_kScreen12: return (BMF_Font*) &bmfScreen12;
|
||||
#endif // BMF_INCLUDE_SCR12
|
||||
#if BMF_INCLUDE_SCR14
|
||||
case BMF_kScreen14: return (BMF_Font*) &bmfScreen14;
|
||||
#endif // BMF_INCLUDE_SCR14
|
||||
#if BMF_INCLUDE_SCR15
|
||||
case BMF_kScreen15: return (BMF_Font*) &bmfScreen15;
|
||||
#endif // BMF_INCLUDE_SCR15
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int BMF_DrawCharacter(BMF_Font* font, char c)
|
||||
{
|
||||
char str[2] = {c, '\0'};
|
||||
return BMF_DrawString(font, str);
|
||||
}
|
||||
|
||||
|
||||
int BMF_DrawString(BMF_Font* font, const char* str)
|
||||
{
|
||||
if (!font) return 0;
|
||||
((BMF_BitmapFont*)font)->DrawString(str);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int BMF_GetCharacterWidth(BMF_Font* font, char c)
|
||||
{
|
||||
char str[2] = {c, '\0'};
|
||||
return BMF_GetStringWidth(font, str);
|
||||
}
|
||||
|
||||
|
||||
int BMF_GetStringWidth(BMF_Font* font, char* str)
|
||||
{
|
||||
if (!font) return 0;
|
||||
return ((BMF_BitmapFont*)font)->GetStringWidth(str);
|
||||
}
|
||||
|
||||
|
||||
void BMF_GetBoundingBox(BMF_Font* font, int *xmin_r, int *ymin_r, int *xmax_r, int *ymax_r)
|
||||
{
|
||||
if (!font) return;
|
||||
((BMF_BitmapFont*)font)->GetBoundingBox(*xmin_r, *ymin_r, *xmax_r, *ymax_r);
|
||||
}
|
||||
|
||||
int BMF_GetFontTexture(BMF_Font* font) {
|
||||
if (!font) return -1;
|
||||
return ((BMF_BitmapFont*)font)->GetTexture();
|
||||
}
|
||||
|
||||
void BMF_DrawStringTexture(BMF_Font* font, char *string, float x, float y, float z) {
|
||||
if (!font) return;
|
||||
((BMF_BitmapFont*)font)->DrawStringTexture(string, x, y, z);
|
||||
}
|
||||
128
Demos/OpenGL/BMF_Api.h
Normal file
128
Demos/OpenGL/BMF_Api.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* ***** BEGIN GPL/BL DUAL 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. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* 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/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* Copyright (C) 2001 NaN Technologies B.V.
|
||||
*
|
||||
* API of the OpenGL bitmap font library.
|
||||
* Currently draws fonts using the glBitmap routine.
|
||||
* This implies that drawing speed is heavyly dependant on
|
||||
* the 2D capabilities of the graphics card.
|
||||
*/
|
||||
|
||||
#ifndef __BMF_API_H
|
||||
#define __BMF_API_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "BMF_Fonts.h"
|
||||
|
||||
/**
|
||||
* Returns the font for a given font type.
|
||||
* @param font The font to retrieve.
|
||||
* @return The font (or nil if not found).
|
||||
*/
|
||||
BMF_Font* BMF_GetFont(BMF_FontType font);
|
||||
|
||||
/**
|
||||
* Draws a character at the current raster position.
|
||||
* @param font The font to use.
|
||||
* @param c The character to draw.
|
||||
* @return Indication of success (0 == error).
|
||||
*/
|
||||
int BMF_DrawCharacter(BMF_Font* font, char c);
|
||||
|
||||
/**
|
||||
* Draws a string at the current raster position.
|
||||
* @param font The font to use.
|
||||
* @param str The string to draw.
|
||||
* @return Indication of success (0 == error).
|
||||
*/
|
||||
int BMF_DrawString(BMF_Font* font, const char* str);
|
||||
|
||||
/**
|
||||
* Returns the width of a character in pixels.
|
||||
* @param font The font to use.
|
||||
* @param c The character.
|
||||
* @return The length.
|
||||
*/
|
||||
int BMF_GetCharacterWidth(BMF_Font* font, char c);
|
||||
|
||||
/**
|
||||
* Returns the width of a string of characters.
|
||||
* @param font The font to use.
|
||||
* @param str The string.
|
||||
* @return The length.
|
||||
*/
|
||||
int BMF_GetStringWidth(BMF_Font* font, char* str);
|
||||
|
||||
/**
|
||||
* Returns the bounding box of the font. The width and
|
||||
* height represent the bounding box of the union of
|
||||
* all glyps. The minimum and maximum values of the
|
||||
* box represent the extent of the font and its positioning
|
||||
* about the origin.
|
||||
*/
|
||||
void BMF_GetBoundingBox(BMF_Font* font, int *xmin_r, int *ymin_r, int *xmax_r, int *ymax_r);
|
||||
|
||||
/**
|
||||
* Convert the given @a font to a texture, and return the GL texture
|
||||
* ID of the texture. If the texture ID is bound, text can
|
||||
* be drawn using the texture by calling DrawStringTexture.
|
||||
*
|
||||
* @param font The font to create the texture from.
|
||||
* @return The GL texture ID of the new texture, or -1 if unable
|
||||
* to create.
|
||||
*/
|
||||
int BMF_GetFontTexture(BMF_Font* font);
|
||||
|
||||
/**
|
||||
* Draw the given @a str at the point @a x, @a y, @a z, using
|
||||
* texture coordinates. This assumes that an appropriate texture
|
||||
* has been bound, see BMF_BitmapFont::GetTexture(). The string
|
||||
* is drawn along the positive X axis.
|
||||
*
|
||||
* @param font The font to draw with.
|
||||
* @param string The c-string to draw.
|
||||
* @param x The x coordinate to start drawing at.
|
||||
* @param y The y coordinate to start drawing at.
|
||||
* @param z The z coordinate to start drawing at.
|
||||
*/
|
||||
void BMF_DrawStringTexture(BMF_Font* font, char* string, float x, float y, float z);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BMF_API_H */
|
||||
|
||||
208
Demos/OpenGL/BMF_BitmapFont.cpp
Normal file
208
Demos/OpenGL/BMF_BitmapFont.cpp
Normal file
@@ -0,0 +1,208 @@
|
||||
/**
|
||||
* ***** BEGIN GPL/BL DUAL 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. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* 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/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* Copyright (C) 2001 NaN Technologies B.V.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(WIN32) || defined(__APPLE__)
|
||||
#ifdef WIN32
|
||||
#if !defined(__CYGWIN32__)
|
||||
#pragma warning(disable:4244)
|
||||
#endif /* __CYGWIN32__ */
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#else // WIN32
|
||||
// __APPLE__ is defined
|
||||
#include <AGL/gl.h>
|
||||
#endif // WIN32
|
||||
#else // defined(WIN32) || defined(__APPLE__)
|
||||
#include <GL/gl.h>
|
||||
#endif // defined(WIN32) || defined(__APPLE__)
|
||||
|
||||
#include "BMF_BitmapFont.h"
|
||||
|
||||
|
||||
BMF_BitmapFont::BMF_BitmapFont(BMF_FontData* fontData)
|
||||
: m_fontData(fontData)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BMF_BitmapFont::~BMF_BitmapFont(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BMF_BitmapFont::DrawString(const char* str)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
GLint alignment;
|
||||
unsigned char c;
|
||||
|
||||
glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
while (c = (unsigned char) *str++) {
|
||||
BMF_CharData & cd = m_fontData->chars[c];
|
||||
|
||||
if (cd.data_offset==-1) {
|
||||
GLubyte nullBitmap = 0;
|
||||
|
||||
glBitmap(1, 1, 0, 0, cd.advance, 0, &nullBitmap);
|
||||
} else {
|
||||
GLubyte *bitmap = &m_fontData->bitmap_data[cd.data_offset];
|
||||
|
||||
glBitmap(cd.width, cd.height, cd.xorig, cd.yorig, cd.advance, 0, bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
|
||||
}
|
||||
|
||||
|
||||
int BMF_BitmapFont::GetStringWidth(char* str)
|
||||
{
|
||||
unsigned char c;
|
||||
int length = 0;
|
||||
|
||||
while (c = (unsigned char) *str++) {
|
||||
length += m_fontData->chars[c].advance;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
void BMF_BitmapFont::GetBoundingBox(int & xMin, int & yMin, int & xMax, int & yMax)
|
||||
{
|
||||
xMin = m_fontData->xmin;
|
||||
yMin = m_fontData->ymin;
|
||||
xMax = m_fontData->xmax;
|
||||
yMax = m_fontData->ymax;
|
||||
}
|
||||
|
||||
int BMF_BitmapFont::GetTexture()
|
||||
{
|
||||
int fWidth = m_fontData->xmax - m_fontData->xmin;
|
||||
int fHeight = m_fontData->ymax - m_fontData->ymin;
|
||||
|
||||
if (fWidth>=16 || fHeight>=16) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int cRows = 16, cCols = 16;
|
||||
int cWidth = 16, cHeight = 16;
|
||||
int iWidth = cCols*cWidth;
|
||||
int iHeight = cRows*cHeight;
|
||||
GLubyte *img = new GLubyte [iHeight*iWidth];
|
||||
GLuint texId;
|
||||
|
||||
int baseLine = -(m_fontData->ymin);
|
||||
|
||||
memset(img, 0, iHeight*iWidth);
|
||||
for (int i = 0; i<256; i++) {
|
||||
BMF_CharData & cd = m_fontData->chars[i];
|
||||
|
||||
if (cd.data_offset != -1) {
|
||||
int cellX = i%16;
|
||||
int cellY = i/16;
|
||||
|
||||
for (int y = 0; y<cd.height; y++) {
|
||||
GLubyte* imgRow = &img[(cellY*cHeight + y + baseLine - cd.yorig)*iWidth];
|
||||
GLubyte* chrRow = &m_fontData->bitmap_data[cd.data_offset + ((cd.width+7)/8)*y];
|
||||
|
||||
for (int x = 0; x<cd.width; x++) {
|
||||
GLubyte* imgPxl = &imgRow[(cellX*cWidth + x - cd.xorig)];
|
||||
int byteIdx = x/8;
|
||||
int bitIdx = 7 - (x%8);
|
||||
|
||||
if (chrRow[byteIdx]&(1<<bitIdx)) {
|
||||
imgPxl[0] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glGenTextures(1, &texId);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texId);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA4, iWidth, iHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, img);
|
||||
if (glGetError()) {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE4_ALPHA4, iWidth, iHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, img);
|
||||
}
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
delete [] img;
|
||||
|
||||
return texId;
|
||||
}
|
||||
|
||||
void BMF_BitmapFont::DrawStringTexture(char *str, float x, float y, float z)
|
||||
{
|
||||
unsigned char c;
|
||||
float pos = 0;
|
||||
|
||||
int baseLine = -(m_fontData->ymin);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
while (c = (unsigned char) *str++) {
|
||||
BMF_CharData & cd = m_fontData->chars[c];
|
||||
|
||||
if (cd.data_offset != -1) {
|
||||
float cellX = (c%16)/16.0;
|
||||
float cellY = (c/16)/16.0;
|
||||
|
||||
glTexCoord2f(cellX + 1.0/16.0, cellY);
|
||||
glVertex3f(x + pos + 16.0, -baseLine + y + 0.0, z);
|
||||
|
||||
glTexCoord2f(cellX + 1.0/16.0, cellY + 1.0/16.0);
|
||||
glVertex3f(x + pos + 16.0, -baseLine + y + 16.0, z);
|
||||
|
||||
glTexCoord2f(cellX, cellY + 1.0/16.0);
|
||||
glVertex3f(x + pos + 0.0, -baseLine + y + 16.0, z);
|
||||
|
||||
glTexCoord2f(cellX, cellY);
|
||||
glVertex3f(x + pos + 0.0, -baseLine + y + 0.0, z);
|
||||
}
|
||||
|
||||
pos += cd.advance;
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
111
Demos/OpenGL/BMF_BitmapFont.h
Normal file
111
Demos/OpenGL/BMF_BitmapFont.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* ***** BEGIN GPL/BL DUAL 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. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* 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/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* Copyright (C) 2001 NaN Technologies B.V.
|
||||
*/
|
||||
|
||||
#ifndef __BMF_BITMAP_FONT_H
|
||||
#define __BMF_BITMAP_FONT_H
|
||||
|
||||
#include "BMF_FontData.h"
|
||||
|
||||
/**
|
||||
* Base class for OpenGL bitmap fonts.
|
||||
*/
|
||||
class BMF_BitmapFont
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
BMF_BitmapFont(BMF_FontData* fontData);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~BMF_BitmapFont(void);
|
||||
|
||||
/**
|
||||
* Draws a string at the current raster position.
|
||||
* @param str The string to draw.
|
||||
*/
|
||||
void DrawString(const char* str);
|
||||
|
||||
void DrawStringMemory(char* str);
|
||||
|
||||
|
||||
/**
|
||||
* Draws a string at the current raster position.
|
||||
* @param str The string to draw.
|
||||
* @return The width of the string.
|
||||
*/
|
||||
int GetStringWidth(char* str);
|
||||
|
||||
/**
|
||||
* Returns the bounding box of the font. The width and
|
||||
* height represent the bounding box of the union of
|
||||
* all glyps. The minimum and maximum values of the
|
||||
* box represent the extent of the font and its positioning
|
||||
* about the origin.
|
||||
*/
|
||||
void GetBoundingBox(int & xMin, int & yMin, int & xMax, int & yMax);
|
||||
|
||||
/**
|
||||
* Convert the font to a texture, and return the GL texture
|
||||
* ID of the texture. If the texture ID is bound, text can
|
||||
* be drawn using the texture by calling DrawStringTexture.
|
||||
*
|
||||
* @return The GL texture ID of the new texture, or -1 if unable
|
||||
* to create.
|
||||
*/
|
||||
int GetTexture();
|
||||
|
||||
/**
|
||||
* Draw the given @a string at the point @a x, @a y, @a z, using
|
||||
* texture coordinates. This assumes that an appropriate texture
|
||||
* has been bound, see BMF_BitmapFont::GetTexture(). The string
|
||||
* is drawn along the positive X axis.
|
||||
*
|
||||
* @param string The c-string to draw.
|
||||
* @param x The x coordinate to start drawing at.
|
||||
* @param y The y coordinate to start drawing at.
|
||||
* @param z The z coordinate to start drawing at.
|
||||
*/
|
||||
void DrawStringTexture(char* string, float x, float y, float z);
|
||||
|
||||
protected:
|
||||
/** Pointer to the font data. */
|
||||
BMF_FontData* m_fontData;
|
||||
};
|
||||
|
||||
#endif // __BMF_BITMAP_FONT_H
|
||||
|
||||
56
Demos/OpenGL/BMF_FontData.h
Normal file
56
Demos/OpenGL/BMF_FontData.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* ***** BEGIN GPL/BL DUAL 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. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* 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/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* Copyright (C) 2001 NaN Technologies B.V.
|
||||
*/
|
||||
|
||||
#ifndef __BMF_FONTDATA_H__
|
||||
#define __BMF_FONTDATA_H__
|
||||
|
||||
typedef struct {
|
||||
signed char width, height;
|
||||
signed char xorig, yorig;
|
||||
signed char advance;
|
||||
|
||||
short data_offset;
|
||||
} BMF_CharData;
|
||||
|
||||
typedef struct {
|
||||
int xmin, ymin;
|
||||
int xmax, ymax;
|
||||
|
||||
BMF_CharData chars[256];
|
||||
unsigned char* bitmap_data;
|
||||
} BMF_FontData;
|
||||
|
||||
#endif
|
||||
|
||||
75
Demos/OpenGL/BMF_Fonts.h
Normal file
75
Demos/OpenGL/BMF_Fonts.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* ***** BEGIN GPL/BL DUAL 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. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* 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/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* Copyright (C) 2001 NaN Technologies B.V.
|
||||
* Defines the names of the fonts in the library.
|
||||
*/
|
||||
|
||||
#ifndef __BMF_FONTS_H
|
||||
#define __BMF_FONTS_H
|
||||
|
||||
#include "BMF_Settings.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BMF_kHelvetica10 = 0,
|
||||
#if BMF_INCLUDE_HELV12
|
||||
BMF_kHelvetica12,
|
||||
#endif
|
||||
#if BMF_INCLUDE_HELVB8
|
||||
BMF_kHelveticaBold8,
|
||||
#endif
|
||||
#if BMF_INCLUDE_HELVB10
|
||||
BMF_kHelveticaBold10,
|
||||
#endif
|
||||
#if BMF_INCLUDE_HELVB12
|
||||
BMF_kHelveticaBold12,
|
||||
#endif
|
||||
#if BMF_INCLUDE_HELVB14
|
||||
BMF_kHelveticaBold14,
|
||||
#endif
|
||||
#if BMF_INCLUDE_SCR12
|
||||
BMF_kScreen12,
|
||||
#endif
|
||||
#if BMF_INCLUDE_SCR14
|
||||
BMF_kScreen14,
|
||||
#endif
|
||||
#if BMF_INCLUDE_SCR15
|
||||
BMF_kScreen15,
|
||||
#endif
|
||||
BMF_kNumFonts
|
||||
} BMF_FontType;
|
||||
|
||||
typedef struct BMF_Font BMF_Font;
|
||||
|
||||
#endif /* __BMF_FONTS_H */
|
||||
|
||||
52
Demos/OpenGL/BMF_Settings.h
Normal file
52
Demos/OpenGL/BMF_Settings.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* ***** BEGIN GPL/BL DUAL 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. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* 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/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* Copyright (C) 2001 NaN Technologies B.V.
|
||||
* Allows you to determine which fonts to include in the library.
|
||||
*/
|
||||
|
||||
#ifndef __BMF_SETTINGS_H
|
||||
#define __BMF_SETTINGS_H
|
||||
|
||||
|
||||
#define BMF_INCLUDE_HELV12 0
|
||||
#define BMF_INCLUDE_HELVB8 0
|
||||
#define BMF_INCLUDE_HELVB10 0
|
||||
#define BMF_INCLUDE_HELVB12 0
|
||||
#define BMF_INCLUDE_HELVB14 0
|
||||
#define BMF_INCLUDE_SCR12 0
|
||||
#define BMF_INCLUDE_SCR14 0
|
||||
#define BMF_INCLUDE_SCR15 0
|
||||
#define BMF_INCLUDE_HELV10 1
|
||||
|
||||
#endif /* __BMF_SETTINGS_H */
|
||||
|
||||
491
Demos/OpenGL/BMF_font_helv10.cpp
Normal file
491
Demos/OpenGL/BMF_font_helv10.cpp
Normal file
@@ -0,0 +1,491 @@
|
||||
/**
|
||||
* ***** BEGIN GPL/BL DUAL 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. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* 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/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "BMF_FontData.h"
|
||||
#include "BMF_Settings.h"
|
||||
|
||||
#if BMF_INCLUDE_HELV10
|
||||
|
||||
static unsigned char bitmap_data[]= {
|
||||
0x80,0x00,0x80,0x80,0x80,0x80,0x80,0x80,
|
||||
0xa0,0xa0,0x50,0x50,0xf8,0x28,0x7c,0x28,
|
||||
0x28,0x20,0x70,0xa8,0x28,0x70,0xa0,0xa8,
|
||||
0x70,0x20,0x26,0x29,0x16,0x10,0x08,0x68,
|
||||
0x94,0x64,0x64,0x98,0x98,0xa4,0x60,0x50,
|
||||
0x50,0x20,0x80,0x40,0x40,0x20,0x40,0x40,
|
||||
0x80,0x80,0x80,0x80,0x40,0x40,0x20,0x80,
|
||||
0x40,0x40,0x20,0x20,0x20,0x20,0x40,0x40,
|
||||
0x80,0xa0,0x40,0xa0,0x20,0x20,0xf8,0x20,
|
||||
0x20,0x80,0x40,0x40,0xf8,0x80,0x80,0x80,
|
||||
0x40,0x40,0x40,0x40,0x20,0x20,0x70,0x88,
|
||||
0x88,0x88,0x88,0x88,0x88,0x70,0x40,0x40,
|
||||
0x40,0x40,0x40,0x40,0xc0,0x40,0xf8,0x80,
|
||||
0x40,0x30,0x08,0x08,0x88,0x70,0x70,0x88,
|
||||
0x08,0x08,0x30,0x08,0x88,0x70,0x10,0x10,
|
||||
0xf8,0x90,0x50,0x50,0x30,0x10,0x70,0x88,
|
||||
0x08,0x08,0xf0,0x80,0x80,0xf8,0x70,0x88,
|
||||
0x88,0xc8,0xb0,0x80,0x88,0x70,0x40,0x40,
|
||||
0x20,0x20,0x10,0x10,0x08,0xf8,0x70,0x88,
|
||||
0x88,0x88,0x70,0x88,0x88,0x70,0x70,0x88,
|
||||
0x08,0x68,0x98,0x88,0x88,0x70,0x80,0x00,
|
||||
0x00,0x00,0x00,0x80,0x80,0x40,0x40,0x00,
|
||||
0x00,0x00,0x00,0x40,0x20,0x40,0x80,0x40,
|
||||
0x20,0xf0,0x00,0xf0,0x80,0x40,0x20,0x40,
|
||||
0x80,0x40,0x00,0x40,0x40,0x20,0x10,0x90,
|
||||
0x60,0x3e,0x00,0x40,0x00,0x9b,0x00,0xa4,
|
||||
0x80,0xa4,0x80,0xa2,0x40,0x92,0x40,0x4d,
|
||||
0x40,0x20,0x80,0x1f,0x00,0x82,0x82,0x7c,
|
||||
0x44,0x28,0x28,0x10,0x10,0xf0,0x88,0x88,
|
||||
0x88,0xf0,0x88,0x88,0xf0,0x78,0x84,0x80,
|
||||
0x80,0x80,0x80,0x84,0x78,0xf0,0x88,0x84,
|
||||
0x84,0x84,0x84,0x88,0xf0,0xf8,0x80,0x80,
|
||||
0x80,0xf8,0x80,0x80,0xf8,0x80,0x80,0x80,
|
||||
0x80,0xf0,0x80,0x80,0xf8,0x74,0x8c,0x84,
|
||||
0x8c,0x80,0x80,0x84,0x78,0x84,0x84,0x84,
|
||||
0x84,0xfc,0x84,0x84,0x84,0x80,0x80,0x80,
|
||||
0x80,0x80,0x80,0x80,0x80,0x60,0x90,0x10,
|
||||
0x10,0x10,0x10,0x10,0x10,0x88,0x88,0x90,
|
||||
0x90,0xe0,0xa0,0x90,0x88,0xf0,0x80,0x80,
|
||||
0x80,0x80,0x80,0x80,0x80,0x92,0x92,0x92,
|
||||
0xaa,0xaa,0xc6,0xc6,0x82,0x8c,0x8c,0x94,
|
||||
0x94,0xa4,0xa4,0xc4,0xc4,0x78,0x84,0x84,
|
||||
0x84,0x84,0x84,0x84,0x78,0x80,0x80,0x80,
|
||||
0x80,0xf0,0x88,0x88,0xf0,0x02,0x7c,0x8c,
|
||||
0x94,0x84,0x84,0x84,0x84,0x78,0x88,0x88,
|
||||
0x88,0x88,0xf0,0x88,0x88,0xf0,0x70,0x88,
|
||||
0x88,0x08,0x70,0x80,0x88,0x70,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0xf8,0x78,0x84,
|
||||
0x84,0x84,0x84,0x84,0x84,0x84,0x10,0x28,
|
||||
0x28,0x44,0x44,0x44,0x82,0x82,0x22,0x00,
|
||||
0x22,0x00,0x22,0x00,0x55,0x00,0x49,0x00,
|
||||
0x49,0x00,0x88,0x80,0x88,0x80,0x88,0x88,
|
||||
0x50,0x50,0x20,0x50,0x88,0x88,0x10,0x10,
|
||||
0x10,0x28,0x28,0x44,0x44,0x82,0xf8,0x80,
|
||||
0x40,0x20,0x20,0x10,0x08,0xf8,0xc0,0x80,
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,
|
||||
0x20,0x20,0x40,0x40,0x40,0x40,0x80,0x80,
|
||||
0xc0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
|
||||
0x40,0xc0,0x88,0x50,0x50,0x20,0x20,0xfc,
|
||||
0x80,0x80,0x40,0x68,0x90,0x90,0x70,0x10,
|
||||
0xe0,0xb0,0xc8,0x88,0x88,0xc8,0xb0,0x80,
|
||||
0x80,0x60,0x90,0x80,0x80,0x90,0x60,0x68,
|
||||
0x98,0x88,0x88,0x98,0x68,0x08,0x08,0x60,
|
||||
0x90,0x80,0xf0,0x90,0x60,0x40,0x40,0x40,
|
||||
0x40,0x40,0xe0,0x40,0x30,0x70,0x08,0x68,
|
||||
0x98,0x88,0x88,0x98,0x68,0x88,0x88,0x88,
|
||||
0x88,0xc8,0xb0,0x80,0x80,0x80,0x80,0x80,
|
||||
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x80,
|
||||
0x80,0x80,0x80,0x80,0x00,0x80,0x90,0x90,
|
||||
0xa0,0xc0,0xa0,0x90,0x80,0x80,0x80,0x80,
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x92,0x92,
|
||||
0x92,0x92,0x92,0xec,0x88,0x88,0x88,0x88,
|
||||
0xc8,0xb0,0x70,0x88,0x88,0x88,0x88,0x70,
|
||||
0x80,0x80,0xb0,0xc8,0x88,0x88,0xc8,0xb0,
|
||||
0x08,0x08,0x68,0x98,0x88,0x88,0x98,0x68,
|
||||
0x80,0x80,0x80,0x80,0xc0,0xa0,0x60,0x90,
|
||||
0x10,0x60,0x90,0x60,0x60,0x40,0x40,0x40,
|
||||
0x40,0xe0,0x40,0x40,0x70,0x90,0x90,0x90,
|
||||
0x90,0x90,0x20,0x20,0x50,0x50,0x88,0x88,
|
||||
0x28,0x28,0x54,0x54,0x92,0x92,0x88,0x88,
|
||||
0x50,0x20,0x50,0x88,0x80,0x40,0x40,0x60,
|
||||
0xa0,0xa0,0x90,0x90,0xf0,0x80,0x40,0x20,
|
||||
0x10,0xf0,0x20,0x40,0x40,0x40,0x40,0x80,
|
||||
0x40,0x40,0x40,0x20,0x80,0x80,0x80,0x80,
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x40,
|
||||
0x40,0x40,0x40,0x20,0x40,0x40,0x40,0x80,
|
||||
0x98,0x64,0x80,0x80,0x80,0x80,0x80,0x80,
|
||||
0x00,0x80,0x40,0x70,0xa8,0xa0,0xa0,0xa8,
|
||||
0x70,0x10,0xb0,0x48,0x40,0x40,0xe0,0x40,
|
||||
0x48,0x30,0x90,0x60,0x90,0x90,0x60,0x90,
|
||||
0x20,0xf8,0x20,0xf8,0x50,0x50,0x88,0x88,
|
||||
0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x80,
|
||||
0x80,0x80,0x70,0x88,0x18,0x70,0xc8,0x98,
|
||||
0x70,0xc0,0x88,0x70,0xa0,0x38,0x44,0x9a,
|
||||
0xa2,0x9a,0x44,0x38,0xe0,0x00,0xa0,0x20,
|
||||
0xe0,0x28,0x50,0xa0,0x50,0x28,0x08,0x08,
|
||||
0xf8,0xe0,0x38,0x44,0xaa,0xb2,0xba,0x44,
|
||||
0x38,0xe0,0x60,0x90,0x90,0x60,0xf8,0x00,
|
||||
0x20,0x20,0xf8,0x20,0x20,0xe0,0x40,0xa0,
|
||||
0x60,0xc0,0x20,0x40,0xe0,0x80,0x40,0x80,
|
||||
0x80,0xf0,0x90,0x90,0x90,0x90,0x90,0x28,
|
||||
0x28,0x28,0x28,0x28,0x68,0xe8,0xe8,0xe8,
|
||||
0x7c,0xc0,0xc0,0x40,0x40,0x40,0xc0,0x40,
|
||||
0xe0,0x00,0xe0,0xa0,0xe0,0xa0,0x50,0x28,
|
||||
0x50,0xa0,0x21,0x00,0x17,0x80,0x13,0x00,
|
||||
0x09,0x00,0x48,0x00,0x44,0x00,0xc4,0x00,
|
||||
0x42,0x00,0x27,0x12,0x15,0x0b,0x48,0x44,
|
||||
0xc4,0x42,0x21,0x00,0x17,0x80,0x13,0x00,
|
||||
0x09,0x00,0xc8,0x00,0x24,0x00,0x44,0x00,
|
||||
0xe2,0x00,0x60,0x90,0x80,0x40,0x20,0x20,
|
||||
0x00,0x20,0x82,0x82,0x7c,0x44,0x28,0x28,
|
||||
0x10,0x10,0x00,0x10,0x20,0x82,0x82,0x7c,
|
||||
0x44,0x28,0x28,0x10,0x10,0x00,0x10,0x08,
|
||||
0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,
|
||||
0x00,0x28,0x10,0x82,0x82,0x7c,0x44,0x28,
|
||||
0x28,0x10,0x10,0x00,0x28,0x14,0x82,0x82,
|
||||
0x7c,0x44,0x28,0x28,0x10,0x10,0x00,0x28,
|
||||
0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,
|
||||
0x10,0x28,0x10,0x8f,0x80,0x88,0x00,0x78,
|
||||
0x00,0x48,0x00,0x2f,0x80,0x28,0x00,0x18,
|
||||
0x00,0x1f,0x80,0x30,0x10,0x78,0x84,0x80,
|
||||
0x80,0x80,0x80,0x84,0x78,0xf8,0x80,0x80,
|
||||
0x80,0xf8,0x80,0x80,0xf8,0x00,0x20,0x40,
|
||||
0xf8,0x80,0x80,0x80,0xf8,0x80,0x80,0xf8,
|
||||
0x00,0x20,0x10,0xf8,0x80,0x80,0xf8,0x80,
|
||||
0x80,0x80,0xf8,0x00,0x50,0x20,0xf8,0x80,
|
||||
0x80,0x80,0xf8,0x80,0x80,0xf8,0x00,0x50,
|
||||
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
|
||||
0x00,0x40,0x80,0x80,0x80,0x80,0x80,0x80,
|
||||
0x80,0x80,0x80,0x00,0x80,0x40,0x40,0x40,
|
||||
0x40,0x40,0x40,0x40,0x40,0x40,0x00,0xa0,
|
||||
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
|
||||
0x40,0x00,0xa0,0x78,0x44,0x42,0x42,0xf2,
|
||||
0x42,0x44,0x78,0x8c,0x8c,0x94,0x94,0xa4,
|
||||
0xa4,0xc4,0xc4,0x00,0x50,0x28,0x78,0x84,
|
||||
0x84,0x84,0x84,0x84,0x84,0x78,0x00,0x10,
|
||||
0x20,0x78,0x84,0x84,0x84,0x84,0x84,0x84,
|
||||
0x78,0x00,0x10,0x08,0x78,0x84,0x84,0x84,
|
||||
0x84,0x84,0x84,0x78,0x00,0x28,0x10,0x78,
|
||||
0x84,0x84,0x84,0x84,0x84,0x84,0x78,0x00,
|
||||
0x50,0x28,0x78,0x84,0x84,0x84,0x84,0x84,
|
||||
0x84,0x78,0x00,0x48,0x88,0x50,0x20,0x50,
|
||||
0x88,0x80,0x78,0xc4,0xa4,0xa4,0x94,0x94,
|
||||
0x8c,0x78,0x04,0x78,0x84,0x84,0x84,0x84,
|
||||
0x84,0x84,0x84,0x00,0x10,0x20,0x78,0x84,
|
||||
0x84,0x84,0x84,0x84,0x84,0x84,0x00,0x20,
|
||||
0x10,0x78,0x84,0x84,0x84,0x84,0x84,0x84,
|
||||
0x84,0x00,0x28,0x10,0x78,0x84,0x84,0x84,
|
||||
0x84,0x84,0x84,0x84,0x00,0x48,0x10,0x10,
|
||||
0x10,0x28,0x28,0x44,0x44,0x82,0x00,0x10,
|
||||
0x08,0x80,0x80,0xf0,0x88,0x88,0xf0,0x80,
|
||||
0x80,0xa0,0x90,0x90,0x90,0xa0,0x90,0x90,
|
||||
0x60,0x68,0x90,0x90,0x70,0x10,0xe0,0x00,
|
||||
0x20,0x40,0x68,0x90,0x90,0x70,0x10,0xe0,
|
||||
0x00,0x20,0x10,0x68,0x90,0x90,0x70,0x10,
|
||||
0xe0,0x00,0x50,0x20,0x68,0x90,0x90,0x70,
|
||||
0x10,0xe0,0x00,0xa0,0x50,0x68,0x90,0x90,
|
||||
0x70,0x10,0xe0,0x00,0x50,0x68,0x90,0x90,
|
||||
0x70,0x10,0xe0,0x20,0x50,0x20,0x6c,0x92,
|
||||
0x90,0x7e,0x12,0xec,0x60,0x20,0x60,0x90,
|
||||
0x80,0x80,0x90,0x60,0x60,0x90,0x80,0xf0,
|
||||
0x90,0x60,0x00,0x20,0x40,0x60,0x90,0x80,
|
||||
0xf0,0x90,0x60,0x00,0x40,0x20,0x60,0x90,
|
||||
0x80,0xf0,0x90,0x60,0x00,0x50,0x20,0x60,
|
||||
0x90,0x80,0xf0,0x90,0x60,0x00,0x50,0x40,
|
||||
0x40,0x40,0x40,0x40,0x40,0x00,0x40,0x80,
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x80,
|
||||
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
|
||||
0xa0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
|
||||
0x00,0xa0,0x70,0x88,0x88,0x88,0x88,0x78,
|
||||
0x90,0x60,0x50,0x90,0x90,0x90,0x90,0x90,
|
||||
0xe0,0x00,0xa0,0x50,0x70,0x88,0x88,0x88,
|
||||
0x88,0x70,0x00,0x20,0x40,0x70,0x88,0x88,
|
||||
0x88,0x88,0x70,0x00,0x20,0x10,0x70,0x88,
|
||||
0x88,0x88,0x88,0x70,0x00,0x50,0x20,0x70,
|
||||
0x88,0x88,0x88,0x88,0x70,0x00,0x50,0x28,
|
||||
0x70,0x88,0x88,0x88,0x88,0x70,0x00,0x50,
|
||||
0x20,0x00,0xf8,0x00,0x20,0x70,0x88,0xc8,
|
||||
0xa8,0x98,0x74,0x70,0x90,0x90,0x90,0x90,
|
||||
0x90,0x00,0x20,0x40,0x70,0x90,0x90,0x90,
|
||||
0x90,0x90,0x00,0x40,0x20,0x70,0x90,0x90,
|
||||
0x90,0x90,0x90,0x00,0x50,0x20,0x70,0x90,
|
||||
0x90,0x90,0x90,0x90,0x00,0x50,0x80,0x40,
|
||||
0x40,0x60,0xa0,0xa0,0x90,0x90,0x00,0x20,
|
||||
0x10,0x80,0x80,0xb0,0xc8,0x88,0x88,0xc8,
|
||||
0xb0,0x80,0x80,0x80,0x40,0x40,0x60,0xa0,
|
||||
0xa0,0x90,0x90,0x00,0x50,
|
||||
};
|
||||
|
||||
BMF_FontData BMF_font_helv10 = {
|
||||
-1, -2,
|
||||
10, 11,
|
||||
{
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0, 0, 0, 0, 12, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0, 0, 0, 0, 3, -1},
|
||||
{1, 8, -1, 0, 3, 0},
|
||||
{3, 2, -1, -6, 4, 8},
|
||||
{6, 7, 0, 0, 6, 10},
|
||||
{5, 9, 0, 1, 6, 17},
|
||||
{8, 8, 0, 0, 9, 26},
|
||||
{6, 8, -1, 0, 8, 34},
|
||||
{2, 3, -1, -5, 3, 42},
|
||||
{3, 10, 0, 2, 4, 45},
|
||||
{3, 10, -1, 2, 4, 55},
|
||||
{3, 3, 0, -5, 4, 65},
|
||||
{5, 5, 0, -1, 6, 68},
|
||||
{2, 3, 0, 2, 3, 73},
|
||||
{5, 1, -1, -3, 7, 76},
|
||||
{1, 1, -1, 0, 3, 77},
|
||||
{3, 8, 0, 0, 3, 78},
|
||||
{5, 8, 0, 0, 6, 86},
|
||||
{2, 8, -1, 0, 6, 94},
|
||||
{5, 8, 0, 0, 6, 102},
|
||||
{5, 8, 0, 0, 6, 110},
|
||||
{5, 8, 0, 0, 6, 118},
|
||||
{5, 8, 0, 0, 6, 126},
|
||||
{5, 8, 0, 0, 6, 134},
|
||||
{5, 8, 0, 0, 6, 142},
|
||||
{5, 8, 0, 0, 6, 150},
|
||||
{5, 8, 0, 0, 6, 158},
|
||||
{1, 6, -1, 0, 3, 166},
|
||||
{2, 8, 0, 2, 3, 172},
|
||||
{3, 5, -1, -1, 6, 180},
|
||||
{4, 3, 0, -2, 5, 185},
|
||||
{3, 5, -1, -1, 6, 188},
|
||||
{4, 8, -1, 0, 6, 193},
|
||||
{10, 10, 0, 2, 11, 201},
|
||||
{7, 8, 0, 0, 7, 221},
|
||||
{5, 8, -1, 0, 7, 229},
|
||||
{6, 8, -1, 0, 8, 237},
|
||||
{6, 8, -1, 0, 8, 245},
|
||||
{5, 8, -1, 0, 7, 253},
|
||||
{5, 8, -1, 0, 6, 261},
|
||||
{6, 8, -1, 0, 8, 269},
|
||||
{6, 8, -1, 0, 8, 277},
|
||||
{1, 8, -1, 0, 3, 285},
|
||||
{4, 8, 0, 0, 5, 293},
|
||||
{5, 8, -1, 0, 7, 301},
|
||||
{4, 8, -1, 0, 6, 309},
|
||||
{7, 8, -1, 0, 9, 317},
|
||||
{6, 8, -1, 0, 8, 325},
|
||||
{6, 8, -1, 0, 8, 333},
|
||||
{5, 8, -1, 0, 7, 341},
|
||||
{7, 9, -1, 1, 8, 349},
|
||||
{5, 8, -1, 0, 7, 358},
|
||||
{5, 8, -1, 0, 7, 366},
|
||||
{5, 8, 0, 0, 5, 374},
|
||||
{6, 8, -1, 0, 8, 382},
|
||||
{7, 8, 0, 0, 7, 390},
|
||||
{9, 8, 0, 0, 9, 398},
|
||||
{5, 8, -1, 0, 7, 414},
|
||||
{7, 8, 0, 0, 7, 422},
|
||||
{5, 8, -1, 0, 7, 430},
|
||||
{2, 10, -1, 2, 3, 438},
|
||||
{3, 8, 0, 0, 3, 448},
|
||||
{2, 10, 0, 2, 3, 456},
|
||||
{5, 5, 0, -3, 6, 466},
|
||||
{6, 1, 0, 2, 6, 471},
|
||||
{2, 3, 0, -5, 3, 472},
|
||||
{5, 6, 0, 0, 5, 475},
|
||||
{5, 8, 0, 0, 6, 481},
|
||||
{4, 6, 0, 0, 5, 489},
|
||||
{5, 8, 0, 0, 6, 495},
|
||||
{4, 6, 0, 0, 5, 503},
|
||||
{4, 8, 0, 0, 4, 509},
|
||||
{5, 8, 0, 2, 6, 517},
|
||||
{5, 8, 0, 0, 6, 525},
|
||||
{1, 8, 0, 0, 2, 533},
|
||||
{1, 9, 0, 1, 2, 541},
|
||||
{4, 8, 0, 0, 5, 550},
|
||||
{1, 8, 0, 0, 2, 558},
|
||||
{7, 6, 0, 0, 8, 566},
|
||||
{5, 6, 0, 0, 6, 572},
|
||||
{5, 6, 0, 0, 6, 578},
|
||||
{5, 8, 0, 2, 6, 584},
|
||||
{5, 8, 0, 2, 6, 592},
|
||||
{3, 6, 0, 0, 4, 600},
|
||||
{4, 6, 0, 0, 5, 606},
|
||||
{3, 8, 0, 0, 4, 612},
|
||||
{4, 6, 0, 0, 5, 620},
|
||||
{5, 6, 0, 0, 6, 626},
|
||||
{7, 6, 0, 0, 8, 632},
|
||||
{5, 6, 0, 0, 6, 638},
|
||||
{4, 8, 0, 2, 5, 644},
|
||||
{4, 6, 0, 0, 5, 652},
|
||||
{3, 10, 0, 2, 3, 658},
|
||||
{1, 10, -1, 2, 3, 668},
|
||||
{3, 10, 0, 2, 3, 678},
|
||||
{6, 2, 0, -3, 7, 688},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0,0,0,0,0, -1},
|
||||
{0, 0, 0, 0, 3, -1},
|
||||
{1, 8, -1, 2, 3, 690},
|
||||
{5, 8, 0, 1, 6, 698},
|
||||
{5, 8, 0, 0, 6, 706},
|
||||
{4, 6, 0, -1, 5, 714},
|
||||
{5, 8, 0, 0, 6, 720},
|
||||
{1, 10, -1, 2, 3, 728},
|
||||
{5, 10, 0, 2, 6, 738},
|
||||
{3, 1, 0, -7, 3, 748},
|
||||
{7, 7, -1, 0, 9, 749},
|
||||
{3, 5, 0, -3, 4, 756},
|
||||
{5, 5, 0, 0, 6, 761},
|
||||
{5, 3, -1, -2, 7, 766},
|
||||
{3, 1, 0, -3, 4, 769},
|
||||
{7, 7, -1, 0, 9, 770},
|
||||
{3, 1, 0, -7, 3, 777},
|
||||
{4, 4, 0, -3, 4, 778},
|
||||
{5, 7, 0, 0, 6, 782},
|
||||
{3, 4, 0, -3, 3, 789},
|
||||
{3, 4, 0, -3, 3, 793},
|
||||
{2, 2, 0, -6, 3, 797},
|
||||
{4, 8, 0, 2, 5, 799},
|
||||
{6, 10, 0, 2, 6, 807},
|
||||
{2, 1, 0, -3, 3, 817},
|
||||
{2, 2, 0, 2, 3, 818},
|
||||
{2, 4, 0, -3, 3, 820},
|
||||
{3, 5, 0, -3, 4, 824},
|
||||
{5, 5, 0, 0, 6, 829},
|
||||
{9, 8, 0, 0, 9, 834},
|
||||
{8, 8, 0, 0, 9, 850},
|
||||
{9, 8, 0, 0, 9, 858},
|
||||
{4, 8, -1, 2, 6, 874},
|
||||
{7, 11, 0, 0, 7, 882},
|
||||
{7, 11, 0, 0, 7, 893},
|
||||
{7, 11, 0, 0, 7, 904},
|
||||
{7, 11, 0, 0, 7, 915},
|
||||
{7, 10, 0, 0, 7, 926},
|
||||
{7, 11, 0, 0, 7, 936},
|
||||
{9, 8, 0, 0, 10, 947},
|
||||
{6, 10, -1, 2, 8, 963},
|
||||
{5, 11, -1, 0, 7, 973},
|
||||
{5, 11, -1, 0, 7, 984},
|
||||
{5, 11, -1, 0, 7, 995},
|
||||
{5, 10, -1, 0, 7, 1006},
|
||||
{2, 11, 0, 0, 3, 1016},
|
||||
{2, 11, -1, 0, 3, 1027},
|
||||
{3, 11, 0, 0, 3, 1038},
|
||||
{3, 10, 0, 0, 3, 1049},
|
||||
{7, 8, 0, 0, 8, 1059},
|
||||
{6, 11, -1, 0, 8, 1067},
|
||||
{6, 11, -1, 0, 8, 1078},
|
||||
{6, 11, -1, 0, 8, 1089},
|
||||
{6, 11, -1, 0, 8, 1100},
|
||||
{6, 11, -1, 0, 8, 1111},
|
||||
{6, 10, -1, 0, 8, 1122},
|
||||
{5, 5, 0, -1, 6, 1132},
|
||||
{6, 10, -1, 1, 8, 1137},
|
||||
{6, 11, -1, 0, 8, 1147},
|
||||
{6, 11, -1, 0, 8, 1158},
|
||||
{6, 11, -1, 0, 8, 1169},
|
||||
{6, 10, -1, 0, 8, 1180},
|
||||
{7, 11, 0, 0, 7, 1190},
|
||||
{5, 8, -1, 0, 7, 1201},
|
||||
{4, 8, 0, 0, 5, 1209},
|
||||
{5, 9, 0, 0, 5, 1217},
|
||||
{5, 9, 0, 0, 5, 1226},
|
||||
{5, 9, 0, 0, 5, 1235},
|
||||
{5, 9, 0, 0, 5, 1244},
|
||||
{5, 8, 0, 0, 5, 1253},
|
||||
{5, 9, 0, 0, 5, 1261},
|
||||
{7, 6, 0, 0, 8, 1270},
|
||||
{4, 8, 0, 2, 5, 1276},
|
||||
{4, 9, 0, 0, 5, 1284},
|
||||
{4, 9, 0, 0, 5, 1293},
|
||||
{4, 9, 0, 0, 5, 1302},
|
||||
{4, 8, 0, 0, 5, 1311},
|
||||
{2, 9, 1, 0, 2, 1319},
|
||||
{2, 9, 0, 0, 2, 1328},
|
||||
{3, 9, 1, 0, 2, 1337},
|
||||
{3, 8, 0, 0, 2, 1346},
|
||||
{5, 9, 0, 0, 6, 1354},
|
||||
{4, 9, 0, 0, 5, 1363},
|
||||
{5, 9, 0, 0, 6, 1372},
|
||||
{5, 9, 0, 0, 6, 1381},
|
||||
{5, 9, 0, 0, 6, 1390},
|
||||
{5, 9, 0, 0, 6, 1399},
|
||||
{5, 8, 0, 0, 6, 1408},
|
||||
{5, 5, 0, -1, 6, 1416},
|
||||
{6, 6, 0, 0, 6, 1421},
|
||||
{4, 9, 0, 0, 5, 1427},
|
||||
{4, 9, 0, 0, 5, 1436},
|
||||
{4, 9, 0, 0, 5, 1445},
|
||||
{4, 8, 0, 0, 5, 1454},
|
||||
{4, 11, 0, 2, 5, 1462},
|
||||
{5, 10, 0, 2, 6, 1473},
|
||||
{4, 10, 0, 2, 5, 1483},
|
||||
},
|
||||
bitmap_data
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
76
Demos/OpenGL/DebugCastResult.h
Normal file
76
Demos/OpenGL/DebugCastResult.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef DEBUG_CAST_RESULT_H
|
||||
#define DEBUG_CAST_RESULT_H
|
||||
|
||||
#include "NarrowPhaseCollision/ConvexCast.h"
|
||||
#include "SimdTransform.h"
|
||||
#include "GL_ShapeDrawer.h"
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
struct DebugCastResult : public ConvexCast::CastResult
|
||||
{
|
||||
|
||||
SimdTransform m_fromTrans;
|
||||
const PolyhedralConvexShape* m_shape;
|
||||
SimdVector3 m_linVel;
|
||||
SimdVector3 m_angVel;
|
||||
|
||||
DebugCastResult(const SimdTransform& fromTrans,const PolyhedralConvexShape* shape,
|
||||
const SimdVector3& linVel,const SimdVector3& angVel)
|
||||
:m_fromTrans(fromTrans),
|
||||
m_shape(shape),
|
||||
m_linVel(linVel),
|
||||
m_angVel(angVel)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void DrawCoordSystem(const SimdTransform& tr)
|
||||
{
|
||||
float m[16];
|
||||
tr.getOpenGLMatrix(m);
|
||||
glPushMatrix();
|
||||
glLoadMatrixf(m);
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1, 0, 0);
|
||||
glVertex3d(0, 0, 0);
|
||||
glVertex3d(1, 0, 0);
|
||||
glColor3f(0, 1, 0);
|
||||
glVertex3d(0, 0, 0);
|
||||
glVertex3d(0, 1, 0);
|
||||
glColor3f(0, 0, 1);
|
||||
glVertex3d(0, 0, 0);
|
||||
glVertex3d(0, 0, 1);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
virtual void DebugDraw(SimdScalar fraction)
|
||||
{
|
||||
|
||||
float m[16];
|
||||
SimdTransform hitTrans;
|
||||
SimdTransformUtil::IntegrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans);
|
||||
hitTrans.getOpenGLMatrix(m);
|
||||
GL_ShapeDrawer::DrawOpenGL(m,m_shape,SimdVector3(1,0,0),IDebugDraw::DBG_NoDebug);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif //DEBUG_CAST_RESULT_H
|
||||
53
Demos/OpenGL/GLDebugDrawer.cpp
Normal file
53
Demos/OpenGL/GLDebugDrawer.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
#include "GLDebugDrawer.h"
|
||||
#include "SimdPoint3.h"
|
||||
|
||||
#ifdef WIN32 //needed for glut.h
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <GL/glut.h>
|
||||
#include "BMF_Api.h"
|
||||
#include <stdio.h> //printf debugging
|
||||
GLDebugDrawer::GLDebugDrawer()
|
||||
:m_debugMode(0)
|
||||
{
|
||||
|
||||
}
|
||||
void GLDebugDrawer::DrawLine(const SimdVector3& from,const SimdVector3& to,const SimdVector3& color)
|
||||
{
|
||||
if (m_debugMode > 0)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(color.getX(), color.getY(), color.getZ());
|
||||
glVertex3d(from.getX(), from.getY(), from.getZ());
|
||||
glVertex3d(to.getX(), to.getY(), to.getZ());
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void GLDebugDrawer::SetDebugMode(int debugMode)
|
||||
{
|
||||
m_debugMode = debugMode;
|
||||
|
||||
}
|
||||
|
||||
void GLDebugDrawer::DrawContactPoint(const SimdVector3& pointOnB,const SimdVector3& normalOnB,float distance,int lifeTime,const SimdVector3& color)
|
||||
{
|
||||
if (m_debugMode & IDebugDraw::DBG_DrawContactPoints)
|
||||
{
|
||||
SimdVector3 to=pointOnB+normalOnB*distance;
|
||||
const SimdVector3&from = pointOnB;
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(color.getX(), color.getY(), color.getZ());
|
||||
glVertex3d(from.getX(), from.getY(), from.getZ());
|
||||
glVertex3d(to.getX(), to.getY(), to.getZ());
|
||||
glEnd();
|
||||
|
||||
glRasterPos3f(from.x(), from.y(), from.z());
|
||||
char buf[12];
|
||||
sprintf(buf," %d",lifeTime);
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
26
Demos/OpenGL/GLDebugDrawer.h
Normal file
26
Demos/OpenGL/GLDebugDrawer.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef GL_DEBUG_DRAWER_H
|
||||
#define GL_DEBUG_DRAWER_H
|
||||
|
||||
#include "IDebugDraw.h"
|
||||
|
||||
|
||||
|
||||
class GLDebugDrawer : public IDebugDraw
|
||||
{
|
||||
int m_debugMode;
|
||||
|
||||
public:
|
||||
|
||||
GLDebugDrawer();
|
||||
|
||||
virtual void DrawLine(const SimdVector3& from,const SimdVector3& to,const SimdVector3& color);
|
||||
|
||||
virtual void DrawContactPoint(const SimdVector3& PointOnB,const SimdVector3& normalOnB,float distance,int lifeTime,const SimdVector3& color);
|
||||
|
||||
virtual void SetDebugMode(int debugMode);
|
||||
|
||||
virtual int GetDebugMode() const { return m_debugMode;}
|
||||
|
||||
};
|
||||
|
||||
#endif//GL_DEBUG_DRAWER_H
|
||||
232
Demos/OpenGL/GL_ShapeDrawer.cpp
Normal file
232
Demos/OpenGL/GL_ShapeDrawer.cpp
Normal file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifdef WIN32 //needed for glut.h
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <GL/glut.h>
|
||||
#include "GL_ShapeDrawer.h"
|
||||
#include "CollisionShapes/PolyhedralConvexShape.h"
|
||||
#include "CollisionShapes/TriangleMeshShape.h"
|
||||
#include "CollisionShapes/BoxShape.h"
|
||||
#include "CollisionShapes/SphereShape.h"
|
||||
#include "CollisionShapes/ConeShape.h"
|
||||
#include "CollisionShapes/CylinderShape.h"
|
||||
#include "CollisionShapes/Simplex1to4Shape.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#include "IDebugDraw.h"
|
||||
//for debugmodes
|
||||
#include "BMF_Api.h"
|
||||
#include <stdio.h> //printf debugging
|
||||
|
||||
void GL_ShapeDrawer::DrawCoordSystem() {
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1, 0, 0);
|
||||
glVertex3d(0, 0, 0);
|
||||
glVertex3d(1, 0, 0);
|
||||
glColor3f(0, 1, 0);
|
||||
glVertex3d(0, 0, 0);
|
||||
glVertex3d(0, 1, 0);
|
||||
glColor3f(0, 0, 1);
|
||||
glVertex3d(0, 0, 0);
|
||||
glVertex3d(0, 0, 1);
|
||||
glEnd();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class GlDrawcallback : public TriangleCallback
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void ProcessTriangle(SimdVector3* triangle,int partId, int triangleIndex)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1, 0, 0);
|
||||
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
||||
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
||||
glColor3f(0, 1, 0);
|
||||
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
||||
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
||||
glColor3f(0, 0, 1);
|
||||
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
||||
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
||||
glEnd();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const SimdVector3& color,int debugMode)
|
||||
{
|
||||
glPushMatrix();
|
||||
glLoadMatrixf(m);
|
||||
|
||||
//DrawCoordSystem();
|
||||
|
||||
glPushMatrix();
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glColor3f(color.x(),color.y(), color.z());
|
||||
|
||||
glRasterPos3f(0.0, 0.0, 0.0);
|
||||
|
||||
bool useWireframeFallback = true;
|
||||
|
||||
if (!(debugMode & IDebugDraw::DBG_DrawWireframe))
|
||||
{
|
||||
switch (shape->GetShapeType())
|
||||
{
|
||||
case BOX_SHAPE_PROXYTYPE:
|
||||
{
|
||||
const BoxShape* boxShape = static_cast<const BoxShape*>(shape);
|
||||
SimdVector3 halfExtent = boxShape->GetHalfExtents();
|
||||
glScaled(2*halfExtent[0], 2*halfExtent[1], 2*halfExtent[2]);
|
||||
glutSolidCube(1.0);
|
||||
useWireframeFallback = false;
|
||||
break;
|
||||
}
|
||||
case TRIANGLE_SHAPE_PROXYTYPE:
|
||||
case TETRAHEDRAL_SHAPE_PROXYTYPE:
|
||||
{
|
||||
const BU_Simplex1to4* tetra = static_cast<const BU_Simplex1to4*>(shape);
|
||||
//todo:
|
||||
useWireframeFallback = false;
|
||||
break;
|
||||
}
|
||||
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
||||
case SPHERE_SHAPE_PROXYTYPE:
|
||||
{
|
||||
const SphereShape* sphereShape = static_cast<const SphereShape*>(shape);
|
||||
float radius = sphereShape->GetMargin();//radius doesn't include the margin, so draw with margin
|
||||
glutSolidSphere(radius,10,10);
|
||||
useWireframeFallback = false;
|
||||
break;
|
||||
}
|
||||
case MULTI_SPHERE_SHAPE_PROXYTYPE:
|
||||
case CONE_SHAPE_PROXYTYPE:
|
||||
{
|
||||
const ConeShape* coneShape = static_cast<const ConeShape*>(shape);
|
||||
float radius = coneShape->GetRadius();//+coneShape->GetMargin();
|
||||
float height = coneShape->GetHeight();//+coneShape->GetMargin();
|
||||
glutSolidCone(radius,height,10,10);
|
||||
useWireframeFallback = false;
|
||||
break;
|
||||
|
||||
}
|
||||
case CONVEX_SHAPE_PROXYTYPE:
|
||||
case CYLINDER_SHAPE_PROXYTYPE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (useWireframeFallback)
|
||||
{
|
||||
/// for polyhedral shapes
|
||||
if (shape->IsPolyhedral())
|
||||
{
|
||||
PolyhedralConvexShape* polyshape = (PolyhedralConvexShape*) shape;
|
||||
|
||||
|
||||
glBegin(GL_LINES);
|
||||
|
||||
|
||||
int i;
|
||||
for (i=0;i<polyshape->GetNumEdges();i++)
|
||||
{
|
||||
SimdPoint3 a,b;
|
||||
polyshape->GetEdge(i,a,b);
|
||||
|
||||
glVertex3f(a.getX(),a.getY(),a.getZ());
|
||||
glVertex3f(b.getX(),b.getY(),b.getZ());
|
||||
|
||||
|
||||
}
|
||||
glEnd();
|
||||
|
||||
|
||||
|
||||
if (debugMode==IDebugDraw::DBG_DrawText)
|
||||
{
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape->GetName());
|
||||
}
|
||||
|
||||
if (debugMode==IDebugDraw::DBG_DrawFeaturesText)
|
||||
{
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape->GetExtraDebugInfo());
|
||||
|
||||
glColor3f(1.f, 1.f, 1.f);
|
||||
for (i=0;i<polyshape->GetNumVertices();i++)
|
||||
{
|
||||
SimdPoint3 vtx;
|
||||
polyshape->GetVertex(i,vtx);
|
||||
glRasterPos3f(vtx.x(), vtx.y(), vtx.z());
|
||||
char buf[12];
|
||||
sprintf(buf," %d",i);
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
||||
}
|
||||
|
||||
for (i=0;i<polyshape->GetNumPlanes();i++)
|
||||
{
|
||||
SimdVector3 normal;
|
||||
SimdPoint3 vtx;
|
||||
polyshape->GetPlane(normal,vtx,i);
|
||||
SimdScalar d = vtx.dot(normal);
|
||||
|
||||
glRasterPos3f(normal.x()*d, normal.y()*d, normal.z()*d);
|
||||
char buf[12];
|
||||
sprintf(buf," plane %d",i);
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shape->GetShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||
{
|
||||
TriangleMeshShape* concaveMesh = (TriangleMeshShape*) shape;
|
||||
//SimdVector3 aabbMax(1e30f,1e30f,1e30f);
|
||||
//SimdVector3 aabbMax(100,100,100);//1e30f,1e30f,1e30f);
|
||||
|
||||
extern float eye[3];
|
||||
SimdVector3 aabbMax(eye[0]+100,eye[1]+100,eye[2]+100);//1e30f,1e30f,1e30f);
|
||||
SimdVector3 aabbMin(eye[0]-100,eye[1]-100,eye[2]-100);//1e30f,1e30f,1e30f);
|
||||
|
||||
GlDrawcallback drawCallback;
|
||||
|
||||
concaveMesh->ProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
|
||||
}
|
||||
31
Demos/OpenGL/GL_ShapeDrawer.h
Normal file
31
Demos/OpenGL/GL_ShapeDrawer.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#ifndef GL_SHAPE_DRAWER_H
|
||||
#define GL_SHAPE_DRAWER_H
|
||||
|
||||
class CollisionShape;
|
||||
#include "SimdVector3.h"
|
||||
|
||||
/// OpenGL shape drawing
|
||||
class GL_ShapeDrawer
|
||||
{
|
||||
public:
|
||||
|
||||
static void DrawOpenGL(float* m, const CollisionShape* shape, const SimdVector3& color,int debugMode);
|
||||
static void DrawCoordSystem();
|
||||
|
||||
};
|
||||
|
||||
#endif //GL_SHAPE_DRAWER_H
|
||||
75
Demos/OpenGL/GL_Simplex1to4.cpp
Normal file
75
Demos/OpenGL/GL_Simplex1to4.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "GL_Simplex1to4.h"
|
||||
#include "NarrowPhaseCollision/SimplexSolverInterface.h"
|
||||
#include "GL_ShapeDrawer.h"
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
#include "SimdTransform.h"
|
||||
|
||||
GL_Simplex1to4::GL_Simplex1to4()
|
||||
:m_simplexSolver(0)
|
||||
{
|
||||
}
|
||||
|
||||
///
|
||||
/// Debugging method CalcClosest calculates the closest point to the origin, using m_simplexSolver
|
||||
///
|
||||
void GL_Simplex1to4::CalcClosest(float* m)
|
||||
{
|
||||
SimdTransform tr;
|
||||
tr.setFromOpenGLMatrix(m);
|
||||
|
||||
|
||||
|
||||
GL_ShapeDrawer::DrawCoordSystem();
|
||||
|
||||
if (m_simplexSolver)
|
||||
{
|
||||
m_simplexSolver->reset();
|
||||
bool res;
|
||||
|
||||
SimdVector3 v;
|
||||
SimdPoint3 pBuf[4];
|
||||
SimdPoint3 qBuf[4];
|
||||
SimdPoint3 yBuf[4];
|
||||
|
||||
|
||||
for (int i=0;i<m_numVertices;i++)
|
||||
{
|
||||
v = tr(m_vertices[i]);
|
||||
m_simplexSolver->addVertex(v,v,SimdPoint3(0.f,0.f,0.f));
|
||||
res = m_simplexSolver->closest(v);
|
||||
int res = m_simplexSolver->getSimplex(pBuf, qBuf, yBuf);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//draw v?
|
||||
glDisable(GL_LIGHTING);
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1.f, 0.f, 0.f);
|
||||
glVertex3f(0.f, 0.f, 0.f);
|
||||
glVertex3f(v.x(),v.y(),v.z());
|
||||
glEnd();
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
40
Demos/OpenGL/GL_Simplex1to4.h
Normal file
40
Demos/OpenGL/GL_Simplex1to4.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#ifndef GL_SIMPLEX_1TO4_H
|
||||
#define GL_SIMPLEX_1TO4_H
|
||||
|
||||
#include "CollisionShapes/Simplex1to4Shape.h"
|
||||
|
||||
#include "NarrowPhaseCollision/SimplexSolverInterface.h"
|
||||
|
||||
///GL_Simplex1to4 is a class to debug a Simplex Solver with 1 to 4 points.
|
||||
///Can be used by GJK.
|
||||
class GL_Simplex1to4 : public BU_Simplex1to4
|
||||
{
|
||||
SimplexSolverInterface* m_simplexSolver;
|
||||
|
||||
public:
|
||||
|
||||
GL_Simplex1to4();
|
||||
|
||||
void CalcClosest(float* m);
|
||||
|
||||
void SetSimplexSolver(SimplexSolverInterface* simplexSolver) {
|
||||
m_simplexSolver = simplexSolver;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //GL_SIMPLEX_1TO4_H
|
||||
358
Demos/OpenGL/GlutStuff.cpp
Normal file
358
Demos/OpenGL/GlutStuff.cpp
Normal file
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifdef WIN32//for glut.h
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <GL/glut.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "IDebugDraw.h"
|
||||
//see IDebugDraw.h for modes
|
||||
static int sDebugMode = 0;
|
||||
|
||||
int getDebugMode()
|
||||
{
|
||||
return sDebugMode ;
|
||||
}
|
||||
|
||||
void setDebugMode(int mode)
|
||||
{
|
||||
sDebugMode = mode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "GlutStuff.h"
|
||||
|
||||
void myinit(void) {
|
||||
|
||||
GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
|
||||
GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
/* light_position is NOT default value */
|
||||
GLfloat light_position0[] = { 1.0, 1.0, 1.0, 0.0 };
|
||||
GLfloat light_position1[] = { -1.0, -1.0, -1.0, 0.0 };
|
||||
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
|
||||
|
||||
glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
|
||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
|
||||
glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
|
||||
glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_LIGHT1);
|
||||
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
|
||||
glClearColor(0.8,0.8,0.8,0);
|
||||
|
||||
// glEnable(GL_CULL_FACE);
|
||||
// glCullFace(GL_BACK);
|
||||
}
|
||||
|
||||
|
||||
static float DISTANCE = 15;
|
||||
void setCameraDistance(float dist)
|
||||
{
|
||||
DISTANCE = dist;
|
||||
}
|
||||
|
||||
static float ele = 0, azi = 0;
|
||||
float eye[3] = {0, 0, DISTANCE};
|
||||
static float center[3] = {0, 0, 0};
|
||||
static const double SCALE_BOTTOM = 0.5;
|
||||
static const double SCALE_FACTOR = 2;
|
||||
|
||||
bool stepping= true;
|
||||
bool singleStep = false;
|
||||
|
||||
|
||||
static bool idle = false;
|
||||
|
||||
void toggleIdle() {
|
||||
|
||||
|
||||
if (idle) {
|
||||
glutIdleFunc(clientMoveAndDisplay);
|
||||
idle = false;
|
||||
}
|
||||
else {
|
||||
glutIdleFunc(0);
|
||||
idle = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setCamera() {
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
float rele = ele * 0.01745329251994329547;// rads per deg
|
||||
float razi = azi * 0.01745329251994329547;// rads per deg
|
||||
eye[0] = DISTANCE * sin(razi) * cos(rele);
|
||||
eye[1] = DISTANCE * sin(rele);
|
||||
eye[2] = DISTANCE * cos(razi) * cos(rele);
|
||||
|
||||
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 100.0);
|
||||
gluLookAt(eye[0], eye[1], eye[2],
|
||||
center[0], center[1], center[2],
|
||||
0, 1, 0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const float STEPSIZE = 5;
|
||||
|
||||
void stepLeft() { azi -= STEPSIZE; if (azi < 0) azi += 360; setCamera(); }
|
||||
void stepRight() { azi += STEPSIZE; if (azi >= 360) azi -= 360; setCamera(); }
|
||||
void stepFront() { ele += STEPSIZE; if (azi >= 360) azi -= 360; setCamera(); }
|
||||
void stepBack() { ele -= STEPSIZE; if (azi < 0) azi += 360; setCamera(); }
|
||||
void zoomIn() { DISTANCE -= 1; setCamera(); }
|
||||
void zoomOut() { DISTANCE += 1; setCamera(); }
|
||||
|
||||
|
||||
int glutScreenWidth = 0;
|
||||
int glutScreenHeight = 0;
|
||||
|
||||
void myReshape(int w, int h) {
|
||||
glutScreenWidth = w;
|
||||
glutScreenHeight = h;
|
||||
|
||||
glViewport(0, 0, w, h);
|
||||
setCamera();
|
||||
}
|
||||
|
||||
int lastKey = 0;
|
||||
|
||||
void defaultKeyboard(unsigned char key, int x, int y)
|
||||
{
|
||||
lastKey = 0;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 'q' : exit(0); break;
|
||||
|
||||
case 'l' : stepLeft(); break;
|
||||
case 'r' : stepRight(); break;
|
||||
case 'f' : stepFront(); break;
|
||||
case 'b' : stepBack(); break;
|
||||
case 'z' : zoomIn(); break;
|
||||
case 'x' : zoomOut(); break;
|
||||
case 'i' : toggleIdle(); break;
|
||||
case 'h':
|
||||
if (sDebugMode & IDebugDraw::DBG_NoHelpText)
|
||||
sDebugMode = sDebugMode & (~IDebugDraw::DBG_NoHelpText);
|
||||
else
|
||||
sDebugMode |= IDebugDraw::DBG_NoHelpText;
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
if (sDebugMode & IDebugDraw::DBG_DrawWireframe)
|
||||
sDebugMode = sDebugMode & (~IDebugDraw::DBG_DrawWireframe);
|
||||
else
|
||||
sDebugMode |= IDebugDraw::DBG_DrawWireframe;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
if (sDebugMode & IDebugDraw::DBG_ProfileTimings)
|
||||
sDebugMode = sDebugMode & (~IDebugDraw::DBG_ProfileTimings);
|
||||
else
|
||||
sDebugMode |= IDebugDraw::DBG_ProfileTimings;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
if (sDebugMode & IDebugDraw::DBG_EnableSatComparison)
|
||||
sDebugMode = sDebugMode & (~IDebugDraw::DBG_EnableSatComparison);
|
||||
else
|
||||
sDebugMode |= IDebugDraw::DBG_EnableSatComparison;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
if (sDebugMode & IDebugDraw::DBG_DisableBulletLCP)
|
||||
sDebugMode = sDebugMode & (~IDebugDraw::DBG_DisableBulletLCP);
|
||||
else
|
||||
sDebugMode |= IDebugDraw::DBG_DisableBulletLCP;
|
||||
break;
|
||||
|
||||
case 't' :
|
||||
if (sDebugMode & IDebugDraw::DBG_DrawText)
|
||||
sDebugMode = sDebugMode & (~IDebugDraw::DBG_DrawText);
|
||||
else
|
||||
sDebugMode |= IDebugDraw::DBG_DrawText;
|
||||
break;
|
||||
case 'y':
|
||||
if (sDebugMode & IDebugDraw::DBG_DrawFeaturesText)
|
||||
sDebugMode = sDebugMode & (~IDebugDraw::DBG_DrawFeaturesText);
|
||||
else
|
||||
sDebugMode |= IDebugDraw::DBG_DrawFeaturesText;
|
||||
break;
|
||||
case 'a':
|
||||
if (sDebugMode & IDebugDraw::DBG_DrawAabb)
|
||||
sDebugMode = sDebugMode & (~IDebugDraw::DBG_DrawAabb);
|
||||
else
|
||||
sDebugMode |= IDebugDraw::DBG_DrawAabb;
|
||||
break;
|
||||
case 'c' :
|
||||
if (sDebugMode & IDebugDraw::DBG_DrawContactPoints)
|
||||
sDebugMode = sDebugMode & (~IDebugDraw::DBG_DrawContactPoints);
|
||||
else
|
||||
sDebugMode |= IDebugDraw::DBG_DrawContactPoints;
|
||||
break;
|
||||
|
||||
case 'd' :
|
||||
if (sDebugMode & IDebugDraw::DBG_NoDeactivation)
|
||||
sDebugMode = sDebugMode & (~IDebugDraw::DBG_NoDeactivation);
|
||||
else
|
||||
sDebugMode |= IDebugDraw::DBG_NoDeactivation;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case 'o' :
|
||||
{
|
||||
stepping = !stepping;
|
||||
break;
|
||||
}
|
||||
case 's' : clientMoveAndDisplay(); break;
|
||||
// case ' ' : newRandom(); break;
|
||||
case ' ':
|
||||
clientResetScene();
|
||||
break;
|
||||
case '1':
|
||||
{
|
||||
if (sDebugMode & IDebugDraw::DBG_EnableCCD)
|
||||
sDebugMode = sDebugMode & (~IDebugDraw::DBG_EnableCCD);
|
||||
else
|
||||
sDebugMode |= IDebugDraw::DBG_EnableCCD;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// std::cout << "unused key : " << key << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void mySpecial(int key, int x, int y)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case GLUT_KEY_LEFT : stepLeft(); break;
|
||||
case GLUT_KEY_RIGHT : stepRight(); break;
|
||||
case GLUT_KEY_UP : stepFront(); break;
|
||||
case GLUT_KEY_DOWN : stepBack(); break;
|
||||
case GLUT_KEY_PAGE_UP : zoomIn(); break;
|
||||
case GLUT_KEY_PAGE_DOWN : zoomOut(); break;
|
||||
case GLUT_KEY_HOME : toggleIdle(); break;
|
||||
default:
|
||||
// std::cout << "unused (special) key : " << key << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void goodbye( void)
|
||||
{
|
||||
printf("goodbye \n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
void menu(int choice)
|
||||
{
|
||||
static int fullScreen = 0;
|
||||
static int px, py, sx, sy;
|
||||
|
||||
switch(choice) {
|
||||
case 1:
|
||||
if (fullScreen == 1) {
|
||||
glutPositionWindow(px,py);
|
||||
glutReshapeWindow(sx,sy);
|
||||
glutChangeToMenuEntry(1,"Full Screen",1);
|
||||
fullScreen = 0;
|
||||
} else {
|
||||
px=glutGet((GLenum)GLUT_WINDOW_X);
|
||||
py=glutGet((GLenum)GLUT_WINDOW_Y);
|
||||
sx=glutGet((GLenum)GLUT_WINDOW_WIDTH);
|
||||
sy=glutGet((GLenum)GLUT_WINDOW_HEIGHT);
|
||||
glutFullScreen();
|
||||
glutChangeToMenuEntry(1,"Close Full Screen",1);
|
||||
fullScreen = 1;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
toggleIdle();
|
||||
break;
|
||||
case 3:
|
||||
goodbye();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void createMenu()
|
||||
{
|
||||
glutCreateMenu(menu);
|
||||
glutAddMenuEntry("Full Screen", 1);
|
||||
glutAddMenuEntry("Toggle Idle (Start/Stop)", 2);
|
||||
glutAddMenuEntry("Quit", 3);
|
||||
glutAttachMenu(GLUT_RIGHT_BUTTON);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int glutmain(int argc, char **argv,int width,int height,const char* title) {
|
||||
|
||||
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
|
||||
glutInitWindowPosition(0, 0);
|
||||
glutInitWindowSize(width, height);
|
||||
glutCreateWindow(title);
|
||||
|
||||
myinit();
|
||||
glutKeyboardFunc(clientKeyboard);
|
||||
glutSpecialFunc(mySpecial);
|
||||
glutReshapeFunc(myReshape);
|
||||
//createMenu();
|
||||
glutIdleFunc(clientMoveAndDisplay);
|
||||
glutMouseFunc(clientMouseFunc);
|
||||
glutMotionFunc(clientMotionFunc);
|
||||
glutDisplayFunc( clientDisplay );
|
||||
|
||||
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
35
Demos/OpenGL/GlutStuff.h
Normal file
35
Demos/OpenGL/GlutStuff.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#ifndef GLUT_STUFF_H
|
||||
#define GLUT_STUFF_H
|
||||
|
||||
//to be implemented by the demo
|
||||
void clientDisplay();
|
||||
void clientMoveAndDisplay();
|
||||
void clientResetScene();
|
||||
|
||||
|
||||
int glutmain(int argc, char **argv,int width,int height,const char* title);
|
||||
|
||||
void setCameraDistance(float dist);
|
||||
int getDebugMode();
|
||||
void setDebugMode(int mode);
|
||||
|
||||
void defaultKeyboard(unsigned char key, int x, int y);
|
||||
void clientKeyboard(unsigned char key, int x, int y);
|
||||
|
||||
void clientMouseFunc(int button, int state, int x, int y);
|
||||
void clientMotionFunc(int x,int y);
|
||||
#endif //GLUT_STUFF_H
|
||||
8
Demos/OpenGL/Jamfile
Normal file
8
Demos/OpenGL/Jamfile
Normal file
@@ -0,0 +1,8 @@
|
||||
SubDir TOP Demos OpenGL ;
|
||||
|
||||
if $(GLUT.AVAILABLE) = "yes"
|
||||
{
|
||||
Description bulletopenglsupport : "Bullet OpenGL support" ;
|
||||
Library bulletopenglsupport : [ Wildcard *.h *.cpp ] : noinstall ;
|
||||
ExternalLibs bulletopenglsupport : GLUT ;
|
||||
}
|
||||
73
Demos/OpenGL/RenderTexture.cpp
Normal file
73
Demos/OpenGL/RenderTexture.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "RenderTexture.h"
|
||||
#include <memory.h>
|
||||
#include "BMF_FontData.h"
|
||||
|
||||
RenderTexture::RenderTexture(int width,int height)
|
||||
:m_height(height),m_width(width)
|
||||
{
|
||||
m_buffer = new unsigned char[m_width*m_height*4];
|
||||
|
||||
//clear screen
|
||||
memset(m_buffer,0,m_width*m_height*4);
|
||||
|
||||
//clear screen version 2
|
||||
for (int x=0;x<m_width;x++)
|
||||
{
|
||||
for (int y=0;y<m_height;y++)
|
||||
{
|
||||
SetPixel(x,y,SimdVector4(float(x),float(y),0.f,1.f));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RenderTexture::Printf(char* str, BMF_FontData* fontData, int startx,int starty)
|
||||
{
|
||||
unsigned char c;
|
||||
int rasterposx = startx;
|
||||
int rasterposy = starty;
|
||||
while (c = (unsigned char) *str++) {
|
||||
BMF_CharData & cd = fontData->chars[c];
|
||||
|
||||
if (cd.data_offset!=-1) {
|
||||
unsigned char* bitmap = &fontData->bitmap_data[cd.data_offset];
|
||||
for (int y=0;y<cd.height;y++)
|
||||
{
|
||||
int bit = 128;
|
||||
for (int x=0;x<cd.width;x++)
|
||||
{
|
||||
char packedColor = bitmap[y];
|
||||
float colorf = packedColor & bit ? 1.f : 0.f;
|
||||
SimdVector4 rgba(colorf,colorf,colorf,1.f);
|
||||
SetPixel(rasterposx+x,rasterposy+8-y-1,rgba);
|
||||
bit >>=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
rasterposx+= cd.advance;
|
||||
}
|
||||
}
|
||||
|
||||
RenderTexture::~RenderTexture()
|
||||
{
|
||||
delete [] m_buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
53
Demos/OpenGL/RenderTexture.h
Normal file
53
Demos/OpenGL/RenderTexture.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RENDER_TEXTURE_H
|
||||
#define RENDER_TEXTURE_H
|
||||
|
||||
#include "SimdVector3.h"
|
||||
#include "BMF_FontData.h"
|
||||
|
||||
///
|
||||
///RenderTexture provides a software-render context (setpixel/printf)
|
||||
///
|
||||
class RenderTexture
|
||||
{
|
||||
int m_height;
|
||||
int m_width;
|
||||
unsigned char* m_buffer;
|
||||
|
||||
public:
|
||||
|
||||
RenderTexture(int width,int height);
|
||||
~RenderTexture();
|
||||
|
||||
inline void SetPixel(int x,int y,const SimdVector4& rgba)
|
||||
{
|
||||
unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4];
|
||||
|
||||
pixel[0] = (unsigned char)(255*rgba.getX());
|
||||
pixel[1] = (unsigned char)(255*rgba.getY());
|
||||
pixel[2] = (unsigned char)(255*rgba.getZ());
|
||||
pixel[3] = (unsigned char)(255*rgba.getW());
|
||||
}
|
||||
|
||||
const unsigned char* GetBuffer() const { return m_buffer;}
|
||||
int GetWidth() const { return m_width;}
|
||||
int GetHeight() const { return m_height;}
|
||||
void Printf(char* str, BMF_FontData* fontData, int startx = 0,int starty=0);
|
||||
|
||||
};
|
||||
|
||||
#endif //RENDER_TEXTURE_H
|
||||
Reference in New Issue
Block a user