-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Turbobadger integration by Robert Campbell --------- Co-authored-by: Robert Campbell <waprave@gmail.com>
- Loading branch information
1 parent
da5ff13
commit 739da61
Showing
265 changed files
with
5,438 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ Radon Labs GmbH, Berlin/Germany | |
|
||
Johannes Hirche | ||
Gustav Sterbrant | ||
Fredrik Lindahl | ||
Fredrik Lindahl | ||
Robert Campbell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#------------------------------------------------------------------------------- | ||
# tbui module | ||
#------------------------------------------------------------------------------- | ||
|
||
nebula_begin_module(tbui) | ||
fips_ide_group(addons) | ||
|
||
fips_deps(render turbobadger) | ||
target_precompile_headers(tbui PRIVATE <render/stdneb.h>) | ||
target_include_directories(tbui PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
fips_files( | ||
tbuicontext.cc | ||
tbuicontext.h | ||
tbuiinputhandler.cc | ||
tbuiinputhandler.h | ||
tbuiview.cc | ||
tbuiview.h | ||
) | ||
|
||
add_shaders(tbui.fx) | ||
|
||
fips_dir(backend) | ||
fips_files( | ||
tbuibatch.h | ||
tbuibitmap.cc | ||
tbuibitmap.h | ||
tbuiclipboard.cc | ||
tbuifile.cc | ||
tbuifile.h | ||
tbuirenderer.cc | ||
tbuirenderer.h | ||
tbuisystem.cc | ||
tbuivertex.h | ||
) | ||
|
||
nebula_end_module() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
//------------------------------------------------------------------------------ | ||
/** | ||
Turbobadger UI Batch | ||
@copyright | ||
(C) 2024 Individual contributors, see AUTHORS file | ||
*/ | ||
//------------------------------------------------------------------------------ | ||
#include "coregraphics/buffer.h" | ||
#include "coregraphics/texture.h" | ||
#include "util/array.h" | ||
#include "math/rectangle.h" | ||
#include "tbuivertex.h" | ||
|
||
//------------------------------------------------------------------------------ | ||
namespace TBUI | ||
{ | ||
struct TBUIBatch | ||
{ | ||
CoreGraphics::TextureId texture; | ||
Util::Array<TBUIVertex> vertices; | ||
Math::intRectangle clipRect; | ||
}; | ||
} // namespace TBUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//------------------------------------------------------------------------------ | ||
// backend/tbuibitmap.cc | ||
// (C) 2024 Individual contributors, see AUTHORS file | ||
//------------------------------------------------------------------------------ | ||
#include "render/stdneb.h" | ||
#include "tbuibitmap.h" | ||
#include "tbuirenderer.h" | ||
|
||
|
||
namespace TBUI | ||
{ | ||
|
||
//------------------------------------------------------------------------------ | ||
/* | ||
*/ | ||
TBUIBitmap::TBUIBitmap(TBUIRenderer* renderer) | ||
: renderer(renderer), | ||
texture(CoreGraphics::InvalidTextureId) | ||
{ | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
/* | ||
*/ | ||
TBUIBitmap::~TBUIBitmap() | ||
{ | ||
this->renderer->FlushBitmap(this); | ||
CoreGraphics::DestroyTexture(this->texture); | ||
this->texture = CoreGraphics::InvalidTextureId; | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
/* | ||
*/ | ||
bool | ||
TBUIBitmap::Init(int width, int height, unsigned int* data) | ||
{ | ||
this->width = width; | ||
this->height = height; | ||
|
||
CoreGraphics::TextureCreateInfo texInfo; | ||
texInfo.name = "tbui_generated_texture"_atm; | ||
texInfo.usage = CoreGraphics::TextureUsage::SampleTexture; | ||
texInfo.tag = "tbui"_atm; | ||
texInfo.data = data; | ||
texInfo.dataSize = width * height * CoreGraphics::PixelFormat::ToSize(CoreGraphics::PixelFormat::SRGBA8); | ||
texInfo.type = CoreGraphics::TextureType::Texture2D; | ||
texInfo.format = CoreGraphics::PixelFormat::SRGBA8; | ||
texInfo.width = width; | ||
texInfo.height = height; | ||
|
||
this->texture = CoreGraphics::CreateTexture(texInfo); | ||
|
||
//SetData(data); | ||
return true; | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
/* | ||
*/ | ||
int | ||
TBUIBitmap::Width() | ||
{ | ||
return this->width; | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
/* | ||
*/ | ||
int | ||
TBUIBitmap::Height() | ||
{ | ||
return this->height; | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
/* | ||
*/ | ||
void | ||
TBUIBitmap::SetData(unsigned int* data) | ||
{ | ||
const SizeT dataSize = this->width * this->height * CoreGraphics::PixelFormat::ToSize(CoreGraphics::PixelFormat::SRGBA8); | ||
CoreGraphics::TextureUpdate(this->renderer->GetCmdBufferId(), this->texture, this->width, this->height, 0, 0, data, dataSize); | ||
} | ||
} // namespace TBUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
//------------------------------------------------------------------------------ | ||
/** | ||
Turbobadger UI Bitmap | ||
@copyright | ||
(C) 2024 Individual contributors, see AUTHORS file | ||
*/ | ||
//------------------------------------------------------------------------------ | ||
#include "coregraphics/texture.h" | ||
#include "tb_renderer.h" | ||
|
||
//------------------------------------------------------------------------------ | ||
namespace TBUI | ||
{ | ||
|
||
class TBUIRenderer; | ||
|
||
//------------------------------------------------------------------------------ | ||
class TBUIBitmap : public tb::TBBitmap | ||
{ | ||
public: | ||
|
||
/// | ||
TBUIBitmap(TBUIRenderer* renderer); | ||
|
||
/** Note: Implementations for batched renderers should call TBRenderer::FlushBitmap | ||
to make sure any active batch is being flushed before the bitmap is deleted. */ | ||
~TBUIBitmap() override; | ||
|
||
/// | ||
bool Init(int width, int height, unsigned int* data); | ||
|
||
/// | ||
int Width() override; | ||
/// | ||
int Height() override; | ||
|
||
/** Update the bitmap with the given data (in BGRA32 format). | ||
Note: Implementations for batched renderers should call TBRenderer::FlushBitmap | ||
to make sure any active batch is being flushed before the bitmap is changed. */ | ||
void SetData(unsigned int* data) override; | ||
|
||
/// | ||
CoreGraphics::TextureId GetTexture() const; | ||
|
||
private: | ||
TBUIRenderer* renderer; | ||
int width = 0; | ||
int height = 0; | ||
CoreGraphics::TextureId texture; | ||
}; | ||
|
||
//------------------------------------------------------------------------------ | ||
/* | ||
*/ | ||
inline CoreGraphics::TextureId | ||
TBUIBitmap::GetTexture() const | ||
{ | ||
return this->texture; | ||
} | ||
} // namespace TBUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//------------------------------------------------------------------------------ | ||
// backend/tbuiclipboard.cc | ||
// (C) 2024 Individual contributors, see AUTHORS file | ||
//------------------------------------------------------------------------------ | ||
#include "render/stdneb.h" | ||
#include "tb_system.h" | ||
|
||
namespace tb | ||
{ | ||
|
||
// == TBClipboard ===================================== | ||
|
||
TBStr clipboard; ///< Obviosly not a full implementation since it ignores the OS :) | ||
|
||
void | ||
TBClipboard::Empty() | ||
{ | ||
clipboard.Clear(); | ||
} | ||
|
||
bool | ||
TBClipboard::HasText() | ||
{ | ||
return !clipboard.IsEmpty(); | ||
} | ||
|
||
bool | ||
TBClipboard::SetText(const char* text) | ||
{ | ||
return clipboard.Set(text); | ||
} | ||
|
||
bool | ||
TBClipboard::GetText(TBStr& text) | ||
{ | ||
return text.Set(clipboard); | ||
} | ||
|
||
} // namespace tb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
//------------------------------------------------------------------------------ | ||
// backend/tbuifile.cc | ||
// (C) 2024 Individual contributors, see AUTHORS file | ||
//------------------------------------------------------------------------------ | ||
#include "render/stdneb.h" | ||
#include "io/ioserver.h" | ||
#include "io/stream.h" | ||
#include "tbuifile.h" | ||
#include "tb_system.h" | ||
|
||
namespace tb | ||
{ | ||
//------------------------------------------------------------------------------ | ||
/** | ||
*/ | ||
TBFile* | ||
TBFile::Open(const char* filename, TBFileMode mode) | ||
{ | ||
if (mode != TBFileMode::MODE_READ) | ||
return nullptr; | ||
|
||
TBUI::TBUIFile* file = new ::TBUI::TBUIFile(filename, IO::Stream::AccessMode::ReadAccess); | ||
if (!file->IsOpen()) | ||
{ | ||
file = nullptr; | ||
} | ||
|
||
return file; | ||
} | ||
} // namespace tb | ||
|
||
namespace TBUI | ||
{ | ||
//------------------------------------------------------------------------------ | ||
/** | ||
*/ | ||
TBUIFile::TBUIFile(const Util::String& filePath, IO::Stream::AccessMode accessMode) | ||
: fileStream(nullptr) | ||
{ | ||
this->fileStream = IO::IoServer::Instance()->CreateStream(filePath).downcast<IO::FileStream>(); | ||
this->fileStream->SetAccessMode(accessMode); | ||
if (!this->fileStream->Open()) | ||
{ | ||
this->fileStream = nullptr; | ||
} | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
/** | ||
*/ | ||
TBUIFile::~TBUIFile() | ||
{ | ||
if (this->fileStream->IsOpen()) | ||
{ | ||
this->fileStream->Close(); | ||
} | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
/** | ||
*/ | ||
long | ||
TBUIFile::Size() | ||
{ | ||
return this->fileStream->GetSize(); | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
/** | ||
*/ | ||
size_t | ||
TBUIFile::Read(void* buf, size_t elemSize, size_t count) | ||
{ | ||
return this->fileStream->Read(buf, count); | ||
} | ||
} // namespace TBUI |
Oops, something went wrong.