Getting syntax error in GLSL array constructor not supported - glsl

with this code
var mat_add = gpu.createKernel(function(A, B) {
var sum = [];
for (var i=0; i<3; i++) {
sum.push(A[this.thread.y][i] + B[i][this.thread.x]);
}
return sum;
}).dimensions([2, 2]);
I am getting this error:
An error occurred compiling the shaders: ERROR: 0:141: '' : array size must be greater than zero
ERROR: 0:141: '[]' : array constructor supported in GLSL ES 3.00 and above only
ERROR: 0:141: 'constructor' : array constructor needs one argument per array element
ERROR: 0:141: '=' : Invalid operation for arrays
ERROR: 0:141: '=' : cannot convert from 'const array[1] of float' to 'highp float'
ERROR: 0:145: 'sum' : undeclared identifier
ERROR: 0:145: '' : methods supported in GLSL ES 3.00 and above only
ERROR: 0:145: 'push' : invalid method
This actually works:
var mat_mult = gpu.createKernel(function(A, B) {
var sum = 0;
for (var i=0; i<3; i++) {
sum += A[this.thread.y][i] * B[i][this.thread.x];
}
return sum;
}).dimensions([2, 1]);
Does anyone know how to fix this syntax error?
Thanks

i created python code to convert list into function getters : https://github.com/MhadhbiXissam/GLSL_LIST

Related

request for member ‘begin’ in ‘ionDistance’, which is of non-class type ‘float*’

I have written the code below and I am receiving the error. What am I doing wrong?
float sampledEnergies ( float ionDistance[], float ionEnergy[])
{
float samTime[1000];
float simPos[1000];
float closeEnergy[1000];
float close;
int maxSamples = chamberLength / (driftVel * adcSampleRate);
for (int i = 0; i < maxSamples; i++)
{
samTime[i] = i * adcSampleRate;
simPos[i] = chamberLength - (driftVel * samTime[i]);
printf("%.2f\t%.2f\n",samTime[i],simPos[i]);
close = lower_bound(ionDistance.begin(),ionDistance.end(), simPos[i]);
for (int j = 0; j < maxSamples; j++)
{
if (close = ionDistance[j])
{
closeEnergy[i] = ionEnergy[j];
}
}
}
}
The above is the code and the error is as follows.
TBraggSimulation_v1.cpp: In function ‘float sampledEnergies(float*, float*)’:
TBraggSimulation_v1.cpp:37: error: request for member ‘begin’ in ‘ionDistance’, which is of non-class type ‘float*’
TBraggSimulation_v1.cpp:37: error: request for member ‘end’ in ‘ionDistance’, which is of non-class type ‘float*’
Your ionDistance is a pointer (to a first element of an array) and not a standard-library container. Your code tries to call begin and end, which are only defined for containers.
To obtain a range of iterators for a pointer, use:
lower_bound(ionDistance, ionDistance + n, simPos[i]);
Here n is the number of elements in your ionDistance array. I don't understand your code enough to suggest it's equal to maxSamples; if it's not, add a parameter to your function:
float sampledEnergies ( float ionDistance[], float ionEnergy[], size_t numIons)
{
lower_bound(ionDistance,ionDistance + numIons, simPos[i]);
}

OGRE No suitable conversion function exists

I'm having a hard time trying to get an app to compile in Visual Studio 2013. I've solved a good amount of errors but I can't find a solution for the last one.
here it is:
void Application::setupRenderSystem() {
mState->dumpValues();
String val = mState->getStringValue("renderSystem");
RenderSystemList *renderSystems = mRoot->getAvailableRenderers();
RenderSystemList::iterator r_it;
bool renderSystemFound = false;
for (r_it = renderSystems->begin(); r_it != renderSystems->end(); r_it++) {
RenderSystem *tmp = *r_it;
std::string rName(tmp->getName());
// returns -1 if string not found
if ((int)rName.find(val) >= 0) {
mRoot->setRenderSystem(*r_it);
renderSystemFound = true;
break;
}
}
if (!renderSystemFound) {
OGRE_EXCEPT(0, "Specified render system (" + val + ") not found, exiting...", "Application")
}
}
Visual Studio indicates that the line RenderSystemList *renderSystems = mRoot->getAvailableRenderers(); is the problem, especially mRoot
Here is the error I get:
error C2440: 'initializing' : cannot convert from 'const Ogre::RenderSystemList' to 'Ogre::RenderSystemList *'
The getAvailableRenderers method doesn't return a pointer to a RenderSystemList. You'd want to have the value stored in a reference to a RenderSystemList:
RenderSystemList const& renderSystems = mRoot->getAvailableRenderers();
The Ogre API says:
const RenderSystemList & getAvailableRenderers (void)
So it returns a const reference and not a pointer.
Modify your code like this
const RenderSystemList &renderSystems = mRoot->getAvailableRenderers();

