Bookstore

Recent

Author Topic: Using SDL+OpenGL - White pixels in the corners of the window?  (Read 1650 times)

ZXDunny

  • New member
  • *
  • Posts: 7
Hi all - Little help?

I've been messing around porting a windows app to OSX - I've got it building in Linux for ARM and x86 without issues, replacing the only visual component with an SDL surface (the entire thing runs in one surface only for output).

Using SDL for OSX firstly gets the colours backwards (ugh) and also is limited to 30fps. Having looked around, I have implemented OpenGL for the display by using a texture as the surface instead of the SDL surface - but I'm still using SDL to open the main window. Now the colours are correct, and the speed is lovely.

But! I'm getting white pixels in the bottom corners (Sorry for the huge image!):

http://s27.postimg.org/7y5nwut35/Screen_Shot_2016_03_30_at_16_18_17.png

Here's the code to open the window:

Code: [Select]
  If FullScreen Then Begin

    Screen := SDL_SetVideoMode(Width, Height, 32, SDL_FULLSCREEN or SDL_HWSURFACE{$IFDEF OPENGL} or SDL_OPENGL{$ENDIF});
    SPFULLSCREEN := True;
    Result := Screen <> nil;

  end Else Begin

    Screen := SDL_SetVideoMode(Width, Height, 32, SDL_HWSURFACE {$IFDEF OPENGL}or SDL_OPENGL{$ENDIF});
    SPFULLSCREEN := False;
    Result := Screen <> nil;

  end;

  FinalisePalette;

  {$IFDEF OPENGL}
  DISPLAYSTRIDE := Width * 4;
  SetLength(PixArray, Width * Height * 4);
  DISPLAYPOINTER := @PixArray[0];

  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  glClearColor(0, 0, 0, 0);
  glClearDepth(1);

  glViewPort(0, 0, Width, Height);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity;

  glOrtho(0, Width, Height, 0, 1, -1);

  glMatrixMode(GL_MODELVIEW);
  glEnable(GL_TEXTURE_2D);
  glLoadIdentity;

  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, DISPLAYPOINTER);
  glTexParameterI(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  glTexParameterI(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glEnable(GL_TEXTURE_2D);
  {$ELSE}
  DISPLAYSTRIDE := Screen^.Pitch;
  DISPLAYPOINTER := Screen^.Pixels;
  {$ENDIF}

PixArray[] is just an array the size of the screen in longwords to hold the surface data which is then used to build an OpenGL texture.

If I don't use OpenGL and just use a regular SDL window, I don't get the white corners. With OpenGL I do.

Anyone know how to prevent or fix it?

Many thanks,

Paul.