本文整理汇总了C++中PsychAllocInWindowRecordArg函数的典型用法代码示例。如果您正苦于以下问题:C++ PsychAllocInWindowRecordArg函数的具体用法?C++ PsychAllocInWindowRecordArg怎么用?C++ PsychAllocInWindowRecordArg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PsychAllocInWindowRecordArg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: SCREENglLoadIdentity
PsychError SCREENglLoadIdentity(void)
{
// If you change useString then also change the corresponding synopsis string in ScreenSynopsis.c
static char useString[] = "Screen('glLoadIdentity', windowPtr);";
static char synopsisString[] = "Reset an OpenGL matrix to its default identity setting. "
"See <http://www.opengl.org/documentation/red_book_1.0/> Chapter 4 for detailed information.";
static char seeAlsoString[] = "";
PsychWindowRecordType *windowRecord;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString,seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for superfluous arguments
PsychErrorExit(PsychCapNumInputArgs(1)); // The maximum number of inputs
PsychErrorExit(PsychRequireNumInputArgs(1)); // Number of required inputs.
PsychErrorExit(PsychCapNumOutputArgs(0)); // The maximum number of outputs
//get the window record from the window record argument and get info from the window record
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
// Switch to windows OpenGL context:
PsychSetGLContext(windowRecord);
// Execute it:
glLoadIdentity();
PsychTestForGLErrors();
//All psychfunctions require this.
return(PsychError_none);
}
开发者ID:AlanFreeman,项目名称:Psychtoolbox-3,代码行数:32,代码来源:SCREENglMatrixFunctionWrappers.c
示例2: SCREENTextStyle
PsychError SCREENTextStyle(void)
{
boolean doSetStyle;
PsychWindowRecordType *windowRecord;
int oldTextStyle, newTextStyle;
//all subfunctions should have these two lines.
PsychPushHelp(useString, synopsisString, seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for valid number of arguments
PsychErrorExit(PsychRequireNumInputArgs(1));
PsychErrorExit(PsychCapNumInputArgs(2));
PsychErrorExit(PsychCapNumOutputArgs(1));
//Get the window record
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
//Save the old text size value and return it.
oldTextStyle=windowRecord->textAttributes.textStyle;
PsychCopyOutDoubleArg(1, FALSE, (double)oldTextStyle);
//Fetch and set the new size if it is specified.
doSetStyle= PsychCopyInIntegerArg(2, FALSE, &newTextStyle);
if(doSetStyle)
windowRecord->textAttributes.textStyle=newTextStyle;
return(PsychError_none);
}
开发者ID:BackupTheBerlios,项目名称:osxptb-svn,代码行数:31,代码来源:SCREENTextStyle.c
示例3: SCREENPixelSize
PsychError SCREENPixelSize(void)
{
int screenNumber;
double depth;
PsychWindowRecordType *windowRecord;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString, seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check to see if the user supplied superfluous arguments
PsychErrorExit(PsychCapNumOutputArgs(1));
PsychErrorExit(PsychCapNumInputArgs(1));
//get specified screen number.
if(PsychIsScreenNumberArg(1)){
PsychCopyInScreenNumberArg(1, TRUE, &screenNumber);
depth=(double)PsychGetScreenDepthValue(screenNumber);
}else if(PsychIsWindowIndexArg(1)){
PsychAllocInWindowRecordArg(1,TRUE,&windowRecord);
depth=(double)windowRecord->depth;
}else
PsychErrorExit(PsychError_invalidNumdex);
//Allocate a return matrix and load it with the depth values.
PsychCopyOutDoubleArg(1, FALSE, depth);
return(PsychError_none);
}
开发者ID:BackupTheBerlios,项目名称:osxptb-svn,代码行数:29,代码来源:SCREENPixelSize.c
示例4: SCREENRect
PsychError SCREENRect(void)
{
PsychWindowRecordType *windowRecord;
int screenNumber;
PsychRectType rect;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString,seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for superfluous arguments
PsychErrorExit(PsychCapNumInputArgs(1)); //The maximum number of inputs
PsychErrorExit(PsychRequireNumInputArgs(1)); //Insist that the argument be present.
PsychErrorExit(PsychCapNumOutputArgs(1)); //The maximum number of outputs
if(PsychIsScreenNumberArg(1)){
PsychCopyInScreenNumberArg(1, TRUE, &screenNumber);
PsychGetScreenRect(screenNumber, rect);
PsychCopyOutRectArg(1, FALSE, rect);
}else if(PsychIsWindowIndexArg(1)){
PsychAllocInWindowRecordArg(1, TRUE, &windowRecord);
PsychOSProcessEvents(windowRecord, 0);
PsychCopyOutRectArg(1,FALSE, windowRecord->clientrect);
}else
PsychErrorExitMsg(PsychError_user, "Argument was recognized as neither a window index nor a screen pointer");
return(PsychError_none);
}
开发者ID:rennis250,项目名称:Psychtoolbox-3,代码行数:29,代码来源:SCREENRect.c
示例5: SCREENglPoint
PsychError SCREENglPoint(void)
{
PsychColorType color;
double *xPosition, *yPosition, dotSize;
PsychWindowRecordType *windowRecord;
int whiteValue;
psych_bool isArgThere;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString,seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for superfluous arguments
PsychErrorExit(PsychCapNumInputArgs(5)); //The maximum number of inputs
PsychErrorExit(PsychCapNumOutputArgs(0)); //The maximum number of outputs
//get the window record from the window record argument and get info from the window record
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
//Get the color argument or use the default, then coerce to the form determened by the window depth.
isArgThere=PsychCopyInColorArg(kPsychUseDefaultArgPosition, FALSE, &color);
if(!isArgThere){
whiteValue=PsychGetWhiteValueFromWindow(windowRecord);
PsychLoadColorStruct(&color, kPsychIndexColor, whiteValue ); //index mode will coerce to any other.
}
PsychCoerceColorMode( &color);
//get the x and y position values.
PsychAllocInDoubleArg(3, TRUE, &xPosition);
PsychAllocInDoubleArg(4, TRUE, &yPosition);
dotSize=1; //set the default
PsychCopyInDoubleArg(5, FALSE, &dotSize);
// Enable this windowRecords framebuffer as current drawingtarget:
PsychSetDrawingTarget(windowRecord);
// Set default draw shader:
PsychSetShader(windowRecord, -1);
PsychUpdateAlphaBlendingFactorLazily(windowRecord);
PsychSetGLColor(&color, windowRecord);
glEnable(GL_POINT_SMOOTH);
glPointSize((float)dotSize);
glBegin(GL_POINTS);
glVertex2d( (GLdouble)*xPosition, *yPosition);
glEnd();
glDisable(GL_POINT_SMOOTH);
glPointSize(1);
// Mark end of drawing op. This is needed for single buffered drawing:
PsychFlushGL(windowRecord);
//All psychfunctions require this.
return(PsychError_none);
}
开发者ID:BackupTheBerlios,项目名称:osxptb-svn,代码行数:57,代码来源:SCREENglPoint.c
示例6: SCREENgluDisk
PsychError SCREENgluDisk(void)
{
PsychColorType color;
double *xPosition, *yPosition, dotSize;
PsychWindowRecordType *windowRecord;
int depthValue, whiteValue, colorPlaneSize, numColorPlanes;
boolean isArgThere;
GLUquadricObj *diskQuadric;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString,seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for superfluous arguments
PsychErrorExit(PsychCapNumInputArgs(5)); //The maximum number of inputs
PsychErrorExit(PsychCapNumOutputArgs(0)); //The maximum number of outputs
//get the window record from the window record argument and get info from the window record
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
//Get the depth from the window, we need this to interpret the color argument.
depthValue=PsychGetWindowDepthValueFromWindowRecord(windowRecord);
numColorPlanes=PsychGetNumPlanesFromDepthValue(depthValue);
colorPlaneSize=PsychGetColorSizeFromDepthValue(depthValue);
//Get the color argument or use the default, then coerce to the form determened by the window depth.
isArgThere=PsychCopyInColorArg(kPsychUseDefaultArgPosition, FALSE, &color);
if(!isArgThere){
whiteValue=PsychGetWhiteValueFromDepthValue(depthValue);
PsychLoadColorStruct(&color, kPsychIndexColor, whiteValue ); //index mode will coerce to any other.
}
PsychCoerceColorModeFromSizes(numColorPlanes, colorPlaneSize, &color);
//get the x and y position values.
PsychAllocInDoubleArg(3, TRUE, &xPosition);
PsychAllocInDoubleArg(4, TRUE, &yPosition);
dotSize=1; //set the default
PsychCopyInDoubleArg(5, FALSE, &dotSize);
//Set the color and draw the rect. Note that all GL drawing commands should be sandwiched between
PsychSetGLContext(windowRecord);
PsychUpdateAlphaBlendingFactorLazily(windowRecord);
PsychSetGLColor(&color, depthValue);
glPushMatrix();
glTranslated(*xPosition,*yPosition,0);
diskQuadric=gluNewQuadric();
gluDisk(diskQuadric, 0, dotSize, 30, 30);
gluDeleteQuadric(diskQuadric);
glPopMatrix();
//PsychGLRect(rect);
PsychFlushGL(windowRecord); //OS X: This does nothing if we are multi buffered, otherwise it glFlushes
//All psychfunctions require this.
return(PsychError_none);
}
开发者ID:BackupTheBerlios,项目名称:osxptb-svn,代码行数:56,代码来源:SCREENgluDisk.c
示例7: SCREENDrawLine
PsychError SCREENDrawLine(void)
{
PsychColorType color;
PsychWindowRecordType *windowRecord;
int depthValue, whiteValue, colorPlaneSize, numColorPlanes;
boolean isArgThere;
double sX, sY, dX, dY, penSize;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString,seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for superfluous arguments
PsychErrorExit(PsychCapNumInputArgs(7)); //The maximum number of inputs
PsychErrorExit(PsychCapNumOutputArgs(0)); //The maximum number of outputs
//get the window record from the window record argument and get info from the window record
PsychAllocInWindowRecordArg(1, kPsychArgRequired, &windowRecord);
//Get the depth from the window, we need this to interpret the color argument.
depthValue=PsychGetWindowDepthValueFromWindowRecord(windowRecord);
numColorPlanes=PsychGetNumPlanesFromDepthValue(depthValue);
colorPlaneSize=PsychGetColorSizeFromDepthValue(depthValue);
//Get the color argument or use the default, then coerce to the form determened by the window depth.
isArgThere=PsychCopyInColorArg(2, FALSE, &color);
if(!isArgThere){
whiteValue=PsychGetWhiteValueFromDepthValue(depthValue);
PsychLoadColorStruct(&color, kPsychIndexColor, whiteValue ); //index mode will coerce to any other.
}
PsychCoerceColorModeFromSizes(numColorPlanes, colorPlaneSize, &color);
//get source and destination X and Y values
PsychCopyInDoubleArg(3, kPsychArgRequired, &sX);
PsychCopyInDoubleArg(4, kPsychArgRequired, &sY);
PsychCopyInDoubleArg(5, kPsychArgRequired, &dX);
PsychCopyInDoubleArg(6, kPsychArgRequired, &dY);
//get and set the pen size
penSize=1;
PsychCopyInDoubleArg(7, kPsychArgOptional, &penSize);
glLineWidth((GLfloat)penSize);
//draw the rect
PsychSetGLContext(windowRecord);
PsychUpdateAlphaBlendingFactorLazily(windowRecord);
PsychSetGLColor(&color, depthValue);
glBegin(GL_LINES);
glVertex2d((GLdouble)sX, (GLdouble)sY);
glVertex2d((GLdouble)dX, (GLdouble)dY);
glEnd();
return(PsychError_none);
}
开发者ID:BackupTheBerlios,项目名称:osxptb-svn,代码行数:55,代码来源:SCREENDrawLine.c
示例8: SCREENWindowSize
PsychError SCREENWindowSize(void)
{
PsychWindowRecordType *windowRecord;
int screenNumber;
PsychRectType rect;
double rectWidth, rectHeight;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString,seeAlsoString);
if(PsychIsGiveHelp()) {
PsychGiveHelp();
return(PsychError_none);
};
//check for superfluous arguments
PsychErrorExit(PsychCapNumInputArgs(1)); //The maximum number of inputs
PsychErrorExit(PsychRequireNumInputArgs(1)); //Insist that the argument be present.
PsychErrorExit(PsychCapNumOutputArgs(2)); //The maximum number of outputs
if(PsychIsScreenNumberArg(1)) {
PsychCopyInScreenNumberArg(1, TRUE, &screenNumber);
PsychGetScreenRect(screenNumber, rect);
rectWidth=PsychGetWidthFromRect(rect);
rectHeight=PsychGetHeightFromRect(rect);
PsychCopyOutDoubleArg(1, kPsychArgOptional, rectWidth);
PsychCopyOutDoubleArg(2, kPsychArgOptional, rectHeight);
} else if(PsychIsWindowIndexArg(1)) {
PsychAllocInWindowRecordArg(1, TRUE, &windowRecord);
PsychOSProcessEvents(windowRecord, 0);
rectWidth=PsychGetWidthFromRect(windowRecord->rect);
rectHeight=PsychGetHeightFromRect(windowRecord->rect);
if (windowRecord->specialflags & kPsychHalfWidthWindow) {
// Special case for stereo: Only half the real window width:
rectWidth = rectWidth / 2;
}
if (windowRecord->specialflags & kPsychHalfHeightWindow) {
// Special case for stereo: Only half the real window width:
rectHeight = rectHeight / 2;
}
PsychCopyOutDoubleArg(1, kPsychArgOptional, rectWidth);
PsychCopyOutDoubleArg(2, kPsychArgOptional, rectHeight);
} else
PsychErrorExitMsg(PsychError_user, "Argument was recognized as neither a window index nor a screen pointer");
return(PsychError_none);
}
开发者ID:BackupTheBerlios,项目名称:osxptb-svn,代码行数:51,代码来源:SCREENWindowSize.c
示例9: SCREENglRotate
PsychError SCREENglRotate(void)
{
// If you change useString then also change the corresponding synopsis string in ScreenSynopsis.c
static char useString[] = "Screen('glRotate', windowPtr, angle, [rx = 0], [ry = 0] ,[rz = 1]);";
// 1 2 3 4 5
static char synopsisString[] = "Define a rotation transform by an angle of 'angle' degrees around the "
"axis defined by the vector (rx,ry,rz) in space, relative to the enclosing reference frame."
"See <http://www.opengl.org/documentation/red_book_1.0/> Chapter 4 for detailed information.";
static char seeAlsoString[] = "";
PsychWindowRecordType *windowRecord;
double rx, ry, rz;
double angle;
// Default to rotation around z-axis, aka in-plane rotation:
rx=ry=0;
rz=1;
// Default to a non-rotation (zero degrees):
angle=0;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString,seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for superfluous arguments
PsychErrorExit(PsychCapNumInputArgs(5)); // The maximum number of inputs
PsychErrorExit(PsychRequireNumInputArgs(2)); // Number of required inputs.
PsychErrorExit(PsychCapNumOutputArgs(0)); // The maximum number of outputs
//get the window record from the window record argument and get info from the window record
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
// Fetch rotation angle:
PsychCopyInDoubleArg(2, TRUE, &angle);
// Fetch rotation vector:
PsychCopyInDoubleArg(3, FALSE, &rx);
PsychCopyInDoubleArg(4, FALSE, &ry);
PsychCopyInDoubleArg(5, FALSE, &rz);
// Switch to windows OpenGL context:
PsychSetGLContext(windowRecord);
// Execute it:
glRotated(angle, rx, ry, rz);
PsychTestForGLErrors();
//All psychfunctions require this.
return(PsychError_none);
}
开发者ID:AlanFreeman,项目名称:Psychtoolbox-3,代码行数:50,代码来源:SCREENglMatrixFunctionWrappers.c
示例10: SCREENglPushMatrix
PsychError SCREENglPushMatrix(void)
{
// If you change useString then also change the corresponding synopsis string in ScreenSynopsis.c
static char useString[] = "Screen('glPushMatrix', windowPtr);";
static char synopsisString[] = "Store a backup copy of active current OpenGL matrix on the matrix stack for later reuse. "
"The capacity of the matrix backup stack is limited, typically not more than 27 slots. For each call to glPushMatrix "
"you need to call glPopMatrix at the appropriate place to avoid overflowing the stack. "
"See <http://www.opengl.org/documentation/red_book_1.0/> Chapter 4 for detailed information.";
static char seeAlsoString[] = "";
PsychWindowRecordType *windowRecord;
GLint stack_cur, stack_max;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString,seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for superfluous arguments
PsychErrorExit(PsychCapNumInputArgs(1)); // The maximum number of inputs
PsychErrorExit(PsychRequireNumInputArgs(1)); // Number of required inputs.
PsychErrorExit(PsychCapNumOutputArgs(0)); // The maximum number of outputs
//get the window record from the window record argument and get info from the window record
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
// Switch to windows OpenGL context:
PsychSetGLContext(windowRecord);
glMatrixMode(GL_MODELVIEW);
// Compare current fill level of matrix stack with maximum level: We reserve five
// stack-slots for PTB internal use, so at least that needs to be free before push.
glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &stack_max);
glGetIntegerv(GL_MODELVIEW_STACK_DEPTH, &stack_cur);
if (stack_max - stack_cur < 6) {
printf("\nCouldn't push OpenGL-Modelview matrix because matrix stack is full! The most common reason is\n");
printf("forgetting to call glPopMatrix a matching number of times... \n");
printf("The maximum number of pushable matrices is %i -- Please check your code.\n", stack_max - 5);
PsychErrorExitMsg(PsychError_user, "Too many calls to glPushMatrix. Imbalance?");
}
// Execute push op:
glPushMatrix();
PsychTestForGLErrors();
//All psychfunctions require this.
return(PsychError_none);
}
开发者ID:AlanFreeman,项目名称:Psychtoolbox-3,代码行数:49,代码来源:SCREENglMatrixFunctionWrappers.c
示例11: SCREENTextStyle
PsychError SCREENTextStyle(void)
{
psych_bool doSetStyle, foundFont;
PsychWindowRecordType *windowRecord;
int oldTextStyle, newTextStyle;
#if PSYCH_SYSTEM == PSYCH_OSX
PsychFontStructType *fontRecord;
#endif
//all subfunctions should have these two lines.
PsychPushHelp(useString, synopsisString, seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for valid number of arguments
PsychErrorExit(PsychRequireNumInputArgs(1));
PsychErrorExit(PsychCapNumInputArgs(2));
PsychErrorExit(PsychCapNumOutputArgs(1));
//Get the window record
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
//Save the old text size value and return it.
oldTextStyle=windowRecord->textAttributes.textStyle;
PsychCopyOutDoubleArg(1, FALSE, (double)oldTextStyle);
//Fetch and set the new size if it is specified.
doSetStyle= PsychCopyInIntegerArg(2, FALSE, &newTextStyle);
if (doSetStyle) {
windowRecord->textAttributes.needsRebuild|=(windowRecord->textAttributes.textStyle != newTextStyle) ? TRUE : FALSE;
windowRecord->textAttributes.textStyle=newTextStyle;
#if PSYCH_SYSTEM == PSYCH_OSX
// Need to update font name and number from changed style on OS/X:
foundFont = PsychGetFontRecordFromFontFamilyNameAndFontStyle((char*) windowRecord->textAttributes.textFontName, windowRecord->textAttributes.textStyle, &fontRecord);
if (foundFont) {
strncpy((char*) windowRecord->textAttributes.textFontName, (const char*) fontRecord->fontFMFamilyName, 255);
windowRecord->textAttributes.textFontNumber= fontRecord->fontNumber;
}
else {
// Failed! Revert to old setting:
windowRecord->textAttributes.textStyle = oldTextStyle;
}
#endif
}
return(PsychError_none);
}
开发者ID:BackupTheBerlios,项目名称:osxptb-svn,代码行数:49,代码来源:SCREENTextStyle.c
示例12: SCREENWindowSize
PsychError SCREENWindowSize(void)
{
PsychWindowRecordType *windowRecord;
int screenNumber;
double rectWidth, rectHeight;
long fbWidth, fbHeight;
int realFBSize = 0;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString,seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for superfluous arguments
PsychErrorExit(PsychCapNumInputArgs(2)); //The maximum number of inputs
PsychErrorExit(PsychRequireNumInputArgs(1)); //Insist that the argument be present.
PsychErrorExit(PsychCapNumOutputArgs(2)); //The maximum number of outputs
// Get optional 'realFBSize' flag: Defaults to zero.
PsychCopyInIntegerArg(2, FALSE, &realFBSize);
if(PsychIsScreenNumberArg(1)){
PsychCopyInScreenNumberArg(1, TRUE, &screenNumber);
if (realFBSize) {
// Physical size in pixels:
PsychGetScreenPixelSize(screenNumber, &fbWidth, &fbHeight);
}
else {
// Logical size in points:
PsychGetScreenSize(screenNumber, &fbWidth, &fbHeight);
}
PsychCopyOutDoubleArg(1, kPsychArgOptional, fbWidth);
PsychCopyOutDoubleArg(2, kPsychArgOptional, fbHeight);
}else if(PsychIsWindowIndexArg(1)){
PsychAllocInWindowRecordArg(1, TRUE, &windowRecord);
PsychOSProcessEvents(windowRecord, 0);
rectWidth=PsychGetWidthFromRect((realFBSize) ? windowRecord->rect : windowRecord->clientrect);
rectHeight=PsychGetHeightFromRect((realFBSize) ? windowRecord->rect : windowRecord->clientrect);
PsychCopyOutDoubleArg(1, kPsychArgOptional, rectWidth);
PsychCopyOutDoubleArg(2, kPsychArgOptional, rectHeight);
}else
PsychErrorExitMsg(PsychError_user, "Argument was recognized as neither a window index nor a screen pointer");
return(PsychError_none);
}
开发者ID:ChiNasa511,项目名称:Psychtoolbox-3,代码行数:46,代码来源:SCREENWindowSize.c
示例13: SCREENglPopMatrix
PsychError SCREENglPopMatrix(void)
{
// If you change useString then also change the corresponding synopsis string in ScreenSynopsis.c
static char useString[] = "Screen('glPopMatrix', windowPtr);";
static char synopsisString[] = "Restore an OpenGL matrix by fetching it from the matrix stack. "
"See <http://www.opengl.org/documentation/red_book_1.0/> Chapter 4 for detailed information.";
static char seeAlsoString[] = "";
PsychWindowRecordType *windowRecord;
GLint stack_cur;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString,seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for superfluous arguments
PsychErrorExit(PsychCapNumInputArgs(1)); // The maximum number of inputs
PsychErrorExit(PsychRequireNumInputArgs(1)); // Number of required inputs.
PsychErrorExit(PsychCapNumOutputArgs(0)); // The maximum number of outputs
//get the window record from the window record argument and get info from the window record
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
// Switch to windows OpenGL context:
PsychSetGLContext(windowRecord);
glMatrixMode(GL_MODELVIEW);
// Compare current fill level of matrix stack with maximum level: We reserve five
// stack-slots for PTB internal use, so at least that needs to be free before push.
glGetIntegerv(GL_MODELVIEW_STACK_DEPTH, &stack_cur);
if (stack_cur < 2) {
printf("\nCouldn't pop matrix from top of OpenGL-Modelview matrix stack, because matrix stack is empty! The most common reason is\n");
printf("that you tried to call glPopMatrix more often than you called glPushMatrix -- Please check your code.\n");
PsychErrorExitMsg(PsychError_user, "Too many calls to glPopMatrix. Imbalance?!?");
}
// Execute pop operation:
glPopMatrix();
PsychTestForGLErrors();
//All psychfunctions require this.
return(PsychError_none);
}
开发者ID:AlanFreeman,项目名称:Psychtoolbox-3,代码行数:45,代码来源:SCREENglMatrixFunctionWrappers.c
示例14: SCREENTextFont
PsychError SCREENTextFont(void)
{
boolean doSetByName, doSetByNumber, foundFont;
PsychWindowRecordType *windowRecord;
PsychFontStructType *fontRecord;
int oldTextFontNumber, inputTextFontNumber;
char *oldTextFontName, *inputTextFontName;
//all subfunctions should have these two lines.
PsychPushHelp(useString, synopsisString, seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for valid number of arguments
PsychErrorExit(PsychRequireNumInputArgs(1));
PsychErrorExit(PsychCapNumInputArgs(2));
PsychErrorExit(PsychCapNumOutputArgs(2));
//Get the window record
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
//Save the old text size value and return it.
oldTextFontNumber=windowRecord->textAttributes.textFontNumber;
PsychCopyOutDoubleArg(2, FALSE, (double)oldTextFontNumber);
oldTextFontName=windowRecord->textAttributes.textFontName;
PsychCopyOutCharArg(1, FALSE, oldTextFontName);
//Fetch and set the new font if specified by name or number
PsychCheckInputArgType(2, kPsychArgOptional, PsychArgType_double | PsychArgType_char); //if the argument is there check that it is the right type.
doSetByNumber= PsychCopyInIntegerArg(2, kPsychArgAnything, &inputTextFontNumber);
doSetByName= PsychAllocInCharArg(2, kPsychArgAnything, &inputTextFontName);
foundFont=0;
if(doSetByNumber)
foundFont=PsychGetFontRecordFromFontNumber(inputTextFontNumber, &fontRecord);
if(doSetByName)
foundFont=PsychGetFontRecordFromFontFamilyNameAndFontStyle(inputTextFontName, windowRecord->textAttributes.textStyle, &fontRecord);
if(foundFont){
strncpy(windowRecord->textAttributes.textFontName, fontRecord->fontFMFamilyName, 255);
windowRecord->textAttributes.textFontNumber= fontRecord->fontNumber;
}
return(PsychError_none);
}
开发者ID:BackupTheBerlios,项目名称:osxptb-svn,代码行数:45,代码来源:SCREENTextFont.c
示例15: SCREENglScale
PsychError SCREENglScale(void)
{
// If you change useString then also change the corresponding synopsis string in ScreenSynopsis.c
static char useString[] = "Screen('glScale', windowPtr, sx, sy [, sz]);";
// 1 2 3 4
static char synopsisString[] = "Define a scale transform by (sx, sy, sz) in space, relative to the enclosing reference frame."
"See <http://www.opengl.org/documentation/red_book_1.0/> Chapter 4 for detailed information.";
static char seeAlsoString[] = "";
PsychWindowRecordType *windowRecord;
double sx, sy, sz;
// Default to non-scale, aka scale by 1.0:
sx=sy=sz=1.0f;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString,seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for superfluous arguments
PsychErrorExit(PsychCapNumInputArgs(4)); // The maximum number of inputs
PsychErrorExit(PsychRequireNumInputArgs(3)); // Number of required inputs.
PsychErrorExit(PsychCapNumOutputArgs(0)); // The maximum number of outputs
//get the window record from the window record argument and get info from the window record
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
// Fetch translation vector:
PsychCopyInDoubleArg(2, FALSE, &sx);
PsychCopyInDoubleArg(3, FALSE, &sy);
PsychCopyInDoubleArg(4, FALSE, &sz);
// Switch to windows OpenGL context:
PsychSetGLContext(windowRecord);
// Execute it:
glScaled(sx, sy, sz);
PsychTestForGLErrors();
//All psychfunctions require this.
return(PsychError_none);
}
开发者ID:AlanFreeman,项目名称:Psychtoolbox-3,代码行数:42,代码来源:SCREENglMatrixFunctionWrappers.c
示例16: SCREENTextMode
PsychError SCREENTextMode(void)
{
PsychTextDrawingModeType newCopyMode;
Str255 oldCopyModeName;
char *newCopyModeName;
psych_bool doSetMode;
PsychWindowRecordType *windowRecord;
psych_bool nameError;
//all subfunctions should have these two lines.
PsychPushHelp(useString, synopsisString, seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for valid number of arguments
PsychErrorExit(PsychRequireNumInputArgs(1));
PsychErrorExit(PsychCapNumInputArgs(2));
PsychErrorExit(PsychCapNumOutputArgs(1));
//Get the window record
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
//Get the old copy mode & its name
PsychGetTextDrawingModeNameFromTextDrawingModeConstant(oldCopyModeName, 255, windowRecord->textAttributes.textMode);
PsychCopyOutCharArg(1, FALSE, oldCopyModeName);
//Get the copy new mode string
doSetMode= PsychAllocInCharArg(2, FALSE, &newCopyModeName);
if(doSetMode){
nameError=PsychGetTextDrawingModeConstantFromTextDrawingModeName(&newCopyMode, newCopyModeName);
if(nameError)
PsychErrorExitMsg(PsychError_user, "Invalid text copy mode. See Screen('TextModes') for a list of allowable modes");
windowRecord->textAttributes.needsRebuild|=(windowRecord->textAttributes.textMode != newCopyMode) ? TRUE : FALSE;
windowRecord->textAttributes.textMode=newCopyMode;
}
return(PsychError_none);
}
开发者ID:BackupTheBerlios,项目名称:osxptb-svn,代码行数:38,代码来源:SCREENTextMode.c
示例17: SCREENGlobalRect
PsychError SCREENGlobalRect(void)
{
int screenNumber;
PsychWindowRecordType *windowRecord;
PsychRectType rect;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString,seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for superfluous arguments
PsychErrorExit(PsychCapNumInputArgs(1));
PsychErrorExit(PsychRequireNumInputArgs(1));
PsychErrorExit(PsychCapNumOutputArgs(1));
if(PsychIsScreenNumberArg(1)) {
// Real screen id: Get screens global rect and return it:
PsychCopyInScreenNumberArg(1, TRUE, &screenNumber);
PsychGetGlobalScreenRect(screenNumber, rect);
PsychCopyOutRectArg(1, FALSE, rect);
}
else if(PsychIsWindowIndexArg(1)) {
// Window:
PsychAllocInWindowRecordArg(1, TRUE, &windowRecord);
// Onscreen?
if (PsychIsOnscreenWindow(windowRecord)) {
PsychCopyOutRectArg(1, FALSE, windowRecord->globalrect);
}
else {
PsychCopyOutRectArg(1, FALSE, windowRecord->rect);
}
}
else PsychErrorExitMsg(PsychError_user, "Argument was recognized as neither a window index nor a screen pointer");
return(PsychError_none);
}
开发者ID:BackupTheBerlios,项目名称:osxptb-svn,代码行数:37,代码来源:SCREENGlobalRect.c
示例18: SCREENSetOpenGLTextureFromMemPointer
PsychError SCREENSetOpenGLTextureFromMemPointer(void)
{
PsychWindowRecordType *windowRecord, *textureRecord;
int w, h, d, testarg, upsidedown, glinternalformat, glexternaltype, glexternalformat;
double doubleMemPtr;
GLenum target = 0;
w=h=d=-1;
doubleMemPtr = 0;
upsidedown = 0;
//all subfunctions should have these two lines.
PsychPushHelp(useString, synopsisString, seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
PsychErrorExit(PsychCapNumInputArgs(11)); // The maximum number of inputs
PsychErrorExit(PsychRequireNumInputArgs(5)); // The required number of inputs
PsychErrorExit(PsychCapNumOutputArgs(2)); // The maximum number of outputs
// Get the window record from the window record argument and get info from the window record
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
// Get the texture record from the texture record argument.
// Check if either none ( [] or '' ) or the special value zero was
// provided as Psychtoolbox textureHandle. In that case, we create a new
// empty texture record instead of reusing an existing one.
testarg=0;
PsychCopyInIntegerArg(2, FALSE, &testarg);
if (testarg==0) {
// No valid textureHandle provided. Create a new empty textureRecord.
PsychCreateWindowRecord(&textureRecord);
textureRecord->windowType=kPsychTexture;
textureRecord->screenNumber = windowRecord->screenNumber;
textureRecord->targetSpecific.contextObject = windowRecord->targetSpecific.contextObject;
textureRecord->targetSpecific.deviceContext = windowRecord->targetSpecific.deviceContext;
textureRecord->targetSpecific.glusercontextObject = windowRecord->targetSpecific.glusercontextObject;
textureRecord->colorRange = windowRecord->colorRange;
// Copy imaging mode flags from parent:
textureRecord->imagingMode = windowRecord->imagingMode;
// Mark it valid and return handle to userspace:
PsychSetWindowRecordValid(textureRecord);
}
else {
// None of the special values provided. We assume its a handle to a valid
// and existing PTB texture and try to retrieve the textureRecord:
PsychAllocInWindowRecordArg(2, TRUE, &textureRecord);
}
// Is it a textureRecord?
if (!PsychIsTexture(textureRecord)) {
PsychErrorExitMsg(PsychError_user, "You tried to set texture information on something else than a texture!");
}
// Query double-encoded memory pointer:
PsychCopyInDoubleArg(3, TRUE, &doubleMemPtr);
// Query width:
PsychCopyInIntegerArg(4, TRUE, &w);
// Query height:
PsychCopyInIntegerArg(5, TRUE, &h);
// Query depth:
PsychCopyInIntegerArg(6, TRUE, &d);
// Query (optional) upsidedown - flag:
PsychCopyInIntegerArg(7, FALSE, &upsidedown);
// Query (optional) OpenGL texture target:
PsychCopyInIntegerArg(8, FALSE, (int*) &target);
// Query (optional) full format spec:
glinternalformat = 0;
PsychCopyInIntegerArg(9, FALSE, &glinternalformat);
if (glinternalformat>0) {
// Ok copy the (now non-optional) remaining format spec:
PsychCopyInIntegerArg(10, TRUE, &glexternalformat);
PsychCopyInIntegerArg(11, TRUE, &glexternaltype);
}
// Safety checks:
if (doubleMemPtr == 0) {
PsychErrorExitMsg(PsychError_user, "You tried to set invalid (NULL) imagePtr.");
}
if (w<=0) {
PsychErrorExitMsg(PsychError_user, "You tried to set invalid (negative) texture width.");
}
if (h<=0) {
PsychErrorExitMsg(PsychError_user, "You tried to set invalid (negative) texture height.");
}
if (d<=0) {
PsychErrorExitMsg(PsychError_user, "You tried to set invalid (negative) texture depth.");
}
if (d>4) {
PsychErrorExitMsg(PsychError_user, "You tried to set invalid (greater than four) texture depth.");
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:osxptb-svn,代码行数:101,代码来源:SCREENSetOpenGLTextureFromMemPointer.c
示例19: SCREENGetImage
PsychError SCREENGetImage(void)
{
PsychRectType windowRect,sampleRect;
int nrchannels, ix, iy, sampleRectWidth, sampleRectHeight, invertedY, redReturnIndex, greenReturnIndex, blueReturnIndex, alphaReturnIndex, planeSize;
int viewid;
ubyte *returnArrayBase, *redPlane, *greenPlane, *bluePlane, *alphaPlane;
float *dredPlane, *dgreenPlane, *dbluePlane, *dalphaPlane;
double *returnArrayBaseDouble;
PsychWindowRecordType *windowRecord;
GLboolean isDoubleBuffer, isStereo;
char* buffername = NULL;
boolean floatprecision = FALSE;
GLenum whichBuffer = 0;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString, seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//cap the numbers of inputs and outputs
PsychErrorExit(PsychCapNumInputArgs(5)); //The maximum number of inputs
PsychErrorExit(PsychCapNumOutputArgs(1)); //The maximum number of outputs
// Get windowRecord for this window:
PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord);
// Set window as drawingtarget: Even important if this binding is changed later on!
// We need to make sure all needed transitions are done - esp. in non-imaging mode,
// so backbuffer is in a useable state:
PsychSetDrawingTarget(windowRecord);
// Disable shaders:
PsychSetShader(windowRecord, 0);
// Soft-Reset drawingtarget. This is important to make sure no FBO's are bound,
// otherwise the following glGets for GL_DOUBLEBUFFER and GL_STEREO will retrieve
// wrong results, leading to totally wrong read buffer assignments down the road!!
PsychSetDrawingTarget(0x1);
glGetBooleanv(GL_DOUBLEBUFFER, &isDoubleBuffer);
glGetBooleanv(GL_STEREO, &isStereo);
// Retrieve optional read rectangle:
PsychGetRectFromWindowRecord(windowRect, windowRecord);
if(!PsychCopyInRectArg(2, FALSE, sampleRect)) memcpy(sampleRect, windowRect, sizeof(PsychRectType));
if (IsPsychRectEmpty(sampleRect)) return(PsychError_none);
// Assign read buffer:
if(PsychIsOnscreenWindow(windowRecord)) {
// Onscreen window: We read from the front- or front-left buffer by default.
// This works on single-buffered and double buffered contexts in a consistent fashion:
// Copy in optional override buffer name:
PsychAllocInCharArg(3, FALSE, &buffername);
// Override buffer name provided?
if (buffername) {
// Which one is it?
// "frontBuffer" is always a valid choice:
if (PsychMatch(buffername, "frontBuffer")) whichBuffer = GL_FRONT;
// Allow selection of left- or right front stereo buffer in stereo mode:
if (PsychMatch(buffername, "frontLeftBuffer") && isStereo) whichBuffer = GL_FRONT_LEFT;
if (PsychMatch(buffername, "frontRightBuffer") && isStereo) whichBuffer = GL_FRONT_R
|
请发表评论