Skip to content

Commit

Permalink
Add error handling to glReadPixels
Browse files Browse the repository at this point in the history
  • Loading branch information
Dadido3 committed Apr 11, 2024
1 parent 1d83b0d commit 1936dc1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions bin/capture-b/Capture.pb
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ ProcedureDLL Capture(*capRect.RECT, x.l, y.l, sx.l, sy.l)
ProcedureReturn #False
EndIf

;Protected *pixelBuf = AllocateMemory(3 * width * height)

hDC = StartDrawing(ImageOutput(imageID))
If Not hDC
FreeImage(imageID)
Expand All @@ -142,19 +140,11 @@ ProcedureDLL Capture(*capRect.RECT, x.l, y.l, sx.l, sy.l)

*pixelBuffer = DrawingBuffer()
glReadPixels_(*capRect\left, *capRect\top, capWidth, capHeight, #GL_BGR_EXT, #GL_UNSIGNED_BYTE, *pixelBuffer)

; For y = 0 To *capRect\height - 1
; *Line.Pixel = Buffer + Pitch * y
;
; For x = 0 To *capRect\width - 1
;
; *Line\Pixel = ColorTable(pos2) ; Write the pixel directly to the memory !
; *Line+Offset
;
; ; You can try with regular plot to see the speed difference
; ; Plot(x, y, ColorTable(pos2))
; Next
; Next
If glGetError_() <> #GL_NO_ERROR
StopDrawing()
FreeImage(imageID)
ProcedureReturn #False
EndIf

StopDrawing()

Expand Down Expand Up @@ -188,8 +178,8 @@ EndProcedure

; IDE Options = PureBasic 6.04 LTS (Windows - x64)
; ExecutableFormat = Shared dll
; CursorPosition = 116
; FirstLine = 99
; CursorPosition = 99
; FirstLine = 72
; Folding = -
; Optimizer
; EnableThread
Expand Down
Binary file modified bin/capture-b/capture.dll
Binary file not shown.

0 comments on commit 1936dc1

Please sign in to comment.