Commit graph

3001 commits

Author SHA1 Message Date
Sam Lantinga
b7844cd95f Mason Wheeler to sdl
I updated SDL, and suddenly my SDL frames stopped working.  They'd "initialize" full of gibberish, and I couldn't render anything to them.  After a bit of digging, I found a problem: the renderer initialization routine in my SDL frame code wasn't getting called anymore.

procedure TSdlFrame.Paint;
begin
   if SDL_SelectRenderer(FWindowID) = -1 then
      CreateRenderer;
   SDL_RenderPresent;
end;

function TSdlFrame.CreateRenderer: boolean;
const
   pf: tagPIXELFORMATDESCRIPTOR = (nSize: sizeof(pf); nVersion: 1;
       dwFlags: PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER;
       iPixelType: PFD_TYPE_RGBA; cColorBits: 24; cAlphaBits: 8;
       iLayerType: PFD_MAIN_PLANE);

   RENDERERS: array[TRendererType] of AnsiString = ('software', 'gdi', 'opengl', 'd3d');
var
  pFormat: integer;
begin
   if (SDL_SelectRenderer(FWindowID) = 0) then
   begin
      result := true;
      Exit;
   end;
   if FRendererType = rtOpenGL then
   begin
      pFormat := ChoosePixelFormat(canvas.Handle, @pf);
      if not SetPixelFormat(canvas.Handle, pFormat, @pf) then
         outputDebugString(PChar(SysErrorMessage(GetLastError)));
      if wglCreateContext(canvas.Handle) = 0 then
         outputDebugString(PChar(SysErrorMessage(GetLastError)));
   end;
   if (SDL_CreateRenderer(FWindowID, SDL_RendererIndex(RENDERERS[FRendererType]), [sdlrPresentFlip3, sdlrAccelerated]) = 0) then
   begin
      SDL_ShowWindow(FWindowID);
      assert(SDL_SetRenderDrawColor(0, 0, 0, 255) = 0);
      FFlags := SDL_GetWindowFlags(FWindowID);
      if assigned(FOnAvailable) then
         FOnAvailable(self);
   end
   else outputDebugString(pChar(format('SDL_CreateRenderer failed: %s', [sdl_GetError])));
   result := SDL_SelectRenderer(FWindowID) = 0;
end;

This is a critical issue.  The Paint method gets called when the control receives a WM_PAINT message from Windows.  I can't create the renderer before then, or it will fail and cause trouble.  And when I do create it, it needs to be created with certain parameters.  So imagine my surprise when I started debugging into the DLL and found that SDL_SelectRenderer was trying to be "helpful" by creating the renderer for me if it didn't already exist!  Now not only does my initialization code not get called, I end up with the wrong renderer and so things don't render as expected when I try to use the window.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404226
2009-11-24 04:48:12 +00:00
Sam Lantinga
45a366faf7 Set the error so someone can get more information
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404225
2009-11-22 20:53:53 +00:00
Sam Lantinga
263c9febad Made the comment actually mean something. :)
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404224
2009-11-22 20:00:00 +00:00
Sam Lantinga
224c8b5bec More fixes to compile under Visual C++
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404223
2009-11-22 07:00:26 +00:00
Sam Lantinga
ccfc72055c Fixed include paths for Visual C++
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404222
2009-11-22 06:42:58 +00:00
Sam Lantinga
7b31c3e830 The Direct3D Read/Write pixels interface is in progress.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404221
2009-11-22 06:37:43 +00:00
Sam Lantinga
636dc1e63e Whoops, actually set the SDL error, don't just print the error.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404220
2009-11-22 06:34:45 +00:00
Mike Gorchak
21ee95a08f Added support for QNX default font. Backspace and Return keys now handled.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404219
2009-11-21 08:42:42 +00:00
Sam Lantinga
02d897e864 We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404218
2009-11-21 07:59:19 +00:00
Sam Lantinga
e957ccc22a Increased tolerance a little bit more for multiple blending passes accumulating error.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404217
2009-11-21 07:46:12 +00:00
Sam Lantinga
e70cbce904 Added comment for pixel-perfect line workaround.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404216
2009-11-21 07:26:52 +00:00
Sam Lantinga
21fb49df82 Of COURSE that trick wouldn't work on all renderers. Fall back to something for now, hopefully figure out a better way to do this later.
If we have to, we can use vertical line and horizontal line textures for vertical and horizontal lines, and then create custom textures for diagonal lines and software render those.  It's terrible, but at least it would be pixel perfect.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404215
2009-11-21 07:22:59 +00:00
Sam Lantinga
0c8bb39322 This is terrible, but the OpenGL standard says that lines are half open, which means that one endpoint is not covered so adjoining lines don't overlap. It also doesn't define which end is open, and indeed Mac OS X and Linux differ. Mac OS X seems to leave the second endpoint open, but Linux uses the right-most endpoint for x major lines and the bottom-most endpoint for y major lines.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404214
2009-11-21 07:14:21 +00:00
Sam Lantinga
b10df318c7 Fixed the coordinates for pixel coverage in blits
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404213
2009-11-21 06:34:43 +00:00
Sam Lantinga
e3bfc7307d Use 45 degree lines for the diagonal test to avoid aliasing errors in line drawing.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404212
2009-11-21 06:28:25 +00:00
Sam Lantinga
3110c4d9fb It's not the last pixel, it's the rightmost pixel, or if they're both the same x coordinate, the bottommost pixel.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404211
2009-11-21 06:19:34 +00:00
Mike Gorchak
153a88e1ef RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404210
2009-11-21 06:17:50 +00:00
Sam Lantinga
335b459777 My first OpenGL shader! Momma will be so proud!
This shader implements the software renderer mask semantics where the source pixel is multiplied by the color and alpha modulation values and then any pixel with non-zero alpha is fully opaque.

