@@ -250,13 +250,22 @@ template<class POINTER, class COUNT>
250
250
inline QWebGLFunctionCall *addHelper (QWebGLFunctionCall *event,
251
251
const QPair<POINTER, COUNT> &elements)
252
252
{
253
- if (event) {
254
- for (auto i = 0 ; i < elements.second ; ++i)
255
- event-> add ( elements.first [i]);
256
- }
253
+ QVariantList list;
254
+ for (auto i = 0 ; i < elements.second ; ++i)
255
+ list. append ( QVariant::fromValue ( elements.first [i]) );
256
+ event-> addList (list);
257
257
return event;
258
258
}
259
259
260
+ template <class SIZE >
261
+ inline void addHelper (QWebGLFunctionCall *event, const QPair<const float *, SIZE> &elements)
262
+ {
263
+ QVariantList list;
264
+ for (auto i = 0 ; i < elements.second ; ++i)
265
+ list.append (QVariant::fromValue<double >(elements.first [i]));
266
+ event->addList (list);
267
+ }
268
+
260
269
template <class T >
261
270
inline QWebGLFunctionCall *addHelper (QWebGLFunctionCall *event, const T &value)
262
271
{
@@ -631,7 +640,7 @@ QWEBGL_FUNCTION(deleteBuffers, void, glDeleteBuffers,
631
640
QWEBGL_FUNCTION (deleteFramebuffers, void , glDeleteFramebuffers,
632
641
(GLsizei) n, (const GLuint *) framebuffers)
633
642
{
634
- postEvent<&deleteFramebuffers>(n, qMakePair (framebuffers, n));
643
+ postEvent<&deleteFramebuffers>(qMakePair (framebuffers, n));
635
644
}
636
645
637
646
QWEBGL_FUNCTION_POSTEVENT (deleteProgram, glDeleteProgram,
@@ -640,7 +649,7 @@ QWEBGL_FUNCTION_POSTEVENT(deleteProgram, glDeleteProgram,
640
649
QWEBGL_FUNCTION (deleteRenderbuffers, void , glDeleteRenderbuffers,
641
650
(GLsizei) n, (const GLuint *) renderbuffers)
642
651
{
643
- postEvent<&deleteRenderbuffers>(n, qMakePair (renderbuffers, n));
652
+ postEvent<&deleteRenderbuffers>(qMakePair (renderbuffers, n));
644
653
}
645
654
646
655
QWEBGL_FUNCTION_POSTEVENT (deleteShader, glDeleteShader,
@@ -649,7 +658,7 @@ QWEBGL_FUNCTION_POSTEVENT(deleteShader, glDeleteShader,
649
658
QWEBGL_FUNCTION (deleteTextures, void , glDeleteTextures,
650
659
(GLsizei) n, (const GLuint *) textures)
651
660
{
652
- postEvent<&deleteTextures>(n, qMakePair (textures, n));
661
+ postEvent<&deleteTextures>(qMakePair (textures, n));
653
662
}
654
663
655
664
QWEBGL_FUNCTION_POSTEVENT (depthFunc, glDepthFunc,
@@ -963,7 +972,7 @@ QWEBGL_FUNCTION(getFramebufferAttachmentParameteriv, void, glGetFramebufferAttac
963
972
QWEBGL_FUNCTION (getProgramInfoLog, void , glGetProgramInfoLog,
964
973
(GLuint) program, (GLsizei) bufSize, (GLsizei *) length, (GLchar *) infoLog)
965
974
{
966
- auto value = postEventAndQuery<&getProgramInfoLog>(QString (), program, bufSize );
975
+ auto value = postEventAndQuery<&getProgramInfoLog>(QString (), program);
967
976
*length = value.length ();
968
977
if (bufSize >= value.length ())
969
978
std::memcpy (infoLog, value.constData (), value.length ());
@@ -984,7 +993,7 @@ QWEBGL_FUNCTION(getRenderbufferParameteriv, void, glGetRenderbufferParameteriv,
984
993
QWEBGL_FUNCTION (getShaderInfoLog, void , glGetShaderInfoLog,
985
994
(GLuint) shader, (GLsizei) bufSize, (GLsizei *) length, (GLchar *) infoLog)
986
995
{
987
- const auto value = postEventAndQuery<&getShaderInfoLog>(QString (), shader, bufSize );
996
+ const auto value = postEventAndQuery<&getShaderInfoLog>(QString (), shader);
988
997
*length = value.length ();
989
998
if (bufSize >= value.length ())
990
999
std::memcpy (infoLog, value.constData (), value.length ());
@@ -1010,7 +1019,7 @@ QWEBGL_FUNCTION(getShaderPrecisionFormat, void, glGetShaderPrecisionFormat,
1010
1019
QWEBGL_FUNCTION (getShaderSource, void , glGetShaderSource,
1011
1020
(GLuint) shader, (GLsizei) bufSize, (GLsizei *) length, (GLchar *) source)
1012
1021
{
1013
- const auto value = postEventAndQuery<&getShaderSource>(QString (), shader, bufSize );
1022
+ const auto value = postEventAndQuery<&getShaderSource>(QString (), shader);
1014
1023
*length = value.length ();
1015
1024
if (bufSize >= value.length ())
1016
1025
std::memcpy (source, value.constData (), value.length ());
@@ -1184,17 +1193,15 @@ QWEBGL_FUNCTION(shaderSource, void, glShaderSource,
1184
1193
(GLuint) shader, (GLsizei) count,
1185
1194
(const GLchar *const *) string, (const GLint *) length)
1186
1195
{
1187
- auto event = currentContext ()->createEvent (QStringLiteral (" glShaderSource" ));
1188
- if (!event)
1189
- return ;
1190
- event->addParameters (shader, count);
1191
- for (int i = 0 ; i < count; ++i) {
1192
- if (!length)
1193
- event->addString (QString::fromLatin1 (string[i]));
1194
- else
1195
- event->addString (QString::fromLatin1 (string[i], length[i]));
1196
- }
1197
- QCoreApplication::postEvent (QWebGLIntegrationPrivate::instance ()->webSocketServer , event);
1196
+ QString fullString;
1197
+ std::function<void (int )> concat;
1198
+ if (length)
1199
+ concat = [&](int i) { fullString.append (QString::fromLatin1 (string[i], length[i])); };
1200
+ else
1201
+ concat = [&](int i) { fullString.append (QString::fromLatin1 (string[i])); };
1202
+ for (int i = 0 ; i < count; ++i)
1203
+ concat (i);
1204
+ postEvent<&shaderSource>(shader, fullString);
1198
1205
}
1199
1206
1200
1207
QWEBGL_FUNCTION_POSTEVENT (stencilFunc, glStencilFunc,
@@ -1273,7 +1280,7 @@ QWEBGL_FUNCTION_POSTEVENT(uniform1f, glUniform1f, (GLint) location, (GLfloat) v0
1273
1280
QWEBGL_FUNCTION (uniform1fv, void , glUniform1fv,
1274
1281
(GLint) location, (GLsizei) count, (const GLfloat *) value)
1275
1282
{
1276
- postEvent<&uniform1fv>(location, count, qMakePair (value, count));
1283
+ postEvent<&uniform1fv>(location, qMakePair (value, count));
1277
1284
}
1278
1285
1279
1286
QWEBGL_FUNCTION_POSTEVENT (uniform1i, glUniform1i,
@@ -1282,7 +1289,7 @@ QWEBGL_FUNCTION_POSTEVENT(uniform1i, glUniform1i,
1282
1289
QWEBGL_FUNCTION (uniform1iv, void , glUniform1iv,
1283
1290
(GLint) location, (GLsizei) count, (const GLint *) value)
1284
1291
{
1285
- postEvent<&uniform1iv>(location, count, qMakePair (value, count));
1292
+ postEvent<&uniform1iv>(location, qMakePair (value, count));
1286
1293
}
1287
1294
1288
1295
QWEBGL_FUNCTION_POSTEVENT (uniform2f, glUniform2f,
@@ -1291,7 +1298,7 @@ QWEBGL_FUNCTION_POSTEVENT(uniform2f, glUniform2f,
1291
1298
QWEBGL_FUNCTION (uniform2fv, void , glUniform2fv,
1292
1299
(GLint) location, (GLsizei) count, (const GLfloat *) value)
1293
1300
{
1294
- postEvent<&uniform2fv>(location, count, qMakePair (value, count * 2 ));
1301
+ postEvent<&uniform2fv>(location, qMakePair (value, count * 2 ));
1295
1302
}
1296
1303
1297
1304
QWEBGL_FUNCTION_POSTEVENT (uniform2i, glUniform2i,
@@ -1300,17 +1307,16 @@ QWEBGL_FUNCTION_POSTEVENT(uniform2i, glUniform2i,
1300
1307
QWEBGL_FUNCTION (uniform2iv, void , glUniform2iv,
1301
1308
(GLint) location, (GLsizei) count, (const GLint *) value)
1302
1309
{
1303
- postEvent<&uniform2iv>(location, count, qMakePair (value, count * 2 ));
1310
+ postEvent<&uniform2iv>(location, qMakePair (value, count * 2 ));
1304
1311
}
1305
1312
1306
1313
QWEBGL_FUNCTION_POSTEVENT (uniform3f, glUniform3f,
1307
1314
(GLint) location, (GLfloat) v0, (GLfloat) v1, (GLfloat) v2)
1308
1315
1309
-
1310
1316
QWEBGL_FUNCTION (uniform3fv, void , glUniform3fv,
1311
1317
(GLint) location, (GLsizei) count, (const GLfloat *) value)
1312
1318
{
1313
- postEvent<&uniform3fv>(location, count, qMakePair (value, count * 3 ));
1319
+ postEvent<&uniform3fv>(location, qMakePair (value, count * 3 ));
1314
1320
}
1315
1321
1316
1322
QWEBGL_FUNCTION_POSTEVENT (uniform3i, glUniform3i,
@@ -1319,7 +1325,7 @@ QWEBGL_FUNCTION_POSTEVENT(uniform3i, glUniform3i,
1319
1325
QWEBGL_FUNCTION (uniform3iv, void , glUniform3iv,
1320
1326
(GLint) location, (GLsizei) count, (const GLint *) value)
1321
1327
{
1322
- postEvent<&uniform3iv>(location, count, qMakePair (value, count * 3 ));
1328
+ postEvent<&uniform3iv>(location, qMakePair (value, count * 3 ));
1323
1329
}
1324
1330
1325
1331
QWEBGL_FUNCTION_POSTEVENT (uniform4f, glUniform4f,
@@ -1329,7 +1335,7 @@ QWEBGL_FUNCTION_POSTEVENT(uniform4f, glUniform4f,
1329
1335
QWEBGL_FUNCTION (uniform4fv, void , glUniform4fv,
1330
1336
(GLint) location, (GLsizei) count, (const GLfloat *) value)
1331
1337
{
1332
- postEvent<&uniform4fv>(location, count, qMakePair (value, count * 4 ));
1338
+ postEvent<&uniform4fv>(location, qMakePair (value, count * 4 ));
1333
1339
}
1334
1340
1335
1341
QWEBGL_FUNCTION_POSTEVENT (uniform4i, glUniform4i,
@@ -1338,25 +1344,25 @@ QWEBGL_FUNCTION_POSTEVENT(uniform4i, glUniform4i,
1338
1344
QWEBGL_FUNCTION (uniform4iv, void , glUniform4iv,
1339
1345
(GLint) location, (GLsizei) count, (const GLint *) value)
1340
1346
{
1341
- postEvent<&uniform4iv>(location, count, qMakePair (value, count * 4 ));
1347
+ postEvent<&uniform4iv>(location, qMakePair (value, count * 4 ));
1342
1348
}
1343
1349
1344
1350
QWEBGL_FUNCTION (uniformMatrix2fv, void , glUniformMatrix2fv,
1345
1351
(GLint) location, (GLsizei) count, (GLboolean) transpose, (const GLfloat *) value)
1346
1352
{
1347
- postEvent<&uniformMatrix2fv>(location, count, transpose, qMakePair (value, count * 4 ));
1353
+ postEvent<&uniformMatrix2fv>(location, transpose, qMakePair (value, count * 4 ));
1348
1354
}
1349
1355
1350
1356
QWEBGL_FUNCTION (uniformMatrix3fv, void , glUniformMatrix3fv,
1351
1357
(GLint) location, (GLsizei) count, (GLboolean) transpose, (const GLfloat *) value)
1352
1358
{
1353
- postEvent<&uniformMatrix3fv>(location, count, transpose, qMakePair (value, count * 9 ));
1359
+ postEvent<&uniformMatrix3fv>(location, transpose, qMakePair (value, count * 9 ));
1354
1360
}
1355
1361
1356
1362
QWEBGL_FUNCTION (uniformMatrix4fv, void , glUniformMatrix4fv,
1357
1363
(GLint) location, (GLsizei) count, (GLboolean) transpose, (const GLfloat *) value)
1358
1364
{
1359
- postEvent<&uniformMatrix4fv>(location, count, transpose, qMakePair (value, count * 16 ));
1365
+ postEvent<&uniformMatrix4fv>(location, transpose, qMakePair (value, count * 16 ));
1360
1366
}
1361
1367
1362
1368
QWEBGL_FUNCTION_POSTEVENT (useProgram, glUseProgram,
0 commit comments