Initial revision
This commit is contained in:
225
intern/bmfont/test/BMF_Test.cpp
Normal file
225
intern/bmfont/test/BMF_Test.cpp
Normal file
@@ -0,0 +1,225 @@
|
||||
/**
|
||||
* $Id$
|
||||
* ***** 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 *****
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* $Id$
|
||||
* Copyright (C) 2001 NaN Technologies B.V.
|
||||
* Simple test file for the bitmap font library using GHOST.
|
||||
* @author Maarten Gribnau
|
||||
* @date November 15, 2001
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#if defined(WIN32) || defined(__APPLE__)
|
||||
#ifdef WIN32
|
||||
#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 "STR_String.h"
|
||||
#include "GHOST_Rect.h"
|
||||
|
||||
#include "GHOST_ISystem.h"
|
||||
#include "GHOST_IEvent.h"
|
||||
#include "GHOST_IEventConsumer.h"
|
||||
|
||||
#include "BMF_Api.h"
|
||||
|
||||
static class Application* fApp;
|
||||
static GHOST_ISystem* fSystem = 0;
|
||||
|
||||
|
||||
static void drawGL()
|
||||
{
|
||||
GLint x = 10, y = 10;
|
||||
|
||||
::glRasterPos2i(x, y);
|
||||
BMF_FontPtr font = BMF_GetFont(BMF_kHelvetica10);
|
||||
BMF_DrawString(font, "Helvetica 10 point");
|
||||
y += 14;
|
||||
::glRasterPos2i(x, y);
|
||||
font = BMF_GetFont(BMF_kHelvetica12);
|
||||
BMF_DrawString(font, "Helvetica 12 point");
|
||||
y += 16;
|
||||
::glRasterPos2i(x, y);
|
||||
font = BMF_GetFont(BMF_kHelveticaBold8);
|
||||
BMF_DrawString(font, "Helvetica Bold 8 point");
|
||||
y += 12;
|
||||
::glRasterPos2i(x, y);
|
||||
font = BMF_GetFont(BMF_kHelveticaBold10);
|
||||
BMF_DrawString(font, "Helvetica Bold 10 point");
|
||||
y += 14;
|
||||
::glRasterPos2i(x, y);
|
||||
font = BMF_GetFont(BMF_kHelveticaBold12);
|
||||
BMF_DrawString(font, "Helvetica Bold 12 point");
|
||||
y += 16;
|
||||
::glRasterPos2i(x, y);
|
||||
font = BMF_GetFont(BMF_kHelveticaBold14);
|
||||
BMF_DrawString(font, "Helvetica Bold 14 point");
|
||||
y += 18;
|
||||
::glRasterPos2i(x, y);
|
||||
font = BMF_GetFont(BMF_kScreen12);
|
||||
BMF_DrawString(font, "Screen 12 point");
|
||||
y += 16;
|
||||
::glRasterPos2i(x, y);
|
||||
font = BMF_GetFont(BMF_kScreen14);
|
||||
BMF_DrawString(font, "Screen 14 point");
|
||||
y += 18;
|
||||
::glRasterPos2i(x, y);
|
||||
font = BMF_GetFont(BMF_kScreen15);
|
||||
BMF_DrawString(font, "Screen 15 point");
|
||||
}
|
||||
|
||||
|
||||
static void setViewPortGL(GHOST_IWindow* window)
|
||||
{
|
||||
window->activateDrawingContext();
|
||||
GHOST_Rect bnds;
|
||||
window->getClientBounds(bnds);
|
||||
|
||||
::glViewport(0, 0, bnds.getWidth(), bnds.getHeight());
|
||||
|
||||
::glMatrixMode(GL_PROJECTION);
|
||||
::glLoadIdentity();
|
||||
::glOrtho(0, bnds.getWidth(), 0, bnds.getHeight(), -10, 10);
|
||||
|
||||
::glClearColor(.2f,0.0f,0.0f,0.0f);
|
||||
::glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
class Application : public GHOST_IEventConsumer {
|
||||
public:
|
||||
Application(GHOST_ISystem* system);
|
||||
virtual bool processEvent(GHOST_IEvent* event);
|
||||
|
||||
GHOST_ISystem* m_system;
|
||||
GHOST_IWindow* m_mainWindow;
|
||||
bool m_exitRequested;
|
||||
};
|
||||
|
||||
|
||||
Application::Application(GHOST_ISystem* system)
|
||||
: m_system(system), m_mainWindow(0), m_exitRequested(false)
|
||||
{
|
||||
fApp = this;
|
||||
|
||||
// Create the main window
|
||||
STR_String title1 ("gears - main window");
|
||||
m_mainWindow = system->createWindow(title1, 10, 64, 320, 200, GHOST_kWindowStateNormal, GHOST_kDrawingContextTypeOpenGL);
|
||||
if (!m_mainWindow) {
|
||||
std::cout << "could not create main window\n";
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Application::processEvent(GHOST_IEvent* event)
|
||||
{
|
||||
bool handled = true;
|
||||
|
||||
switch (event->getType()) {
|
||||
case GHOST_kEventWindowClose:
|
||||
{
|
||||
GHOST_TEventWindowData* windowData = (GHOST_TEventWindowData*)((GHOST_IEvent*)event)->getData();
|
||||
GHOST_IWindow* window = windowData->window;
|
||||
if (window == m_mainWindow) {
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
m_system->disposeWindow(window);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GHOST_kEventWindowActivate:
|
||||
handled = false;
|
||||
break;
|
||||
case GHOST_kEventWindowDeactivate:
|
||||
handled = false;
|
||||
break;
|
||||
case GHOST_kEventWindowUpdate:
|
||||
{
|
||||
GHOST_TEventWindowData* windowData = (GHOST_TEventWindowData*)((GHOST_IEvent*)event)->getData();
|
||||
GHOST_IWindow* window = windowData->window;
|
||||
if (!m_system->validWindow(window)) break;
|
||||
{
|
||||
setViewPortGL(window);
|
||||
drawGL();
|
||||
window->swapBuffers();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
handled = false;
|
||||
break;
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
|
||||
int main(int /*argc*/, char** /*argv*/)
|
||||
{
|
||||
// Create the system
|
||||
GHOST_ISystem::createSystem();
|
||||
fSystem = GHOST_ISystem::getSystem();
|
||||
|
||||
if (fSystem) {
|
||||
// Create an application object
|
||||
Application app (fSystem);
|
||||
|
||||
// Add the application as event consumer
|
||||
fSystem->addEventConsumer(&app);
|
||||
|
||||
// Enter main loop
|
||||
while (!app.m_exitRequested) {
|
||||
fSystem->processEvents();
|
||||
fSystem->dispatchEvents();
|
||||
}
|
||||
}
|
||||
|
||||
// Dispose the system
|
||||
GHOST_ISystem::disposeSystem();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
109
intern/bmfont/test/make/msvc_6_0/BMF_Test.dsp
Normal file
109
intern/bmfont/test/make/msvc_6_0/BMF_Test.dsp
Normal file
@@ -0,0 +1,109 @@
|
||||
# Microsoft Developer Studio Project File - Name="BMF_Test" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=BMF_Test - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "BMF_Test.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "BMF_Test.mak" CFG="BMF_Test - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "BMF_Test - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "BMF_Test - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "BMF_Test - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "../../../../../../obj/windows/intern/BMF_bmfont/test"
|
||||
# PROP Intermediate_Dir "../../../../../../obj/windows/intern/BMF_bmfont/test"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "../../../" /I "../../../../../lib/windows/string/include" /I "../../../../../lib/windows/ghost/include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libstring.a libghost.a glu32.lib opengl32.lib user32.lib gdi32.lib /nologo /subsystem:console /machine:I386 /libpath:"../../../../../lib/windows/string/lib" /libpath:"../../../../../lib/windows/ghost/lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "BMF_Test - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "../../../../../../obj/windows/intern/BMF_bmfont/test/debug"
|
||||
# PROP Intermediate_Dir "../../../../../../obj/windows/intern/BMF_bmfont/test/debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../" /I "../../../../../lib/windows/string/include" /I "../../../../../lib/windows/ghost/include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 glu32.lib opengl32.lib libstring.a libghost.a user32.lib gdi32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../../../../../lib/windows/string/lib" /libpath:"../../../../../lib/windows/ghost/lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "BMF_Test - Win32 Release"
|
||||
# Name "BMF_Test - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\intern\BMF_glut_helb8.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\intern\BMF_glut_helb8.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\BMF_Test.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
44
intern/bmfont/test/make/msvc_6_0/BMF_Test.dsw
Normal file
44
intern/bmfont/test/make/msvc_6_0/BMF_Test.dsw
Normal file
@@ -0,0 +1,44 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "BMF_Test"=.\BMF_Test.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name BMF_bmfont
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "BMF_bmfont"=..\..\..\make\msvc_6_0\BMF_bmfont.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
Reference in New Issue
Block a user