Error in 'DrawTexture'

3 views (last 30 days)
Alix
Alix on 6 Sep 2019
Answered: Alix on 10 Sep 2019
Hi everybody,
I'm quite new to the whole matlab experience and I'm hoping someone can help me out with this.
I'm using a script to convert images to texture/mat files, that has worked before. But when put it in my main script and run it, I get the following error, anybody out there who can help =)?
Thank you so much!
Error in function DrawTexture: Missing argument
Discrepancy between a specified and supplied argument:
Specified Argument Description:
direction: Input
position: 2
presence:forbidden
formats allowed:
double
minimum M: 1
maximum M: 1
minimum N: 1
maximum N: 1
minimum P: 1
maximum P: 1
Provided Argument Description:
direction: Input
position: 2
presence: absent
Error using Screen
Usage:
Screen('DrawTexture', windowPointer, texturePointer [,sourceRect] [,destinationRect] [,rotationAngle] [, filterMode]
[, globalAlpha] [, modulateColor] [, textureShader] [, specialFlags] [, auxParameters]);
Error in encoding_2 (line 219)
Screen('DrawTexture', win, tex(trial_order(trial+1))); %uses loadJPG_as_Texture.m
  13 Comments
Alix
Alix on 8 Sep 2019
Thank you both, I got it to work now finally =) just in time.
Enjoy the rest of your weekend!
Guillaume
Guillaume on 9 Sep 2019
As it may be helpful for others to know what the solution was, could you post it as an answer and then accept your own answer?

Sign in to comment.

Accepted Answer

Alix
Alix on 10 Sep 2019
Yes, sorry! It was so simple in the end:
1) I made sure that only jpg's are in the stimulus folder (as the transformation function posted above counts all files, which gives an error later in the script when it seems as if there are more files to be read in then there actually are)
2) when writing your script as a function 'tex' is not a texturepointer but refers to something else (as @Walter suggested in the beginning). So, when converting jpg to texture, instead of saying
tex(nfile) = Screen('MakeTexture', win, img);'
I changed it to
imgtex(nfile) = Screen('MakeTexture', win, img);'.
In the main script, it now reads
Screen('DrawTexture', win, imgtex(trialList.stimNr(trial)));
btw. tested it under the scanner (fMRI) yesterday and it works like a charm =)
Thank you guys again!

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!