@@ -66,15 +66,6 @@ bool GPUDisplayBackendOpenGL::canLimitToVSync() const
6666 return mDisplay ->frontend ()->canSetVSync ();
6767}
6868
69- bool GPUDisplayBackendOpenGL::CoreProfile ()
70- {
71- #ifdef GPUCA_DISPLAY_OPENGL_CORE
72- return true ;
73- #else
74- return false ;
75- #endif
76- }
77-
7869// #define CHKERR(cmd) {cmd;}
7970#define CHKERR (cmd ) \
8071 do { \
@@ -86,15 +77,6 @@ bool GPUDisplayBackendOpenGL::CoreProfile()
8677 } \
8778 } while (false )
8879
89- uint32_t GPUDisplayBackendOpenGL::DepthBits ()
90- {
91- GLint depthBits = 0 ;
92- #ifndef GPUCA_DISPLAY_OPENGL_CORE
93- glGetIntegerv (GL_DEPTH_BITS , &depthBits);
94- #endif
95- return depthBits;
96- }
97-
9880void GPUDisplayBackendOpenGL::createFB (GLfb& fb, bool tex, bool withDepth, bool msaa, uint32_t width, uint32_t height)
9981{
10082 fb.tex = tex;
@@ -185,22 +167,13 @@ uint32_t GPUDisplayBackendOpenGL::drawVertices(const vboList& v, const drawType
185167 }
186168
187169 if (mDisplay ->useMultiVBO ()) {
188- if (!mDisplay ->cfgR ().rendererCompatSmoothing ) { // TODO: Remove OpenGL compat profile completely
189- CHKERR (glBindVertexArray (mVertexArray ));
190- }
170+ CHKERR (glBindVertexArray (mVertexArray ));
191171 CHKERR (glBindBuffer (GL_ARRAY_BUFFER , mVBOId [iSector]));
192- #ifndef GPUCA_DISPLAY_OPENGL_CORE
193- if (mDisplay ->cfgR ().rendererCompatSmoothing ) {
194- CHKERR (glVertexPointer (3 , GL_FLOAT , 0 , nullptr ));
195- } else
196- #endif
197- {
198- CHKERR (glVertexAttribPointer (0 , 3 , GL_FLOAT , GL_FALSE , 0 , nullptr ));
199- glEnableVertexAttribArray (0 );
200- }
172+ CHKERR (glVertexAttribPointer (0 , 3 , GL_FLOAT , GL_FALSE , 0 , nullptr ));
173+ glEnableVertexAttribArray (0 );
201174 }
202175
203- const uint32_t smoothProgram = tt == POINTS ? (mUseSmoothPointShader ? mShaderProgramSmoothPoint : 0 ) : (mUseSmoothLineShader ? mShaderProgramSmoothLine : 0 );
176+ const uint32_t smoothProgram = tt == POINTS ? (mDisplay -> cfgL (). smoothPoints ? mShaderProgramSmoothPoint : 0 ) : (mDisplay -> cfgL (). smoothLines ? mShaderProgramSmoothLine : 0 );
204177 if (smoothProgram) {
205178 CHKERR (glUseProgram (smoothProgram));
206179 }
@@ -222,19 +195,12 @@ uint32_t GPUDisplayBackendOpenGL::drawVertices(const vboList& v, const drawType
222195
223196void GPUDisplayBackendOpenGL::ActivateColor (std::array<float , 4 >& color)
224197{
225- #ifndef GPUCA_DISPLAY_OPENGL_CORE
226- if (mDisplay ->cfgR ().rendererCompatSmoothing ) {
227- glColor4f (color[0 ], color[1 ], color[2 ], color[3 ]);
228- } else
229- #endif
230- {
231- CHKERR (glUniform4fv (UNIFORM_LOCATION_COLOR , 1 , &color[0 ]));
232- if (mUseSmoothPointShader ) {
233- CHKERR (glProgramUniform4fv (mShaderProgramSmoothPoint , UNIFORM_LOCATION_COLOR , 1 , &color[0 ]));
234- }
235- if (mUseSmoothLineShader ) {
236- CHKERR (glProgramUniform4fv (mShaderProgramSmoothLine , UNIFORM_LOCATION_COLOR , 1 , &color[0 ]));
237- }
198+ CHKERR (glUniform4fv (UNIFORM_LOCATION_COLOR , 1 , &color[0 ]));
199+ if (mDisplay ->cfgL ().smoothPoints ) {
200+ CHKERR (glProgramUniform4fv (mShaderProgramSmoothPoint , UNIFORM_LOCATION_COLOR , 1 , &color[0 ]));
201+ }
202+ if (mDisplay ->cfgL ().smoothLines ) {
203+ CHKERR (glProgramUniform4fv (mShaderProgramSmoothLine , UNIFORM_LOCATION_COLOR , 1 , &color[0 ]));
238204 }
239205}
240206
@@ -325,9 +291,6 @@ int32_t GPUDisplayBackendOpenGL::InitBackendA()
325291 CHKERR (glBindBuffer (GL_ARRAY_BUFFER , mVBOId [0 ]));
326292 CHKERR (glGenBuffers (1 , &mIndirectId ));
327293 CHKERR (glBindBuffer (GL_DRAW_INDIRECT_BUFFER , mIndirectId ));
328- #ifndef GPUCA_DISPLAY_OPENGL_CORE
329- CHKERR (glShadeModel (GL_SMOOTH )); // Enable Smooth Shading
330- #endif
331294 setDepthBuffer ();
332295 setQuality ();
333296 CHKERR (mVertexShader = loadShader (GL_VERTEX_SHADER , _binary_opengl_vertex_vert_spv_start, _binary_opengl_vertex_vert_spv_len));
@@ -493,77 +456,34 @@ bool GPUDisplayBackendOpenGL::prepareDraw(const hmm_mat4& proj, const hmm_mat4&
493456 setFrameBuffer (0 );
494457 }
495458 clearScreen ();
496- mUseSmoothPointShader = mDisplay ->cfgL ().smoothPoints && !mDisplay ->cfgR ().rendererCompatSmoothing ; // The compat profile uses GL_POINT_SMOOTH / GL_LINE_SMOOTH
497- mUseSmoothLineShader = mDisplay ->cfgL ().smoothLines && !mDisplay ->cfgR ().rendererCompatSmoothing ;
498- #ifndef GPUCA_DISPLAY_OPENGL_CORE
499- if (mUseSmoothPointShader ) { // Compatibility context: gl_PointCoord is only defined with point sprites
500- CHKERR (glEnable (GL_POINT_SPRITE ));
501- } else {
502- CHKERR (glDisable (GL_POINT_SPRITE ));
503- }
504- if (mDisplay ->cfgL ().smoothPoints && mDisplay ->cfgR ().rendererCompatSmoothing ) {
505- CHKERR (glEnable (GL_POINT_SMOOTH ));
506- } else {
507- CHKERR (glDisable (GL_POINT_SMOOTH ));
508- }
509- if (mDisplay ->cfgL ().smoothLines && mDisplay ->cfgR ().rendererCompatSmoothing ) {
510- CHKERR (glEnable (GL_LINE_SMOOTH ));
511- } else {
512- CHKERR (glDisable (GL_LINE_SMOOTH ));
513- }
514- #endif
515459 CHKERR (glEnable (GL_BLEND ));
516460 CHKERR (glBlendFunc (GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA ));
517461
518462 glViewport (0 , 0 , mRenderWidth , mRenderHeight );
519- #ifndef GPUCA_DISPLAY_OPENGL_CORE
520- if (mDisplay ->cfgR ().rendererCompatSmoothing ) {
521- CHKERR (glEnableClientState (GL_VERTEX_ARRAY ));
522- CHKERR (glVertexPointer (3 , GL_FLOAT , 0 , nullptr ));
523- } else
524- #endif
525- {
526- CHKERR (glBindVertexArray (mVertexArray ));
527- CHKERR (glUseProgram (mShaderProgram ));
528- CHKERR (glVertexAttribPointer (0 , 3 , GL_FLOAT , GL_FALSE , 0 , nullptr ));
529- CHKERR (glEnableVertexAttribArray (0 ));
530- }
531- #ifndef GPUCA_DISPLAY_OPENGL_CORE
532- if (mDisplay ->cfgR ().rendererCompatSmoothing ) {
533- CHKERR (glMatrixMode (GL_PROJECTION ));
534- CHKERR (glLoadMatrixf (&proj.Elements [0 ][0 ]));
535- CHKERR (glMatrixMode (GL_MODELVIEW ));
536- CHKERR (glLoadMatrixf (&view.Elements [0 ][0 ]));
537- } else
538- #endif
539- {
540- const hmm_mat4 modelViewProj = proj * view;
541- CHKERR (glUniformMatrix4fv (UNIFORM_LOCATION_MATRIX , 1 , GL_FALSE , &modelViewProj.Elements [0 ][0 ]));
542- if (mUseSmoothPointShader ) {
543- CHKERR (glProgramUniformMatrix4fv (mShaderProgramSmoothPoint , UNIFORM_LOCATION_MATRIX , 1 , GL_FALSE , &modelViewProj.Elements [0 ][0 ]));
544- }
545- if (mUseSmoothLineShader ) {
546- CHKERR (glProgramUniformMatrix4fv (mShaderProgramSmoothLine , UNIFORM_LOCATION_MATRIX , 1 , GL_FALSE , &modelViewProj.Elements [0 ][0 ]));
547- CHKERR (glProgramUniform2f (mShaderProgramSmoothLine , UNIFORM_LOCATION_VIEWPORT , mRenderWidth , mRenderHeight ));
548- }
549- if (mMagneticFieldVisualization ) {
550- CHKERR (glNamedBufferSubData (mFieldModelViewBuffer , 0 , sizeof (modelViewProj), &modelViewProj));
551- }
463+ CHKERR (glBindVertexArray (mVertexArray ));
464+ CHKERR (glUseProgram (mShaderProgram ));
465+ CHKERR (glVertexAttribPointer (0 , 3 , GL_FLOAT , GL_FALSE , 0 , nullptr ));
466+ CHKERR (glEnableVertexAttribArray (0 ));
467+
468+ const hmm_mat4 modelViewProj = proj * view;
469+ CHKERR (glUniformMatrix4fv (UNIFORM_LOCATION_MATRIX , 1 , GL_FALSE , &modelViewProj.Elements [0 ][0 ]));
470+ if (mDisplay ->cfgL ().smoothPoints ) {
471+ CHKERR (glProgramUniformMatrix4fv (mShaderProgramSmoothPoint , UNIFORM_LOCATION_MATRIX , 1 , GL_FALSE , &modelViewProj.Elements [0 ][0 ]));
472+ }
473+ if (mDisplay ->cfgL ().smoothLines ) {
474+ CHKERR (glProgramUniformMatrix4fv (mShaderProgramSmoothLine , UNIFORM_LOCATION_MATRIX , 1 , GL_FALSE , &modelViewProj.Elements [0 ][0 ]));
475+ CHKERR (glProgramUniform2f (mShaderProgramSmoothLine , UNIFORM_LOCATION_VIEWPORT , mRenderWidth , mRenderHeight ));
476+ }
477+ if (mMagneticFieldVisualization ) {
478+ CHKERR (glNamedBufferSubData (mFieldModelViewBuffer , 0 , sizeof (modelViewProj), &modelViewProj));
552479 }
553480 return true ;
554481}
555482
556483void GPUDisplayBackendOpenGL::finishDraw (bool doScreenshot, bool toMixBuffer, float includeMixImage)
557484{
558- #ifndef GPUCA_DISPLAY_OPENGL_CORE
559- if (mDisplay ->cfgR ().rendererCompatSmoothing ) {
560- CHKERR (glDisableClientState (GL_VERTEX_ARRAY ));
561- } else
562- #endif
563- {
564- CHKERR (glBindVertexArray (0 ));
565- CHKERR (glUseProgram (0 ));
566- }
485+ CHKERR (glBindVertexArray (0 ));
486+ CHKERR (glUseProgram (0 ));
567487
568488 if (mOffscreenBufferMSAA .created ) {
569489 uint32_t dstId = toMixBuffer ? mMixBuffer .fb_id : (mDownsampleFactor != 1 ? mOffscreenBuffer .fb_id : 0 );
@@ -616,15 +536,7 @@ void GPUDisplayBackendOpenGL::prepareText()
616536 setFrameBuffer (0 );
617537 glViewport (0 , 0 , mScreenWidth , mScreenHeight );
618538 hmm_mat4 proj = HMM_Orthographic (0 .f , mScreenWidth , 0 .f , mScreenHeight , -1 , 1 );
619- if (mDisplay ->drawTextInCompatMode ()) {
620- #ifndef GPUCA_DISPLAY_OPENGL_CORE
621- glMatrixMode (GL_MODELVIEW );
622- glLoadIdentity ();
623- glMatrixMode (GL_PROJECTION );
624- glLoadMatrixf (&proj.Elements [0 ][0 ]);
625- glViewport (0 , 0 , mScreenWidth , mScreenHeight );
626- #endif
627- } else if (mFreetypeInitialized ) {
539+ if (mFreetypeInitialized ) {
628540 CHKERR (glUseProgram (mShaderProgramText ));
629541 CHKERR (glActiveTexture (GL_TEXTURE0 ));
630542 CHKERR (glBindVertexArray (VAO_text));
@@ -636,7 +548,7 @@ void GPUDisplayBackendOpenGL::prepareText()
636548
637549void GPUDisplayBackendOpenGL::finishText ()
638550{
639- if (! mDisplay -> drawTextInCompatMode () && mFreetypeInitialized ) {
551+ if (mFreetypeInitialized ) {
640552 CHKERR (glBindVertexArray (0 ));
641553 CHKERR (glBindTexture (GL_TEXTURE_2D , 0 ));
642554 CHKERR (glUseProgram (0 ));
@@ -666,55 +578,25 @@ void GPUDisplayBackendOpenGL::mixImages(float mixSlaveImage)
666578{
667579 hmm_mat4 proj = HMM_Orthographic (0 .f , mRenderWidth , 0 .f , mRenderHeight , -1 .f , 1 .f );
668580 glDisable (GL_DEPTH_TEST );
669- #ifndef GPUCA_DISPLAY_OPENGL_CORE
670- if (mDisplay ->cfgR ().rendererCompatSmoothing ) {
671- glMatrixMode (GL_MODELVIEW );
672- glLoadIdentity ();
673- glMatrixMode (GL_PROJECTION );
674- glLoadMatrixf (&proj.Elements [0 ][0 ]);
675- CHKERR (glEnable (GL_TEXTURE_2D ));
676- } else
677- #endif
678- {
679- CHKERR (glUseProgram (mShaderProgramTexture ));
680- CHKERR (glActiveTexture (GL_TEXTURE0 ));
681- CHKERR (glBindVertexArray (VAO_texture));
682- CHKERR (glUniformMatrix4fv (UNIFORM_LOCATION_MATRIX , 1 , GL_FALSE , &proj.Elements [0 ][0 ]));
683- CHKERR (glUniform1f (UNIFORM_LOCATION_COLOR , mixSlaveImage));
684- }
581+ CHKERR (glUseProgram (mShaderProgramTexture ));
582+ CHKERR (glActiveTexture (GL_TEXTURE0 ));
583+ CHKERR (glBindVertexArray (VAO_texture));
584+ CHKERR (glUniformMatrix4fv (UNIFORM_LOCATION_MATRIX , 1 , GL_FALSE , &proj.Elements [0 ][0 ]));
585+ CHKERR (glUniform1f (UNIFORM_LOCATION_COLOR , mixSlaveImage));
685586
686587 CHKERR (glBindTexture (GL_TEXTURE_2D , mMixBuffer .fbCol_id ));
687588
688- #ifndef GPUCA_DISPLAY_OPENGL_CORE
689- if (mDisplay ->cfgR ().rendererCompatSmoothing ) {
690- glColor4f (1 , 1 , 1 , mixSlaveImage);
691- glBegin (GL_QUADS );
692- glTexCoord2f (0 , 0 );
693- glVertex3f (0 , 0 , 0 );
694- glTexCoord2f (0 , 1 );
695- glVertex3f (0 , mRenderHeight , 0 );
696- glTexCoord2f (1 , 1 );
697- glVertex3f (mRenderWidth , mRenderHeight , 0 );
698- glTexCoord2f (1 , 0 );
699- glVertex3f (mRenderWidth , 0 , 0 );
700- glEnd ();
701- glColor4f (1 , 1 , 1 , 0 );
702- CHKERR (glDisable (GL_TEXTURE_2D ));
703- } else
704- #endif
705- {
706- CHKERR (glDrawArrays (GL_TRIANGLES , 0 , 6 ));
707- CHKERR (glBindVertexArray (0 ));
708- CHKERR (glUseProgram (0 ));
709- }
589+ CHKERR (glDrawArrays (GL_TRIANGLES , 0 , 6 ));
590+ CHKERR (glBindVertexArray (0 ));
591+ CHKERR (glUseProgram (0 ));
710592 CHKERR (glBindTexture (GL_TEXTURE_2D , 0 ));
711593 setDepthBuffer ();
712594}
713595
714596void GPUDisplayBackendOpenGL::pointSizeFactor (float factor)
715597{
716- const float size = mDisplay ->cfgL ().pointSize * mDownsampleFactor * factor + (mUseSmoothPointShader ? SMOOTH_POINT_EXTRA_SIZE : 0 .f );
717- if (mUseSmoothPointShader ) {
598+ const float size = mDisplay ->cfgL ().pointSize * mDownsampleFactor * factor + (mDisplay -> cfgL (). smoothPoints ? SMOOTH_POINT_EXTRA_SIZE : 0 .f );
599+ if (mDisplay -> cfgL (). smoothPoints ) {
718600 CHKERR (glProgramUniform1f (mShaderProgramSmoothPoint , UNIFORM_LOCATION_POINT_SIZE , size));
719601 }
720602 CHKERR (glPointSize (size));
@@ -723,7 +605,7 @@ void GPUDisplayBackendOpenGL::pointSizeFactor(float factor)
723605void GPUDisplayBackendOpenGL::lineWidthFactor (float factor)
724606{
725607 float width = mDisplay ->cfgL ().lineWidth * mDownsampleFactor * factor;
726- if (mUseSmoothLineShader ) {
608+ if (mDisplay -> cfgL (). smoothLines ) {
727609 width += SMOOTH_LINE_EXTRA_WIDTH ;
728610 CHKERR (glProgramUniform1f (mShaderProgramSmoothLine , UNIFORM_LOCATION_LINE_WIDTH , width));
729611 width *= 1 .4143f ; // Wide lines are parallelograms in OpenGL, widen so that the perpendicular width is covered
@@ -788,7 +670,7 @@ void GPUDisplayBackendOpenGL::initializeTextDrawing()
788670
789671void GPUDisplayBackendOpenGL::OpenGLPrint (const char * s, float x, float y, float * color, float scale)
790672{
791- if (!mFreetypeInitialized || mDisplay -> drawTextInCompatMode () ) {
673+ if (!mFreetypeInitialized ) {
792674 return ;
793675 }
794676 CHKERR (glUniform4fv (UNIFORM_LOCATION_COLOR , 1 , color));
0 commit comments