Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

X11 cursors, NaClPlatform replaced by Pepper

- ozEngine
  * Cursor: X11 cursor loader and data structure
- client
  * NaClPlatform & OpenGL removed, replaced by ozEngine counterparts
  * oz::Cursor used for rendering cursors
  • Loading branch information...
commit 9ef51915e4439a3c499243c47d22dc6182c453db 1 parent 3b8efd0
@ducakar authored
Showing with 558 additions and 846 deletions.
  1. +1 −1  ChangeLog.md
  2. +2 −2 build.sh
  3. +2 −2 src/builder/Builder.cc
  4. +1 −2  src/builder/Context.hh
  5. +0 −54 src/builder/UI.cc
  6. +0 −1  src/builder/UI.hh
  7. +1 −1  src/client/BSP.cc
  8. +0 −4 src/client/CMakeLists.txt
  9. +1 −1  src/client/Caelum.cc
  10. +1 −1  src/client/CinematicProxy.cc
  11. +9 −10 src/client/Client.cc
  12. +2 −2 src/client/Context.cc
  13. +1 −1  src/client/ExplosionImago.cc
  14. +1 −1  src/client/FragPool.cc
  15. +1 −1  src/client/GameStage.cc
  16. +6 −3 src/client/Input.cc
  17. +2 −0  src/client/Input.hh
  18. +1 −1  src/client/Loader.cc
  19. +1 −1  src/client/MD2.cc
  20. +1 −1  src/client/MD2Imago.cc
  21. +1 −1  src/client/MD2WeaponImago.cc
  22. +1 −1  src/client/MD3.cc
  23. +1 −1  src/client/MD3Imago.cc
  24. +1 −1  src/client/MenuStage.cc
  25. +1 −1  src/client/Mesh.cc
  26. +0 −2  src/client/NaClDownloader.cc
  27. +0 −109 src/client/NaClPlatform.cc
  28. +0 −128 src/client/NaClPlatform.hh
  29. +4 −6 src/client/NaClUpdater.cc
  30. +0 −238 src/client/OpenGL.cc
  31. +0 −137 src/client/OpenGL.hh
  32. +8 −8 src/client/Render.cc
  33. +1 −1  src/client/SMM.cc
  34. +1 −2  src/client/Shader.cc
  35. +1 −1  src/client/Shape.cc
  36. +2 −3 src/client/Sound.cc
  37. +1 −1  src/client/Terra.cc
  38. +9 −10 src/client/Window.cc
  39. +1 −2  src/client/luaapi.hh
  40. +1 −1  src/client/ui/Area.cc
  41. +1 −2  src/client/ui/Button.cc
  42. +1 −2  src/client/ui/CreditsMenu.cc
  43. +1 −1  src/client/ui/Font.cc
  44. +1 −2  src/client/ui/Frame.cc
  45. +1 −1  src/client/ui/GalileoFrame.cc
  46. +1 −1  src/client/ui/HudArea.cc
  47. +1 −1  src/client/ui/Inventory.cc
  48. +1 −1  src/client/ui/Label.cc
  49. +2 −2 src/client/ui/MainMenu.cc
  50. +1 −2  src/client/ui/MissionMenu.cc
  51. +27 −23 src/client/ui/Mouse.cc
  52. +4 −9 src/client/ui/Mouse.hh
  53. +1 −1  src/client/ui/SettingsFrame.cc
  54. +1 −1  src/client/ui/Text.cc
  55. +1 −1  src/client/ui/UI.cc
  56. +2 −1  src/ozCore/Alloc.hh
  57. +3 −3 src/ozCore/System.cc
  58. +1 −1  src/ozDynamics/collision/Box.hh
  59. +1 −1  src/ozDynamics/collision/Capsule.hh
  60. +2 −0  src/ozEngine/ALBuffer.cc
  61. +2 −2 src/ozEngine/ALBuffer.hh
  62. +2 −0  src/ozEngine/ALSource.cc
  63. +3 −3 src/ozEngine/ALSource.hh
  64. +3 −2 src/ozEngine/ALStreamingBuffer.hh
  65. +1 −1  src/ozEngine/Builder.hh
  66. +2 −0  src/ozEngine/CMakeLists.txt
  67. +204 −0 src/ozEngine/Cursor.cc
  68. +166 −0 src/ozEngine/Cursor.hh
  69. +2 −1  src/ozEngine/GL.hh
  70. +2 −0  src/ozEngine/GLTexture.cc
  71. +4 −4 src/ozEngine/GLTexture.hh
  72. +4 −4 src/ozEngine/Pepper.hh
  73. +1 −0  src/ozEngine/ozEngine.hh
  74. +22 −11 src/tests/engine.cc
  75. +18 −18 src/tools/openzone.cc
