Skip to content

Commit

Permalink
Screen: Fix PsychNormalizeTextureOrientation() for multi-window use.
Browse files Browse the repository at this point in the history
Use of multiple onscreen windows could cause the wrong OpenGL context
of the wrong onscreen window to be in use during operation. Fix this.
  • Loading branch information
kleinerm committed Nov 15, 2024
1 parent 6df6cb3 commit 57b98c4
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3196,11 +3196,15 @@ void PsychNormalizeTextureOrientation(PsychWindowRecordType *sourceRecord)
// step to transform the texture into normalized orientation. Non-planar textures would also
// wreak havoc if not converted into standard pixel-interleaved format:
if (sourceRecord->textureOrientation != 2 || isplanar) {
if (PsychPrefStateGet_Verbosity()>5) printf("PTB-DEBUG: In PsychNormalizeTextureOrientation(): Performing GPU renderswap or format conversion for source gl-texture %i --> ", sourceRecord->textureNumber);
if (PsychPrefStateGet_Verbosity()>5) printf("PTB-DEBUG: In PsychNormalizeTextureOrientation(): Performing GPU renderswap or format conversion for source gl-texture %i ...\n", sourceRecord->textureNumber);

// Soft-reset drawing engine in a safe way:
PsychSetDrawingTarget((PsychWindowRecordType*) 0x1);

// The soft reset will have potentially switched to the wrong OpenGL context if multiple
// onscreen windows are in use, which ends badly. Manually switch to the proper context:
PsychSetGLContext(sourceRecord);

// Normalization needed. Create a suitable FBO as rendertarget:
needzbuffer = FALSE;

Expand Down Expand Up @@ -3417,7 +3421,7 @@ void PsychNormalizeTextureOrientation(PsychWindowRecordType *sourceRecord)
sourceRecord->textureOrientation = 2;

// GPU renderswap finished.
if (PsychPrefStateGet_Verbosity()>5) printf("%i.\n", sourceRecord->textureNumber);
if (PsychPrefStateGet_Verbosity()>5) printf("PTB-DEBUG: In PsychNormalizeTextureOrientation(): New coltex %i.\n", sourceRecord->textureNumber);
}

return;
Expand Down

0 comments on commit 57b98c4

Please sign in to comment.