PJSUA Makefile error: Invalid use of non-static data member 'param'

Working with pjsua and the pjsua-jni folder I have run into a error. Being new to C and C++ I have just learning as I go. I have experience with programming so I am not that out of my league, I hope.
The errors I get from the make file is
nativesrc/pjsua_wrap.cpp:3843:23: error: invalid use of non-static data member 'param'
pjmedia_codec_fmtp::param *arg2 ;
~~~~~~~~~~~~~~~~~~~~^~~~~
nativesrc/pjsua_wrap.cpp:3843:30: error: use of undeclared identifier 'arg2'
pjmedia_codec_fmtp::param *arg2 ;
^
nativesrc/pjsua_wrap.cpp:3849:3: error: use of undeclared identifier 'arg2'
arg2 = *(pjmedia_codec_fmtp::param **)&jarg2;
^
nativesrc/pjsua_wrap.cpp:3849:32: error: invalid use of non-static data member 'param'
arg2 = *(pjmedia_codec_fmtp::param **)&jarg2;
~~~~~~~~~~~~~~~~~~~~^~~~~
nativesrc/pjsua_wrap.cpp:3849:40: error: expected expression
arg2 = *(pjmedia_codec_fmtp::param **)&jarg2;
^
nativesrc/pjsua_wrap.cpp:3852:25: error: invalid use of non-static data member 'param'
pjmedia_codec_fmtp::param *b = (pjmedia_codec_fmtp::param *) arg1->param;
~~~~~~~~~~~~~~~~~~~~^~~~~
nativesrc/pjsua_wrap.cpp:3852:32: error: use of undeclared identifier 'b'
pjmedia_codec_fmtp::param *b = (pjmedia_codec_fmtp::param *) arg1->param;
^
nativesrc/pjsua_wrap.cpp:3852:57: error: invalid use of non-static data member 'param'
pjmedia_codec_fmtp::param *b = (pjmedia_codec_fmtp::param *) arg1->param;
~~~~~~~~~~~~~~~~~~~~^~~~~
nativesrc/pjsua_wrap.cpp:3852:64: error: expected expression
pjmedia_codec_fmtp::param *b = (pjmedia_codec_fmtp::param *) arg1->param;
^
nativesrc/pjsua_wrap.cpp:3853:40: error: use of undeclared identifier 'b'
for (ii = 0; ii < (size_t)8; ii++) b[ii] = *((pjmedia_codec_fmtp::param *) arg2 + ii);
^
nativesrc/pjsua_wrap.cpp:3853:71: error: invalid use of non-static data member 'param'
for (ii = 0; ii < (size_t)8; ii++) b[ii] = *((pjmedia_codec_fmtp::param *) arg2 + ii);
~~~~~~~~~~~~~~~~~~~~^~~~~
nativesrc/pjsua_wrap.cpp:3853:78: error: expected expression
for (ii = 0; ii < (size_t)8; ii++) b[ii] = *((pjmedia_codec_fmtp::param *) arg2 + ii);
I am not sure how to declare this param. When looking in the codecs.h file I find this
typedef struct pjmedia_codec_fmtp
{
pj_uint8_t cnt; /**< Number of parameters. */
struct param {
pj_str_t name; /**< Parameter name. */
pj_str_t val; /**< Parameter value. */
} param [PJMEDIA_CODEC_MAX_FMTP_CNT]; /**< The parameters. */
} pjmedia_codec_fmtp;
So the way its calling the param struct is pjmedia_codec_fmtp::param *arg2. Is that right? I know that the :: usually is how you call a static method but is that how you call structs too?
Anyway help would be great
This is the code it throws the first error on
pjmedia_codec_fmtp *arg1 = (pjmedia_codec_fmtp *) 0 ;
pjmedia_codec_fmtp::param *arg2; // Error

Resolve c++ pointer-to-member error in VS 2003

