Skip to content

Commit 1936dc1

Browse files
committed
Add error handling to glReadPixels
1 parent 1d83b0d commit 1936dc1

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

bin/capture-b/Capture.pb

+7-17
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ ProcedureDLL Capture(*capRect.RECT, x.l, y.l, sx.l, sy.l)
132132
ProcedureReturn #False
133133
EndIf
134134

135-
;Protected *pixelBuf = AllocateMemory(3 * width * height)
136-
137135
hDC = StartDrawing(ImageOutput(imageID))
138136
If Not hDC
139137
FreeImage(imageID)
@@ -142,19 +140,11 @@ ProcedureDLL Capture(*capRect.RECT, x.l, y.l, sx.l, sy.l)
142140

143141
*pixelBuffer = DrawingBuffer()
144142
glReadPixels_(*capRect\left, *capRect\top, capWidth, capHeight, #GL_BGR_EXT, #GL_UNSIGNED_BYTE, *pixelBuffer)
145-
146-
; For y = 0 To *capRect\height - 1
147-
; *Line.Pixel = Buffer + Pitch * y
148-
;
149-
; For x = 0 To *capRect\width - 1
150-
;
151-
; *Line\Pixel = ColorTable(pos2) ; Write the pixel directly to the memory !
152-
; *Line+Offset
153-
;
154-
; ; You can try with regular plot to see the speed difference
155-
; ; Plot(x, y, ColorTable(pos2))
156-
; Next
157-
; Next
143+
If glGetError_() <> #GL_NO_ERROR
144+
StopDrawing()
145+
FreeImage(imageID)
146+
ProcedureReturn #False
147+
EndIf
158148

159149
StopDrawing()
160150

@@ -188,8 +178,8 @@ EndProcedure
188178

189179
; IDE Options = PureBasic 6.04 LTS (Windows - x64)
190180
; ExecutableFormat = Shared dll
191-
; CursorPosition = 116
192-
; FirstLine = 99
181+
; CursorPosition = 99
182+
; FirstLine = 72
193183
; Folding = -
194184
; Optimizer
195185
; EnableThread

bin/capture-b/capture.dll

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)