Ejemplo n.º 1
0
//---------------------------描画------------------------------//
//左下が(0,0), 右上が(Nx,Ny)
void Solver::draw(Complex *p, Complex *q){
	double N = max(mField->getNx(),mField->getNy());
	double ws = 2.0*MAIN_WINDOW_X/WINDOW_W/N;
	double hs = 2.0*MAIN_WINDOW_H/WINDOW_H/N;
	for (int i = mField->getNpml(); i < mField->getNpx()-mField->getNpml(); i++){
		for (int j = mField->getNpml(); j < mField->getNpy()-mField->getNpml(); j++){
			int x = i-mField->getNpml();
			int y = j-mField->getNpml();
			Color c = color( norm(p[index(i,j)] + q[index(i,j)]) );
			//Color c = color(30.0*(p[index(i,j)].real() + q[index(i,j)].real()));
			glColor3d(c.red, c.green, c.blue);
			if(j==mField->getNpy()/2 || i==mField->getNpx()/2) glColor3d(1,1,1);
			
			glRectd(x*ws-1, y*hs-1, (x+1.0)*ws-1, (y+1.0)*hs-1);
				
		}
	}

	//draw_model();
}
Ejemplo n.º 2
0
void Graph::draw(){
//	glClear(GL_COLOR_BUFFER_BIT);
	glColor3d(10,10,10);		//背景を白で描画
	glRectd(-1,-1, 1,1);

	draw_axis();
	glLineWidth(1.0);
	vector<DataSet<double>>::iterator it;
	
	it = Solid.begin();

	while(it != Solid.end() ){
		draw_data((*it), true);
		it++;
	}

	it = Dash.begin();
	while(it != Dash.end() ){
		draw_data((*it), false);
		it++;

	}

}
Ejemplo n.º 3
0
void myUnitCube::draw()
{
	// XY parallel faces
	glPushMatrix();
	glTranslated(0, 0, 0.5);
	glRectd(-0.5, -0.5, 0.5, 0.5);
	glPopMatrix();

	glPushMatrix();
	glTranslated(0, 0, -0.5);
	glRectd(-0.5, 0.5, 0.5, -0.5);
	glPopMatrix();

	// XZ parallel faces
	glPushMatrix();
	glTranslated(0, 0.5, 0);
	glRotated(-90, 1, 0, 0);
	glRectd(-0.5, -0.5, 0.5, 0.5);
	glPopMatrix();

	glPushMatrix();
	glTranslated(0, -0.5, 0);
	glRotated(-90, 1, 0, 0);
	glRectd(-0.5, 0.5, 0.5, -0.5);
	glPopMatrix();

	// YZ parallel faces
	glPushMatrix();
	glTranslated(0.5, 0, 0);
	glRotated(-90, 0, 1, 0);
	glRectd(-0.5, 0.5, 0.5, -0.5);
	glPopMatrix();

	glPushMatrix();
	glTranslated(-0.5, 0, 0);
	glRotated(-90, 0, 1, 0);
	glRectd(-0.5, -0.5, 0.5, 0.5);
	glPopMatrix();
}
Ejemplo n.º 4
0
void Scene::drawOverlay()
{
    int width = glutGet( GLUT_WINDOW_WIDTH );
    int height = glutGet( GLUT_WINDOW_HEIGHT ) / 5;

    glViewport( 0, 0, width, height );

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    gluOrtho2D( 0.0, width, 0.0, height );

    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    gluLookAt( 0.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0 );

    glDisable( GL_LIGHTING );
    glDisable( GL_DEPTH_TEST );
    glEnable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

    glPushMatrix();

    glColor4f( 0.1, 0.5, 0.1, 0.3 );
    glRectd( 0, 0, width, height );

	glPushMatrix();
	glTranslatef( 1.0 * width / 50.0, 1.0 * height / 50.0, 0.0 );
    _powerBar.setWidth( 4.0 * width / 50.0 );
    _powerBar.setHeight( 48.0 * height / 50.0 );
    _powerBar.setPower( _playerTank.getPower() );
    _powerBar.draw();
	glPopMatrix();

	glPushMatrix();
	glTranslatef( 6.0 * width / 50.0, 1.0 * height / 50.0, 0.0 );
    _azimuthBar.setWidth( 8.0 * width / 50.0 );
    _azimuthBar.setHeight( 48.0 * height / 50.0 );
    _azimuthBar.setAzimuth( _playerTank.getAzimuth() );
    _azimuthBar.draw();
	glPopMatrix();

	glPushMatrix();
    glTranslatef( 15 * width / 50.0, 1.0 * height / 50.0, 0.0 );
    _elevationBar.setWidth( 8.0 * width / 50.0 );
    _elevationBar.setHeight( 48.0 * height / 50.0 );
    _elevationBar.setElevation( _playerTank.getElevation() );
    _elevationBar.draw();
	glPopMatrix();

	glPushMatrix();
	glTranslatef( 25.0 * width / 50.0, 1.0 * height / 50.0, 0.0 );
	_gameStateInfo.setWidth( 12.0 * width / 50.0 );
	_gameStateInfo.setHeight( 48.0 * height / 50.0 );
	_gameStateInfo.setTime(_secondsPlayed);
	_gameStateInfo.setHealth(_playerTank.getHealth());
	_gameStateInfo.setLevelNr(_levelNr);
	_gameStateInfo.setKills(_nrKills);
	_gameStateInfo.setDeaths(_nrDeaths);
	_gameStateInfo.setKillsToWin(getNrKillsToWin());
	_gameStateInfo.setDeathsToLose(getNrDeathsToLose());
	_gameStateInfo.setUpdateTime(_updateTime);
	_gameStateInfo.draw();
	glPopMatrix();

    glPopMatrix();
}
Ejemplo n.º 5
0
void display () {

	if (wireframe) {
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
	}

	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glEnable(GL_BLEND);
	glEnable(GL_DEPTH_TEST);

	// Clear the screen
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	enter3D();

	gluLookAt(camera.x, camera.y, camera.z,
			  cameraLookAt.x, cameraLookAt.y, cameraLookAt.z,
			  cameraUp.x, cameraUp.y, cameraUp.z);

	glPushMatrix();
	glScaled(1.0, -1.0, 1.0);

	if (showSky) {
		drawSky();
	}

	// Draw coordinate axis
	// glCallList(axisList);

	for (int i = 0; i < 9; i ++) {
		gravitationalForce[i].draw();
	}

	if (showGround) {
		drawGround();
	}

	if (showPipe) {
		glPushMatrix();
			drawSprinkler(emitterSpacing * emitterCount, sprinkerHeight, 100, 5.0, 40.0);
		glPopMatrix();
	}

	if (showMountains) {
		drawMoutains(3000, 0, 0);
		drawMoutains(4000, 180, -200);
		drawMoutains(5600, 45, -500);
	}

	if (showTrees) {
		drawTrees();
	}

	if (renderMode == PARTICLERENDERMODE_TEXTURESPRITE) {
		Texture::set("shine");
		glBlendFunc(GL_SRC_ALPHA, GL_ONE);
	}

	particleSystem.draw();

	if (renderMode == PARTICLERENDERMODE_TEXTURESPRITE) {
		Texture::done();
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	}

	/*glPushMatrix();
	glColor3f(1.0, 1.0, 1.0);
	glTranslatef(0.0, -100.0, 0.0);
	glScalef(100.0, -100.0, 100.0);
	drawModel();
	glPopMatrix();*/

	if (wireframe) {
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	}

	glDisable(GL_DEPTH_TEST);
	enter2D();

	glColor4d(0.0, 0.0, 0.0, 1.0);
	sprintf(fpsText, "FPS:%4.2f", fps);
	drawText(GLUT_BITMAP_HELVETICA_18, windowWidth - 100, 20, fpsText);

	if (showHUD) {

		drawText(GLUT_BITMAP_HELVETICA_18, 10, 20, "Water sprinkler");

		sprintf(cameraText, "%4.2f %4.2f %4.2f", camera.x, camera.y, camera.z);
		drawText(GLUT_BITMAP_HELVETICA_12, 10, 60, cameraText);

		sprintf(particleText, "Particles: %llu", particleSystem.getParticleCount());
		drawText(GLUT_BITMAP_HELVETICA_12, 10, 100, particleText);

		if (menu) {

			// Current option
			glColor4d(0.2, 0.2, 0.2, 0.8);
			glRectd(10, windowHeight - 40, 120, windowHeight - 10);
			glColor4d(1.0, 1.0, 1.0, 1.0);
			drawText(GLUT_BITMAP_HELVETICA_12, 20, windowHeight - 20, options[currentOption]);

			// Current option value
			glColor4d(0.4, 0.4, 0.4, 0.8);
			glRectd(120, windowHeight - 40, 240, windowHeight - 10);
			glColor4d(1.0, 1.0, 1.0, 1.0);

			switch (currentOption) {
			case 0: sprintf(optionValue, "%4.2f", Particle::initialVelocity); break;
			case 1: sprintf(optionValue, "%d", initialColour); break;
			case 2: sprintf(optionValue, "%d", gravityIntensity); break;
			case 3: sprintf(optionValue, "%d", Particle::startLifeSpan); break;
			case 4: sprintf(optionValue, "%s", renderModes[renderMode]); break;
			case 5: sprintf(optionValue, "%d", emitterCount); break;
			case 6: sprintf(optionValue, "%d", emitterSpacing); break;
			case 7: sprintf(optionValue, "%s", cameras[currentCamera]); break;
			case 8: sprintf(optionValue, "%4.2f", Particle::airResistance); break;
			case 9: sprintf(optionValue, "%s", cycleColours ? "On" : "Off"); break;
			case 10: sprintf(optionValue, "%d", emitFrequency); break;
			case 11: sprintf(optionValue, "%4.2f", ParticleEmitter::emitSpread); break;
			case 12: sprintf(optionValue, "%d", ParticleSystem::perEmit); break;
			case 13: sprintf(optionValue, "%s", ParticleEmitter::show ? "Yes" : "No"); break;
			case 14: sprintf(optionValue, "%s", wireframe ? "Yes" : "No"); break;
			case 15: sprintf(optionValue, "%s", showMountains ? "On" : "Off"); break;
			case 16: sprintf(optionValue, "%s", showTrees ? "On" : "Off"); break;
			case 17: sprintf(optionValue, "%s", showSky ? "On" : "Off"); break;
			case 18: sprintf(optionValue, "%s", showGround ? "On" : "Off"); break;
			case 19: sprintf(optionValue, "%s", demos[demo]->name.c_str()); break;
			case 20: sprintf(optionValue, "%1.1f", Particle::bounce); break;
			case 21: sprintf(optionValue, "%s", skyTexture ? "On" : "Off"); break;
			case 22: sprintf(optionValue, "%s", grassTexture ? "On" : "Off"); break;
			case 23: sprintf(optionValue, "%s", showPipe ? "On" : "Off"); break;
			case 24: sprintf(optionValue, "%s", ParticleEmitter::randomness ? "On" : "Off"); break;
			case 25: sprintf(optionValue, "%s", Tree::drawLeaves ? "On" : "Off"); break;
			default: sprintf(optionValue, "%s", ""); break;
			}

			drawText(GLUT_BITMAP_HELVETICA_12, 130, windowHeight - 20, optionValue);

		}
		else {
			glColor4d(1.0, 1.0, 1.0, 1.0);
			drawText(GLUT_BITMAP_HELVETICA_12, 20, windowHeight - 20, "Press m to toggle menu");
		}

		for (int i = 1; i < 10; i++) {
			if (selectedGravitationalForce == i - 1) {
				glColor4d(1.0, 0.4, 0.4, 0.8);
			}
			else {
				glColor4d(0.4, 0.4, 1.0, 0.2);
			}
			glRectd(200 + ((i - 1) * 50), 10, 230 + ((i - 1) * 50), 40);
			glColor4d(0.0, 0.0, 0.0, 1.0);
			sprintf(n, "%d", i);
			drawText(GLUT_BITMAP_HELVETICA_18, 210 + ((i - 1) * 50), 30, n);
		}

	}

	if (currentCamera == 3) {
		glBegin(GL_LINES);
			glColor3d(0.8, 0.8, 0.8);
			glVertex2d((windowWidth / 2) - 30, windowHeight / 2);
			glVertex2d((windowWidth / 2) + 30, windowHeight / 2);
			glVertex2d(windowWidth / 2, (windowHeight / 2) - 30);
			glVertex2d(windowWidth / 2, (windowHeight / 2) + 30);
		glEnd();
	}

	glPopMatrix();

	glutSwapBuffers();
	glutPostRedisplay();
}
Ejemplo n.º 6
0
template< > inline void glRect< LDOUBL >			(LDOUBL x1,LDOUBL y1,LDOUBL x2, LDOUBL y2 )	{	glRectd((double)x1,(double)y1,(double)x2,(double)y2);	};
Ejemplo n.º 7
0
template< > inline void glRect< double >			(double x1,double y1,double x2, double y2 )	{	glRectd(x1,y1,x2,y2);	};
Ejemplo n.º 8
0
void myRubixCube::display_rotation()
{
    int i, j, k;
    double angle, disp = len + 0.2;

    if (direction) angle = -theta;
    else angle = theta;

    glPushMatrix();
    switch (axis.back())
    {
    case 0:
        for (i = 0; i<3; i++)
        {
            if (i != plane.back())
            {
                for (j = 0; j<3; j++)
                    for (k = 0; k<3; k++)
                        c[cubepos[i][j][k]].display();
            }
        }
        glRotated(angle, 1, 0, 0);
        for (j = 0; j<3; j++)
            for (k = 0; k<3; k++)
                c[cubepos[plane.back()][j][k]].display();
        break;
    case 1:
        for (j = 0; j<3; j++)
        {
            if (j != plane.back())
            {
                for (i = 0; i<3; i++)
                    for (k = 0; k<3; k++)
                        c[cubepos[i][j][k]].display();
            }
        }
        glRotated(angle, 0, 1, 0);
        for (i = 0; i<3; i++)
            for (k = 0; k<3; k++)
                c[cubepos[i][plane.back()][k]].display();
        break;
    case 2:
        for (k = 0; k<3; k++)
        {
            if (k != plane.back())
            {
                for (i = 0; i<3; i++)
                    for (j = 0; j<3; j++)
                        c[cubepos[i][j][k]].display();
            }
        }
        glRotated(angle, 0, 0, 1);
        for (i = 0; i<3; i++)
            for (j = 0; j<3; j++)
                c[cubepos[i][j][plane.back()]].display();
        break;
    }
    if (axis.back() == 0)
    {
        if (plane.back() == 0) glTranslated(-disp, 0, 0);
        else if (plane.back() == 2) glTranslated(disp, 0, 0);
        glRotatef(90, 0, 1, 0);
    }
    else if (axis.back() == 1)
    {
        if (plane.back() == 0) glTranslated(0, -disp, 0);
        else if (plane.back() == 2) glTranslated(0, disp, 0);
        glRotatef(90, 1, 0, 0);
    }
    else
    {
        if (plane.back() == 0) glTranslated(0, 0, disp);
        else if (plane.back() == 2) glTranslated(0, 0, -disp);
    }
    glColor4f(1, 1, 1, 0.3);
    glRectd(-(len*2.25), -(len*2.25), (len*2.25), (len*2.25));
    glPopMatrix();
}
Ejemplo n.º 9
0
/***********************************************
 head = heading of head, ship = ships heading
***********************************************/
void DrawHeadingIndicator(float head, float ship)
{
    int s = 190;
  glPushMatrix();

    glDisable(GL_DEPTH_TEST);
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_CULL_FACE);
    glDisable(GL_LIGHTING);
    gGraphics.SetProjection(GRAPHICS_ORTHO);
    glLoadIdentity();

    //black panel display
    glRectd(160,440,620,500);

    //icons
    
    glBegin(GL_LINES);
      //eyeball
      glColor3f(1,1,0);
      glVertex2f(s,460);
      glVertex2f(s + 5,455);
      glVertex2f(s + 5,455);
      glVertex2f(s + 15,455);  
      glVertex2f(s + 15,455);
      glVertex2f(s + 20,460);
      glVertex2f(s + 20,460);
      glVertex2f(s + 15,465);
      glVertex2f(s + 15,465);
      glVertex2f(s + 5,465);
      glVertex2f(s + 5,465);
      glVertex2f(s,460);
      glVertex2f(s + 8,455);
      glVertex2f(s + 8,462);
      glVertex2f(s + 8,462);
      glVertex2f(s + 12,462);
      glVertex2f(s + 12,462);
      glVertex2f(s + 12,455);    
      
      //spaceship
      glColor3f(1,1,1);
      glVertex2f(s,480);
      glVertex2f(s,495);
      glVertex2f(s,495);
      glVertex2f(s + 20,495);
      glVertex2f(s + 20,495);
      glVertex2f(s + 12,487);
      glVertex2f(s + 12,487);
      glVertex2f(s + 5,487);
      glVertex2f(s + 5,487);
      glVertex2f(s,480);
    glEnd();

    //draws markers
    glBegin(GL_LINES);
    
      //ship heading
      glColor3f(1,1,1);
      if (ship < 181)
      {
        glVertex2f(s + 210 + ( 160 * ship / 180 ), 478);
        glVertex2f(s + 210 + ( 160 * ship / 180), 497);
      }
     else 
      {
        glVertex2f(s + 50 + ( 160 * (ship - 180) / 180 ), 478);
        glVertex2f(s + 50 + ( 160 * (ship - 180) / 180 ), 497);
      }
 
      //head heading...look around
      glColor3f(1,1,0);
      if (head < 181)
      {
        glVertex2f(s + 210 + ( 160 * head / 180 ), 453);
        glVertex2f(s + 210 + ( 160 * head / 180), 472);
      }
     else 
      {
        glVertex2f(s + 50 + ( 160 * (head - 180) / 180 ), 453);
        glVertex2f(s + 50 + ( 160 * (head - 180) / 180 ), 472);
      }
    glEnd();

    //prints reference marks
    glColor3f(1,1,1);
    gGraphics.DrawText2D(s + 35,440,10, "180");
    gGraphics.DrawText2D(s + 115,440,10, "270");
    gGraphics.DrawText2D(s + 195,440,10, "000");
    gGraphics.DrawText2D(s + 275,440,10, "090");
    gGraphics.DrawText2D(s + 355,440,10, "180");


    //gun sights
    s += 40;
    glColor3f(1,1,0);
    glBegin(GL_LINES);
      glVertex2f(s + 170,293); //crosshair - vert line
      glVertex2f(s + 170,307);
      glVertex2f(s + 163,300); //crosshair - horiz line
      glVertex2f(s + 177,300);   
      glVertex2f(s + 160,290); //inner box
      glVertex2f(s + 180,290);
      glVertex2f(s + 180,290);
      glVertex2f(s + 180,310);
      glVertex2f(s + 180,310);
      glVertex2f(s + 160,310);
      glVertex2f(s + 160,310);
      glVertex2f(s + 160,290); 
    
    glEnd();

    gGraphics.ResetProjection(GRAPHICS_ORTHO);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_CULL_FACE);
    glEnable(GL_LIGHTING);

  glPopMatrix();





}
Ejemplo n.º 10
0
PsychError SCREENFrameRect(void)  
{
	
	PsychColorType					color;
	PsychRectType					rect;
	PsychWindowRecordType			*windowRecord;
	int								whiteValue;
	psych_bool							isArgThere;
	double							penSize, lf, fudge;
	GLdouble						dVals[4]; 
    double							*xy, *colors, *penSizes;
	unsigned char					*bytecolors;
	int								numRects, i, j, nc, mc, nrsize;

	//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(PsychCapNumOutputArgs(0));  //The maximum number of outputs

	// Get tweakable correction factor for framerect:
	lf = PsychPrefStateGet_FrameRectCorrection();

	//get the window record from the window record argument and get info from the window record
	PsychAllocInWindowRecordArg(1, kPsychArgRequired, &windowRecord);
	
	// Query, allocate and copy in all vectors...
	numRects = 4;
	nrsize = 0;
	colors = NULL;
	bytecolors = NULL;
	penSizes = NULL;
	
	// The negative position -3 means: xy coords are expected at position 3, but they are optional.
	// NULL means - don't want a size's vector.
	PsychPrepareRenderBatch(windowRecord, -3, &numRects, &xy, 2, &nc, &mc, &colors, &bytecolors, 4, &nrsize, &penSizes);

	// Default rect is fullscreen:
	PsychCopyRect(rect, windowRecord->rect);

	// Only up to one rect provided?
	if (numRects <= 1) {
		// Get the rect and draw it
		isArgThere=PsychCopyInRectArg(kPsychUseDefaultArgPosition, FALSE, rect);	
		if (isArgThere && IsPsychRectEmpty(rect)) return(PsychError_none);
		numRects = 1;
	}

	// Pen size starts as "undefined", just to make sure it gets initially set:
	penSize = -DBL_MAX;
	
	// Framed rect drawing loop:
	for (i=0; i<numRects; i++) {
		// Multiple rects to draw or single iteration to draw provided rect?
		if (numRects > 1) {
			// Multi-Rect drawing: Assign next rect from array and setup corresponding
			// color and penSize...

			// Assign rect:
			rect[kPsychLeft] = xy[i*4 + 0];
			rect[kPsychTop] = xy[i*4 + 1];
			rect[kPsychRight] = xy[i*4 + 2];
			rect[kPsychBottom] = xy[i*4 + 3];

			// Per rect color provided?
			if (nc>1) {
				// Yes. Set color for this specific rect:
				PsychSetArrayColor(windowRecord, i, mc, colors, bytecolors);
			}
		}
		else {
			// Only one single rect to draw in this single loop iteration.
			// The rect is already set up in 'rect', and the drawing color has
			// been set as well by PsychPrepareRenderBatch(). penSize has been
			// set by that routine as well in penSizes[0], so we don't have
			// anything to do here...
			// NO OP.
		}
		
		j = (nrsize > 1) ? i : 0; 
		
		if (penSizes[j] != penSize) {
			penSize = penSizes[j];
			if (lf != -1) glLineWidth((GLfloat) penSize);
		}
		
		if (IsPsychRectEmpty(rect)) continue;

		if (lf == -1) {
			// New style rendering: More robust against variations in GPU implementations:
			fudge = penSize;
			glRectd(rect[kPsychLeft], rect[kPsychTop], rect[kPsychRight], rect[kPsychTop] + fudge);
			glRectd(rect[kPsychLeft], rect[kPsychBottom], rect[kPsychRight], rect[kPsychBottom] - fudge);
			glRectd(rect[kPsychLeft], rect[kPsychTop]+fudge, rect[kPsychLeft]+fudge, rect[kPsychBottom]-fudge);
			glRectd(rect[kPsychRight]-fudge, rect[kPsychTop]+fudge, rect[kPsychRight], rect[kPsychBottom]-fudge);
		}
		else {
			// Old style: Has a couple of problems in corner cases. Left for now as reference...
			if (penSize > 1) {
				// Width > 1
				
				fudge = (penSize > 1) ? lf * penSize/2 : 0.0;
				
				glBegin(GL_LINES);
				// Draw 4 separate segments, extend the left and right
				// vertical segments by half a penWidth.
				glVertex2d(rect[kPsychLeft], rect[kPsychTop] - fudge);
				glVertex2d(rect[kPsychLeft], rect[kPsychBottom] + fudge);
				glVertex2d(rect[kPsychRight], rect[kPsychTop]);
				glVertex2d(rect[kPsychLeft], rect[kPsychTop]);
				glVertex2d(rect[kPsychRight], rect[kPsychBottom] + fudge);
				glVertex2d(rect[kPsychRight], rect[kPsychTop] - fudge);
				glVertex2d(rect[kPsychRight], rect[kPsychBottom]);
				glVertex2d(rect[kPsychLeft], rect[kPsychBottom]);
				glEnd();			
			}
			else {
				// Width <= 1: Simple case...
				glBegin(GL_LINE_LOOP);
				glVertex2d(rect[kPsychLeft], rect[kPsychBottom]);
				glVertex2d(rect[kPsychLeft], rect[kPsychTop]);
				glVertex2d(rect[kPsychRight], rect[kPsychTop]);
				glVertex2d(rect[kPsychRight], rect[kPsychBottom]);
				glEnd();
			}
		}
		// Next rect...
	}
	
	// Need to reset line width?
	if (penSize!=1 && lf!=-1) glLineWidth(1);

	// Mark end of drawing op. This is needed for single buffered drawing:
	PsychFlushGL(windowRecord);

	return(PsychError_none);
}
Ejemplo n.º 11
0
M(void, glRectd, jdouble x1, jdouble y1, jdouble x2, jdouble y2) {
	glRectd(x1, y1, x2, y2);
}
/**************************************************************************//**
 * @author Daniel Andrus, Johnny Ackerman
 * 
 * @par Description:
 * Draws the background, the drawing grid, and the generator as the user draws
 * it. after it passes drawing control back to view
 *****************************************************************************/
