All pastes #954186 Raw Edit

Stuff

public text v1 · immutable
#954186 ·published 2008-03-23 19:04 UTC
rendered paste body
// To Do List: 
// Add Shading

#include "stdafx.h"
#include <glut.h>
#include <GL/gl.h>

void display();
void init();

const int Width = 720;
const int Height = 480;


// prototype
void DisplayGrid(float MaxOrthoView, float MinOrthoView);


void main(int argc, char** argv)
{

	float MaxOrthoView = 720;
	float MinOrthoView = 480;

	DisplayGrid(MaxOrthoView, MinOrthoView);
	glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);

	glutInitWindowSize(Width,Height);

	glutInitWindowPosition(0,0);

	
	
	
	glutCreateWindow("NES");

	glutDisplayFunc(display);
	init();
	glutMainLoop();
	
			
	return;
}


void display()
{
	float linePos;
	int i;

	glClear(GL_COLOR_BUFFER_BIT);

/****************************/
//Light Grey Box
/****************************/
	glBegin(GL_POLYGON);

	glColor3f(.0,.0,.0); //4
	glVertex2f(-4.0,5.0);
	
	glColor3f(.0,.0,.0); //3
	glVertex2f(10.0,5.0);
	
	glColor3f(.68,.68,.68);	//2
	glVertex2f(10.0,-6.0);
	
	glColor3f(.68,.68,.68); //1
	glVertex2f(-4.0,-6.0);

	glEnd();
/****************************/
//Dark Grey Parrellgram thing
/****************************/
	glBegin(GL_POLYGON);

	glColor3f(.39,.39,.39);//4
	glVertex2f(-4.0,-6.0);
	
	glColor3f(.39,.39,.39);	//3
	glVertex2f(10.0,-6.0);
	
	glColor3f(.39,.39,.39);	//2	   
	glVertex2f(9.0,-8.0);
	
	glColor3f(.39,.39,.39);	//1
	glVertex2f(-3.0,-8.0);
	
	glEnd();


/****************************/
//Black Square #1
/****************************/
	glBegin(GL_POLYGON);

	glColor3f(0,0,0); //1	
	glVertex2f(5.,3.0);

	glColor3f(0,0,0); //2
	glVertex2f(7.,3.0);

	glColor3f(0,0,0); //3	
	glVertex2f(7.0,5.0);	

	glColor3f(0,0,0); //4
	glVertex2f(5.0,5.0);	

	
	glEnd();

/****************************/
//Black Square #2
/****************************/
	glBegin(GL_POLYGON);

	glColor3f(0,0,0); //1
	glVertex2f(5.0,-8.0);

	glColor3f(0,0,0); //2
	glVertex2f(7.0,-8.0);

	glColor3f(0,0,0);	//3
	glVertex2f(7.0,-2.0);
	
	glColor3f(0,0,0); //4
	glVertex2f(5.0,-2.0);
	
	glEnd();

/****************************/
//Button #1
/****************************/
	glBegin(GL_POLYGON);

	glColor3f(.35,.35,.35);
	glVertex2f(-2.0,-6.9);
	
	glColor3f(.35,.35,.35);	
	glVertex2f(-1.0,-6.9);
	
	glColor3f(.35,.35,.35);	
	glVertex2f(-1.0,-7.5);	
	
	glColor3f(.35,.35,.35);	
	glVertex2f(-2.0,-7.5);
	
	glEnd();


/****************************/
//Button #2
/****************************/
	glBegin(GL_POLYGON);

	glColor3f(.35,.35,.35);
	glVertex2f(-.7,-6.9);
	
	glColor3f(.35,.35,.35);	
	glVertex2f(.3,-6.9);
	
	glColor3f(.35,.35,.35);	
	glVertex2f(.3,-7.5);
		
	glColor3f(.35,.35,.35);	
	glVertex2f(-.7,-7.5);
	
	glEnd();


/****************************/
//Controller Slot #1
/****************************/
	glBegin(GL_POLYGON);

	glColor3f(.14,.14,.14);
	glVertex2f(5.3,-6.6);
	
	glColor3f(.14,.14,.14);	
	glVertex2f(5.8,-6.6);
	
	glColor3f(.14,.14,.14);	
	glVertex2f(5.8,-7.4);
		
	glColor3f(.14,.14,.14);	
	glVertex2f(5.3,-7.4);
	
	glEnd();


/****************************/
//Controller Slot #2
/****************************/
	glBegin(GL_POLYGON);

	glColor3f(.14,.14,.14);
	glVertex2f(6.2,-6.6);
	
	glColor3f(.14,.14,.14);	
	glVertex2f(6.7,-6.6);
	
	glColor3f(.14,.14,.14);	
	glVertex2f(6.7,-7.4);
		
	glColor3f(.14,.14,.14);	
	glVertex2f(6.2,-7.4);
	
	glEnd();

/****************************/
//Power LED Box
/****************************/
	glBegin(GL_POLYGON);

	glColor3f(0,0,0);
	glVertex2f(-2.4,-7.1);
	
	glColor3f(0,0,0);	
	glVertex2f(-2.2,-7.1);
	
	glColor3f(0,0,0);	
	glVertex2f(-2.2,-7.35);
		
	glColor3f(0,0,0);	
	glVertex2f(-2.4,-7.35);
	
	glEnd();


/****************************/
//Lines
/****************************/

	for(linePos = .25; linePos < 5; linePos += .3)
	{
		glBegin(GL_LINES);
	
			glVertex3f(5, linePos-2, 0);

			glVertex3f(7, linePos-2, 0);

			glEnd();

	}

glBegin(GL_LINES);

	glVertex2f(5, 4);
	glVertex2f(5, -2);

glEnd();

glBegin(GL_LINES);

	glVertex2f(7, 4);
	glVertex2f(7, -2);

glEnd();

/****************************/
//Cartridge Lines
/****************************/

glBegin(GL_LINES);

	glVertex2f(-3, -2.01);
	glVertex2f(5, -2.01);

glEnd();

glBegin(GL_LINES);

	glVertex2f(-3, -2);
	glVertex2f(-3, -4);

glEnd();

glBegin(GL_LINES);

    glColor3f(255,255,255);
	glVertex2f(-4, -4);
	glColor3f(255,255,255);
	glVertex2f(5, -4);

glEnd();

glBegin(GL_LINES);

    glColor3f(255,255,255);
	glVertex2f(7, -4);
	glColor3f(255,255,255);
	glVertex2f(10, -4);

glEnd();

glBegin(GL_LINES);

	glColor3f(0,0,0);
	glVertex2f(-3, -4);
	glVertex2f(-3, -5.3);

glEnd();

glBegin(GL_LINES);

	glVertex2f(-3, -5.3);
	glVertex2f(0, -5.3);

glEnd();

glBegin(GL_LINES);

	glVertex2f(0, -5.3);
	glVertex2f(5, -5.3);

glEnd();

/****************************/
//Stiple Lines 1 - Left Side Below
/****************************/

    glLineWidth(2);
	glEnable (GL_LINE_STIPPLE);
    glLineStipple (1, -3644);
    glBegin (GL_LINE_STRIP);
    
	for(i= 0; i < 2; i++)
	{
		glColor3f(255,0, 0);
		glVertex2f (-2.5 + (i * 5.0), -5.0);
	}
    
	glEnd();

/****************************/
//Stiple Lines 2 - Left Side Above
/****************************/

    glLineWidth(4);
	glEnable (GL_LINE_STIPPLE);
    glLineStipple (1, -3644);
    glBegin (GL_LINE_STRIP);
    
	for(i= 0; i < 2; i++)
	{
		glColor3f(255,0, 0);
		glVertex2f (-2.5 + (i * 3.0), -4.6);
	}
    
	glEnd();	
    
/****************************/
//Stiple Lines 3 - Left Button
/****************************/

    glLineWidth(1);
	glEnable (GL_LINE_STIPPLE);
    glLineStipple (1, -3644);
    glBegin (GL_LINE_STRIP);
    
	for(i= 0; i < 2; i++)
	{
		glColor3f(255,0, 0);
		glVertex2f (-1.9 + (i * 0.8), -7.25);
	}
    
	glEnd();


/****************************/
//Stiple Lines 4 - Right Button
/****************************/

    glLineWidth(1);
	glEnable (GL_LINE_STIPPLE);
    glLineStipple (1, -3644);
    glBegin (GL_LINE_STRIP);
    
	for(i= 0; i < 2; i++)
	{
		glColor3f(255,0, 0);
		glVertex2f (-0.6 + (i * 0.8), -7.25);
	}
    
	glEnd();




/****************************/
	glFlush();

	return;

}


