int InitGL(GLvoid)      // All setup for OpenGL goes here
{

    walltexture=LoadGLTexture( "C:\\Wall.bmp"); // Load BMP Images
	grasstexture=LoadGLTexture( "C:\\grass.bmp");
    darkgrasstexture=LoadGLTexture("C:\\Grass.bmp");
    roadtexture=LoadGLTexture("C:\\Road.bmp");



	glShadeModel(GL_SMOOTH);                // Enable smooth shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);   // Black background
	glClearDepth(1.0f);                     // Depth buffer setup
	glEnable(GL_DEPTH_TEST);                // Enables depth testing
	glDepthFunc(GL_LEQUAL);                 // The type of depth testing to do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);      // Really nice perspective calculations

    isClicked   = false;								            // Clicking The Mouse?
    isDragging  = false;

    WireframeMode();
    glEnable(GL_COLOR_MATERIAL);
    
	return true;                            // Initialization went OK
}
Beispiel #2
0
int main (int argc, char ** argv)
{

    GLenum type;
    
	glutInit(&argc, argv);
	glutInitWindowSize(1024,768);
	type = GLUT_RGB;
	type |= GLUT_DOUBLE;
	type |= GLUT_DEPTH;
    type |= GLUT_MULTISAMPLE;
	glutInitDisplayMode(type);
	glutCreateWindow("Project1");
    
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glEnable(GL_DEPTH_TEST);
	sun_2d=LoadGLTexture("sun.jpg");
    earth_2d=LoadGLTexture("earth_sphere.jpg");
	moon_2d=LoadGLTexture("moon.jpg"); 
	moon2_2d=LoadGLTexture("texture.jpg");
	mars_2d=LoadGLTexture("jupiter.jpg");
	glMatrixMode(GL_PROJECTION);
    gluPerspective(70, 1024/768, 0.1, 100);
    
    glMatrixMode(GL_MODELVIEW);
   
    timerCallback(0);
    glutDisplayFunc(Draw);
	
    glutMainLoop();
    // insert code here...
    std::cout << "Hello, World!\n";
    return 0;
}
Beispiel #3
0
bool OpenGLTest::Start()
{
    if (!LoadGLTexture())
        return false;

    VideoUpdate::GetWindow()->SetWindowResizeCallback(WindowResizeHandler);

    glEnable(GL_TEXTURE_2D);
    glShadeModel(GL_SMOOTH);
    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
    glClearDepth(1.0f);
    glDepthFunc(GL_LEQUAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    glEnable(GL_DEPTH_TEST);

    light1 = LightingManager::NewLight();
    light1->Ambient(Vector<4,float>(0.5f, 0.5f, 0.5f, 1.0f));
    light1->Diffuse(Vector<4,float>(1.0f, 1.0f, 1.0f, 1.0f));
    light1->Position(Vector<4,float>(0.0f, 0.0f, 2.0f, 1.0f));

    glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);

    light1->Enabled(true);

    return true;
}
Beispiel #4
0
void Model::reloadTextures()
{
    for ( int i = 0; i < m_numMaterials; i++ )
        if ( strlen( m_pMaterials[i].m_pTextureFilename ) > 0 )
            m_pMaterials[i].m_texture = LoadGLTexture( m_pMaterials[i].m_pTextureFilename );
        else
            m_pMaterials[i].m_texture = 0;
}
Beispiel #5
0
int InitGL(GLvoid)                              // All Setup For OpenGL Goes Here
{	
	srand(time(nullptr));

	if (!LoadGLTexture())                          // Jump To Texture Loading Routine ( NEW )
	{
		return FALSE;                           // If Texture Didn't Load Return FALSE ( NEW )
	}
	
	glewInit(); //bez tego shadery nie rusz¹!
	glEnable(GL_TEXTURE_2D);                        // Enable Texture Mapping ( NEW )
	glShadeModel(GL_SMOOTH);                        // Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);                   // Black Background
	glClearDepth(1.0f);                         // Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);                        // Enables Depth Testing
	glDepthFunc(GL_LEQUAL);                         // The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);          // Really Nice Perspective Calculations

	FBO = new Framebuffer(width,height);
	pingpong = new Framebuffer(width, height,2);

	const char** animacje = new const char*[7];
	animacje[0] = "Pliki/cyberdemon/idle.md5anim";
	animacje[1] = "Pliki/cyberdemon/walk3fix.md5anim";
	animacje[2] = "Pliki/sabaoth/move_start.md5anim";
	animacje[3] = "Pliki/ziemia/ziemia.md5anim";
	animacje[4] = "Pliki/maledict/inhell.md5anim";
	animacje[5] = "Pliki/vagary/walk3fix.md5anim";
	animacje[6] = "Pliki/maledict/inhell2.md5anim";

	ziemia.init("Pliki/ziemia/ziemia.md5mesh", animacje);
	potworbig.init("Pliki/maledict/maledict.md5mesh", animacje);
	potworsmall.init("Pliki/sabaoth/sabaoth.md5mesh", animacje);
	md5object.init("Pliki/cyberdemon/cyberdemonfix.md5mesh", animacje);
	sgup.init("Pliki/stargate/sg1.md5mesh",animacje);
	sgdown.init("Pliki/stargate/sg1empty.md5mesh",animacje);
	enemy.init("Pliki/vagary/vagary.md5mesh", animacje);
 skateboard.init("Pliki/skateboard/skateboard.md5mesh",animacje);

	podstawowy_shader = new Shader(
		"pliki/shaders/podstawowy.vert",
		"pliki/shaders/podstawowy.frag");
	blur_shader = new Shader(
		"pliki/shaders/blur.vert",
		"pliki/shaders/blur.frag");
	bright_shader = new Shader(
		"pliki/shaders/blur.vert",
		"pliki/shaders/bright.frag");
	blend_shader = new Shader(
		"pliki/shaders/blur.vert",
		"pliki/shaders/blend.frag");
	
	return TRUE;                                // Initialization Went OK
}
int main (int argc, char ** argv)
{


    GLenum type;
    
	glutInit(&argc, argv);

	glutInitWindowSize(1600,1200);
	type = GLUT_RGB;
	type |= GLUT_DOUBLE;
	type |= GLUT_DEPTH;
    type |= GLUT_MULTISAMPLE;
	glutInitDisplayMode(type);
	glutCreateWindow("Ders 2");
   
    glClearColor(0.0, 0, 0.0, 0);
    glEnable(GL_DEPTH_TEST);
	glEnable(GL_TEXTURE_2D);
    texture[0] = LoadGLTexture("sun_sphere.jpg");
    texture[1] = LoadGLTexture("earth_sphere.jpg");
    texture[2] = LoadGLTexture("moon_sphere.jpg");
    texture[3] = LoadGLTexture("mercury_sphere.bmp");
    
    glMatrixMode(GL_PROJECTION);
    gluPerspective(55, 1600/1200, 0.1, 100);
    
    glMatrixMode(GL_MODELVIEW);
    
    timerCallback(0);
	
    glutDisplayFunc(Draw);
	setupLight();
    glutMainLoop();
    return 0;
}
Beispiel #7
0
void Model::reloadTextures()
{
    //设置好了一切参数,但纹理还没有载入内存,下面的代码完成这个功能
	for ( int i = 0; i < m_numMaterials; i++ )
    {
        if ( strlen( m_pMaterials[i].m_pTextureFilename ) > 0 )
        {
            m_pMaterials[i].m_texture = LoadGLTexture( m_pMaterials[i].m_pTextureFilename );
        }
        else
        {
            m_pMaterials[i].m_texture = 0;
        }
    }
}
Beispiel #8
0
int initGL()						/*  All Setup For OpenGL Goes Here */
{
	glEnable(GL_TEXTURE_2D);				/*  Enable Texture Mapping */
	glShadeModel(GL_SMOOTH);				/*  Enable Smooth Shading */
	glClearColor(0.05f, 0.05f, 0.05f, 0.5f);		/*  Black Background */
	glClearDepth(1.0f);					/*  Depth Buffer Setup */
	glEnable(GL_DEPTH_TEST);				/*  Enables Depth Testing */
	glDepthFunc(GL_LEQUAL);					/*  The Type Of Depth Testing To Do */
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	/*  Really Nice Perspective Calculations */

	initBezier();						/*  Initialize the Bezier's control grid */
	LoadGLTexture(&(mybezier.texture), "./data/NeHe.bmp");	/*  Load the texture */
	mybezier.dlBPatch = genBezier(mybezier, divs);		/*  Generate the patch */

	resizeGLScene(GLWin.width, GLWin.height);
	glFlush();

	return True;						/*  Initialization Went OK */
}
Beispiel #9
0
int InitGL(GLvoid)                              // All Setup For OpenGL Goes Here
{
	if (!LoadGLTexture())                          // Jump To Texture Loading Routine ( NEW )
	{
		return FALSE;                           // If Texture Didn't Load Return FALSE ( NEW )
	}
	
	quadric = gluNewQuadric();
	glEnable(GL_TEXTURE_2D);                        // Enable Texture Mapping ( NEW )
	glShadeModel(GL_SMOOTH);                        // Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);                   // Black Background
	glClearDepth(1.0f);                         // Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);                        // Enables Depth Testing
	glDepthFunc(GL_LEQUAL);                         // The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);          // Really Nice Perspective Calculations

	glEnable(GL_FOG);
	setFog();

	
	
	
	return TRUE;                                // Initialization Went OK
}
Beispiel #10
0
void LoadGLTextures()
{
	for (int i = 0; i < SPHERE_COUNT; i++) {
		textures[i] = LoadGLTexture(texturePaths[i]);
    }
}