View
2  ChangeLog.md
@@ -15,7 +15,7 @@
* new SpinLock class
* ALSA and OSS back-ends for System::bell()
* linear algebra classes added as primitives to streams, Log and JSON
- * PFile class merged into File class
+ * PFile class merged into File class (VFS paths begin with '@')
- ozDynamics: new rigid body dynamics library
* collision
+ primitives: Box, Capsule, Polytope, Compound
View
4 build.sh
@@ -15,7 +15,7 @@
buildType=Debug
platforms=(
- Linux-x86_64
+# Linux-x86_64
Linux-x86_64-Clang
# Linux-i686
# Linux-i686-Clang
@@ -28,7 +28,7 @@ platforms=(
# NaCl-i686
# NaCl-ARM
# PNaCl
- Android14-i686
+# Android14-i686
# Android14-ARM
# Android14-ARMv7a
# Android14-MIPS
View
4 src/builder/Builder.cc
@@ -911,12 +911,12 @@ int Builder::main( int argc, char** argv )
lingua.build();
}
if( doUI ) {
- UI::buildCursors();
UI::buildIcons();
UI::copyScheme();
+ copyFiles( "@ui/cur", "ui/cur", "", false );
copyFiles( "@ui/font", "ui/font", "ttf", false );
- copyFiles( "@ui/icon", "ui/icon", "", true );
+ copyFiles( "@ui/icon", "ui/icon", "", false );
}
if( doShaders ) {
copyFiles( "@glsl", "glsl", "glsl", false );
View
3  src/builder/Context.hh
@@ -24,8 +24,7 @@
#pragma once
#include <builder/common.hh>
-
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
struct FIBITMAP;
View
54 src/builder/UI.cc
@@ -51,60 +51,6 @@ const char* const UI::ICON_NAMES[] = {
"arrow"
};
-void UI::buildCursors()
-{
- if( File( "@ui/cur" ).type() != File::DIRECTORY ) {
- return;
- }
-
- Log::println( "Building mouse cursors {" );
- Log::indent();
-
- bool useS3TC = context.useS3TC;
- context.useS3TC = false;
-
- File::mkdir( "ui" );
- File::mkdir( "ui/cur" );
-
- for( int i = 0; i < ui::Mouse::CURSORS_MAX; ++i ) {
- File inFile( String::str( "@ui/cur/%s.in", ui::Mouse::NAMES[i] ) );
- File destFile( String::str( "ui/cur/%s.ozCur", ui::Mouse::NAMES[i] ) );
-
- String realPath = inFile.realPath();
-
- FILE* fs = fopen( realPath, "r" );
- if( fs == nullptr ) {
- OZ_ERROR( "Failed to open cursor description '%s'", realPath.cstr() );
- }
-
- int size, hotspotX, hotspotY;
- char imgPath[32];
-
- int nMatches = fscanf( fs, "%3d %3d %3d %31s", &size, &hotspotX, &hotspotY, imgPath );
- if( nMatches != 4 ) {
- OZ_ERROR( "Invalid xcursor line" );
- }
-
- fclose( fs );
-
- Context::Texture tex = context.loadTexture( String::str( "@ui/cur/%s", imgPath ), false,
- GL_NEAREST, GL_NEAREST );
- OutputStream os( 0 );
-
- os.writeInt( size );
- os.writeInt( hotspotX );
- os.writeInt( hotspotY );
- tex.write( &os );
-
- destFile.write( os.begin(), os.tell() );
- }
-
- context.useS3TC = useS3TC;
-
- Log::unindent();
- Log::println( "}" );
-}
-
void UI::buildIcons()
{
if( File( "@ui/icon" ).type() != File::DIRECTORY ) {
View
1  src/builder/UI.hh
@@ -38,7 +38,6 @@ class UI
public:
- static void buildCursors();
static void buildIcons();
static void copyScheme();
View
2  src/client/BSP.cc
@@ -26,7 +26,7 @@
#include <client/Context.hh>
#include <client/SMM.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
4 src/client/CMakeLists.txt
@@ -34,10 +34,8 @@ add_library( client STATIC
MenuStage.hh
Mesh.hh
NaClDownloader.hh
- NaClPlatform.hh
NaClUpdater.hh
Network.hh
- OpenGL.hh
openzone.hh
Profile.hh
Proxy.hh
@@ -85,10 +83,8 @@ add_library( client STATIC
MenuStage.cc
Mesh.cc
NaClDownloader.cc
- NaClPlatform.cc
NaClUpdater.cc
Network.cc
- OpenGL.cc
Profile.cc
Proxy.cc
QuestList.cc
View
2  src/client/Caelum.cc
@@ -28,7 +28,7 @@
#include <client/Camera.hh>
#include <client/Terra.hh>
#include <client/Shape.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/CinematicProxy.cc
@@ -24,10 +24,10 @@
#include <stable.hh>
#include <client/CinematicProxy.hh>
+#include <ozEngine/Pepper.hh>
#include <common/Timer.hh>
#include <client/Camera.hh>
#include <client/Sound.hh>
-#include <client/NaClPlatform.hh>
#include <client/ui/GalileoFrame.hh>
#include <client/ui/MusicPlayer.hh>
#include <client/ui/UI.hh>
View
19 src/client/Client.cc
@@ -26,6 +26,7 @@
#include <stable.hh>
#include <client/Client.hh>
+#include <ozEngine/Pepper.hh>
#include <common/Timer.hh>
#include <common/Lua.hh>
#include <client/Camera.hh>
@@ -34,7 +35,6 @@
#include <client/Sound.hh>
#include <client/Render.hh>
#include <client/Loader.hh>
-#include <client/NaClPlatform.hh>
#include <client/NaClUpdater.hh>
#include <client/Window.hh>
#include <client/Input.hh>
@@ -381,9 +381,9 @@ int Client::init( int argc, char** argv )
#ifdef __native_client__
- NaClPlatform::post( "lang:" );
+ Pepper::post( "lang:" );
- for( String message = NaClPlatform::poll(); ; message = NaClPlatform::poll() ) {
+ for( String message = Pepper::pop(); ; message = Pepper::pop() ) {
if( message.isEmpty() ) {
Time::sleep( 10 );
}
@@ -392,7 +392,7 @@ int Client::init( int argc, char** argv )
break;
}
else {
- NaClPlatform::push( message );
+ Pepper::push( message );
}
}
@@ -473,7 +473,7 @@ int Client::init( int argc, char** argv )
gameStage.init();
#ifdef __native_client__
- NaClPlatform::post( "none:" );
+ Pepper::post( "none:" );
#endif
Stage::nextStage = nullptr;
@@ -719,15 +719,14 @@ int Client::main()
#ifdef __native_client__
- if( NaClPlatform::width != window.width || NaClPlatform::height != window.height ) {
+ if( Pepper::width != window.width || Pepper::height != window.height ) {
window.resize();
}
- if( window.hasFocus != NaClPlatform::hasFocus ) {
- window.hasFocus = NaClPlatform::hasFocus;
+ if( window.hasFocus != Pepper::hasFocus ) {
+ window.hasFocus = Pepper::hasFocus;
input.reset();
}
- for( String message = NaClPlatform::poll(); !message.isEmpty(); message = NaClPlatform::poll() )
- {
+ for( String message = Pepper::pop(); !message.isEmpty(); message = Pepper::pop() ) {
if( message.equals( "quit:" ) ) {
isAlive = false;
}
View
4 src/client/Context.cc
@@ -35,7 +35,7 @@
#include <client/BotAudio.hh>
#include <client/VehicleAudio.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
#include <ozEngine/AL.hh>
#include <client/eSpeak.hh>
@@ -643,7 +643,7 @@ void Context::load()
void Context::unload()
{
#ifdef __native_client__
- hard_assert( NaClPlatform::isMainThread() );
+ hard_assert( Pepper::isMainThread() );
#endif
Log::println( "Unloading Context {" );
View
2  src/client/ExplosionImago.cc
@@ -26,7 +26,7 @@
#include <common/Timer.hh>
#include <client/Context.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/FragPool.cc
@@ -27,7 +27,7 @@
#include <client/Shader.hh>
#include <client/Context.hh>
#include <client/SMM.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/GameStage.cc
@@ -24,6 +24,7 @@
#include <stable.hh>
#include <client/GameStage.hh>
+#include <ozEngine/Pepper.hh>
#include <matrix/Synapse.hh>
#include <matrix/Matrix.hh>
#include <nirvana/Nirvana.hh>
@@ -38,7 +39,6 @@
#include <client/QuestList.hh>
#include <client/MenuStage.hh>
#include <client/Input.hh>
-#include <client/NaClPlatform.hh>
#include <client/ui/LoadingArea.hh>
namespace oz
View
9 src/client/Input.cc
@@ -25,7 +25,6 @@
#include <client/Input.hh>
#include <client/Window.hh>
-#include <client/NaClPlatform.hh>
namespace oz
{
@@ -463,8 +462,12 @@ void Input::update()
#if defined( __native_client__ )
- mouseX = +NaClPlatform::moveX;
- mouseY = -NaClPlatform::moveY;
+ mouseX = +Pepper::moveX;
+ mouseY = -Pepper::moveY;
+
+ int dx, dy;
+ SDL_GetRelativeMouseState( &dx, &dy );
+ printf( "SMM: %d, %d\n", dx, dy );
#else
View
2  src/client/Input.hh
@@ -23,6 +23,8 @@
#pragma once
+#include <client/common.hh>
+
#include <SDL.h>
namespace oz
View
2  src/client/Loader.cc
@@ -32,7 +32,7 @@
#include <client/MD2.hh>
#include <client/MD3.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
#include <ozEngine/AL.hh>
#include <SDL.h>
View
2  src/client/MD2.cc
@@ -26,7 +26,7 @@
#include <common/Timer.hh>
#include <client/Context.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/MD2Imago.cc
@@ -26,7 +26,7 @@
#include <client/Context.hh>
#include <client/Camera.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/MD2WeaponImago.cc
@@ -26,7 +26,7 @@
#include <client/Camera.hh>
#include <client/Context.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/MD3.cc
@@ -25,7 +25,7 @@
#include <client/MD3.hh>
#include <client/Context.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/MD3Imago.cc
@@ -26,7 +26,7 @@
#include <client/Context.hh>
#include <client/Camera.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/MenuStage.cc
@@ -24,11 +24,11 @@
#include <stable.hh>
#include <client/MenuStage.hh>
+#include <ozEngine/Pepper.hh>
#include <client/Camera.hh>
#include <client/Render.hh>
#include <client/Sound.hh>
#include <client/Input.hh>
-#include <client/NaClPlatform.hh>
namespace oz
{
View
2  src/client/Mesh.cc
@@ -26,7 +26,7 @@
#include <client/Context.hh>
#include <client/Terra.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/NaClDownloader.cc
@@ -26,8 +26,6 @@
#include <stable.hh>
#include <client/NaClDownloader.hh>
-#include <client/NaClPlatform.hh>
-
#include <ppapi/cpp/completion_callback.h>
#include <ppapi/cpp/url_request_info.h>
#include <ppapi/cpp/url_loader.h>
View
109 src/client/NaClPlatform.cc
@@ -1,109 +0,0 @@
-/*
- * OpenZone - simple cross-platform FPS/RTS game engine.
- *
- * Copyright © 2002-2013 Davorin Učakar
- *
- * 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 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * @file client/NaClPlatform.cc
- */
-
-#ifdef __native_client__
-
-#include <stable.hh>
-#include <client/NaClPlatform.hh>
-
-#include <ppapi/cpp/completion_callback.h>
-#include <ppapi/cpp/instance.h>
-#include <ppapi/cpp/core.h>
-#include <ppapi/cpp/graphics_3d.h>
-
-namespace oz
-{
-namespace client
-{
-
-static SpinLock messageLock;
-static List<String> messageQueue;
-static pp::Core* core;
-
-Semaphore NaClPlatform::mainCallSemaphore;
-
-int NaClPlatform::width = 0;
-int NaClPlatform::height = 0;
-
-float NaClPlatform::moveX = 0.0f;
-float NaClPlatform::moveY = 0.0f;
-float NaClPlatform::moveZ = 0.0f;
-float NaClPlatform::moveW = 0.0f;
-
-bool NaClPlatform::hasFocus = false;
-
-bool NaClPlatform::isMainThread()
-{
- return core->IsMainThread();
-}
-
-void NaClPlatform::call( Callback* callback, void* caller )
-{
- core->CallOnMainThread( 0, pp::CompletionCallback( callback, caller ) );
- mainCallSemaphore.wait();
-}
-
-void NaClPlatform::post( const char* message )
-{
- OZ_MAIN_CALL( const_cast<char*>( message ), {
- const char* message = reinterpret_cast<const char*>( _this );
-
- System::instance->PostMessage( pp::Var( message ) );
- } )
-}
-
-String NaClPlatform::poll()
-{
- messageLock.lock();
- String s = messageQueue.isEmpty() ? String() : messageQueue.popFirst();
- messageLock.unlock();
-
- return s;
-}
-
-void NaClPlatform::push( const char* message )
-{
- messageLock.lock();
- messageQueue.pushLast( message );
- messageLock.unlock();
-}
-
-void NaClPlatform::init()
-{
- mainCallSemaphore.init();
-
- core = pp::Module::Get()->core();
-}
-
-void NaClPlatform::destroy()
-{
- messageQueue.clear();
- messageQueue.deallocate();
-
- mainCallSemaphore.destroy();
-}
-
-}
-}
-
-#endif
View
128 src/client/NaClPlatform.hh
@@ -1,128 +0,0 @@
-/*
- * OpenZone - simple cross-platform FPS/RTS game engine.
- *
- * Copyright © 2002-2013 Davorin Učakar
- *
- * 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 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * @file client/NaClPlatform.hh
- */
-
-#pragma once
-
-#include <client/common.hh>
-
-#ifdef __native_client__
-
-#define OZ_MAIN_CALL( t, code ) \
- if( oz::client::NaClPlatform::isMainThread() ) { \
- decltype( t ) _this = ( t ); \
- static_cast<void>( _this ); \
- { code } \
- } \
- else { \
- typedef decltype( t ) _This; \
- struct _Callback \
- { \
- static void _main( void* data, int ) \
- { \
- _This _this = static_cast<_This>( data ); \
- static_cast<void>( _this ); \
- { code } \
- oz::client::NaClPlatform::mainCallSemaphore.post(); \
- } \
- }; \
- oz::client::NaClPlatform::call( _Callback::_main, ( t ) ); \
- }
-
-#define OZ_STATIC_MAIN_CALL( code ) \
- if( oz::client::NaClPlatform::isMainThread() ) { \
- { code } \
- } \
- else { \
- struct _Callback \
- { \
- static void _main( void*, int ) \
- { \
- { code } \
- oz::client::NaClPlatform::mainCallSemaphore.post(); \
- } \
- }; \
- oz::client::NaClPlatform::call( _Callback::_main, nullptr ); \
- }
-
-namespace oz
-{
-namespace client
-{
-
-class NaClPlatform
-{
- public:
-
- typedef void Callback( void*, int );
-
- static Semaphore mainCallSemaphore;
-
- static int width; ///< Module area width.
- static int height; ///< Module area height.
-
- static float moveX; ///< Mouse X axis.
- static float moveY; ///< Mouse Y axis.
- static float moveZ; ///< Mouse wheel (horizontal scroll).
- static float moveW; ///< Mouse wheel (vertical scroll).
-
- static bool hasFocus; ///< True iff fullscreen and mouse captured.
-
- explicit NaClPlatform() = delete;
-
- /*
- * Main thread call.
- */
- static bool isMainThread();
- static void call( Callback* callback, void* caller );
-
- /*
- * JavaScript messages.
- */
- static void post( const char* message );
- static String poll();
- static void push( const char* message );
-
- /*
- * General
- */
- static void init();
- static void destroy();
-
-};
-
-}
-}
-
-#else
-
-#define OZ_MAIN_CALL( this, code ) \
- { \
- decltype( this ) _this = ( this ); \
- static_cast<void>( _this ); \
- { code } \
- }
-
-#define OZ_STATIC_MAIN_CALL( code ) \
- { code }
-
-#endif
View
10 src/client/NaClUpdater.cc
@@ -26,7 +26,6 @@
#include <stable.hh>
#include <client/NaClUpdater.hh>
-#include <client/NaClPlatform.hh>
#include <client/NaClDownloader.hh>
namespace oz
@@ -172,11 +171,10 @@ void NaClUpdater::downloadUpdates()
float progress = downloader.progress() * 100.0f;
if( Math::isNaN( progress ) ) {
- NaClPlatform::post( String::str( "upd1:%d/%d", packageNum, nRemotePackages ) );
+ Pepper::post( String::str( "upd1:%d/%d", packageNum, nRemotePackages ) );
}
else {
- NaClPlatform::post( String::str( "upd1:%d/%d: %.0f %%", packageNum, nRemotePackages,
- progress ) );
+ Pepper::post( String::str( "upd1:%d/%d: %.0f %%", packageNum, nRemotePackages, progress ) );
}
}
while( !downloader.isComplete() );
@@ -234,7 +232,7 @@ DArray<String> NaClUpdater::update()
Log::println( "Updating game data files {" );
Log::indent();
- NaClPlatform::post( "upd0:" );
+ Pepper::post( "upd0:" );
if( checkUpdates() ) {
downloadUpdates();
@@ -249,7 +247,7 @@ DArray<String> NaClUpdater::update()
localPackages.clear();
remotePackages.clear();
- NaClPlatform::post( "none:" );
+ Pepper::post( "none:" );
Log::unindent();
Log::println( "}" );
View
238 src/client/OpenGL.cc
@@ -1,238 +0,0 @@
-/*
- * OpenZone - simple cross-platform FPS/RTS game engine.
- *
- * Copyright © 2002-2013 Davorin Učakar
- *
- * 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 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * @file client/OpenGL.cc
- */
-
-#include <stable.hh>
-#include <client/OpenGL.hh>
-
-#include <SDL.h>
-
-#ifdef _WIN32
-# define OZ_DL_GLLOAD( func ) \
- *( void** )( &func ) = SDL_GL_GetProcAddress( #func ); \
- if( func == nullptr ) { \
- OZ_ERROR( "Failed to link OpenGL function: " #func ); \
- }
-#endif
-
-namespace oz
-{
-namespace client
-{
-
-#ifdef _WIN32
-
-OZ_DL_DEFINE( glUniform1i );
-OZ_DL_DEFINE( glUniform2i );
-OZ_DL_DEFINE( glUniform3i );
-OZ_DL_DEFINE( glUniform4i );
-OZ_DL_DEFINE( glUniform1iv );
-OZ_DL_DEFINE( glUniform2iv );
-OZ_DL_DEFINE( glUniform3iv );
-OZ_DL_DEFINE( glUniform4iv );
-OZ_DL_DEFINE( glUniform1f );
-OZ_DL_DEFINE( glUniform2f );
-OZ_DL_DEFINE( glUniform3f );
-OZ_DL_DEFINE( glUniform4f );
-OZ_DL_DEFINE( glUniform1fv );
-OZ_DL_DEFINE( glUniform2fv );
-OZ_DL_DEFINE( glUniform3fv );
-OZ_DL_DEFINE( glUniform4fv );
-OZ_DL_DEFINE( glUniformMatrix2fv );
-OZ_DL_DEFINE( glUniformMatrix3fv );
-OZ_DL_DEFINE( glUniformMatrix4fv );
-
-OZ_DL_DEFINE( glEnableVertexAttribArray );
-OZ_DL_DEFINE( glVertexAttribPointer );
-OZ_DL_DEFINE( glDrawRangeElements );
-
-OZ_DL_DEFINE( glGenBuffers );
-OZ_DL_DEFINE( glDeleteBuffers );
-OZ_DL_DEFINE( glBindBuffer );
-OZ_DL_DEFINE( glBufferData );
-OZ_DL_DEFINE( glMapBuffer );
-OZ_DL_DEFINE( glUnmapBuffer );
-
-OZ_DL_DEFINE( glCreateShader );
-OZ_DL_DEFINE( glDeleteShader );
-OZ_DL_DEFINE( glShaderSource );
-OZ_DL_DEFINE( glCompileShader );
-OZ_DL_DEFINE( glGetShaderiv );
-OZ_DL_DEFINE( glGetShaderInfoLog );
-OZ_DL_DEFINE( glCreateProgram );
-OZ_DL_DEFINE( glDeleteProgram );
-OZ_DL_DEFINE( glAttachShader );
-OZ_DL_DEFINE( glDetachShader );
-OZ_DL_DEFINE( glLinkProgram );
-OZ_DL_DEFINE( glGetProgramiv );
-OZ_DL_DEFINE( glGetProgramInfoLog );
-OZ_DL_DEFINE( glGetUniformLocation );
-OZ_DL_DEFINE( glBindAttribLocation );
-OZ_DL_DEFINE( glUseProgram );
-
-OZ_DL_DEFINE( glActiveTexture );
-OZ_DL_DEFINE( glCompressedTexImage2D );
-OZ_DL_DEFINE( glGetCompressedTexImage );
-
-OZ_DL_DEFINE( glGenerateMipmapEXT );
-OZ_DL_DEFINE( glGenRenderbuffersEXT );
-OZ_DL_DEFINE( glDeleteRenderbuffersEXT );
-OZ_DL_DEFINE( glBindRenderbufferEXT );
-OZ_DL_DEFINE( glRenderbufferStorageEXT );
-OZ_DL_DEFINE( glGenFramebuffersEXT );
-OZ_DL_DEFINE( glDeleteFramebuffersEXT );
-OZ_DL_DEFINE( glBindFramebufferEXT );
-OZ_DL_DEFINE( glFramebufferRenderbufferEXT );
-OZ_DL_DEFINE( glFramebufferTexture2DEXT );
-OZ_DL_DEFINE( glCheckFramebufferStatusEXT );
-
-#endif
-
-#ifndef NDEBUG
-
-void glCheckError( const char* function, const char* file, int line )
-{
- const char* message;
- GLenum result = glGetError();
-
- switch( result ) {
- case GL_NO_ERROR: {
- return;
- }
- case GL_INVALID_ENUM: {
- message = "GL_INVALID_ENUM";
- break;
- }
- case GL_INVALID_VALUE: {
- message = "GL_INVALID_VALUE";
- break;
- }
- case GL_INVALID_OPERATION: {
- message = "GL_INVALID_OPERATION";
- break;
- }
-# ifdef GL_STACK_OVERFLOW
- case GL_STACK_OVERFLOW: {
- message = "GL_STACK_OVERFLOW";
- break;
- }
-# endif
-# ifdef GL_STACK_UNDERFLOW
- case GL_STACK_UNDERFLOW: {
- message = "GL_STACK_UNDERFLOW";
- break;
- }
-# endif
- case GL_OUT_OF_MEMORY: {
- message = "GL_OUT_OF_MEMORY";
- break;
- }
-# ifdef GL_TABLE_TOO_LARGE
- case GL_TABLE_TOO_LARGE: {
- message = "GL_TABLE_TOO_LARGE";
- break;
- }
-# endif
- default: {
- message = String::str( "UNKNOWN(%d)", int( result ) );
- break;
- }
- }
-
- System::error( function, file, line, 1, "GL error '%s'", message );
-}
-
-#endif
-
-void glInit()
-{
-#ifdef _WIN32
-
- OZ_DL_GLLOAD( glUniform1i );
- OZ_DL_GLLOAD( glUniform2i );
- OZ_DL_GLLOAD( glUniform3i );
- OZ_DL_GLLOAD( glUniform4i );
- OZ_DL_GLLOAD( glUniform1iv );
- OZ_DL_GLLOAD( glUniform2iv );
- OZ_DL_GLLOAD( glUniform3iv );
- OZ_DL_GLLOAD( glUniform4iv );
- OZ_DL_GLLOAD( glUniform1f );
- OZ_DL_GLLOAD( glUniform2f );
- OZ_DL_GLLOAD( glUniform3f );
- OZ_DL_GLLOAD( glUniform4f );
- OZ_DL_GLLOAD( glUniform1fv );
- OZ_DL_GLLOAD( glUniform2fv );
- OZ_DL_GLLOAD( glUniform3fv );
- OZ_DL_GLLOAD( glUniform4fv );
- OZ_DL_GLLOAD( glUniformMatrix2fv );
- OZ_DL_GLLOAD( glUniformMatrix3fv );
- OZ_DL_GLLOAD( glUniformMatrix4fv );
-
- OZ_DL_GLLOAD( glEnableVertexAttribArray );
- OZ_DL_GLLOAD( glVertexAttribPointer );
- OZ_DL_GLLOAD( glDrawRangeElements );
-
- OZ_DL_GLLOAD( glGenBuffers );
- OZ_DL_GLLOAD( glDeleteBuffers );
- OZ_DL_GLLOAD( glBindBuffer );
- OZ_DL_GLLOAD( glBufferData );
- OZ_DL_GLLOAD( glMapBuffer );
- OZ_DL_GLLOAD( glUnmapBuffer );
-
- OZ_DL_GLLOAD( glCreateShader );
- OZ_DL_GLLOAD( glDeleteShader );
- OZ_DL_GLLOAD( glShaderSource );
- OZ_DL_GLLOAD( glCompileShader );
- OZ_DL_GLLOAD( glGetShaderiv );
- OZ_DL_GLLOAD( glGetShaderInfoLog );
- OZ_DL_GLLOAD( glCreateProgram );
- OZ_DL_GLLOAD( glDeleteProgram );
- OZ_DL_GLLOAD( glAttachShader );
- OZ_DL_GLLOAD( glDetachShader );
- OZ_DL_GLLOAD( glLinkProgram );
- OZ_DL_GLLOAD( glGetProgramiv );
- OZ_DL_GLLOAD( glGetProgramInfoLog );
- OZ_DL_GLLOAD( glGetUniformLocation );
- OZ_DL_GLLOAD( glBindAttribLocation );
- OZ_DL_GLLOAD( glUseProgram );
-
- OZ_DL_GLLOAD( glActiveTexture );
- OZ_DL_GLLOAD( glCompressedTexImage2D );
- OZ_DL_GLLOAD( glGetCompressedTexImage );
-
- OZ_DL_GLLOAD( glGenerateMipmapEXT );
- OZ_DL_GLLOAD( glGenRenderbuffersEXT );
- OZ_DL_GLLOAD( glDeleteRenderbuffersEXT );
- OZ_DL_GLLOAD( glBindRenderbufferEXT );
- OZ_DL_GLLOAD( glRenderbufferStorageEXT );
- OZ_DL_GLLOAD( glGenFramebuffersEXT );
- OZ_DL_GLLOAD( glDeleteFramebuffersEXT );
- OZ_DL_GLLOAD( glBindFramebufferEXT );
- OZ_DL_GLLOAD( glFramebufferRenderbufferEXT );
- OZ_DL_GLLOAD( glFramebufferTexture2DEXT );
- OZ_DL_GLLOAD( glCheckFramebufferStatusEXT );
-
-#endif
-}
-
-}
-}
View
137 src/client/OpenGL.hh
@@ -1,137 +0,0 @@
-/*
- * OpenZone - simple cross-platform FPS/RTS game engine.
- *
- * Copyright © 2002-2013 Davorin Učakar
- *
- * 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 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * @file client/OpenGL.hh
- */
-
-#pragma once
-
-#include <client/NaClPlatform.hh>
-
-#ifdef OZ_GL_ES
-# include <GLES2/gl2.h>
-#else
-# define GL_GLEXT_PROTOTYPES
-# include <SDL_opengl.h>
-#endif
-
-// Floating-point texture formats.
-#ifndef GL_VERSION_3_0
-# define GL_RGBA32F 0x8814
-# define GL_RGB32F 0x8815
-# define GL_RGBA16F 0x881A
-# define GL_RGB16F 0x881B
-#endif
-
-// S3 texture compression formats.
-#ifndef GL_EXT_texture_compression_s3tc
-# define GL_EXT_texture_compression_s3tc
-# define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
-# define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
-# define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
-# define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
-#endif
-
-namespace oz
-{
-namespace client
-{
-
-#ifdef _WIN32
-
-extern OZ_DL_DECLARE( glUniform1i );
-extern OZ_DL_DECLARE( glUniform2i );
-extern OZ_DL_DECLARE( glUniform3i );
-extern OZ_DL_DECLARE( glUniform4i );
-extern OZ_DL_DECLARE( glUniform1iv );
-extern OZ_DL_DECLARE( glUniform2iv );
-extern OZ_DL_DECLARE( glUniform3iv );
-extern OZ_DL_DECLARE( glUniform4iv );
-extern OZ_DL_DECLARE( glUniform1f );
-extern OZ_DL_DECLARE( glUniform2f );
-extern OZ_DL_DECLARE( glUniform3f );
-extern OZ_DL_DECLARE( glUniform4f );
-extern OZ_DL_DECLARE( glUniform1fv );
-extern OZ_DL_DECLARE( glUniform2fv );
-extern OZ_DL_DECLARE( glUniform3fv );
-extern OZ_DL_DECLARE( glUniform4fv );
-extern OZ_DL_DECLARE( glUniformMatrix2fv );
-extern OZ_DL_DECLARE( glUniformMatrix3fv );
-extern OZ_DL_DECLARE( glUniformMatrix4fv );
-
-extern OZ_DL_DECLARE( glEnableVertexAttribArray );
-extern OZ_DL_DECLARE( glVertexAttribPointer );
-extern OZ_DL_DECLARE( glDrawRangeElements );
-
-extern OZ_DL_DECLARE( glGenBuffers );
-extern OZ_DL_DECLARE( glDeleteBuffers );
-extern OZ_DL_DECLARE( glBindBuffer );
-extern OZ_DL_DECLARE( glBufferData );
-extern OZ_DL_DECLARE( glMapBuffer );
-extern OZ_DL_DECLARE( glUnmapBuffer );
-
-extern OZ_DL_DECLARE( glCreateShader );
-extern OZ_DL_DECLARE( glDeleteShader );
-extern OZ_DL_DECLARE( glShaderSource );
-extern OZ_DL_DECLARE( glCompileShader );
-extern OZ_DL_DECLARE( glGetShaderiv );
-extern OZ_DL_DECLARE( glGetShaderInfoLog );
-extern OZ_DL_DECLARE( glCreateProgram );
-extern OZ_DL_DECLARE( glDeleteProgram );
-extern OZ_DL_DECLARE( glAttachShader );
-extern OZ_DL_DECLARE( glDetachShader );
-extern OZ_DL_DECLARE( glLinkProgram );
-extern OZ_DL_DECLARE( glGetProgramiv );
-extern OZ_DL_DECLARE( glGetProgramInfoLog );
-extern OZ_DL_DECLARE( glGetUniformLocation );
-extern OZ_DL_DECLARE( glBindAttribLocation );
-extern OZ_DL_DECLARE( glUseProgram );
-
-extern OZ_DL_DECLARE( glActiveTexture );
-extern OZ_DL_DECLARE( glCompressedTexImage2D );
-extern OZ_DL_DECLARE( glGetCompressedTexImage );
-
-extern OZ_DL_DECLARE( glGenerateMipmapEXT );
-extern OZ_DL_DECLARE( glGenRenderbuffersEXT );
-extern OZ_DL_DECLARE( glDeleteRenderbuffersEXT );
-extern OZ_DL_DECLARE( glBindRenderbufferEXT );
-extern OZ_DL_DECLARE( glRenderbufferStorageEXT );
-extern OZ_DL_DECLARE( glGenFramebuffersEXT );
-extern OZ_DL_DECLARE( glDeleteFramebuffersEXT );
-extern OZ_DL_DECLARE( glBindFramebufferEXT );
-extern OZ_DL_DECLARE( glFramebufferRenderbufferEXT );
-extern OZ_DL_DECLARE( glFramebufferTexture2DEXT );
-extern OZ_DL_DECLARE( glCheckFramebufferStatusEXT );
-
-#endif
-
-#ifdef NDEBUG
-# define OZ_GL_CHECK_ERROR() void( 0 )
-#else
-# define OZ_GL_CHECK_ERROR() oz::client::glCheckError( __PRETTY_FUNCTION__, __FILE__, __LINE__ )
-
-void glCheckError( const char* function, const char* file, int line );
-
-#endif
-
-void glInit();
-
-}
-}
View
16 src/client/Render.cc
@@ -36,7 +36,7 @@
#include <client/ExplosionImago.hh>
#include <client/MD2WeaponImago.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
@@ -431,7 +431,7 @@ void Render::drawUI()
void Render::draw( int flags_ )
{
#ifdef __native_client__
- hard_assert( !NaClPlatform::isMainThread() );
+ hard_assert( !Pepper::isMainThread() );
#endif
flags = flags_;
@@ -454,7 +454,7 @@ void Render::draw( int flags_ )
void Render::swap()
{
#ifdef __native_client__
- hard_assert( !NaClPlatform::isMainThread() );
+ hard_assert( !Pepper::isMainThread() );
#endif
uint beginMicros = Time::uclock();
@@ -553,7 +553,7 @@ void Render::resize()
void Render::load()
{
#ifdef __native_client__
- hard_assert( NaClPlatform::isMainThread() );
+ hard_assert( Pepper::isMainThread() );
#endif
Log::print( "Loading Render ..." );
@@ -582,7 +582,7 @@ void Render::load()
void Render::unload()
{
#ifdef __native_client__
- hard_assert( NaClPlatform::isMainThread() );
+ hard_assert( Pepper::isMainThread() );
#endif
Log::print( "Unloading Render ..." );
@@ -612,7 +612,7 @@ void Render::unload()
void Render::init()
{
#ifdef __native_client__
- hard_assert( NaClPlatform::isMainThread() );
+ hard_assert( Pepper::isMainThread() );
#endif
Log::println( "Initialising Render {" );
@@ -698,7 +698,7 @@ void Render::init()
shader.hasS3TC = true;
}
- glInit();
+ GL::init();
String sScaleFilter;
@@ -746,7 +746,7 @@ void Render::init()
void Render::destroy()
{
#ifdef __native_client__
- hard_assert( NaClPlatform::isMainThread() );
+ hard_assert( Pepper::isMainThread() );
#endif
Log::println( "Destroying Render {" );
View
2  src/client/SMM.cc
@@ -29,7 +29,7 @@
#include <client/SMM.hh>
#include <client/Context.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
3  src/client/Shader.cc
@@ -27,9 +27,8 @@
#include <client/Shader.hh>
#include <matrix/Liber.hh>
-
#include <client/Camera.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
#define OZ_REGISTER_UNIFORM( uniformVar, uniformName ) \
programs[id].uniform.uniformVar = glGetUniformLocation( programs[id].program, uniformName )
View
2  src/client/Shape.cc
@@ -26,7 +26,7 @@
#include <client/Camera.hh>
#include <client/Context.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
#include <ozDynamics/ozDynamics.hh>
View
5 src/client/Sound.cc
@@ -26,7 +26,6 @@
#include <client/Camera.hh>
#include <client/eSpeak.hh>
-#include <client/NaClPlatform.hh>
#include <SDL.h>
@@ -662,7 +661,7 @@ void Sound::sync()
void Sound::init()
{
#ifdef __native_client__
- hard_assert( NaClPlatform::isMainThread() );
+ hard_assert( Pepper::isMainThread() );
#endif
Log::println( "Initialising Sound {" );
@@ -826,7 +825,7 @@ void Sound::init()
void Sound::destroy()
{
#ifdef __native_client__
- hard_assert( NaClPlatform::isMainThread() );
+ hard_assert( Pepper::isMainThread() );
#endif
Log::print( "Destroying Sound ..." );
View
2  src/client/Terra.cc
@@ -27,7 +27,7 @@
#include <common/Timer.hh>
#include <client/Frustum.hh>
#include <client/Context.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
19 src/client/Window.cc
@@ -25,8 +25,7 @@
#include <client/Window.hh>
#include <client/Input.hh>
-#include <client/OpenGL.hh>
-#include <client/NaClPlatform.hh>
+#include <ozEngine/GL.hh>
#ifdef __native_client__
# include <ppapi/cpp/completion_callback.h>
@@ -83,10 +82,10 @@ void Window::warpMouse()
}
#ifdef __native_client__
- NaClPlatform::moveX = 0.0f;
- NaClPlatform::moveY = 0.0f;
- NaClPlatform::moveZ = 0.0f;
- NaClPlatform::moveW = 0.0f;
+ Pepper::moveX = 0.0f;
+ Pepper::moveY = 0.0f;
+ Pepper::moveZ = 0.0f;
+ Pepper::moveW = 0.0f;
#elif SDL_MAJOR_VERSION >= 2
SDL_WarpMouseInWindow( descriptor, width / 2, height / 2 );
SDL_PumpEvents();
@@ -129,8 +128,8 @@ void Window::resize()
{
#ifdef __native_client__
- width = NaClPlatform::width;
- height = NaClPlatform::height;
+ width = Pepper::width;
+ height = Pepper::height;
OZ_MAIN_CALL( this, {
glSetCurrentContextPPAPI( 0 );
@@ -209,8 +208,8 @@ void Window::init()
flushSemaphore.init();
- width = NaClPlatform::width;
- height = NaClPlatform::height;
+ width = Pepper::width;
+ height = Pepper::height;
flags = 0;
isFull = false;
View
3  src/client/luaapi.hh
@@ -27,11 +27,10 @@
#include <nirvana/luaapi.hh>
+#include <ozEngine/Pepper.hh>
#include <client/QuestList.hh>
#include <client/Camera.hh>
#include <client/Profile.hh>
-#include <client/NaClPlatform.hh>
-
#include <client/ui/BuildMenu.hh>
#include <client/ui/UI.hh>
View
2  src/client/ui/Area.cc
@@ -26,7 +26,7 @@
#include <client/Camera.hh>
#include <client/Shape.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
#include <SDL_ttf.h>
View
3  src/client/ui/Button.cc
@@ -26,9 +26,8 @@
#include <client/Input.hh>
#include <client/Shape.hh>
-#include <client/OpenGL.hh>
-
#include <client/ui/Style.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
3  src/client/ui/CreditsMenu.cc
@@ -28,10 +28,9 @@
#include <client/Camera.hh>
#include <client/Context.hh>
#include <client/Input.hh>
-#include <client/OpenGL.hh>
-#include <client/NaClPlatform.hh>
#include <client/ui/Style.hh>
#include <client/ui/Button.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/ui/Font.cc
@@ -25,7 +25,7 @@
#include <client/ui/Font.hh>
#include <client/Shader.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
#include <SDL_ttf.h>
View
3  src/client/ui/Frame.cc
@@ -26,9 +26,8 @@
#include <client/Input.hh>
#include <client/Shape.hh>
-#include <client/OpenGL.hh>
-
#include <client/ui/Style.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/ui/GalileoFrame.cc
@@ -28,8 +28,8 @@
#include <client/Camera.hh>
#include <client/Context.hh>
#include <client/QuestList.hh>
-#include <client/OpenGL.hh>
#include <client/ui/Style.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/ui/HudArea.cc
@@ -28,7 +28,7 @@
#include <client/Shape.hh>
#include <client/Camera.hh>
#include <client/Context.hh>
-#include <client/OpenGL.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/ui/Inventory.cc
@@ -29,8 +29,8 @@
#include <client/Camera.hh>
#include <client/Context.hh>
#include <client/Input.hh>
-#include <client/OpenGL.hh>
#include <client/ui/Style.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/ui/Label.cc
@@ -26,9 +26,9 @@
#include <client/Shader.hh>
#include <client/Shape.hh>
-#include <client/OpenGL.hh>
#include <client/ui/Area.hh>
#include <client/ui/Style.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
4 src/client/ui/MainMenu.cc
@@ -28,7 +28,6 @@
#include <client/Shape.hh>
#include <client/GameStage.hh>
#include <client/MenuStage.hh>
-#include <client/OpenGL.hh>
#include <client/Window.hh>
#include <client/BuildInfo.hh>
#include <client/ui/Style.hh>
@@ -36,6 +35,7 @@
#include <client/ui/SettingsFrame.hh>
#include <client/ui/CreditsMenu.hh>
#include <client/ui/UI.hh>
+#include <ozEngine/GL.hh>
#if defined( __ANDROID__ ) || defined( __native_client__ )
#elif defined( _WIN32 )
@@ -99,7 +99,7 @@ static void openWeb( Button* )
{
#if defined( __ANDROID__ )
#elif defined( __native_client__ )
- NaClPlatform::post( "navi:http://ducakar.github.com/openzone/" );
+ Pepper::post( "navi:http://ducakar.github.com/openzone/" );
#elif defined( _WIN32 )
ShellExecute( nullptr, "open", "http://ducakar.github.com/openzone/", nullptr, nullptr,
SW_SHOWNORMAL );
View
3  src/client/ui/MissionMenu.cc
@@ -29,9 +29,8 @@
#include <client/Context.hh>
#include <client/GameStage.hh>
#include <client/Input.hh>
-#include <client/OpenGL.hh>
-#include <client/NaClPlatform.hh>
#include <client/ui/Style.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
50 src/client/ui/Mouse.cc
@@ -24,13 +24,14 @@
#include <stable.hh>
#include <client/ui/Mouse.hh>
+#include <common/Timer.hh>
#include <client/Shape.hh>
#include <client/Camera.hh>
#include <client/Context.hh>
#include <client/Window.hh>
#include <client/Input.hh>
-#include <client/OpenGL.hh>
#include <client/ui/Area.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
@@ -81,44 +82,48 @@ void Mouse::update()
}
}
-void Mouse::draw() const
+void Mouse::draw()
{
+ Cursor& cursor = cursors[icon];
+
if( doShow ) {
- const Cursor& cur = cursors[icon];
+ if( icon != oldIcon || !wasShown ) {
+ cursor.reset();
+ }
shape.colour( 1.0f, 1.0f, 1.0f, 1.0f );
- glBindTexture( GL_TEXTURE_2D, cur.texId );
- shape.fill( x - cur.hotspotX, y + 1 + cur.hotspotY - cur.size, cur.size, cur.size );
+ glBindTexture( GL_TEXTURE_2D, cursor.textureId() );
+ shape.fillInv( x - cursor.hotspotLeft(), y - cursor.height() + 1 + cursor.hotspotTop(),
+ cursor.width(), cursor.height() );
glBindTexture( GL_TEXTURE_2D, shader.defaultTexture );
+
+ cursor.advance( timer.frameMicros / 1000 );
}
+
+ oldIcon = icon;
+ wasShown = doShow;
}
void Mouse::init()
{
Log::print( "Initialising Mouse ..." );
- x = camera.centreX;
- y = camera.centreY;
- dx = 0;
- dy = 0;
+ x = camera.centreX;
+ y = camera.centreY;
+ dx = 0;
+ dy = 0;
- icon = ARROW;
- doShow = false;
+ icon = ARROW;
+ oldIcon = ARROW;
+ doShow = false;
+ wasShown = false;
for( int i = 0; i < CURSORS_MAX; ++i ) {
- File file( String::str( "@ui/cur/%s.ozCur", NAMES[i] ) );
+ File file( String::str( "@ui/cur/%s", NAMES[i] ) );
- Buffer buffer = file.read();
- if( buffer.isEmpty() ) {
+ if( !cursors[i].load( file ) ) {
OZ_ERROR( "Cursor loading failed" );
}
-
- InputStream is = buffer.inputStream();
-
- cursors[i].size = is.readInt();
- cursors[i].hotspotX = is.readInt();
- cursors[i].hotspotY = is.readInt();
- cursors[i].texId = context.readTextureLayer( &is );
}
Log::printEnd( " OK" );
@@ -129,8 +134,7 @@ void Mouse::destroy()
Log::print( "Destroying Mouse ..." );
for( int i = 0; i < CURSORS_MAX; ++i ) {
- glDeleteTextures( 1, &cursors[i].texId );
- cursors[i].texId = 0;
+ cursors[i].destroy();
}
Log::printEnd( " OK" );
View
13 src/client/ui/Mouse.hh
@@ -24,6 +24,7 @@
#pragma once
#include <client/common.hh>
+#include <ozEngine/Cursor.hh>
namespace oz
{
@@ -51,15 +52,9 @@ class Mouse
private:
- struct Cursor
- {
- int size;
- int hotspotX;
- int hotspotY;
- uint texId;
- };
-
Cursor cursors[CURSORS_MAX];
+ Icon oldIcon;
+ bool wasShown;
public:
@@ -73,7 +68,7 @@ class Mouse
void update();
- void draw() const;
+ void draw();
void init();
void destroy();
View
2  src/client/ui/SettingsFrame.cc
@@ -26,10 +26,10 @@
#include <client/Shape.hh>
#include <client/Camera.hh>
-#include <client/OpenGL.hh>
#include <client/ui/Style.hh>
#include <client/ui/MainMenu.hh>
#include <client/ui/UI.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
2  src/client/ui/Text.cc
@@ -26,9 +26,9 @@
#include <client/Shader.hh>
#include <client/Shape.hh>
-#include <client/OpenGL.hh>
#include <client/ui/Style.hh>
#include <client/ui/Area.hh>
+#include <ozEngine/GL.hh>
#if defined( __ANDROID__ ) || defined( _WIN32 )
static char* strchrnul( const char* s, int c )
View
2  src/client/ui/UI.cc
@@ -29,7 +29,6 @@
#include <client/Input.hh>
#include <client/Context.hh>
#include <client/Shape.hh>
-#include <client/OpenGL.hh>
#include <client/ui/Style.hh>
#include <client/ui/LoadingArea.hh>
#include <client/ui/StrategicArea.hh>
@@ -41,6 +40,7 @@
#include <client/ui/InfoFrame.hh>
#include <client/ui/BuildMenu.hh>
#include <client/ui/DebugFrame.hh>
+#include <ozEngine/GL.hh>
namespace oz
{
View
3  src/ozCore/Alloc.hh
@@ -74,7 +74,8 @@ class Alloc
/**
* Information about an allocated memory chunk.
*
- * Internal list of all memory allocations is held to spot memory leaks and `new`/`delete` mismatches.
+ * Internal list of all memory allocations is held to detect memory leaks and `new`/`delete`
+ * mismatches.
*/
struct ChunkInfo
{
View
6 src/ozCore/System.cc
@@ -496,15 +496,15 @@ static void waitBell()
}
// Wait bell to finish playing on (normal) process termination.
-static struct BellBlockade
+static struct BellFinaliser
{
OZ_HIDDEN
- ~BellBlockade()
+ ~BellFinaliser()
{
waitBell();
}
}
-bellBlockade;
+bellFinaliser;
OZ_NORETURN
static void abort( bool doHalt )
View
2  src/ozDynamics/collision/Box.hh
@@ -34,7 +34,7 @@ namespace oz
{
/**
- * Box.
+ * %Box.
*/
class Box : public Shape
{
View
2  src/ozDynamics/collision/Capsule.hh
@@ -34,7 +34,7 @@ namespace oz
{
/**
- * Capsule, represents a radius-region around a line segment.
+ * %Capsule, represents a radius-region around a line segment.
*/
class Capsule : public Shape
{
View
2  src/ozEngine/ALBuffer.cc
@@ -26,6 +26,8 @@
#include "ALBuffer.hh"
+#include "AL.hh"
+
namespace oz
{
View
4 src/ozEngine/ALBuffer.hh
@@ -40,7 +40,7 @@ class ALBuffer
{
private:
- ALuint bufferId; ///< OpenAL buffer id, 0 if not loaded.
+ uint bufferId; ///< OpenAL buffer id, 0 if not loaded.
public:
@@ -86,7 +86,7 @@ class ALBuffer
/**
* Get OpenAL buffer id.
*/
- ALuint id() const
+ uint id() const
{
return bufferId;
}
View
2  src/ozEngine/ALSource.cc
@@ -26,6 +26,8 @@
#include "ALSource.hh"
+#include "AL.hh"
+
namespace oz
{
View
6 src/ozEngine/ALSource.hh
@@ -28,7 +28,7 @@
#pragma once
-#include "AL.hh"
+#include "common.hh"
namespace oz
{
@@ -40,7 +40,7 @@ class ALSource
{
private:
- ALuint sourceId; ///< OpenAL source id, 0 if not created.
+ uint sourceId; ///< OpenAL source id, 0 if not created.
public:
@@ -83,7 +83,7 @@ class ALSource
/**
* Get OpenAL source id.
*/
- ALuint id() const
+ uint id() const
{
return sourceId;
}
View
5 src/ozEngine/ALStreamingBuffer.hh
@@ -28,6 +28,7 @@
#pragma once
+#include "AL.hh"
#include "ALSource.hh"
namespace oz
@@ -41,7 +42,7 @@ class ALStreamingBuffer
private:
AL::Streamer streamer; ///< Internal streamer.
- ALuint sourceId; ///< Attached source id, 0 if none.
+ uint sourceId; ///< Attached source id, 0 if none.
public:
@@ -81,7 +82,7 @@ class ALStreamingBuffer
/**
* Get attached OpenAL source id.
*/
- ALuint attachedSource() const
+ uint attachedSource() const
{
return sourceId;
}
View
2  src/ozEngine/Builder.hh
@@ -34,7 +34,7 @@ namespace oz
{
/**
- * Builder class wraps functions for conversion of generic image and 3D model formats to ones used
+ * %Builder class wraps functions for conversion of generic image and 3D model formats to ones used
* by OpenZone engine.
*/
class Builder
View
2  src/ozEngine/CMakeLists.txt
@@ -10,6 +10,7 @@ add_library( ozEngine
ALStreamingBuffer.hh
Builder.hh
common.hh
+ Cursor.hh
GL.hh
GLTexture.hh
ozEngine.hh
@@ -22,6 +23,7 @@ add_library( ozEngine
ALStreamingBuffer.cc
Builder.cc
common.cc
+ Cursor.cc
GL.cc
GLTexture.cc
Pepper.cc
View
204 src/ozEngine/Cursor.cc
@@ -0,0 +1,204 @@
+/*
+ * ozEngine - OpenZone Engine Library.
+ *
+ * Copyright © 2002-2013 Davorin Učakar
+ *
+ * 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 acknowledgement 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.
+ */
+
+/**
+ * @file ozEngine/Cursor.cc
+ */
+
+#include "Cursor.hh"
+
+#include "GL.hh"
+
+namespace oz
+{
+
+Cursor::Cursor() :
+ images{}, nImages( 0 ), frame( 0 ), frameTime( 0 )
+{}
+
+Cursor::Cursor( const oz::File& file, int size ) :
+ images{}, nImages( 0 ), frame( 0 ), frameTime( 0 )
+{
+ load( file, size );
+}
+
+Cursor::~Cursor()
+{
+ destroy();
+}
+
+Cursor::Cursor( Cursor&& c ) :
+ nImages( c.nImages ), frame( c.frame ), frameTime( c.frameTime )
+{
+ aCopy<Image>( images, c.images, MAX_IMAGES );
+
+ aFill<Image>( c.images, Image{}, MAX_IMAGES );
+ c.nImages = 0;
+ c.frame = 0;
+ c.frameTime = 0;
+}
+
+Cursor& Cursor::operator = ( Cursor&& c )
+{
+ if( &c == this ) {
+ return *this;
+ }
+
+ aCopy<Image>( images, c.images, MAX_IMAGES );
+ nImages = c.nImages;
+ frame = c.frame;
+ frameTime = c.frameTime;
+
+ aFill<Image>( c.images, Image{}, MAX_IMAGES );
+ c.nImages = 0;
+ c.frame = 0;
+ c.frameTime = 0;
+
+ return *this;
+}
+
+void Cursor::reset()
+{
+ frame = 0;
+ frameTime = 0;
+}
+
+void Cursor::advance( int millis )
+{
+ if( nImages == 0 ) {
+ return;
+ }
+
+ int delay = images[frame].delay;
+
+ frameTime += millis;
+ frame = ( frame + frameTime / delay ) % nImages;
+ frameTime = frameTime % delay;
+}
+
+bool Cursor::load( const File& file, int size )
+{
+ Buffer buffer;
+ InputStream istream;
+
+ if( file.isMapped() ) {
+ istream = file.inputStream();
+ }
+ else {
+ buffer = file.read();
+ istream = buffer.inputStream();
+ }
+
+ // Implementation is based on specifications from xcursor(3) manual.
+ if( !istream.isAvailable() || !String::beginsWith( istream.begin(), "Xcur" ) ) {
+ return false;
+ }
+
+ istream.seek( 12 );
+ int nEntries = istream.readInt();
+
+ nImages = 0;
+ frame = 0;
+ frameTime = 0;
+
+ for( int i = 0; i < nEntries && nImages < MAX_IMAGES; ++i ) {
+ uint type = istream.readUInt();
+ int subtype = istream.readInt();
+ int position = istream.readInt();
+
+ if( type != 0xfffd0002 ) {
+ continue;
+ }
+ else if( size == -1 ) {
+ size = subtype;
+ }
+ else if( subtype != size ) {
+ continue;
+ }
+
+ int tablePos = istream.tell();
+ istream.seek( position );
+
+ istream.readInt();
+ istream.readInt();
+ istream.readInt();
+ istream.readInt();
+
+ Image& image = images[nImages];
+ ++nImages;
+
+ image.width = istream.readInt();
+ image.height = istream.readInt();
+ image.hotspotLeft = istream.readInt();
+ image.hotspotTop = istream.readInt();
+ image.delay = istream.readInt();
+
+ int size = image.width*image.height * 4;
+
+ char* pixels = new char[size];