Permalink
Browse files

DDS for UI images, Builder::buildDDS()

- ozCore
  * float quasi-specialisations for abs(), min(), max() & clmp() removed, could
    override templates in some cases
- ozEngine
  * Builder::buildDDS()
- client
  * DDS & GLTexture used for icons, UI images
  * Shape::fill() removed fillInv() -> fill()
  • Loading branch information...
1 parent 9ef5191 commit e3c6bac2611297e10b094b483a7cede010a0d1d1 @ducakar committed Apr 30, 2013
Showing with 464 additions and 639 deletions.
  1. +5 −2 CMakeLists.txt
  2. +1 −0 ChangeLog.md
  3. +1 −1 build.sh
  4. +1 −1 cmake/PNaCl.Toolchain.cmake
  5. 0 data/oz_base/ui/{ → style}/style.json
  6. +7 −9 src/builder/Builder.cc
  7. +8 −11 src/builder/Terra.cc
  8. +43 −32 src/builder/UI.cc
  9. +0 −1 src/builder/UI.hh
  10. +0 −1 src/builder/common.hh
  11. +0 −1 src/client/Audio.cc
  12. +0 −1 src/client/BSP.cc
  13. +0 −1 src/client/BSPAudio.cc
  14. +0 −1 src/client/Caelum.cc
  15. +0 −1 src/client/CinematicProxy.cc
  16. +0 −1 src/client/Client.cc
  17. +0 −15 src/client/Context.cc
  18. +0 −1 src/client/Context.hh
  19. +0 −1 src/client/ExplosionImago.cc
  20. +0 −1 src/client/FragPool.cc
  21. +0 −1 src/client/GameStage.cc
  22. +0 −3 src/client/Loader.cc
  23. +0 −1 src/client/MD2.cc
  24. +0 −1 src/client/MD2Imago.cc
  25. +0 −1 src/client/MD2WeaponImago.cc
  26. +0 −1 src/client/MD3.cc
  27. +0 −1 src/client/MD3Imago.cc
  28. +0 −1 src/client/MenuStage.cc
  29. +0 −1 src/client/Mesh.cc
  30. +0 −2 src/client/Render.cc
  31. +0 −1 src/client/SMM.cc
  32. +0 −1 src/client/Shader.cc
  33. +49 −70 src/client/Shape.cc
  34. +0 −2 src/client/Shape.hh
  35. +0 −1 src/client/Sound.hh
  36. +0 −1 src/client/Terra.cc
  37. +0 −1 src/client/Window.cc
  38. +1 −0 src/client/common.hh
  39. +0 −1 src/client/luaapi.hh
  40. +0 −1 src/client/ui/Area.cc
  41. +0 −1 src/client/ui/Button.cc
  42. +0 −1 src/client/ui/CreditsMenu.cc
  43. +0 −1 src/client/ui/Font.cc
  44. +0 −1 src/client/ui/Frame.cc
  45. +8 −39 src/client/ui/GalileoFrame.cc
  46. +12 −17 src/client/ui/GalileoFrame.hh
  47. +23 −38 src/client/ui/HudArea.cc
  48. +36 −37 src/client/ui/HudArea.hh
  49. +9 −19 src/client/ui/Inventory.cc
  50. +14 −15 src/client/ui/Inventory.hh
  51. +2 −3 src/client/ui/Label.cc
  52. +0 −1 src/client/ui/MainMenu.cc
  53. +11 −30 src/client/ui/MissionMenu.cc
  54. +6 −7 src/client/ui/MissionMenu.hh
  55. +2 −3 src/client/ui/Mouse.cc
  56. +0 −1 src/client/ui/Mouse.hh
  57. +0 −1 src/client/ui/SettingsFrame.cc
  58. +1 −1 src/client/ui/Style.cc
  59. +0 −1 src/client/ui/Text.cc
  60. +0 −1 src/client/ui/UI.cc
  61. +0 −5 src/ozCore/File.cc
  62. +0 −10 src/ozCore/File.hh
  63. +2 −40 src/ozCore/Math.hh
  64. +5 −1 src/ozEngine/ALBuffer.cc
  65. +4 −3 src/ozEngine/ALBuffer.hh
  66. +3 −3 src/ozEngine/ALSource.hh
  67. +2 −3 src/ozEngine/ALStreamingBuffer.hh
  68. +142 −157 src/ozEngine/Builder.cc
  69. +8 −8 src/ozEngine/Builder.hh
  70. +8 −0 src/ozEngine/CMakeLists.txt
  71. +3 −3 src/ozEngine/Cursor.cc
  72. +10 −5 src/ozEngine/GL.cc
  73. +5 −1 src/ozEngine/GL.hh
  74. +8 −1 src/ozEngine/GLTexture.cc
  75. +15 −6 src/ozEngine/GLTexture.hh
  76. +3 −0 src/ozEngine/config.hh.in
  77. +6 −1 src/tests/engine.cc
