Fragen zu DisplayListen und anderen Performancesteigernden Maßnahmen.



  • Hi,
    ich hatte gestern schon einen Thread fertig geschrieben aber es dann doch nochmals selbst versucht...leider ohne Erfolg.

    Zuerst hoffe ich dass sich jemand die Mühe macht den Thread zu lesen, ist ja immerhin ein bisschen länger aber da ich momentan nicht mehr weiterkomme möchte ich natürlich auch dass ihr material zum Anschaun habt bzw. einen Einblick habt was ich mir überlegt habe etc.

    Als Beispiel habe ich ganz am ende mal mein Project gelinkt und eine Map die ihr laden könnt. Dann könnt ihr euch selbst ein Bild machen.

    http://www.bindig.net/dunno/Earth_ScreenShot.1.jpg <--screenshot

    Im Grunde dreht es sich um *.txt dateien die mir information für jedes Feld geben. Boni, Terraineigenschaften, Wald, Berge, usw.

    Meine erste Frage:
    Wenn keine der ecken des Tiles im Sichtfeld ist ist es natürlich blöd das Feld zu zeichen. Wie mache ich das? Ich habe die 3D->2D Übersetzung nicht umsetzen können. Kann mir hierfür bitte jemand Hilfestellung leisten?

    Und die Zweite:
    Sind displaylisten für sowas überhaupt geeignet?
    Ich habe bisher die Minimalversion laufen indem ich ein Quad ohne Textur in einer Displayliste habe. Diese rufe ich auf nachdem ich durch meinen Parsingcode die passenende Textur draufgeklebt habe und zur richtigen Stelle ge-Translatef-ed habe. (is nicht viel aber wahrscheinlich doch besser als garnichts????)
    Immerhin veringert es bei einer 100x100 Karte die Anzahl der OpenGL Befehle pro Paint vorgang von 520100 auf 130100. Leider merke ich da noch nichts an Performancesteigerung. Scheint wohl am for(0,100,++){for(0,100,++)} zu liegen.
    Das Compilieren einer Liste die alle Felder enthält dauert an die 3 Minuten.
    Kann das sein? Habe mal die nehe Tuts durchgeschaut und ähnliche loops erstellt. Dort dauert eine loop von 100^2 feldern vielleicht 4-5 Sekunden. Allerdings steckt in den loops auch nicht so ein riesiger Parsingcode wie bei mir.

    Und die dritte(n): ;P
    Welche Vorschläge habt ihr sonstnoch? Was kann man sonst noch drehen damits flotter läuft? Was mache ich falsch, was richtig?

    http://www.bindig.net/MapView/MapView.0.1.4.469.zip <--programm
    http://forums.civfanatics.com/attachment.php?attachmentid=101946&d=1130518610 <-- eine karte, nen text sourcefile mit der das prog gefüttert werden will.

    http://forums.civfanatics.com/showthread.php?t=141622 <--- der thread dazu (falls es jemanden interessiert)

    Anmerkungen:

    glTranslatef(0,0,0.0004);
    glCallList(dspl_tile);
    glTranslatef(0,0,-0.0004);
    

    Ich weiss dass das wohl blöd ist aber es funktioniert. wenn ich 0.1 nehmen würde hätte ich perspektivische verzerrungen zwischen den layern. Es reicht aus um Opengl klarzumachen wie es die tga transparency anwenden soll.

    void __fastcall TForm1::OpenGLAPPanel1Paint(TObject *Sender)
    {
    	// Clear Screen And Depth Buffer
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glLoadIdentity();
    
        //paint läuft zum ersten mal
        if(firstdraw)
        {
            //object in der ansicht zentrieren zentrieren
            RotX=(-GlobalMapX/2)*0.2;
            RotY=(-GlobalMapY/2)*0.2;
    
            //tile displayliste erstellen
            dspl_tile=glGenLists(1);							
    	glNewList(dspl_tile,GL_COMPILE);						
    		glBegin(GL_QUADS);
                            glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.1f, 0.1f, 0.0f);
                            glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.1f, 0.1f, 0.0f);
                            glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.1f, -0.1f, 0.0f);
                            glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.1f, -0.1f, 0.0f);
    		glEnd();
    	glEndList();
    
            firstdraw=false;
        }
    
        //sicht anpassen, siehe mousemove
        glTranslated(RotX, RotY, ZoomFactor);
    
        //vars
        int paintx,painty;
        float temp = float(GlobalMapX-1);
    
        //loop durch alle Felder
        for(painty = 0; painty <= GlobalMapY-1; painty++)
        {
            for(paintx= 0; paintx <= GlobalMapX-1; paintx++)
            {
    
            //alle infos für das feld grabben
    
            //terraintype, remember we added PlotType so it´s actually Terrain_Type+PlotType=3 ...
                    string ttype = GlobalTerrain[paintx][painty];
                    ttype.replace( ttype.find( "+PlotType="), strlen("+PlotType=")+1, "");
    
            //plottype, see terraintype
                    string tplot = GlobalTerrain[paintx][painty];
                    tplot.replace( tplot.find(ttype), strlen(ttype.c_str()), "");
                    tplot.replace( tplot.find("+PlotType="), strlen("+PlotType="), "");
    
                    string tfeature = GlobalFeature[paintx][painty];
                    string tbonus = GlobalBonus[paintx][painty];
                    string triver = GlobalRiver[paintx][painty];
    
                    //modify according to feature (ice)
                    string p = tfeature.c_str();
    
            //set textures depending on terrain
    
                    if(ttype=="TERRAIN_OCEAN")
                            glBindTexture(GL_TEXTURE_2D, texture[0]);
                    else if(ttype=="TERRAIN_DESERT")
                            glBindTexture(GL_TEXTURE_2D, texture[1]);
                    else if(ttype=="TERRAIN_PLAINS")
                            glBindTexture(GL_TEXTURE_2D, texture[2]);
                    else if(ttype=="TERRAIN_GRASS")
                            glBindTexture(GL_TEXTURE_2D, texture[3]);
                    else if(ttype=="TERRAIN_SNOW")
                            glBindTexture(GL_TEXTURE_2D, texture[4]);
                    else if(ttype=="TERRAIN_TUNDRA")
                            glBindTexture(GL_TEXTURE_2D, texture[5]);
                    else if(ttype=="TERRAIN_COAST")
                            glBindTexture(GL_TEXTURE_2D, texture[6]);
                    else
                            glBindTexture(GL_TEXTURE_2D, texture[7]);
    
            //feature ice, textur faken
                    if( p.rfind("FEATURE_ICE") != std::string::npos)
                            glBindTexture(GL_TEXTURE_2D, texture[8]);
    
            //PAINT TERRAIN LAYER
                    glCallList(dspl_tile);
    
            //PAINT PEAK LAYER
                   if(show_peaks && tplot=="0")
                   {
                            glBindTexture(GL_TEXTURE_2D, texture[45]);
                            glTranslatef(0,0,0.0001);
                            glCallList(dspl_tile);
                            glTranslatef(0,0,-0.0001);
                   }
            //PAINT FEATURE LAYER (FORESTS)
                   if(tfeature !="" && show_landscape)
                   {
                         if(show_forests && p.rfind("FEATURE_FOREST") != std::string::npos )
                            {
                                    glBindTexture(GL_TEXTURE_2D, texture[42]);
                            }
                            glTranslatef(0,0,0.0002);
                            glCallList(dspl_tile);
                            glTranslatef(0,0,-0.0002);
                   }
    
            //PAINT RIVER LAYER
                    if(triver!="" && show_rivers)
                    {
                         if(triver.rfind("N")!= std::string::npos)
                            {
                            glBindTexture(GL_TEXTURE_2D, texture[43]);
    
                            glTranslatef(0,0,0.0003);
                            glCallList(dspl_tile);
                            glTranslatef(0,0,-0.0003);
                            }
    
                            if (triver.rfind("W")!= std::string::npos)
                            {
                            glBindTexture(GL_TEXTURE_2D, texture[44]);
    
                            glTranslatef(0,0,0.0004);
                            glCallList(dspl_tile);
                            glTranslatef(0,0,-0.0004);
                            }
                   }
    
            //PAINT BONUS LAYER
                   if(tbonus!="" && show_ressources)
                   {
                            if(tbonus=="BONUS_ALUMINUM")
                                    glBindTexture(GL_TEXTURE_2D, texture[9]);
                            else if(tbonus=="BONUS_BANANA")
                                    glBindTexture(GL_TEXTURE_2D, texture[10]);
                            else if(tbonus=="BONUS_CRAB")
                                    glBindTexture(GL_TEXTURE_2D, texture[11]);
                            else if(tbonus=="BONUS_COW")
                                    glBindTexture(GL_TEXTURE_2D, texture[12]);
                            else if(tbonus=="BONUS_SHEEP")
                                    glBindTexture(GL_TEXTURE_2D, texture[13]);
                            else if(tbonus=="BONUS_PIG")
                                    glBindTexture(GL_TEXTURE_2D, texture[14]);
                            else if(tbonus=="BONUS_COAL")
                                    glBindTexture(GL_TEXTURE_2D, texture[15]);
                            else if(tbonus=="BONUS_IVORY")
                                    glBindTexture(GL_TEXTURE_2D, texture[16]);
                            else if(tbonus=="BONUS_FISH")
                                    glBindTexture(GL_TEXTURE_2D, texture[17]);
                            else if(tbonus=="BONUS_HORSE")
                                    glBindTexture(GL_TEXTURE_2D, texture[18]);
                            else if(tbonus=="BONUS_RICE")
                                    glBindTexture(GL_TEXTURE_2D, texture[19]);
                            else if(tbonus=="BONUS_CORN")
                                    glBindTexture(GL_TEXTURE_2D, texture[20]);
                            else if(tbonus=="BONUS_URANIUM")
                                    glBindTexture(GL_TEXTURE_2D, texture[21]);
                            else if(tbonus=="BONUS_GOLD")
                                    glBindTexture(GL_TEXTURE_2D, texture[22]);
                            else if(tbonus=="BONUS_SPICES")
                                    glBindTexture(GL_TEXTURE_2D, texture[23]);
                            else if(tbonus=="BONUS_FUR")
                                    glBindTexture(GL_TEXTURE_2D, texture[24]);
                            else if(tbonus=="BONUS_DYE")
                                    glBindTexture(GL_TEXTURE_2D, texture[25]);
                            else if(tbonus=="BONUS_WHEAT")
                                    glBindTexture(GL_TEXTURE_2D, texture[26]);
                            else if(tbonus=="BONUS_DEER")
                                    glBindTexture(GL_TEXTURE_2D, texture[27]);
                            else if(tbonus=="BONUS_WINE")
                                    glBindTexture(GL_TEXTURE_2D, texture[28]);
                            else if(tbonus=="BONUS_OIL")
                                    glBindTexture(GL_TEXTURE_2D, texture[29]);
                            else if(tbonus=="BONUS_SUGAR")
                                    glBindTexture(GL_TEXTURE_2D, texture[30]);
                            else if(tbonus=="BONUS_SILVER")
                                    glBindTexture(GL_TEXTURE_2D, texture[31]);
                            else if(tbonus=="BONUS_COPPER")
                                    glBindTexture(GL_TEXTURE_2D, texture[32]);
                            else if(tbonus=="BONUS_WHALE")
                                    glBindTexture(GL_TEXTURE_2D, texture[33]);
                            else if(tbonus=="BONUS_CLAM")
                                    glBindTexture(GL_TEXTURE_2D, texture[34]);
                            else if(tbonus=="BONUS_SILK")
                                    glBindTexture(GL_TEXTURE_2D, texture[35]);
                            else if(tbonus=="BONUS_IRON")
                                    glBindTexture(GL_TEXTURE_2D, texture[36]);
                            else if(tbonus=="BONUS_STONE")
                                    glBindTexture(GL_TEXTURE_2D, texture[37]);
                            else if(tbonus=="BONUS_MARBLE")
                                    glBindTexture(GL_TEXTURE_2D, texture[38]);
                            else if(tbonus=="BONUS_INCENSE")
                                    glBindTexture(GL_TEXTURE_2D, texture[39]);
                            else if(tbonus=="BONUS_GEMS")
                                    glBindTexture(GL_TEXTURE_2D, texture[40]);
                            else  //unsupported ressource
                                    glBindTexture(GL_TEXTURE_2D, texture[41]);
    
                            glTranslatef(0,0,0.0005);
                            glCallList(dspl_tile);
                            glTranslatef(0,0,-0.0005);
                   }
    
            //TRANSLATEF TO NEXT FIELD, auf x=0 stringen wenn wir durch sind
                    if(paintx<GlobalMapX-1)
                            glTranslatef(0.2,0,0);
                    else
                            glTranslatef(-temp/5,0,0);
            }
            //TRANSLATEF to next field
            glTranslatef(0,0.2,0);
      }
    }
    

    Bin für jede Hilfe dankbar.

    Grey



  • GreyHound schrieb:

    Meine erste Frage:
    Wenn keine der ecken des Tiles im Sichtfeld ist ist es natürlich blöd das Feld zu zeichen. Wie mache ich das? Ich habe die 3D->2D Übersetzung nicht umsetzen können. Kann mir hierfür bitte jemand Hilfestellung leisten?

    Ich nehme an, du kannst die Ansicht weder drehen noch neigen. In diesem Fall ist es recht einfach. Du musst bestimmen, welches Feld links unten gerade noch in den Bildschirm ragt und das selbe für rechts oben. Alle Felder in dem Rechteck dazwischen und die Randfelder selber zeichnest du. Je nachdem, wie du dein Koordinatensystem aufgebaut hast, können es auch andere Ecken sein.
    Um diese Felder zu bestimmen, musst du dir überlegen, welche Transformationen (Translation, Scaling, Projection) durchgeführt werden, bis das Ding an deinem Bildschirm erscheint und diese rückgängig machen. Du hast eine Spielfeldebene und eine Bildschirmebene, also sparst du dir dabei schon eine Menge Ärger.
    Das ist auch die wichtigste Optimierung, die du erstmal machen musst. Vorher mit Display-Listen schon rumzufrickeln bringt dir nur im Kleinen was, aber so lange du stets das komplette Feld renderst, bist du Größenordnungsmäßig schlecht dran.


  • Mod

    änder GlobalTerrain in eine klasse die schon die fertig verarbeiteten stringdaten enthällt, sodass du nicht für jedes tile immerwieder hunderte von stringcompares durchführen mußt.

    um im einfachsten fall dann statt:

    if(tbonus=="BONUS_ALUMINUM")
                                    glBindTexture(GL_TEXTURE_2D, texture[9]);
                            else if(tbonus=="BONUS_BANANA")
                                    glBindTexture(GL_TEXTURE_2D, texture[10]);
                            else if(tbonus=="BONUS_CRAB")
                                    glBindTexture(GL_TEXTURE_2D, texture[11]);
                            else if(tbonus=="BONUS_COW")
                                    glBindTexture(GL_TEXTURE_2D, texture[12]);
                            else if(tbonus=="BONUS_SHEEP")
                                    glBindTexture(GL_TEXTURE_2D, texture[13]);
                            else if(tbonus=="BONUS_PIG")
                                    glBindTexture(GL_TEXTURE_2D, texture[14]);
                            else if(tbonus=="BONUS_COAL")
                                    glBindTexture(GL_TEXTURE_2D, texture[15]);
                            else if(tbonus=="BONUS_IVORY")
                                    glBindTexture(GL_TEXTURE_2D, texture[16]);
                            else if(tbonus=="BONUS_FISH")
                                    glBindTexture(GL_TEXTURE_2D, texture[17]);
                            else if(tbonus=="BONUS_HORSE")
                                    glBindTexture(GL_TEXTURE_2D, texture[18]);
                            else if(tbonus=="BONUS_RICE")
                                    glBindTexture(GL_TEXTURE_2D, texture[19]);
                            else if(tbonus=="BONUS_CORN")
                                    glBindTexture(GL_TEXTURE_2D, texture[20]);
                            else if(tbonus=="BONUS_URANIUM")
                                    glBindTexture(GL_TEXTURE_2D, texture[21]);
                            else if(tbonus=="BONUS_GOLD")
                                    glBindTexture(GL_TEXTURE_2D, texture[22]);
                            else if(tbonus=="BONUS_SPICES")
                                    glBindTexture(GL_TEXTURE_2D, texture[23]);
                            else if(tbonus=="BONUS_FUR")
                                    glBindTexture(GL_TEXTURE_2D, texture[24]);
                            else if(tbonus=="BONUS_DYE")
                                    glBindTexture(GL_TEXTURE_2D, texture[25]);
                            else if(tbonus=="BONUS_WHEAT")
                                    glBindTexture(GL_TEXTURE_2D, texture[26]);
                            else if(tbonus=="BONUS_DEER")
                                    glBindTexture(GL_TEXTURE_2D, texture[27]);
                            else if(tbonus=="BONUS_WINE")
                                    glBindTexture(GL_TEXTURE_2D, texture[28]);
                            else if(tbonus=="BONUS_OIL")
                                    glBindTexture(GL_TEXTURE_2D, texture[29]);
                            else if(tbonus=="BONUS_SUGAR")
                                    glBindTexture(GL_TEXTURE_2D, texture[30]);
                            else if(tbonus=="BONUS_SILVER")
                                    glBindTexture(GL_TEXTURE_2D, texture[31]);
                            else if(tbonus=="BONUS_COPPER")
                                    glBindTexture(GL_TEXTURE_2D, texture[32]);
                            else if(tbonus=="BONUS_WHALE")
                                    glBindTexture(GL_TEXTURE_2D, texture[33]);
                            else if(tbonus=="BONUS_CLAM")
                                    glBindTexture(GL_TEXTURE_2D, texture[34]);
                            else if(tbonus=="BONUS_SILK")
                                    glBindTexture(GL_TEXTURE_2D, texture[35]);
                            else if(tbonus=="BONUS_IRON")
                                    glBindTexture(GL_TEXTURE_2D, texture[36]);
                            else if(tbonus=="BONUS_STONE")
                                    glBindTexture(GL_TEXTURE_2D, texture[37]);
                            else if(tbonus=="BONUS_MARBLE")
                                    glBindTexture(GL_TEXTURE_2D, texture[38]);
                            else if(tbonus=="BONUS_INCENSE")
                                    glBindTexture(GL_TEXTURE_2D, texture[39]);
                            else if(tbonus=="BONUS_GEMS")
                                    glBindTexture(GL_TEXTURE_2D, texture[40]);
                            else  //unsupported ressource
                                    glBindTexture(GL_TEXTURE_2D, texture[41]);
    

    eher

    glBindTexture(GL_TEXTURE_2D, texture[tbonus]);
    

    schreiben zu können, das dürfte die performance deines zeichnens schon um einiges verbessern.

    grundsätzlich könntest du dir überlegen, ob du für so große datenmengen statt textdateien, eher vielleicht bitmaps verwendest, das dürfte einfacher zu editieren sein denk ich mir, und auch schneller einzulesen.

    rapso->greets();



  • Hi!

    Das hat jetzt zwar nix direkt mit Deinem Problem zu tun, aber das ist mir irgendwie ins Auge gestochen.

    GreyHound schrieb:

    //PAINT BONUS LAYER
                   if(tbonus!="" && show_ressources)
                   {
                            if(tbonus=="BONUS_ALUMINUM")
                                    glBindTexture(GL_TEXTURE_2D, texture[9]);
                            else if(tbonus=="BONUS_BANANA")
                                    glBindTexture(GL_TEXTURE_2D, texture[10]);
                            else if(tbonus=="BONUS_CRAB")
                                    glBindTexture(GL_TEXTURE_2D, texture[11]);
                            else if(tbonus=="BONUS_COW")
                                    glBindTexture(GL_TEXTURE_2D, texture[12]);
                            else if(tbonus=="BONUS_SHEEP")
                                    glBindTexture(GL_TEXTURE_2D, texture[13]);
                            else if(tbonus=="BONUS_PIG")
                                    glBindTexture(GL_TEXTURE_2D, texture[14]);
                            else if(tbonus=="BONUS_COAL")
                                    glBindTexture(GL_TEXTURE_2D, texture[15]);
                            else if(tbonus=="BONUS_IVORY")
                                    glBindTexture(GL_TEXTURE_2D, texture[16]);
                            else if(tbonus=="BONUS_FISH")
                                    glBindTexture(GL_TEXTURE_2D, texture[17]);
                            else if(tbonus=="BONUS_HORSE")
                                    glBindTexture(GL_TEXTURE_2D, texture[18]);
                            else if(tbonus=="BONUS_RICE")
                                    glBindTexture(GL_TEXTURE_2D, texture[19]);
                            else if(tbonus=="BONUS_CORN")
                                    glBindTexture(GL_TEXTURE_2D, texture[20]);
                            else if(tbonus=="BONUS_URANIUM")
                                    glBindTexture(GL_TEXTURE_2D, texture[21]);
                            else if(tbonus=="BONUS_GOLD")
                                    glBindTexture(GL_TEXTURE_2D, texture[22]);
                            else if(tbonus=="BONUS_SPICES")
                                    glBindTexture(GL_TEXTURE_2D, texture[23]);
                            else if(tbonus=="BONUS_FUR")
                                    glBindTexture(GL_TEXTURE_2D, texture[24]);
                            else if(tbonus=="BONUS_DYE")
                                    glBindTexture(GL_TEXTURE_2D, texture[25]);
                            else if(tbonus=="BONUS_WHEAT")
                                    glBindTexture(GL_TEXTURE_2D, texture[26]);
                            else if(tbonus=="BONUS_DEER")
                                    glBindTexture(GL_TEXTURE_2D, texture[27]);
                            else if(tbonus=="BONUS_WINE")
                                    glBindTexture(GL_TEXTURE_2D, texture[28]);
                            else if(tbonus=="BONUS_OIL")
                                    glBindTexture(GL_TEXTURE_2D, texture[29]);
                            else if(tbonus=="BONUS_SUGAR")
                                    glBindTexture(GL_TEXTURE_2D, texture[30]);
                            else if(tbonus=="BONUS_SILVER")
                                    glBindTexture(GL_TEXTURE_2D, texture[31]);
                            else if(tbonus=="BONUS_COPPER")
                                    glBindTexture(GL_TEXTURE_2D, texture[32]);
                            else if(tbonus=="BONUS_WHALE")
                                    glBindTexture(GL_TEXTURE_2D, texture[33]);
                            else if(tbonus=="BONUS_CLAM")
                                    glBindTexture(GL_TEXTURE_2D, texture[34]);
                            else if(tbonus=="BONUS_SILK")
                                    glBindTexture(GL_TEXTURE_2D, texture[35]);
                            else if(tbonus=="BONUS_IRON")
                                    glBindTexture(GL_TEXTURE_2D, texture[36]);
                            else if(tbonus=="BONUS_STONE")
                                    glBindTexture(GL_TEXTURE_2D, texture[37]);
                            else if(tbonus=="BONUS_MARBLE")
                                    glBindTexture(GL_TEXTURE_2D, texture[38]);
                            else if(tbonus=="BONUS_INCENSE")
                                    glBindTexture(GL_TEXTURE_2D, texture[39]);
                            else if(tbonus=="BONUS_GEMS")
                                    glBindTexture(GL_TEXTURE_2D, texture[40]);
                            else  //unsupported ressource
                                    glBindTexture(GL_TEXTURE_2D, texture[41]);
    
                            glTranslatef(0,0,0.0005);
                            glCallList(dspl_tile);
                            glTranslatef(0,0,-0.0005);
                   }
    

    Das ist ja mal voll viel Tipperei. Wie wär's mit einer map<string,Texture>?

    Dann mußt Du nur noch schreiben

    if(tbonus!="" && show_ressources)
    {
      glBindTexture(GL_TEXTURE_2D, bonusTextures[tbonus]);
      glTranslatef(0,0,0.0005);
      glCallList(dspl_tile);
      glTranslatef(0,0,-0.0005);
    }
    

    Die Zuordnung kannst Du dann vielleicht sogar über ne Textdatei machen und das Ganze wird schön modifizierbar. Außerdem steiger es die Lesbarkeit enorm.

    edit: Mist, zu langsam!



  • Jup das dachte ich mir auchschon....ich befasse mich erst seit einer Woche mit Cpp und Klassen sind mir immer noch ein Mysterium. Aber danke für den Ratschlag!
    Da ich aber jetzt noch keine Ahnung habe wie ich das hinkriege muss ich mich da erst schlaumachen sonst würde ich den Code direkt ändern.



  • ...und wenns um geschwindigkeit geht, würde ich niemals über strings gehen, sondern über integer, du vergleichst dich da ja dumm und dämlich!



  • Korbinian schrieb:

    ...und wenns um geschwindigkeit geht, würde ich niemals über strings gehen, sondern über integer, du vergleichst dich da ja dumm und dämlich!

    yoar das habe ich mir auch schon überlegt weil ich eigentlich nen switch benutzen wollte.



  • rapso schrieb:

    grundsätzlich könntest du dir überlegen, ob du für so große datenmengen statt textdateien, eher vielleicht bitmaps verwendest, das dürfte einfacher zu editieren sein denk ich mir, und auch schneller einzulesen.

    das tool ist ja für civ4 und dient eben dazu scenarien auszulesen und darzustellen, da kann ich leider nichts drehen.



  • Jester schrieb:

    Hi!

    Das ist ja mal voll viel Tipperei. Wie wär's mit einer map<string,Texture>?
    ...

    edit: Mist, zu langsam!

    FETT DANKE, habs begriffen.

    und zu deinem edit!!
    Deine Antwort war viel hilfreicher als die andere, auch wenn die Essenz wohl die gleiche ist, zumindest einmal für mich als newb, so hatte ich gültigen syntax als ausgangspunkt, danke

    GLuint	texture[50];
    typedef map<string,GLuint> TextureMap;
    TextureMap TerrainTexture;
    
    ...
    
    glGenTextures(50, texture);
    LoadTexture("Textures\\ocean.tga", texture[0]);
    TerrainTexture["TERRAIN_OCEAN"]=texture[0];
    
    ...
    
    glBindTexture(GL_TEXTURE_2D, TerrainTexture[ttype]);  //ttype natürlich in dem beispiel ein string "TERRAIN_OCEAN"
    


  • hmmm,
    ich habe jetzt für BONUS und TERRAIN maps laufen aber habe keine merkliche Änderung bemerkt. lägt noch genauso vie vorher. Schneint Performancetechnisch wenig auszumachen. Allerdings steckt der bind command nicht mit in den texture listen. ob das ob der dynamische texture bin überhaupt möglich ist habe ich noch nicht probiert.

    seh ich das richtig dass ich mit displaylisten dafür dorge das daten im grafikram hocken? wenn ich jetzt (auch wenn anfangs aufwendig) den bind jeder textur in eine displayliste knalle einen extremen sprung machen kann? oder wie mach ich es dass der bind nicht jdesmal den kompletten bus auslastet? den ich glaube das dies wohl das hauptproblem ist.


  • Mod

    eine texture die da an eine ID gebunden ist, liegt bereits im grakaram.

    btw. die essens seiner aussage war nicht gleich meiner ;), ich hab dir geraten die strings beim initialisieren zu verarbeiten und dann die fertigen Indices aus einer klasse auszulesen. in performancekritischen bereichen sollte man möglichst nie mit strings arbeiten, ne map+strings ist wie eine ferrarikarosse+trabbimotor ;), aber natürlich ist jesters vorschlag "log n"-mal besser als das bisherige *hehe*.

    displaylists machen intern sehr viel mehr als dinge ins vram zu stecken, theoretisch kannst du alles Zeichnen, dass du machst in eine displaylist stecken und der treiber optimiert das. das läuft meistens besser als es jemand mit sagen wir mal 6monaten opengl-erfahrung hinbekommen würde.

    rapso->greets();



  • Ja, ich wollte nicht zu viel auf einmal verlangen. 😉
    Selbstverständlich isses noch besser, die Textur-Pointer in nem Array abzulegen und dann mit der ID als index da reinzugreifen. Ich wollte aber zunächst mal Codekürze ohne exzessives Umschreiben des umliegenden Codes erreichen.


  • Mod

    quick&dirty 😃
    dat kenn ich

    rapso->greets();



  • muss man verstehen, warum du das mit OpenGL machst und nicht einfach ne Bitmap nimmst, dein zeugs reinmalst und als TImage anzeigst? kann mir echt nicht vorstellen, dass hier OpenGL auch nur ansatzweisse einen Vorteil bringt...



  • ne das is ja auf jeden Fall schon viel besser so, von 200 Zeilen sind jetzt gerade einmal 30 übriggeblieben. thx

    hm wieso opengl und net bitmap..hmm weiss net...hab angefangen und es lief gut... 😉 ausserdem find ich es interessanter



  • Sunday schrieb:

    muss man verstehen, warum du das mit OpenGL machst und nicht einfach ne Bitmap nimmst, dein zeugs reinmalst und als TImage anzeigst? kann mir echt nicht vorstellen, dass hier OpenGL auch nur ansatzweisse einen Vorteil bringt...

    ... einen Vorteil gegenüber was? Gegenüber dem Windows-API? Plattformunabhängigkeit, zum Beispiel. Außerdem ist es schnell und es spricht nichts dagegen. OpenGL ist auch für 2D-Grafik ideal. 🙂



  • Optimizer schrieb:

    Plattformunabhängigkeit

    er programmiert mit borland c++ builder unter windows. nix mit plattformunabhängigkeit! und in ein bild ein paar sachen zeichnen und anzeigen ist kein grosser akt. auch ein scroller nach rechts/links oder ein zoom.

    es spricht nichts dagegen

    und ausser dem übungszweck auch nichts dafür...



  • Mit Zoom fängt's doch schon an. Richtig schön flüssiges zoomen kannst du mit dem Windows GDI vergessen. Das Argument der Geschwindigkeit hast du also nicht widerlegt. Und da du anscheinend auch nicht der Meinung bist, dass etwas gegen OpenGL spricht (denn du hast nur entgegnet, es spräche nichts dafür), worauf willst du dann eigentlich hinaus?



  • dann nochmal für dich zum mitmeiseln:

    um ein einzelnes bild anzuzeigen, ist es nicht unbedingt notwendig opengl zu verwenden. ich hab nie gesagt (geschrieben), dass ich etwas dagegen habe, sondern das die notwendigkeit in meinen augen nicht begründe ist (auch nicht für nen zoom). wenn er das gerne benutzen will, bitte, ich hindere ihn doch nicht daran. wenn er etwas davon lernt, okay, klasse, toll, nur zu empfehlen. 👍



  • nur mal so: is bei civ4 nicht so nen worldbuilder dabei? (habs erst seit 2 tagen ;))


Anmelden zum Antworten