示例#1
0
GLvoid NEHE17::InitGL(){
	if(!LoadGLTextures("NeheGL/img/Font.bmp", 0)){
        cout<<"Fail to load font texture"<<endl;
    }
	
	if(!LoadGLTextures("NeheGL/img/Bumps.bmp", 1)){
        cout<<"Fail to load bumps texture"<<endl;
    }
	
	buildFont();
	
	// Enable Texture Mapping
	glEnable(GL_TEXTURE_2D);
	
	// Enables Smooth Shading
	glShadeModel(GL_SMOOTH);
	
	// clear background as black
	glClearColor(0.0f,0.0f,0.0f,0.0f);
	
	glClearDepth(1.0f);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	
	// want the best perspective correction to be done
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
	
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);	// Select The Type Of Blending
	
}
示例#2
0
/* general OpenGL initialization function */
int initGL( GLvoid )
{

    /* Enable smooth shading */
    glShadeModel( GL_SMOOTH );

    /* Set the background black */
    glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );

    /* Depth buffer setup */
    glClearDepth( 1.0f );

    #if 0
    /* Enables Depth Testing */
    glEnable( GL_DEPTH_TEST );

    /* The Type Of Depth Test To Do */
    glDepthFunc( GL_LEQUAL );
    #endif

    glLineWidth(.5);

    /* Really Nice Perspective Calculations */
    glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );

    buildFont( );
    return( TRUE );
}
bool MainWindow::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: buildPalette(); break;
    case 1: buildFont(); break;
    case 2: tunePalette(); break;
    case 3: paletteSelected((int)static_QUType_int.get(_o+1)); break;
    case 4: styleSelected((const QString&)static_QUType_QString.get(_o+1)); break;
    case 5: familySelected((const QString&)static_QUType_QString.get(_o+1)); break;
    case 6: substituteSelected((const QString&)static_QUType_QString.get(_o+1)); break;
    case 7: removeSubstitute(); break;
    case 8: addSubstitute(); break;
    case 9: downSubstitute(); break;
    case 10: upSubstitute(); break;
    case 11: removeLibpath(); break;
    case 12: addLibpath(); break;
    case 13: downLibpath(); break;
    case 14: upLibpath(); break;
    case 15: browseLibpath(); break;
    case 16: removeFontpath(); break;
    case 17: addFontpath(); break;
    case 18: downFontpath(); break;
    case 19: upFontpath(); break;
    case 20: browseFontpath(); break;
    case 21: fileSave(); break;
    case 22: fileExit(); break;
    case 23: somethingModified(); break;
    case 24: helpAbout(); break;
    case 25: helpAboutQt(); break;
    case 26: pageChanged((QWidget*)static_QUType_ptr.get(_o+1)); break;
    default:
	return MainWindowBase::qt_invoke( _id, _o );
    }
    return TRUE;
}
示例#4
0
void MainWindow::familySelected(const QString &family)
{
    QFontDatabase db;
    QStringList styles = db.styles(family);
    ui->fontStyleCombo->clear();
    ui->fontStyleCombo->addItems(styles);
    ui->familySubstitutionCombo->addItem(family);
    buildFont();
}
示例#5
0
void MainWindow::familySelected(const QString &family)
{
    QFontDatabase db;
    QStringList styles = db.styles(family);
    stylecombo->clear();
    stylecombo->insertStringList(styles);
    familysubcombo->insertItem(family);
    buildFont();
}
示例#6
0
void MyGLWidget::initializeGL()
{
    loadGLTexture();
    buildFont();                                                // Build The Font
    glClearColor (0.0f, 0.0f, 0.0f, 0.5f);						// Black Background
    glClearDepth(1.0);                                          // 设置深度缓存
    glDepthFunc(GL_LEQUAL);                                     // 所作深度测试的类型
    glBlendFunc(GL_SRC_ALPHA,GL_ONE);                           // 设置混合因子
    glShadeModel (GL_SMOOTH);									// Select Smooth Shading
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);			// Set Perspective Calculations To Most Accurate
}
bool Font::initialize(const char *filename){
    font = loadTexture(filename);

    if(font == 0)
    {
        logError("Could't Load Font");
        return false;
    }

    buildFont();
    if(list == 0){
        logError("Could't load the display list for the font %s %s",filename,SDL_GetError());
        return false;
    }

    return true;
}
示例#8
0
void Sample_17::initGL()
{
	glPushAttrib(GL_ALL_ATTRIB_BITS);
	// set here server attributes (states)

    /* Enable smooth shading */
    glShadeModel( GL_SMOOTH );

    /* Set the background black */
    glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );

    /* Depth buffer setup */
    glClearDepth( 1.0f );

    /* The Type Of Depth Test To Do */
    glDepthFunc( GL_LEQUAL );

    /* Select The Type Of Blending */
    glBlendFunc( GL_SRC_ALPHA, GL_ONE );

    /* Enable 2D Texture Mapping */
    glEnable( GL_TEXTURE_2D );

	glPushClientAttrib(GL_ALL_CLIENT_ATTRIB_BITS);
	// set here client attributes (states)

	// Build All The Textures
	glBindTexture(GL_TEXTURE_2D, m_texture[TEX_1]);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
	glTexImage2D(GL_TEXTURE_2D, 0, 3, m_imageFont.sizeY(), m_imageFont.sizeY(), 0, GL_RGB,
			GL_UNSIGNED_BYTE, m_imageFont.data() );

	glBindTexture(GL_TEXTURE_2D, m_texture[TEX_2]);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
	glTexImage2D(GL_TEXTURE_2D, 0, 3, m_imagePict.sizeY(), m_imagePict.sizeY(), 0, GL_RGB,
			GL_UNSIGNED_BYTE, m_imagePict.data() );

	buildFont();
}
示例#9
0
static void setup_opengl( int width, int height ) {
    float ratio = (float) width / (float) height;
    glShadeModel( GL_SMOOTH );
    glCullFace( GL_BACK );
    glFrontFace( GL_CCW );
    glEnable( GL_CULL_FACE );
    glEnable( GL_DEPTH_TEST );
    glClearColor( 0, 0, 0, 0 );
    glViewport( 0, 0, width, height );
    glMatrixMode( GL_PROJECTION );
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
    glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
    glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);
    glEnable(GL_LIGHT1);
    glLoadIdentity( );
    // TODO Replace this with a call to glFrustum.
    gluPerspective( 60.0, ratio, 1.0, 1024.0 );
    buildFont();
    return;
}
示例#10
0
int initGL(void) {
    int i;
    for (i = 0; i < SDLK_LAST; i++) keys[i] = FALSE;

//    if (!LoadTextures())
//        return FALSE;

    glEnable(GL_TEXTURE_2D);

    glShadeModel(GL_SMOOTH);

    glClearColor(0.1f, 0.17f, 0.12f, 0.0f);

    //glClearDepth(1.0f);

    //glEnable(GL_DEPTH_TEST);

    //glDepthFunc(GL_LEQUAL);

    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);

//    glColor4f(1.0f, 1.0f, 1.0f, 0.3f);
/*
    GLfloat LightAmbient[] = {0.5f, 0.5f, 0.5f, 1.0f}; // Значения фонового света
    GLfloat LightDiffuse[] = {1.0f, 1.0f, 1.0f, 1.0f}; // Значения диффузного света
    GLfloat LightPosition[] = {0.0f, 0.0f, 2.0f, 1.0f}; // Позиция света

    glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Установка Фонового Света
    glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Установка Диффузного Света
    glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); // Позиция света
    glEnable(GL_LIGHT1); // Разрешение источника света номер один
    glEnable(GL_LIGHTING); // Разрешить освещение
*/
    buildFont();
    return ( TRUE);
}
示例#11
0
	OnEvent(SpriteFont, evt_build) {
		buildFont();
	}
示例#12
0
 void init() {
   buildFont();
   resetObjects();                                           // Set Player / Enemy Starting Positions
   timerInit();
 }