Skip to content

Commit

Permalink
Merge remote branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mahlemiut committed Mar 23, 2015
2 parents 4e43710 + b56b22a commit 5592347
Show file tree
Hide file tree
Showing 766 changed files with 48,664 additions and 27,580 deletions.
14 changes: 7 additions & 7 deletions 3rdparty/bgfx/3rdparty/ib-compress/writebitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define WBS_INLINE __forceinline
#else
#define WBS_INLINE inline
#endif
#endif

// Very simple bitstream for writing that will grow to accomodate written bits.
// Very simple bitstream for writing that will grow to accomodate written bits.
class WriteBitstream
{
public:

// Construct the bit stream with an initial buffer capacity - should be a multiple of 8 and > 0
// Construct the bit stream with an initial buffer capacity - should be a multiple of 8 and > 0
WriteBitstream( size_t initialBufferCapacity = 16 )
{
m_bufferCursor =
Expand All @@ -66,7 +66,7 @@ class WriteBitstream
// Write a V int to the stream.
void WriteVInt( uint32_t value );

// Get the size in bytes
// Get the size in bytes
size_t ByteSize() const { return ( m_size + 7 ) >> 3; }

// Finish writing by flushing the buffer.
Expand All @@ -80,7 +80,7 @@ class WriteBitstream
// If we need to grow the buffer.
void GrowBuffer();

// Not copyable
// Not copyable
WriteBitstream( const WriteBitstream& );

// Not assignable
Expand All @@ -96,7 +96,7 @@ class WriteBitstream

WBS_INLINE void WriteBitstream::Write( uint32_t value, uint32_t bitCount )
{
m_bitBuffer |= ( static_cast<uint64_t>( value ) << ( 64 - m_bitsLeft ) ) & ( m_bitsLeft == 0 ? 0 : 0xFFFFFFFFFFFFFFFF );
m_bitBuffer |= ( static_cast<uint64_t>( value ) << ( 64 - m_bitsLeft ) ) & ( m_bitsLeft == 0 ? 0 : UINT64_C(0xFFFFFFFFFFFFFFFF) );

if ( bitCount > m_bitsLeft )
{
Expand Down Expand Up @@ -175,4 +175,4 @@ WBS_INLINE void WriteBitstream::GrowBuffer()
m_bufferEnd = m_buffer + newBufferSize;
}

#endif // -- WRITE_BIT_STREAM_H__
#endif // -- WRITE_BIT_STREAM_H__
9 changes: 7 additions & 2 deletions 3rdparty/bgfx/3rdparty/ocornut-imgui/imconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
//---- Define assertion handler. Defaults to calling assert().
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)

//---- Don't implement default clipboard handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
//#define IMGUI_API __declspec( dllexport )
//#define IMGUI_API __declspec( dllimport )

//---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS

//---- Include imgui_user.inl at the end of imgui.cpp so you can include code that extends ImGui using its private data/functions.
//#define IMGUI_INCLUDE_IMGUI_USER_INL
Expand All @@ -36,7 +41,7 @@

//---- Freely implement extra functions within the ImGui:: namespace.
//---- Declare helpers or widgets implemented in imgui_user.inl or elsewhere, so end-user doesn't need to include multiple files.
//---- e.g. you can create variants of the ImGui::Value() helper for your low-level math types.
//---- e.g. you can create variants of the ImGui::Value() helper for your low-level math types, or your own widgets/helpers.
/*
namespace ImGui
{
Expand Down
1,707 changes: 1,149 additions & 558 deletions 3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp

Large diffs are not rendered by default.

206 changes: 120 additions & 86 deletions 3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h

Large diffs are not rendered by default.

47 changes: 36 additions & 11 deletions 3rdparty/bgfx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
What is it?
-----------

Cross-platform rendering library.
Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style
rendering library.

Supported rendering backends:

Expand Down Expand Up @@ -69,9 +70,17 @@ very early development and primary focusing on Mac as primary target. This is
how it currently looks.
![mac_screenshot](https://raw.githubusercontent.com/emoon/ProDBG/master/data/screens/mac_screenshot.png)


http://www.dogbytegames.com/ Dogbyte Games is an indie mobile developer studio
focusing on racing games.
focusing on racing games.
![ios](http://www.dogbytegames.com/bgfx/offroadlegends2_bgfx_ipad2.jpg)

https://github.com/andr3wmac/Torque6 Torque 6 is an MIT licensed 3D engine
loosely based on Torque2D. Being neither Torque2D or Torque3D it is the 6th
derivative of the original Torque Engine.

https://github.com/cgbystrom/twinkle GPU-accelerated UI framework powered by
JavaScript for desktop/mobile apps. Idea is to combine the fast workflow and
deployment model of web with the performance of native code and GPU acceleration.

Examples
--------
Expand Down Expand Up @@ -311,18 +320,27 @@ Building
Steps bellow are for default build system inside bgfx repository. There is
alterative way to build bgfx and examples with [fips](https://github.com/floooh/fips-bgfx/#fips-bgfx).

### Prerequisites

Windows users download GnuWin32 utilities from:
[http://gnuwin32.sourceforge.net/packages/make.htm](http://gnuwin32.sourceforge.net/packages/make.htm)
[http://gnuwin32.sourceforge.net/packages/coreutils.htm](http://gnuwin32.sourceforge.net/packages/coreutils.htm)
[http://gnuwin32.sourceforge.net/packages/libiconv.htm](http://gnuwin32.sourceforge.net/packages/libiconv.htm)
[http://gnuwin32.sourceforge.net/packages/libintl.htm](http://gnuwin32.sourceforge.net/packages/libintl.htm)

### Getting source

git clone git://github.com/bkaradzic/bx.git
git clone git://github.com/bkaradzic/bgfx.git

### Quick start (Windows with Visual Studio)

Enter bgfx directory:

cd bgfx

Generate Visual Studio 2013 project files:

..\bx\tools\bin\windows\genie vs2013

Open bgfx solution in Visual Studio 2013:

start .build\projects\vs2013\bgfx.sln

### Generating project files for all targets

cd bgfx
make

Expand Down Expand Up @@ -353,6 +371,12 @@ Download Native Client SDK from:

### Prerequisites for Windows

Windows users download GnuWin32 utilities from:
[http://gnuwin32.sourceforge.net/packages/make.htm](http://gnuwin32.sourceforge.net/packages/make.htm)
[http://gnuwin32.sourceforge.net/packages/coreutils.htm](http://gnuwin32.sourceforge.net/packages/coreutils.htm)
[http://gnuwin32.sourceforge.net/packages/libiconv.htm](http://gnuwin32.sourceforge.net/packages/libiconv.htm)
[http://gnuwin32.sourceforge.net/packages/libintl.htm](http://gnuwin32.sourceforge.net/packages/libintl.htm)

When building on Windows, you have to set DXSDK_DIR environment variable to
point to DirectX SDK directory.

Expand Down Expand Up @@ -593,6 +617,7 @@ Todo
- Animated mesh example.
- Direct3D 12 renderer backend.
- Metal renderer backend.
- Vulkan renderer backend.

Contact
-------
Expand Down
17 changes: 17 additions & 0 deletions 3rdparty/bgfx/examples/08-update/fs_update_3d.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$input v_texcoord0

/*
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/

#include "../common/common.sh"

SAMPLER3D(u_texColor, 0);
uniform float u_time;

void main()
{
vec3 uvw = vec3(v_texcoord0.xy*0.5+0.5, sin(u_time)*0.5+0.5);
gl_FragColor = vec4_splat(texture3D(u_texColor, uvw).x);
}
72 changes: 66 additions & 6 deletions 3rdparty/bgfx/examples/08-update/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,46 @@ int _main_(int /*_argc*/, char** /*_argv*/)
loadTexture("texture_compression_ptc24.pvr"),
};