void GeneratorView::draw()
{
	const static double grid_spacing = 32.0;

	// Draw background
	glColor3ub(255, 255, 255);
	glRectd(x, y, x+width, y+height);

	// Draw grid
	glColor3f(0.75, 0.75, 0.75);
	glBegin(GL_LINES);
	for (double i = grid_spacing; i < width; i += grid_spacing)
	{
		glVertex2d(x + i - 0.5, y);
		glVertex2d(x + i - 0.5, y + height);
	}
	for (double i = grid_spacing; i < height; i += grid_spacing)
	{
		glVertex2d(x, y + i - 0.5);
		glVertex2d(x + width, y + i - 0.5);
	}
	glEnd();
	
	// Draw border
	glBegin(GL_LINE_LOOP);
	{
		glVertex2d(x + 0.5, y + 0.5);
		glVertex2d(x + 0.5, y + height - 0.5);
		glVertex2d(x + width - 0.5, y + height - 0.5);
		glVertex2d(x + width - 0.5, y + 0.5);
	}
	glEnd();

	// Display every line in generator
	glColor3f(0.0, 0.0, 0.0);
	if (generator.size() > 1)
	{
		glBegin(GL_LINES);
		auto it1 = generator.begin();
		auto it2 = generator.begin();
		for (it2++; it2 != generator.end(); it1++, it2++)
		{
			glVertex2d(it1->x, it1->y);
			glVertex2d(it2->x, it2->y);
		}
		glEnd();
	}

	// Draw rubberband line
	if (leftButton)
	{
		glBegin(GL_LINES);
		glVertex2d(generator.back().x, generator.back().y);
		glVertex2d(endx, endy);
		glEnd();
	}


	//draw instuctions
	if(generator.size() == 0 )
	{
		View::instructions( "Click and drag to draw" );
	}

	View::draw();
}
Ejemplo n.º 13
0
/////////////////////////////////////////////////////////
// Render
//
void GEMglRectd :: render(GemState *state)
{
  glRectd (x1, y1, x2, y2);
}