void init()
{
	glClearColor(.7,0.7,0.7,0.0); //sets clear color to black, alpha opacity to see through
	glColor3f(1.0,1.0,1.0); //sets the fill color to white

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(-10.0,15.0,-10.0,10.0);


	return;

}


// function
void DisplayGrid(float MaxOrthoView, float MinOrthoView)
{
   // start points for verticle lines
   float PointAX = MinOrthoView;
   float PointAY = MinOrthoView;
   float PointBX = MinOrthoView;
   float PointBY = MaxOrthoView;

   // start points for horizontal lines
   float PointCX = MinOrthoView;
   float PointCY = MinOrthoView;
   float PointDX = MaxOrthoView;
   float PointDY = MinOrthoView;

   // incrament for for loop equal to the size of the grid
   int INC = MaxOrthoView + MaxOrthoView;
   
   glClear(GL_COLOR_BUFFER_BIT);
   
   // creates the verticle lines
   glBegin(GL_LINES);
   for( int i = 0; i < INC; i++)
   {
      glColor3f(1.0,1.0,1.0);
      glVertex2f(PointCX,PointCY);
      glColor3f(1.0,1.0,1.0);
      glVertex2f(PointDX,PointDY);
      
      PointCY++;
      PointDY++;
   }
   
   // creates the horizontal lines
   for( int i = 0; i < INC; i++)
   {
   
      glColor3f(1.0,1.0,1.0);
      glVertex2f(PointAX,PointAY);
      glColor3f(1.0,1.0,1.0);
      glVertex2f(PointBX,PointBY);
      
      PointAX++;
      PointBX++;
   }
   glEnd();
   return;
}