const bgfx::Memory* mem8 = bgfx::alloc(32*32*32);
const bgfx::Memory* mem16f = bgfx::alloc(32*32*32*2);
const bgfx::Memory* mem32f = bgfx::alloc(32*32*32*4);
for (uint8_t zz = 0; zz < 32; ++zz)
{
for (uint8_t yy = 0; yy < 32; ++yy)
{
for (uint8_t xx = 0; xx < 32; ++xx)
{
const uint32_t offset = ( (zz*32+yy)*32+xx);
const uint32_t val = xx ^ yy ^ zz;
mem8->data[offset] = val<<3;
*(uint16_t*)&mem16f->data[offset*2] = bx::halfFromFloat( (float)val/32.0f);
*(float*)&mem32f->data[offset*4] = (float)val/32.0f;
}
}
}

bgfx::TextureHandle textures3d[] =
{
bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R8, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem8),
bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R16F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem16f),
bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R32F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem32f),
};

// Create static vertex buffer.
bgfx::VertexBufferHandle vbh = bgfx::createVertexBuffer(bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ), PosTexcoordVertex::ms_decl);

// Create static index buffer.
bgfx::IndexBufferHandle ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) );

// Create texture sampler uniforms.
bgfx::UniformHandle u_texCube = bgfx::createUniform("u_texCube", bgfx::UniformType::Uniform1iv);

bgfx::UniformHandle u_texCube = bgfx::createUniform("u_texCube", bgfx::UniformType::Uniform1iv);
bgfx::UniformHandle u_texColor = bgfx::createUniform("u_texColor", bgfx::UniformType::Uniform1iv);

bgfx::ProgramHandle program = loadProgram("vs_update", "fs_update");
bgfx::ProgramHandle programCmp = loadProgram("vs_update", "fs_update_cmp");
bgfx::UniformHandle u_time = bgfx::createUniform("u_time", bgfx::UniformType::Uniform1f);

bgfx::ProgramHandle program = loadProgram("vs_update", "fs_update");
bgfx::ProgramHandle programCmp = loadProgram("vs_update", "fs_update_cmp");
bgfx::ProgramHandle program3d = loadProgram("vs_update", "fs_update_3d");

const uint32_t textureSide = 2048;

Expand Down Expand Up @@ -210,6 +237,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
const int64_t freq = bx::getHPFrequency();
const double toMs = 1000.0/double(freq);
float time = (float)( (now - timeOffset)/double(bx::getHPFrequency() ) );
bgfx::setUniform(u_time, &time);

