mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 18:23:45 +00:00
Use standard types instead of GL types in 3D raytracing renderer.
This commit is contained in:
parent
094d265313
commit
8e4f6889d5
3d-viewer/3d_rendering/raytracing
render_3d_raytrace_base.cpprender_3d_raytrace_base.hrender_3d_raytrace_gl.cpprender_3d_raytrace_ram.cpprender_3d_raytrace_ram.h
pcbnew
@ -106,7 +106,7 @@ void RENDER_3D_RAYTRACE_BASE::restartRenderState()
|
||||
}
|
||||
|
||||
|
||||
static inline void SetPixel( GLubyte* p, const COLOR_RGBA& v )
|
||||
static inline void SetPixel( uint8_t* p, const COLOR_RGBA& v )
|
||||
{
|
||||
p[0] = v.c[0];
|
||||
p[1] = v.c[1];
|
||||
@ -121,7 +121,7 @@ SFVEC4F RENDER_3D_RAYTRACE_BASE::premultiplyAlpha( const SFVEC4F& aInput )
|
||||
}
|
||||
|
||||
|
||||
void RENDER_3D_RAYTRACE_BASE::render( GLubyte* ptrPBO, REPORTER* aStatusReporter )
|
||||
void RENDER_3D_RAYTRACE_BASE::render( uint8_t* ptrPBO, REPORTER* aStatusReporter )
|
||||
{
|
||||
if( ( m_renderState == RT_RENDER_STATE_FINISH ) || ( m_renderState >= RT_RENDER_STATE_MAX ) )
|
||||
{
|
||||
@ -136,7 +136,7 @@ void RENDER_3D_RAYTRACE_BASE::render( GLubyte* ptrPBO, REPORTER* aStatusReporter
|
||||
// This way it will draw the full buffer but only shows the updated (
|
||||
// already calculated) squares
|
||||
unsigned int nPixels = m_realBufferSize.x * m_realBufferSize.y;
|
||||
GLubyte* tmp_ptrPBO = ptrPBO + 3; // PBO is RGBA
|
||||
uint8_t* tmp_ptrPBO = ptrPBO + 3; // PBO is RGBA
|
||||
|
||||
for( unsigned int i = 0; i < nPixels; ++i )
|
||||
{
|
||||
@ -181,7 +181,7 @@ void RENDER_3D_RAYTRACE_BASE::render( GLubyte* ptrPBO, REPORTER* aStatusReporter
|
||||
}
|
||||
|
||||
|
||||
void RENDER_3D_RAYTRACE_BASE::renderTracing( GLubyte* ptrPBO, REPORTER* aStatusReporter )
|
||||
void RENDER_3D_RAYTRACE_BASE::renderTracing( uint8_t* ptrPBO, REPORTER* aStatusReporter )
|
||||
{
|
||||
m_isPreview = false;
|
||||
|
||||
@ -295,7 +295,7 @@ SFVEC4F ConvertSRGBAToLinear( const SFVEC4F& aSRGBAcolor )
|
||||
#endif
|
||||
|
||||
|
||||
void RENDER_3D_RAYTRACE_BASE::renderFinalColor( GLubyte* ptrPBO, const SFVEC4F& rgbColor,
|
||||
void RENDER_3D_RAYTRACE_BASE::renderFinalColor( uint8_t* ptrPBO, const SFVEC4F& rgbColor,
|
||||
bool applyColorSpaceConversion )
|
||||
{
|
||||
SFVEC4F color = rgbColor;
|
||||
@ -476,7 +476,7 @@ void RENDER_3D_RAYTRACE_BASE::renderAntiAliasPackets( const SFVEC4F* aBgColorY,
|
||||
#define DISP_FACTOR 0.075f
|
||||
|
||||
|
||||
void RENDER_3D_RAYTRACE_BASE::renderBlockTracing( GLubyte* ptrPBO, signed int iBlock )
|
||||
void RENDER_3D_RAYTRACE_BASE::renderBlockTracing( uint8_t* ptrPBO, signed int iBlock )
|
||||
{
|
||||
// Initialize ray packets
|
||||
const SFVEC2UI& blockPos = m_blockPositions[iBlock];
|
||||
@ -535,7 +535,7 @@ void RENDER_3D_RAYTRACE_BASE::renderBlockTracing( GLubyte* ptrPBO, signed int iB
|
||||
|
||||
for( unsigned int x = 0; x < RAYPACKET_DIM; ++x )
|
||||
{
|
||||
GLubyte* ptr = &ptrPBO[( yConst + x ) * 4];
|
||||
uint8_t* ptr = &ptrPBO[( yConst + x ) * 4];
|
||||
|
||||
renderFinalColor( ptr, outColor, isFinalColor );
|
||||
}
|
||||
@ -628,7 +628,7 @@ void RENDER_3D_RAYTRACE_BASE::renderBlockTracing( GLubyte* ptrPBO, signed int iB
|
||||
}
|
||||
|
||||
// Copy results to the next stage
|
||||
GLubyte* ptr = &ptrPBO[( blockPos.x + ( blockPos.y * m_realBufferSize.x ) ) * 4];
|
||||
uint8_t* ptr = &ptrPBO[( blockPos.x + ( blockPos.y * m_realBufferSize.x ) ) * 4];
|
||||
|
||||
const uint32_t ptrInc = ( m_realBufferSize.x - RAYPACKET_DIM ) * 4;
|
||||
|
||||
@ -687,7 +687,7 @@ void RENDER_3D_RAYTRACE_BASE::renderBlockTracing( GLubyte* ptrPBO, signed int iB
|
||||
}
|
||||
|
||||
|
||||
void RENDER_3D_RAYTRACE_BASE::postProcessShading( GLubyte* /* ptrPBO */, REPORTER* aStatusReporter )
|
||||
void RENDER_3D_RAYTRACE_BASE::postProcessShading( uint8_t* /* ptrPBO */, REPORTER* aStatusReporter )
|
||||
{
|
||||
if( m_boardAdapter.m_Cfg->m_Render.raytrace_post_processing )
|
||||
{
|
||||
@ -739,7 +739,7 @@ void RENDER_3D_RAYTRACE_BASE::postProcessShading( GLubyte* /* ptrPBO */, REPORTE
|
||||
}
|
||||
|
||||
|
||||
void RENDER_3D_RAYTRACE_BASE::postProcessBlurFinish( GLubyte* ptrPBO, REPORTER* /* aStatusReporter */ )
|
||||
void RENDER_3D_RAYTRACE_BASE::postProcessBlurFinish( uint8_t* ptrPBO, REPORTER* /* aStatusReporter */ )
|
||||
{
|
||||
if( m_boardAdapter.m_Cfg->m_Render.raytrace_post_processing )
|
||||
{
|
||||
@ -756,7 +756,7 @@ void RENDER_3D_RAYTRACE_BASE::postProcessBlurFinish( GLubyte* ptrPBO, REPORTER*
|
||||
for( size_t y = nextBlock.fetch_add( 1 ); y < m_realBufferSize.y;
|
||||
y = nextBlock.fetch_add( 1 ) )
|
||||
{
|
||||
GLubyte* ptr = &ptrPBO[ y * m_realBufferSize.x * 4 ];
|
||||
uint8_t* ptr = &ptrPBO[ y * m_realBufferSize.x * 4 ];
|
||||
|
||||
for( signed int x = 0; x < (int)m_realBufferSize.x; ++x )
|
||||
{
|
||||
@ -796,7 +796,7 @@ void RENDER_3D_RAYTRACE_BASE::postProcessBlurFinish( GLubyte* ptrPBO, REPORTER*
|
||||
}
|
||||
|
||||
|
||||
void RENDER_3D_RAYTRACE_BASE::renderPreview( GLubyte* ptrPBO )
|
||||
void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
|
||||
{
|
||||
m_isPreview = true;
|
||||
|
||||
@ -1351,7 +1351,7 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( GLubyte* ptrPBO )
|
||||
}
|
||||
|
||||
// Set pixel colors
|
||||
GLubyte* ptr =
|
||||
uint8_t* ptr =
|
||||
&ptrPBO[( 4 * x + m_blockPositionsFast[iBlock].x
|
||||
+ m_realBufferSize.x
|
||||
* ( m_blockPositionsFast[iBlock].y + 4 * y ) ) * 4];
|
||||
|
@ -77,11 +77,11 @@ protected:
|
||||
float aLayerZOffset );
|
||||
|
||||
void restartRenderState();
|
||||
void renderTracing( GLubyte* ptrPBO, REPORTER* aStatusReporter );
|
||||
void postProcessShading( GLubyte* ptrPBO, REPORTER* aStatusReporter );
|
||||
void postProcessBlurFinish( GLubyte* ptrPBO, REPORTER* aStatusReporter );
|
||||
void renderBlockTracing( GLubyte* ptrPBO , signed int iBlock );
|
||||
void renderFinalColor( GLubyte* ptrPBO, const SFVEC4F& rgbColor,
|
||||
void renderTracing( uint8_t* ptrPBO, REPORTER* aStatusReporter );
|
||||
void postProcessShading( uint8_t* ptrPBO, REPORTER* aStatusReporter );
|
||||
void postProcessBlurFinish( uint8_t* ptrPBO, REPORTER* aStatusReporter );
|
||||
void renderBlockTracing( uint8_t* ptrPBO , signed int iBlock );
|
||||
void renderFinalColor( uint8_t* ptrPBO, const SFVEC4F& rgbColor,
|
||||
bool applyColorSpaceConversion );
|
||||
|
||||
void renderRayPackets( const SFVEC4F* bgColorY, const RAY* aRayPkt, HITINFO_PACKET* aHitPacket,
|
||||
@ -119,8 +119,8 @@ protected:
|
||||
|
||||
void initializeBlockPositions();
|
||||
|
||||
void render( GLubyte* ptrPBO, REPORTER* aStatusReporter );
|
||||
void renderPreview( GLubyte* ptrPBO );
|
||||
void render( uint8_t* ptrPBO, REPORTER* aStatusReporter );
|
||||
void renderPreview( uint8_t* ptrPBO );
|
||||
|
||||
static SFVEC4F premultiplyAlpha( const SFVEC4F& aInput );
|
||||
|
||||
|
@ -158,7 +158,7 @@ bool RENDER_3D_RAYTRACE_GL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
|
||||
glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, m_pboId );
|
||||
|
||||
// Get the PBO pixel pointer to write the data
|
||||
GLubyte* ptrPBO = (GLubyte *)glMapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB,
|
||||
uint8_t* ptrPBO = (uint8_t *)glMapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB,
|
||||
GL_WRITE_ONLY_ARB );
|
||||
|
||||
if( ptrPBO )
|
||||
@ -179,7 +179,7 @@ bool RENDER_3D_RAYTRACE_GL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
|
||||
if( m_renderState != RT_RENDER_STATE_FINISH )
|
||||
{
|
||||
// Get the PBO pixel pointer to write the data
|
||||
GLubyte* ptrPBO = (GLubyte *)glMapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB,
|
||||
uint8_t* ptrPBO = (uint8_t *)glMapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB,
|
||||
GL_WRITE_ONLY_ARB );
|
||||
|
||||
if( ptrPBO )
|
||||
|
@ -41,7 +41,7 @@ RENDER_3D_RAYTRACE_RAM::~RENDER_3D_RAYTRACE_RAM()
|
||||
}
|
||||
|
||||
|
||||
GLubyte* RENDER_3D_RAYTRACE_RAM::GetBuffer()
|
||||
uint8_t* RENDER_3D_RAYTRACE_RAM::GetBuffer()
|
||||
{
|
||||
return m_outputBuffer;
|
||||
}
|
||||
@ -155,5 +155,5 @@ void RENDER_3D_RAYTRACE_RAM::initPbo()
|
||||
deletePbo();
|
||||
|
||||
m_pboDataSize = m_realBufferSize.x * m_realBufferSize.y * 4;
|
||||
m_outputBuffer = new GLubyte[m_pboDataSize]();
|
||||
m_outputBuffer = new uint8_t[m_pboDataSize]();
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
|
||||
~RENDER_3D_RAYTRACE_RAM();
|
||||
|
||||
GLubyte* GetBuffer();
|
||||
uint8_t* GetBuffer();
|
||||
wxSize GetRealBufferSize();
|
||||
|
||||
void SetCurWindowSize( const wxSize& aSize ) override;
|
||||
@ -50,8 +50,8 @@ private:
|
||||
void initPbo() override;
|
||||
void deletePbo() override;
|
||||
|
||||
GLubyte* m_outputBuffer;
|
||||
GLuint m_pboDataSize;
|
||||
uint8_t* m_outputBuffer;
|
||||
uint32_t m_pboDataSize;
|
||||
};
|
||||
|
||||
|
||||
|
@ -350,7 +350,7 @@ int PCBNEW_JOBS_HANDLER::JobExportRender( JOB* aJob )
|
||||
}
|
||||
}
|
||||
|
||||
GLubyte* rgbaBuffer = raytrace.GetBuffer();
|
||||
uint8_t* rgbaBuffer = raytrace.GetBuffer();
|
||||
wxSize realSize = raytrace.GetRealBufferSize();
|
||||
bool success = !!rgbaBuffer;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user