Esempio n. 1
0
void GFXCore::Sprites::render(const int id, Textures& textures)
{
#if defined (_DEBUG) | defined(DEBUG)
	CHECK_OUT_OF_BOUNDS(id, (int)spriteList.size());
#endif

	HRESULT hr = pSprite->Draw(textures.getTexture(spriteList[id].nTextureId),
											spriteList[id].bHasClipRect == true ? &spriteList[id].clipRect : NULL,
											spriteList[id].bCenterIsTopLeft == true ? NULL : &spriteList[id].center,
											&spriteList[id].position,
											spriteList[id].color);

	if (FAILED(hr))
		ErrorMsg(L"Sprite Draw Failure!", L"Sprites::render()");
}
Esempio n. 2
0
void initGL() {	 	
	buildScene();

	glClearColor(0.0f,0.0f,0.0f,1.0);
    glEnable(GL_LIGHTING);
	globalOn = true;

	glEnable(GL_COLOR_MATERIAL);
	glMaterialf(GL_FRONT, GL_SHININESS, 0.1f);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_NORMALIZE);
	glShadeModel(GL_SMOOTH);

	// Viewport set up
    glViewport(0, 0, WIDTH, HEIGHT);  

	 // Light0
    glEnable(GL_LIGHT0);
    GLfloat d[]={1.0,1.0,1.0,1.0};
    glLightfv(GL_LIGHT0, GL_DIFFUSE, d);
    GLfloat a[]={0.3f,0.3f,0.3f,1.0};
    glLightfv(GL_LIGHT0, GL_AMBIENT, a);
	GLfloat p[]={25.0, 25.0, 0.0, 1.0};	 
	glLightfv(GL_LIGHT0, GL_POSITION, p);

	//Light2
	glEnable(GL_LIGHT2);
	GLfloat p2[]={1.0, 1.0, 0.0, 0.0};
	glLightfv(GL_LIGHT2, GL_POSITION, p2);
	GLfloat d2[]={1.0,1.0,1.0,1.0};
    glLightfv(GL_LIGHT2, GL_DIFFUSE, d2);
    GLfloat a2[]={0.3f,0.3f,0.3f,1.0};
    glLightfv(GL_LIGHT2, GL_AMBIENT, a2);

	//Niebla
	glEnable(GL_FOG);
	glFogi(GL_FOG_MODE, GL_LINEAR);
	GLfloat color[]={0.0f,0.0f,1.0f,0.0f};
	//glFogfv(GL_FOG_COLOR, color);
	//glFogf(GL_FOG_DENSITY, 0.5f);
	glFogi(GL_FOG_START, 20);
	glFogi(GL_FOG_END, 50);

	//Texturas
	unsigned int width;
	unsigned int height;
	unsigned char * data = loadBMPRaw("./bmp/madera.bmp", width, height);
	unsigned char * data2 = loadBMPRaw("./bmp/grass.bmp", width, height);
	cout<< width << endl;
	cout<< height << endl;

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, 0);


	//Textura mesa
	glBindTexture(GL_TEXTURE_2D, t.getTexture(0));
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);

	//Textura tapete
	glBindTexture(GL_TEXTURE_2D, t.getTexture(1));
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data2);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
 }