mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 06:34:10 +00:00
Show all valid light material textures with editLights
This commit is contained in:
parent
cde3a596ee
commit
329d822d32
10 changed files with 123 additions and 32 deletions
|
@ -1433,10 +1433,15 @@ void idClass::EditLights_f( const idCmdArgs& args )
|
|||
if( g_editEntityMode.GetInteger() != 1 )
|
||||
{
|
||||
g_editEntityMode.SetInteger( 1 );
|
||||
|
||||
// turn off com_smp multithreading so we can load and check light textures on main thread
|
||||
com_editors |= EDITOR_LIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_editEntityMode.SetInteger( 0 );
|
||||
|
||||
com_editors &= ~EDITOR_LIGHT;
|
||||
}
|
||||
}
|
||||
// RB end
|
|
@ -284,14 +284,14 @@ void NotifyDisplaySizeChanged( int width, int height )
|
|||
Init( width, height );
|
||||
|
||||
// reuse the default ImGui font
|
||||
idImage* image = globalImages->GetImage( "_imguiFont" );
|
||||
const idMaterial* image = declManager->FindMaterial( "_imguiFont" );
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
byte* pixels = NULL;
|
||||
io.Fonts->GetTexDataAsRGBA32( &pixels, &width, &height );
|
||||
|
||||
io.Fonts->TexID = ( void* )( intptr_t )image->GetImGuiTextureID();
|
||||
io.Fonts->TexID = ( void* )image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -362,14 +362,14 @@ void idGuiModel::EmitImGui( ImDrawData* drawData )
|
|||
|
||||
int numIndexes = pcmd->ElemCount;
|
||||
|
||||
// TODO support more than just the imGui Font texture
|
||||
// but we can live with the current solution because ImGui is only meant to draw a few bars and timers
|
||||
// support more than just the imGui Font texture
|
||||
const idMaterial* mat = tr.imgGuiMaterial;
|
||||
if( pcmd->TextureId && ( mat != ( const idMaterial* )pcmd->TextureId ) )
|
||||
{
|
||||
mat = ( const idMaterial* )pcmd->TextureId;
|
||||
}
|
||||
|
||||
//glBindTexture( GL_TEXTURE_2D, ( GLuint )( intptr_t )pcmd->TextureId )
|
||||
|
||||
//const idMaterial* material = declManager->FindMaterial( texture name of pcmd->TextureId );
|
||||
|
||||
idDrawVert* verts = renderSystem->AllocTris( numVerts, indexBufferOffset, numIndexes, tr.imgGuiMaterial, STEREO_DEPTH_TYPE_NONE );
|
||||
idDrawVert* verts = renderSystem->AllocTris( numVerts, indexBufferOffset, numIndexes, mat, STEREO_DEPTH_TYPE_NONE );
|
||||
if( verts == NULL )
|
||||
{
|
||||
continue;
|
||||
|
|
|
@ -258,6 +258,24 @@ idImage* idMaterial::GetEditorImage() const
|
|||
return editorImage;
|
||||
}
|
||||
|
||||
// RB - just look for first stage and fallback to editor image like D3Radiant does
|
||||
idImage* idMaterial::GetLightEditorImage() const
|
||||
{
|
||||
if( numStages && stages )
|
||||
{
|
||||
for( int i = 0; i < numStages; i++ )
|
||||
{
|
||||
idImage* image = stages[i].texture.image;
|
||||
if( image )
|
||||
{
|
||||
return image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return GetEditorImage();
|
||||
}
|
||||
// RB end
|
||||
|
||||
// info parms
|
||||
typedef struct
|
||||
|
@ -3320,16 +3338,38 @@ bool idMaterial::SetDefaultText()
|
|||
if( 1 ) //fileSystem->ReadFile( GetName(), NULL ) != -1 ) {
|
||||
{
|
||||
char generated[2048];
|
||||
idStr::snPrintf( generated, sizeof( generated ),
|
||||
"material %s // IMPLICITLY GENERATED\n"
|
||||
"{\n"
|
||||
"{\n"
|
||||
"blend blend\n"
|
||||
"colored\n"
|
||||
"map \"%s\"\n"
|
||||
"clamp\n"
|
||||
"}\n"
|
||||
"}\n", GetName(), GetName() );
|
||||
|
||||
// RB: HACK super hack for light editor 2D rendering
|
||||
idStr matName = GetName();
|
||||
if( matName.IcmpPrefix( "lighteditor/" ) == 0 )
|
||||
{
|
||||
idStr imageName = GetName();
|
||||
imageName.StripLeading( "lighteditor/" );
|
||||
|
||||
idStr::snPrintf( generated, sizeof( generated ),
|
||||
"material %s // IMPLICITLY GENERATED\n"
|
||||
"{\n"
|
||||
"{\n"
|
||||
"blend blend\n"
|
||||
"colored\n"
|
||||
"map \"%s\"\n"
|
||||
"clamp\n"
|
||||
"}\n"
|
||||
"}\n", matName.c_str(), imageName.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
idStr::snPrintf( generated, sizeof( generated ),
|
||||
"material %s // IMPLICITLY GENERATED\n"
|
||||
"{\n"
|
||||
"{\n"
|
||||
"blend blend\n"
|
||||
"colored\n"
|
||||
"map \"%s\"\n"
|
||||
"clamp\n"
|
||||
"}\n"
|
||||
"}\n", GetName(), GetName() );
|
||||
}
|
||||
SetText( generated );
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,14 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#ifndef __MATERIAL_H__
|
||||
#define __MATERIAL_H__
|
||||
|
||||
|
||||
// RB: define this to use the id Tech 4.5 UI interface for ImGui instead of OpenGL or Vulkan
|
||||
// this allows to have the com_showFPS stats in screenshots
|
||||
|
||||
//#if defined( USE_VULKAN )
|
||||
#define IMGUI_BFGUI 1
|
||||
//#endif
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
|
@ -799,6 +807,7 @@ public:
|
|||
|
||||
// gets an image for the editor to use
|
||||
idImage* GetEditorImage() const;
|
||||
idImage* GetLightEditorImage() const; // RB
|
||||
int GetImageWidth() const;
|
||||
int GetImageHeight() const;
|
||||
|
||||
|
|
|
@ -39,9 +39,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "Font.h"
|
||||
#include "Framebuffer.h"
|
||||
|
||||
// RB: define this to use the id Tech 4.5 UI interface for ImGui instead of OpenGL or Vulkan
|
||||
// this allows to have the com_showFPS stats in screenshots
|
||||
#define IMGUI_BFGUI 1
|
||||
|
||||
|
||||
// maximum texture units
|
||||
const int MAX_PROG_TEXTURE_PARMS = 16;
|
||||
|
|
|
@ -665,7 +665,7 @@ void idRenderSystemLocal::SwapCommandBuffers_FinishRendering(
|
|||
// and only update the screen when we update the progress bar in the console
|
||||
if( !takingEnvprobe )
|
||||
{
|
||||
#if !defined( USE_VULKAN ) && !defined( IMGUI_BFGUI )
|
||||
#if !IMGUI_BFGUI
|
||||
ImGuiHook::Render();
|
||||
#endif
|
||||
|
||||
|
@ -821,7 +821,7 @@ const emptyCommand_t* idRenderSystemLocal::SwapCommandBuffers_FinishCommandBuffe
|
|||
|
||||
// RB: general GUI system path to treat ImGui surfaces in the renderer frontend like SWF
|
||||
// this calls io.RenderDrawListsFn
|
||||
#if defined( USE_VULKAN ) || IMGUI_BFGUI
|
||||
#if IMGUI_BFGUI
|
||||
ImGuiHook::Render();
|
||||
#endif
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#pragma hdrstop
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "libs/imgui/imgui.h"
|
||||
|
||||
#include "RenderCommon.h"
|
||||
|
||||
// RB begin
|
||||
|
@ -1612,6 +1614,11 @@ void R_InitMaterials()
|
|||
|
||||
// RB: create implicit material
|
||||
tr.imgGuiMaterial = declManager->FindMaterial( "_imguiFont", true );
|
||||
|
||||
#if IMGUI_BFGUI
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.Fonts->TexID = ( void* )( intptr_t )tr.imgGuiMaterial;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -378,7 +378,7 @@ void LightEditor::Reset()
|
|||
lightEntity = NULL;
|
||||
currentTextureIndex = 0;
|
||||
currentTexture = NULL;
|
||||
|
||||
currentTextureMaterial = NULL;
|
||||
currentStyleIndex = 0;
|
||||
}
|
||||
|
||||
|
@ -402,14 +402,30 @@ void LightEditor::LoadLightTextures()
|
|||
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
// just get the name of the light material
|
||||
const idMaterial* mat = declManager->MaterialByIndex( i, false );
|
||||
|
||||
idStr str = mat->GetName();
|
||||
str.ToLower(); // FIXME: why? (this is from old doom3 code)
|
||||
idStr matName = mat->GetName();
|
||||
matName.ToLower(); // FIXME: why? (this is from old doom3 code)
|
||||
|
||||
if( str.Icmpn( "lights/", strlen( "lights/" ) ) == 0 || str.Icmpn( "fogs/", strlen( "fogs/" ) ) == 0 )
|
||||
if( matName.Icmpn( "lights/", strlen( "lights/" ) ) == 0 || matName.Icmpn( "fogs/", strlen( "fogs/" ) ) == 0 )
|
||||
{
|
||||
textureNames.Append( str );
|
||||
// actually load the material
|
||||
const idMaterial* material = declManager->FindMaterial( matName, false );
|
||||
if( material != NULL )
|
||||
{
|
||||
// check if the material has textures or is just a leftover from the development
|
||||
idImage* editorImage = mat->GetLightEditorImage();
|
||||
if( !editorImage->IsLoaded() )
|
||||
{
|
||||
editorImage->ActuallyLoadImage( false );
|
||||
}
|
||||
|
||||
if( !editorImage->IsDefaulted() )
|
||||
{
|
||||
textureNames.Append( matName );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,7 +465,17 @@ void LightEditor::LoadCurrentTexture()
|
|||
const idMaterial* mat = declManager->FindMaterial( cur.strTexture, false );
|
||||
if( mat != NULL )
|
||||
{
|
||||
currentTexture = mat->GetEditorImage();
|
||||
currentTexture = mat->GetLightEditorImage();
|
||||
if( currentTexture )
|
||||
{
|
||||
// RB: create extra 2D material of the image for UI rendering
|
||||
|
||||
// HACK that deserves being called a hack
|
||||
idStr uiName( "lighteditor/" );
|
||||
uiName += currentTexture->GetName();
|
||||
|
||||
currentTextureMaterial = declManager->FindMaterial( uiName, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -681,10 +707,15 @@ void LightEditor::DrawWindow()
|
|||
LoadCurrentTexture();
|
||||
}
|
||||
|
||||
if( currentTexture != NULL )
|
||||
if( currentTextureMaterial != nullptr && currentTexture != nullptr )
|
||||
{
|
||||
ImVec2 size( currentTexture->GetUploadWidth(), currentTexture->GetUploadHeight() );
|
||||
ImGui::Image( currentTexture->GetImGuiTextureID(), size, ImVec2( 0, 0 ), ImVec2( 1, 1 ),
|
||||
|
||||
#if !IMGUI_BFGUI
|
||||
ImGui::Image( ( void* )currentTexture->GetImGuiTextureID(), size, ImVec2( 0, 0 ), ImVec2( 1, 1 ),
|
||||
#else
|
||||
ImGui::Image( ( void* )currentTextureMaterial, size, ImVec2( 0, 0 ), ImVec2( 1, 1 ),
|
||||
#endif
|
||||
ImColor( 255, 255, 255, 255 ), ImColor( 255, 255, 255, 128 ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ private:
|
|||
idList<idStr> textureNames;
|
||||
int currentTextureIndex;
|
||||
idImage* currentTexture;
|
||||
const idMaterial* currentTextureMaterial;
|
||||
|
||||
// RB: light style support
|
||||
idList<idStr> styleNames;
|
||||
|
|
Loading…
Reference in a new issue