5
5
from OpenGL .GLU import *
6
6
from random import Random
7
7
import time
8
+ import argparse
8
9
9
10
TARGET_FPS = 30
10
11
@@ -54,6 +55,11 @@ def Cube():
54
55
glEnd ()
55
56
56
57
58
+ parser = argparse .ArgumentParser ()
59
+ parser .add_argument ('--use-send-fbo' , dest = 'useSendFbo' ,
60
+ action = 'store_true' )
61
+ args = parser .parse_args ()
62
+
57
63
pygame .init ()
58
64
pygame .display .set_caption ('Texture Sender Example' )
59
65
pygame .display .set_mode ((DISPLAY_WIDTH , DISPLAY_HEIGHT ),
@@ -70,8 +76,8 @@ def Cube():
70
76
SEND_WIDTH , SEND_HEIGHT , 0 )
71
77
72
78
# Create framebuffer and attach texture
73
- fbo = glGenFramebuffers (1 )
74
- glBindFramebuffer (GL_FRAMEBUFFER , fbo )
79
+ fboID = glGenFramebuffers (1 )
80
+ glBindFramebuffer (GL_FRAMEBUFFER , fboID )
75
81
glFramebufferTexture2D (
76
82
GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , sendTextureID , 0 )
77
83
@@ -99,11 +105,16 @@ def Cube():
99
105
100
106
# Copy on-screen framebuffer to our fbo
101
107
glBlitNamedFramebuffer (
102
- 0 , fbo , 0 , 0 , DISPLAY_WIDTH , DISPLAY_HEIGHT , 0 , 0 , SEND_WIDTH , SEND_HEIGHT , GL_COLOR_BUFFER_BIT , GL_NEAREST )
108
+ 0 , fboID , 0 , 0 , DISPLAY_WIDTH , DISPLAY_HEIGHT , 0 , 0 , SEND_WIDTH , SEND_HEIGHT , GL_COLOR_BUFFER_BIT , GL_NEAREST )
103
109
104
110
# Send the texture
105
- result = sender .sendTexture (
106
- sendTextureID , GL_TEXTURE_2D , SEND_WIDTH , SEND_HEIGHT , True , 0 )
111
+ if args .useSendFbo :
112
+ glBindFramebuffer (GL_FRAMEBUFFER , fboID )
113
+ result = sender .sendFbo (fboID , SEND_WIDTH , SEND_HEIGHT , True )
114
+ glBindFramebuffer (GL_FRAMEBUFFER , 0 )
115
+ else :
116
+ result = sender .sendTexture (
117
+ sendTextureID , GL_TEXTURE_2D , SEND_WIDTH , SEND_HEIGHT , True , 0 )
107
118
108
119
# Indicate that a frame is ready to read
109
120
sender .setFrameSync (SENDER_NAME )
0 commit comments