예제 #1
0
void RendererGL::deleteBuffers()
{
	if(!isExtSupported(XGL_ARB_vertex_buffer_object))
		return;

	for (unsigned int id = 1; id < m_maxBufferID; ++id)
	{
		if( glIsBufferARB(id) )
			glDeleteBuffersARB( 1, &id );
	}
}
예제 #2
0
void RendererGL::prepareBufferedMesh(IndexedFaceSet* pMesh)
{
	if(!isExtSupported(XGL_ARB_vertex_buffer_object))
		return;
 /*   
	// Create a Vertex Buffer Object and an Element Buffer Object
	int sz = pMesh->getVertexCount();
    int nArrayObjectSize = (2* sizeof(Vector3) + sizeof(Vertex2D)) * pMesh->getVertexCount();
	char *pData = new char[nArrayObjectSize];
	memcpy(pData, pMesh->getVertices(), sizeof(Vector3)*sz);
	memcpy(&pData[sizeof(Vector3)*sz], pMesh->getNormals(), sizeof(Vector3)*sz);
	memcpy(&pData[2*sizeof(Vector3)*sz], pMesh->getTexCoords(), sizeof(Vertex2D)*sz);

    int nParam_ArrayObjectSize = 0;

	unsigned int id = 0;
    glGenBuffersARB( 1, &id );
	pMesh->setBufferID(id);
	m_maxBufferID = max(id, m_maxBufferID);

    glBindBufferARB( GL_ARRAY_BUFFER_ARB, id );
	glBufferDataARB( GL_ARRAY_BUFFER_ARB, nArrayObjectSize, pData, GL_STATIC_DRAW_ARB );

    glGetBufferParameterivARB( GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &nParam_ArrayObjectSize );

    if( nParam_ArrayObjectSize <= 0 )
        return;
    
    // Don't forget the Element Buffer Object to hold our quad's indices.
	nArrayObjectSize = sizeof(unsigned short) * pMesh->getIndexCount();
    nParam_ArrayObjectSize = 0;

    glGenBuffersARB( 1, &id );
	pMesh->setIndexBufferID(id);
	m_maxBufferID = max(id, m_maxBufferID);

    glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, id );
    glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, nArrayObjectSize, pMesh->getIndices(), GL_STATIC_DRAW_ARB );

    glGetBufferParameterivARB( GL_ELEMENT_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &nParam_ArrayObjectSize );

    if( nParam_ArrayObjectSize <= 0 )
		return;

    glBindBufferARB( GL_ARRAY_BUFFER_ARB, NULL );
    glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, NULL );

	delete []pData;
*/
}
예제 #3
0
bool OGLInspector::PBOSupported()
{
	return isExtSupported("GL_ARB_pixel_buffer_object");
}
예제 #4
0
bool OGLInspector::ImagingSupported()
{
	return isExtSupported("GL_ARB_imaging");
}
예제 #5
0
파일: main.cpp 프로젝트: The-Aslan/Invasion
int main(int nArg, char** pArgs)
{
    int width, height;
    bool fullscreen;
    FILE* res = fopen("Config/resolution.txt", "r");
    if(!res)
    {
        fprintf(stderr, "Fichier resolution.txt introuvable\n");
        return -1;
    }

    char line[128];
    fgets(line, 128, res);
    width = atoi(line);
    fgets(line, 128, res);
    height = atoi(line);
    fgets(line, 128, res);

    if(!strnicmp(line, "true", 4))
        fullscreen = true;
    else
        fullscreen = false;

    fclose(res);

    cxt = new invContext(width, height, fullscreen);
	game.setWindowResolution(width, height);

	// Init Context
	if(!cxt->create("Invasion", s_vfs->iconsandcursors("icons/icone.ico")))
	{
		fprintf(stderr, "Could not create the context\n");
		return -1;
	}

	glewInit();
	// extensions
	if(isExtSupported("GL_ARB_vertex_buffer_object"))
	{
		printf("VBO supported\n");
	}
	cxt->setBackground(0.f, 0.f, 0.1f);
	cxt->setFocus(false);

	// Cursor

	// Init Camera
	cam.init(cxt->width, cxt->height, 55.f);
	cam.setPos(Vec3f(0.f, 10.f, 10.f));

	// Define Flow
	flow.compensator = 0; // COMPENSATION;
	flow.setElapsedTime(&elapsedTime);

	flow.add(&flow.always, "checkEvent", &checkEvent);
	flow.add(&flow.always, "picking", &picking_system);
	flow.add(&flow.always, "move", &move);
	flow.add(&flow.always, "draw", &draw);

	// Load infos and models
	game.initScriptEngine();

	// init shaders
	// sh.load("vertex.vsh", "fragment.fsh");
	initLight();

	// launch timer
	before = cxt->secs();

	// run the main script
	game.circle = loadTexture(s_vfs->texture("circle.png"));
	game.runScripts();

	// V-Sync
	glPointSize(4.f);

	//------------------------------------------------
	// Launch the game
	//------------------------------------------------
	flow.loop();

	// Release circle texture
	glDeleteTextures(1, &game.circle);

	// unload the shaders
	// sh.unload();

	// Destroy the context
	cxt->destroy();
	delete cxt;

	// finish success
	return 0;
}