// Use debug font to print information about this example.
bgfx::dbgTextClear();
Expand Down Expand Up @@ -345,10 +373,11 @@ int _main_(int /*_argc*/, char** /*_argv*/)
// Submit primitive for rendering to view 1.
bgfx::submit(1);

const float xpos = -8.0f - BX_COUNTOF(textures)*0.1f*0.5f;

for (uint32_t ii = 0; ii < BX_COUNTOF(textures); ++ii)
{
bx::mtxTranslate(mtx, -8.0f - BX_COUNTOF(textures)*0.1f*0.5f + ii*2.1f, 4.0f, 0.0f);
bx::mtxTranslate(mtx, xpos + ii*2.1f, 4.0f, 0.0f);

// Set model matrix for rendering.
bgfx::setTransform(mtx);
Expand All @@ -370,9 +399,33 @@ int _main_(int /*_argc*/, char** /*_argv*/)
bgfx::submit(1);
}

for (uint32_t ii = 0; ii < BX_COUNTOF(textures3d); ++ii)
{
bx::mtxTranslate(mtx, xpos + ii*2.1f, -4.0f, 0.0f);

// Set model matrix for rendering.
bgfx::setTransform(mtx);

// Set vertex and fragment shaders.
bgfx::setProgram(program3d);

// Set vertex and index buffer.
bgfx::setVertexBuffer(vbh);
bgfx::setIndexBuffer(ibh, 0, 6);

// Bind texture.
bgfx::setTexture(0, u_texColor, textures3d[ii]);

// Set render states.
bgfx::setState(BGFX_STATE_DEFAULT);

// Submit primitive for rendering to view 1.
bgfx::submit(1);
}

for (uint32_t ii = 0; ii < 3; ++ii)
{
bx::mtxTranslate(mtx, -8.0f - BX_COUNTOF(textures)*0.1f*0.5f + 8*2.1f, -4.0f + ii*2.1f, 0.0f);
bx::mtxTranslate(mtx, xpos + 8*2.1f, -4.0f + ii*2.1f, 0.0f);

// Set model matrix for rendering.
bgfx::setTransform(mtx);
Expand Down Expand Up @@ -412,12 +465,19 @@ int _main_(int /*_argc*/, char** /*_argv*/)
bgfx::destroyTexture(textures[ii]);
}

for (uint32_t ii = 0; ii < BX_COUNTOF(textures3d); ++ii)
{
bgfx::destroyTexture(textures3d[ii]);
}

bgfx::destroyTexture(texture2d);
bgfx::destroyTexture(textureCube);
bgfx::destroyIndexBuffer(ibh);
bgfx::destroyVertexBuffer(vbh);
bgfx::destroyProgram(program3d);
bgfx::destroyProgram(programCmp);
bgfx::destroyProgram(program);
bgfx::destroyUniform(u_time);
bgfx::destroyUniform(u_texColor);
bgfx::destroyUniform(u_texCube);

Expand Down
18 changes: 6 additions & 12 deletions 3rdparty/bgfx/examples/23-vectordisplay/vectordisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ void VectorDisplay::resize(uint16_t _width, uint16_t _height)

void VectorDisplay::teardown()
{
for (size_t i = 0; i < m_vertexBuffers.size(); ++i)
{
bgfx::destroyDynamicVertexBuffer(m_vertexBuffers[i]);
}

teardownResDependent();

bgfx::destroyProgram(m_drawToScreenShader);
Expand All @@ -147,9 +152,6 @@ void VectorDisplay::beginFrame()
void VectorDisplay::endFrame()
{
float proj[16];
float ident[16];
bx::mtxIdentity(ident);

bx::mtxOrtho(proj, 0.0f, (float)m_screenWidth, (float)m_screenHeight, 0.0f, 0.0f, 1000.0f);

bgfx::setViewRect(m_view, 0, 0, m_screenWidth, m_screenHeight);
Expand All @@ -166,14 +168,6 @@ void VectorDisplay::endFrame()
);
m_vertexBuffersSize[m_currentDrawStep] = (uint32_t)m_points.size();

//if the index buffer is cleared from the last "submit"-call everything is fine, but if not
//we clear it here again just to be sure it's not set... (the same for the Transform)
bgfx::IndexBufferHandle ib;
ib.idx = bgfx::invalidHandle;
bgfx::setIndexBuffer(ib);

bgfx::setTransform(ident);

for (int loopvar = 0; loopvar < m_numberDecaySteps; loopvar++)
{
int stepi = m_numberDecaySteps - loopvar - 1;
Expand Down Expand Up @@ -728,7 +722,7 @@ bool VectorDisplay::setDecaySteps(int _steps)
{
for (size_t i = 0; i < m_vertexBuffers.size(); ++i)
{
destroyDynamicVertexBuffer(m_vertexBuffers[i]);
bgfx::destroyDynamicVertexBuffer(m_vertexBuffers[i]);
}

m_vertexBuffers.clear();
Expand Down
Loading

0 comments on commit 5592347

Please sign in to comment.