The OpenGL renderer on Mac OS X now passes all the automated render tests! :)

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404209
2009-11-21 05:29:31 +00:00
Sam Lantinga
22c1e66180 pixels don't need to be dynamically allocated
Added a dump_screen() function to assist with test failure diagnosis

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404208
2009-11-21 05:25:08 +00:00
Sam Lantinga
fc3f393af6 SDL_RenderReadPixels() needs to flush asynchronous operations before it reads.
The semantics are that it reads the back buffer, and those pixels may not be available once SDL_RenderPresent() has happened.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404207
2009-11-21 05:05:19 +00:00
Mike Gorchak
474b543c63 Support for UTF-8 text input has been added.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404206
2009-11-20 14:42:40 +00:00
Mike Gorchak
cb70cb42eb 1. SDL_RenderPresent() call has been added after each test to be sure, that all graphics output is flushed in case if it was asynchronous.
2. After each renderer test window recreation has been added.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404205
2009-11-20 07:11:29 +00:00
Mike Gorchak
4fd1d48088 Output last SDL error in case of test was failed.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404204
2009-11-20 07:08:28 +00:00
Mike Gorchak
3038604a81 RenderReadPixels and RenderWritePixels now work properly.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404203
2009-11-20 07:07:41 +00:00
Mike Gorchak
6e0c12e7f7 Deinitialization fixes, in case if QNXGF driver is not initialized properly.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404202
2009-11-20 07:06:50 +00:00
Mike Gorchak
413e9a6218 Added support for generic getopt() function instead of getopt_long(). Because not all platforms have getopt_long().
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404201
2009-11-19 09:07:09 +00:00
Mike Gorchak
93f91c687b Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404200
2009-11-19 08:44:07 +00:00
Sam Lantinga
0c1f40faf7 Mike Gorchak to Sam
Hello Sam!

You have reverted back my patches for OpenGL renderer :)

To reproduce an issue, compare graphics output while running these tests:

testdraw2 --renderer opengl --blend mask --cyclealpha
and
testdraw2 --renderer software --blend mask --cyclealpha

You will see, that software renderer output is different from opengl renderer output.

Thanks!

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404199
2009-11-19 08:02:00 +00:00
Sam Lantinga
0f770140c0 Found a way to implement mask semantics in OpenGL
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404198
2009-11-19 05:33:41 +00:00
Sam Lantinga
92f130691a Allow some variation in the pixel values to account for blending accuracy differences.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404197
2009-11-19 05:06:01 +00:00
Sam Lantinga
556c82f866 Include the endpoint in the line we're drawing
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404196
2009-11-19 04:59:19 +00:00
Sam Lantinga
78855cf981 Adjust the vertices to be over the texel center.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404195
2009-11-19 04:33:35 +00:00
Sam Lantinga
ffed135358 Fixed a bunch of bugs in the blit blend mode tests
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404194
2009-11-18 09:39:32 +00:00
Sam Lantinga
ae9dabec32 Use SDL's string and memory functions instead of stdlib
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404193
2009-11-18 09:28:35 +00:00
Sam Lantinga
a6bfcda464 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
This is helpful to validate the automated test suite, since this renderer is super simple and should always pass tests.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404192
2009-11-18 09:20:01 +00:00
Sam Lantinga
6e102beb88 Don't add the OpenGL renderers for drivers that don't support OpenGL
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404191
2009-11-18 09:17:29 +00:00
Sam Lantinga
50cac453d4 Fixes for the automated rendering test
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404190
2009-11-18 09:07:13 +00:00
Sam Lantinga
9e98b7ad9e If we explicitly request a driver, try to initialize it.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404189
2009-11-18 08:54:13 +00:00
Sam Lantinga
a192c6e6bc Fixed GL_RenderReadPixels() - thanks Ryan!
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404188
2009-11-18 08:07:37 +00:00
Sam Lantinga
2d9880b962 First pass (untested) at RenderWritePixels()
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404187
2009-11-18 07:35:00 +00:00
Sam Lantinga
7f4f3792ce Refactored to use render_loadTestFace()
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404186
2009-11-18 07:34:05 +00:00
Sam Lantinga
86dbbd0dd3 Fixed endianness of the face image surface
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404185
2009-11-18 07:22:22 +00:00
Sam Lantinga
87442cb483 Trying to figure out why the OpenGL tests are failing...
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404184
2009-11-18 06:15:44 +00:00
Sam Lantinga
200856fb2b Compare against the correct image
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404183
2009-11-18 06:15:21 +00:00
Sam Lantinga
508336f894 Debug info to help track down render test failures
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404182
2009-11-17 06:51:14 +00:00
Sam Lantinga
a3226cf7d3 Added missing return values
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404181
2009-11-17 06:50:29 +00:00
Sam Lantinga
c635254fa1 Fixed some bugs in the automated test suite, revealed by working SDL_RenderReadPixels()
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404180
2009-11-17 05:17:11 +00:00
Sam Lantinga
82d400ccd4 Scott to slouken
Heres the wiz patch and additional files. (I think I got everything)

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404177
2009-11-17 04:53:15 +00:00
Sam Lantinga
f62ed3cb3f Thank you automated tests (and bobbens!), fixed alpha blending for accuracy
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404176
2009-11-16 09:47:34 +00:00
Sam Lantinga
209448b796 Fixed memory corruption in SW_RenderReadPixels()
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404175
2009-11-16 07:39:08 +00:00