예제 #1
0
int main(int argc, char *argv[])
{
    //  initialize the GLUT library.
    glutInit(&argc, argv);
    // set the display mode
    glutInitDisplayMode(GLUT_RGBA | GLUT_ALPHA | GLUT_DEPTH | GLUT_DOUBLE);
    // set the window size
    glutInitWindowSize(windowWidth, windowHeight);
    // creates a top-level window.
    glutCreateWindow("LengXuegang's Homework");
    // initialize the extension entry points
    GLenum error = glewInit();
    if (GLEW_OK != error)
    {
        fprintf(stderr, "Error: %s\n", glewGetErrorString(error));
        exit(-1);
    }

    FreeImage_Initialise(false);

    const char *version = FreeImage_GetVersion();
    fprintf(stdout, "version: %s", version);

    const char *copyright = FreeImage_GetCopyrightMessage();
    fprintf(stdout, "copyright: %s", copyright);

    initPrograms();

    GLint n = initVertex();
    if (n < 0)
    {
        fprintf(stderr, "init vertex failed");
        exit(-1);
    }

    GLint uModelMatrix = glGetUniformLocation(program->getProgramID(), "u_ModelMatrix");
    // GLint uMvpMatrix = glGetUniformLocation(program, "u_MvpMatrix");
    GLint uNormalMatrix = glGetUniformLocation(program->getProgramID(), "u_NormalMatrix");
    GLint uLightColor = glGetUniformLocation(program->getProgramID(), "u_LightColor");
    GLint uLightPosition = glGetUniformLocation(program->getProgramID(), "u_LightPosition");
    GLint uAmbientLight = glGetUniformLocation(program->getProgramID(), "u_AmbientLight");

    glUniform3f(uLightColor, 0.5, 0.9, 0.1);
    glUniform3f(uLightPosition, 1.0, 2.0, 3.0);
    glUniform3f(uAmbientLight, 0.6, 0.6, 0.6);

    // glUniformMatrix4fv(uModelMatrix, )
    // glUniformMatrix4fv(uNormalMatrix, )
    // sets the display callback for the current window.
    glutDisplayFunc(display);
    // sets the reshape callback for the current window.
    glutReshapeFunc(reshape);
    // sets the special keyboard callback for the current window.
    // glutSpecialFunc(specialKey);
    // enters the GLUT event processing loop.
    glutMainLoop();

    return 0;
}
예제 #2
0
파일: Field.cpp 프로젝트: didii/Minesweeper
// FIELD FUNCTIONS
void Field::create() {
	if (is_debugging)
		cout << "Calling Field::create()\n";
	addBombs();
	initNumbers();
	VA = sf::VertexArray(sf::Quads, 4*size.x*size.y);
	initVertex();
	makeRandomSpecial();
	m_state = INITIALIZED;
	cout << "Bombs left: " << no_bombs << endl;
}
예제 #3
0
int main(int argc, char const *argv[])
{
	FILE *file;
	int j = 0;
	vertexPtr rear = NULL;
	char target1[100], target2[100];
	char* buf = (char*)malloc(sizeof(char) * MAX_BUFFER);
	for (int i = 1; i < argc; ++i)
	{
		char* arg = argv[i];
		if ((file = fopen(arg, "r")) == NULL)
		{
			printf("Cannot open file %s!\n", argv[0]);
		}
		else
		{
			contPtr info = (contPtr)malloc(sizeof(struct contacts));
			info->name = arg;
			if (rear == NULL)
			{
				rear = initVertex(info);
			}

			while ((j = fgets(buf, MAX_BUFFER, file)) != NULL)
			{
				for (j = 0; buf[j] != '\n'; ++j);
				buf[j] = '\0';
				rear = addVertexRelationOnName(rear, arg, buf);
				//free(buf);
				buf = (char*)malloc(sizeof(char) * MAX_BUFFER);
			}
		}
	}
	while (1)
	{
		printf("Please input two target name:\n");
		scanf("%s%s", target1, target2);
		vertexPtr target = getVertexBasedOnName(rear, target2);
		if (target == NULL) 
		{
			printf("Don't has %s on the graph!\n", target2);
			break;
		}
		vertexPtr src = getVertexBasedOnName(rear, target1);
		if (src== NULL)
		{
			printf("Don't has %s on the graph!\n", target1);
			break;
		}
		bool e = DFS(src, target);
		if (e == FALSE)
		{
			printf("They don't have any relationship on the graph\n");
		}
		else
		{
			printf("\n");
		}
	}
	/* code */
	system("PAUSE");
	return 0;
}