I have a c++ program that I'm trying to port from VS98 to VS2003 (incremental steps). One error that occurs throughout is "Error 2275"
For instance: k:\RR\chart\chartdlg.cpp(2025): error C2475: 'CRrDoc::cFldFilter' : forming a pointer-to-member requires explicit use of the address-of operator ('&') and a qualified name
The offending code is shown below:
void CDataPage::OnBtnLabelField()
{
FLDID fid ;
LPMFFIELD f ;
CRrApp *pApp = (CRrApp *)AfxGetApp();
CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
CRrDoc *pDoc = (CRrDoc *)pFrame->GetActiveDocument();
CSelectFieldDlg dlg;
//**************************************************
//BOOL CRrDoc::*zcFldFilter = &CRrDoc::cFldFilter;
//dlg.ck = CRrDoc->*zcFldFilter;
//**************************************************
dlg.ck = pDoc->cFldFilter ;
dlg.TitleTextID = IDS_2676;
fid = (FLDID)dlg.DoModal();
if (fid != NOID)
{
f = pDoc->m_pComposite->mfbyndx(fid);
// find index
int i, iCount;
iCount = m_lboxLabel.GetCount();
for (i = 0; i < iCount; i++)
{
if(fid == m_lboxLabel.GetItemData(i))
{
m_lboxLabel.SetCurSel(i);
OnSelchangeComboLabel();
}
}
}
}
I tried handling it according to a Microsoft page: But that just generated a set of other problems (the commented code between the asterisks). Note that I also commented out the following line:
dlg.ck = pDoc->cFldFilter
Unfortunately, this leads to a new error: k:\RR\chart\chartdlg.cpp(2022): error C2440: 'initializing' : cannot convert from 'BOOL (__cdecl )(LPMFFIELD)' to 'BOOL CRrDoc:: '
The definition in the .H file looks like:
public:
static BOOL cFldFilter(LPMFFIELD f);
Any ideas how to handle the pointer-to-member issue?
since you have:
static BOOL CRrDoc::cFldFilter(LPMFFIELD f);
its type is not a member variable but a function:
//BOOL CRrDoc::*zcFldFilter = &CRrDoc::cFldFilter; // doesn't work
BOOL (*zcFldFilter)(LPMFFIELD) = &CRrDoc::cFldFilter; // works
Since dlg.ck is of a correct type, you should do
dlg.ck = &CRrDoc::cFldFilter;

Getting a mysterious type conversion when using the get function from Maya API class MArgList

I am using the MArgList class from the Maya API to retrieve arguments entered in the Maya command line. According to the class reference MArgList::get should be able to take an int or double as its second argument but it seems to be expecting a bool only and so throws a conversion error during compiling. The following is the code section and the errors generated. Any thoughts on what might be causing this would be much appreciated. The code was typed straight out of a tutorial on Maya plugin development, so it is a mystery why it is not working.
const int nPosts = 5;
const double radius = 0.5;
const double height = 5.0;
unsigned index;
index = args.flagIndex( "n", "number" );
if( MArgList::kInvalidArgIndex != index )
args.get( index + 1, nPosts );
unsigned index;
index = args.flagIndex( "r", "radius" );
if( MArgList::kInvalidArgIndex != index )
args.get( index + 1, radius );
unsigned index;
index = args.flagIndex( "h", "height" );
if( MArgList::kInvalidArgIndex != index )
args.get( index + 1, height );
1>Posts1Cmd.cpp(37): error C2664: 'MStatus MArgList::get(unsigned int,bool &) const' : cannot convert parameter 2 from 'const int' to 'bool &'
1>Posts1Cmd.cpp(39): error C2086: 'unsigned int index' : redefinition
1> Posts1Cmd.cpp(34) : see declaration of 'index'
1>Posts1Cmd.cpp(42): error C2664: 'MStatus MArgList::get(unsigned int,bool &) const' : cannot convert parameter 2 from 'const double' to 'bool &'
1>Posts1Cmd.cpp(44): error C2086: 'unsigned int index' : redefinition
1> Posts1Cmd.cpp(34) : see declaration of 'index'
1>Posts1Cmd.cpp(47): error C2664: 'MStatus MArgList::get(unsigned int,bool &) const' : cannot convert parameter 2 from 'const double' to 'bool &'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If you are going to get new values from the get function, you cannot have the target variables const.
Try
int nPosts = 5;
double radius = 0.5;
double height = 5.0;
Also, you should not declare a new index variable for each call. Just declare it once and reuse it.