View
@@ -35,6 +35,7 @@ set( OZ_PLATFORM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR} )
if( PLATFORM_EMBEDDED )
set( OZ_PLATFORM_NAME ${PLATFORM_NAME}-${CMAKE_SYSTEM_PROCESSOR} )
set( OZ_GL_ES ON )
+ set( OZ_NONFREE OFF )
set( OZ_STANDALONE OFF )
endif()
@@ -135,10 +136,12 @@ endif()
if( NOT PLATFORM_EMBEDDED )
find_library( FREEIMAGE_LIBRARY freeimage )
+ find_library( FREEIMAGEPLUS_LIBRARY freeimageplus)
mark_as_advanced( FREEIMAGE_LIBRARY )
+ mark_as_advanced( FREEIMAGEPLUS_LIBRARY )
- if( NOT FREEIMAGE_LIBRARY )
- message( FATAL_ERROR "FreeImage library is missing" )
+ if( NOT FREEIMAGE_LIBRARY OR NOT FREEIMAGEPLUS_LIBRARY )
+ message( FATAL_ERROR "FreeImage(Plus) library is missing" )
endif()
if( OZ_NONFREE )
View
@@ -16,6 +16,7 @@
* 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 (VFS paths begin with '@')
+ * new SharedLib class
- ozDynamics: new rigid body dynamics library
* collision
+ primitives: Box, Capsule, Polytope, Compound
View
@@ -24,7 +24,7 @@ platforms=(
# FreeBSD-i686-Clang
# FreeBSD-i686-GCC
Windows-i686
- NaCl-x86_64
+# NaCl-x86_64
# NaCl-i686
# NaCl-ARM
# PNaCl
@@ -9,7 +9,7 @@ set( PLATFORM_TRIPLET "pnacl" )
set( PLATFORM_PREFIX "$ENV{NACL_SDK_ROOT}/toolchain/linux_x86_pnacl/newlib" )
set( PLATFORM_PORTS_PREFIX "${CMAKE_SOURCE_DIR}/ports/PNaCl" )
set( PLATFORM_EXE_SUFFIX ".pexe" )
-set( PLATFORM_FLAGS "-I $ENV{NACL_SDK_ROOT}/include" )
+set( PLATFORM_FLAGS "-isystem $ENV{NACL_SDK_ROOT}/include" )
set( CMAKE_SYSTEM_NAME "Linux" CACHE STRING "Target system." )
set( CMAKE_SYSTEM_PROCESSOR "LLVM-IR" CACHE STRING "Target processor." )
File renamed without changes.
View
@@ -649,26 +649,24 @@ void Builder::buildMissions()
copyFiles( mission->path(), &mission->path()[1], "json", false );
File srcFile( mission->path() + "/description.png" );
- File outFile( &( mission->path() + "/description.ozImage" )[1] );
+ File outFile( &( mission->path() + "/description.dds" )[1] );
if( srcFile.type() == File::MISSING ) {
continue;
}
- Log::println( "Building thumbnail {" );
- Log::indent();
-
- Context::Texture imageTex = context.loadTexture( srcFile.path(), false, GL_LINEAR, GL_LINEAR );
+ Log::print( "Building thumbnail '%s' ...", outFile.path().cstr() );
OutputStream os( 0 );
- imageTex.write( &os );
+ if( !oz::Builder::buildDDS( srcFile.path(), 0, &os ) ) {
+ OZ_ERROR( "Failed to convert '%s' to DDS", srcFile.path().cstr() );
+ }
if( !outFile.write( os.begin(), os.tell() ) ) {
OZ_ERROR( "Failed to write '%s'", outFile.path().cstr() );
}
- Log::unindent();
- Log::println( "}" );
+ Log::printEnd( " OK" );
}
lingua.buildMissions();
@@ -912,11 +910,11 @@ int Builder::main( int argc, char** argv )
}
if( doUI ) {
UI::buildIcons();
- UI::copyScheme();
copyFiles( "@ui/cur", "ui/cur", "", false );
copyFiles( "@ui/font", "ui/font", "ttf", false );
copyFiles( "@ui/icon", "ui/icon", "", false );
+ copyFiles( "@ui/style", "ui/style", "json", false );
}
if( doShaders ) {
copyFiles( "@glsl", "glsl", "glsl", false );
View
@@ -178,7 +178,6 @@ void Terra::saveMatrix()
void Terra::saveClient()
{
File destFile( "terra/" + name + ".ozcTerra" );
- File minimapFile( "terra/" + name + ".ozcTex" );
Log::println( "Compiling terrain model to '%s' {", destFile.path().cstr() );
Log::indent();
@@ -269,23 +268,21 @@ void Terra::saveClient()
Log::unindent();
Log::println( "}" );
- bool useS3TC = context.useS3TC;
- context.useS3TC = false;
+ File minimapIn( "@terra/" + mapTexture );
+ File minimapOut( "terra/" + name + ".dds" );
- mapTex = context.loadTexture( "@terra/" + mapTexture );
-
- Log::print( "Writing minimap texture '%s' ...", minimapFile.path().cstr() );
+ Log::print( "Writing minimap texture '%s' ...", minimapOut.path().cstr() );
os.rewind();
- mapTex.write( &os );
+ if( !Builder::buildDDS( minimapIn, 0, &os ) ) {
+ OZ_ERROR( "Minimap texture '%s' loading failed", minimapIn.path().cstr() );
+ }
- if( !minimapFile.write( os.begin(), os.tell() ) ) {
- OZ_ERROR( "Minimap texture '%s' writing failed", minimapFile.path().cstr() );
+ if( !minimapOut.write( os.begin(), os.tell() ) ) {
+ OZ_ERROR( "Minimap texture '%s' writing failed", minimapOut.path().cstr() );
}
Log::printEnd( " OK" );
-
- context.useS3TC = useS3TC;
}
void Terra::build( const char* name_ )
View
@@ -24,9 +24,6 @@
#include <stable.hh>
#include <builder/UI.hh>
-#include <client/ui/Mouse.hh>
-#include <builder/Context.hh>
-
namespace oz
{
namespace builder
@@ -53,55 +50,69 @@ const char* const UI::ICON_NAMES[] = {
void UI::buildIcons()
{
- if( File( "@ui/icon" ).type() != File::DIRECTORY ) {
+ File dir( "@ui/icon" );
+
+ if( dir.type() != File::DIRECTORY ) {
return;
}
+ HashMap<String, bool> icons;
+ foreach( name, citer( ICON_NAMES ) ) {
+ icons.add( *name, false );
+ }
+
Log::println( "Building UI icons {" );
Log::indent();
- bool useS3TC = context.useS3TC;
- context.useS3TC = false;
-
File::mkdir( "ui" );
File::mkdir( "ui/icon" );
- foreach( name, citer( ICON_NAMES ) ) {
- String srcPath = String::str( "@ui/icon/%s.png", *name );
- String destPath = String::str( "ui/icon/%s.ozIcon", *name );
+ DArray<File> images = dir.ls();
- Context::Texture tex = context.loadTexture( srcPath, false, GL_NEAREST, GL_NEAREST );
- hard_assert( !tex.isEmpty() );
+ foreach( image, images.citer() ) {
+ String name = image->baseName();
- OutputStream os( 0 );
+ bool* isBuilt = icons.find( name );
+ if( image->type() != File::REGULAR || isBuilt == nullptr || *isBuilt ) {
+ continue;
+ }
- Log::println( "Compiling '%s'", destPath.cstr() );
- tex.write( &os );
+ File destFile( "ui/icon/" + name + ".dds" );
- if( !File( destPath ).write( os.begin(), os.tell() ) ) {
- OZ_ERROR( "Texture writing failed" );
+ OutputStream os( 0 );
+ if( image->hasExtension( "dds" ) ) {
+ if( !image->read( &os ) ) {
+ OZ_ERROR( "Error reading image '%s'", image->path().cstr() );
+ }
+ else {
+ Log::println( "'%s' copied", image->path().cstr() );
+ }
+ }
+ else {
+ if( !Builder::buildDDS( *image, 0, &os ) ) {
+ continue;
+ }
+ else {
+ Log::println( "'%s' converted to DDS", image->path().cstr() );
+ }
}
+
+ if( !destFile.write( os.begin(), os.tell() ) ) {
+ OZ_ERROR( "Failed to write '%s' file", destFile.path().cstr() );
+ }
+
+ *isBuilt = true;
}
- context.useS3TC = useS3TC;
+ foreach( i, icons.citer() ) {
+ if( !i->value ) {
+ OZ_ERROR( "Mission icon: %s", i->key.cstr() );
+ }
+ }
Log::unindent();
Log::println( "}" );
}
-void UI::copyScheme()
-{
- File srcFile( "@ui/style.json" );
- File outFile( "ui/style.json" );
-
- if( srcFile.type() == File::REGULAR ) {
- Log::print( "Copying UI colour scheme '%s' ...", srcFile.path().cstr() );
-
- outFile.write( srcFile.read() );
-
- Log::printEnd( " OK" );
- }
-}
-
}
}
View
@@ -39,7 +39,6 @@ class UI
public:
static void buildIcons();
- static void copyScheme();
};
View
@@ -24,7 +24,6 @@
#pragma once
#include <client/common.hh>
-
#include <builder/config.hh>
namespace oz
View
@@ -26,7 +26,6 @@
#include <client/Camera.hh>
#include <client/Context.hh>
-#include <ozEngine/AL.hh>
namespace oz
{
View
@@ -26,7 +26,6 @@
#include <client/Context.hh>
#include <client/SMM.hh>
-#include <ozEngine/GL.hh>
namespace oz
{
View
@@ -25,7 +25,6 @@
#include <client/BSPAudio.hh>
#include <client/Context.hh>
-#include <ozEngine/AL.hh>
namespace oz
{
View
@@ -28,7 +28,6 @@
#include <client/Camera.hh>
#include <client/Terra.hh>
#include <client/Shape.hh>
-#include <ozEngine/GL.hh>
namespace oz
{
@@ -24,7 +24,6 @@
#include <stable.hh>
#include <client/CinematicProxy.hh>
-#include <ozEngine/Pepper.hh>
#include <common/Timer.hh>
#include <client/Camera.hh>
#include <client/Sound.hh>
View
@@ -26,7 +26,6 @@
#include <stable.hh>
#include <client/Client.hh>
-#include <ozEngine/Pepper.hh>
#include <common/Timer.hh>
#include <common/Lua.hh>
#include <client/Camera.hh>
View
@@ -35,8 +35,6 @@
#include <client/BotAudio.hh>
#include <client/VehicleAudio.hh>
-#include <ozEngine/GL.hh>
-#include <ozEngine/AL.hh>
#include <client/eSpeak.hh>
#include <SDL.h>
@@ -321,19 +319,6 @@ uint Context::readTextureLayer( InputStream* istream )
return texId;
}
-uint Context::loadTextureLayer( const char* path )
-{
- File file( path );
- Buffer buffer = file.read();
-
- if( buffer.isEmpty() ) {
- OZ_ERROR( "Texture file '%s' mmap failed", file.path().cstr() );
- }
-
- InputStream is = buffer.inputStream();
- return readTextureLayer( &is );
-}
-
Texture Context::readTexture( InputStream* istream )
{
Texture texture;
View
@@ -171,7 +171,6 @@ class Context
explicit Context();
static uint readTextureLayer( InputStream* istream );
- static uint loadTextureLayer( const char* path );
static Texture readTexture( InputStream* istream );
static Texture loadTexture( const char* path );
@@ -26,7 +26,6 @@
#include <common/Timer.hh>
#include <client/Context.hh>
-#include <ozEngine/GL.hh>
namespace oz
{
View
@@ -27,7 +27,6 @@
#include <client/Shader.hh>
#include <client/Context.hh>
#include <client/SMM.hh>
-#include <ozEngine/GL.hh>
namespace oz
{
View
@@ -24,7 +24,6 @@
#include <stable.hh>
#include <client/GameStage.hh>
-#include <ozEngine/Pepper.hh>
#include <matrix/Synapse.hh>
#include <matrix/Matrix.hh>
#include <nirvana/Nirvana.hh>
View
@@ -32,9 +32,6 @@
#include <client/MD2.hh>
#include <client/MD3.hh>
-#include <ozEngine/GL.hh>
-#include <ozEngine/AL.hh>
-
#include <SDL.h>
namespace oz
View
@@ -26,7 +26,6 @@
#include <common/Timer.hh>
#include <client/Context.hh>
-#include <ozEngine/GL.hh>
namespace oz
{
View
@@ -26,7 +26,6 @@
#include <client/Context.hh>
#include <client/Camera.hh>
-#include <ozEngine/GL.hh>
namespace oz
{
Oops, something went wrong.

0 comments on commit e3c6bac

Please sign in to comment.