mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 03:09:18 +02:00
openvr WIP
This commit is contained in:
33
Texture.cpp
33
Texture.cpp
@@ -164,7 +164,7 @@ opengl_texture::load() {
|
||||
if (data_state == resource_state::good)
|
||||
return;
|
||||
|
||||
if( type == "make:" ) {
|
||||
if( type == "make:" || type == "internalsrc:" ) {
|
||||
// for generated texture we delay data creation until texture is bound
|
||||
// this ensures the script will receive all simulation data it might potentially want
|
||||
// as any binding will happen after simulation is loaded, initialized and running
|
||||
@@ -279,8 +279,8 @@ void opengl_texture::load_STBI()
|
||||
}
|
||||
|
||||
void
|
||||
opengl_texture::make_stub() {
|
||||
|
||||
opengl_texture::make_stub()
|
||||
{
|
||||
data_width = 2;
|
||||
data_height = 2;
|
||||
data.resize( data_width * data_height * 3 );
|
||||
@@ -289,6 +289,26 @@ opengl_texture::make_stub() {
|
||||
data_format = GL_RGB;
|
||||
data_components = GL_RGB;
|
||||
data_state = resource_state::good;
|
||||
|
||||
is_texstub = true;
|
||||
}
|
||||
|
||||
void
|
||||
opengl_texture::make_from_memory(size_t width, size_t height, const uint8_t *raw)
|
||||
{
|
||||
release();
|
||||
|
||||
data_width = width;
|
||||
data_height = width;
|
||||
data.resize(data_width * data_height * 4);
|
||||
memcpy(data.data(), raw, data.size());
|
||||
|
||||
data_format = GL_RGBA;
|
||||
data_components = GL_RGBA;
|
||||
data_mapcount = 1;
|
||||
data_state = resource_state::good;
|
||||
|
||||
is_texstub = false;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1113,8 +1133,9 @@ texture_manager::create(std::string Filename, bool const Loadnow , GLint fh) {
|
||||
// discern textures generated by a script
|
||||
// TBD: support file: for file resources?
|
||||
auto const isgenerated { Filename.find( "make:" ) == 0 };
|
||||
auto const isinternalsrc { Filename.find( "internal_src:" ) == 0 };
|
||||
// process supplied resource name
|
||||
if( isgenerated ) {
|
||||
if( isgenerated || isinternalsrc ) {
|
||||
// generated resource
|
||||
// scheme:(user@)path?query
|
||||
|
||||
@@ -1159,6 +1180,10 @@ texture_manager::create(std::string Filename, bool const Loadnow , GLint fh) {
|
||||
locator.first = Filename;
|
||||
locator.second = "make:";
|
||||
}
|
||||
else if ( isinternalsrc ) {
|
||||
locator.first = Filename;
|
||||
locator.second = "internalsrc:";
|
||||
}
|
||||
else {
|
||||
// ...for file resources check if it's on disk
|
||||
locator = find_on_disk( Filename );
|
||||
|
||||
Reference in New Issue
Block a user