Beispiel #1
0
void init()
{
	Particles a = *(new Particles()); 
	glClearColor(0.5,0.5,0.5,1.0);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(45,640.0/480.0,1.0,500.0);
	//glFrustum(-10, 10, -10, 10, 10, 1000); 
	glMatrixMode(GL_MODELVIEW);
	glEnable(GL_DEPTH_TEST);
	cube=obj.load("temple.obj");	//load it
	glEnable(GL_NORMALIZE); 
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	//glEnable(GL_LIGHT1); 

	float col[]={1.0,1.0,1.0,1.0};
	float direction[] = {0, 0, 0}; 
	float pos[] = {1, 1, 1, 1}; 
	float color[] = {1, 0.5, 0.5, 1}; 
	
	glLightfv(GL_LIGHT0,GL_DIFFUSE,col);
	
	//glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, direction); 
	glLightfv(GL_LIGHT1, GL_DIFFUSE, color); 
	//glLightfv(GL_LIGHT1, GL_POSITION, pos); 
	glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 5 );
	for(int i =0; i < 1000; i++)
	{
		particles.push_back(new Particles()); 
	} 
	a.createParticles(particles); 
	particleTexture = obj.loadTexture("fire.bmp"); 	
}
void init(SDL_Surface* screen)
{
  glClearColor(0.5, 0.5, 0.5, 1.0);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(45, static_cast<float>(screen->w)/static_cast<float>(screen->h), 1.0, 500.0);
  glMatrixMode(GL_MODELVIEW);
  glShadeModel(GL_SMOOTH); // This is the default setting anyways.

  glEnable(GL_DEPTH_TEST);

  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);
  float lightcolor[] = {1.0, 1.0, 1.0, 1.0};
  glLightfv(GL_LIGHT0, GL_DIFFUSE, lightcolor);

  //glEnable(GL_BLEND);
  //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // (A*S) + (B*D)

  sky = new Skybox();
  sky->Init("img/skybox/");
  sky->Compile(50.0);

  cube = obj.load("model/obj/angrysphere.obj");
  cam = new Camera(0.0, 0.0, -5.0, 0.0, 0.0);

  return;
}
Beispiel #3
0
void init(SDL_Surface* screen)
{
  const unsigned char* version = glGetString(GL_VERSION);
  std::cout << "OpenGL version: " << version << std::endl;

  GLint maxTex;
  glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTex);
  std::cout << "Maximum texture units: " << maxTex << std::endl;

  glClearColor(0.0, 0.0, 0.0, 1.0);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(45, static_cast<float>(screen->w)/static_cast<float>(screen->h), 1.0, 500.0);
  glMatrixMode(GL_MODELVIEW);
  glShadeModel(GL_SMOOTH); // This is the default setting anyways.

  glEnable(GL_DEPTH_TEST);

  cam = new Camera(0.0, 0.0, 0.0, 0.0, 0.0);

  initShader("shader/lighting.vs", "shader/lighting.frag", prog, vert, frag);

  monkey = obj.load("model/obj/stapler.obj");

  return;
}
Beispiel #4
0
void init()
{
        glClearColor(0.5,0.5,0.5,1.0);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(45,640.0/480.0,1.0,500.0);
        glMatrixMode(GL_MODELVIEW);
        glEnable(GL_DEPTH_TEST);
        cube=obj.load("test.obj");      //load it
        glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);
        float col[]={1.0,1.0,1.0,1.0};
        glLightfv(GL_LIGHT0,GL_DIFFUSE,col);
}