bool TitleImagesLoad(void) { if (!AnimationLoad(&TitleAnim, "data/graphics/anim.png", 169, 40, 12)) { return false; } if (!AnimationLoad( &GameOverAnim, "data/graphics/gameover.png", 131, 40, 3)) { return false; } for (int i = 0; i < MAX_PLAYERS; i++) { char buf[256]; #ifdef __GCW0__ sprintf(buf, "data/graphics/gcw%d.png", i); #else sprintf(buf, "data/graphics/keyboard%d.png", i); #endif ControlTexes[i] = LoadTex(buf); if (ControlTexes[i].T == NULL) { return false; } } #ifdef __GCW0__ ControlTex0Analog = LoadTex("data/graphics/gcw0analog.png"); if (ControlTex0Analog.T == NULL) return false; ControlTex0G = LoadTex("data/graphics/gcw0g.png"); if (ControlTex0G.T == NULL) return false; #endif return true; }
//////////////////////////////////////////////////////////// /// Populate all the required game sprites //////////////////////////////////////////////////////////// void MainClient::_populateSprites(void) { //Weapon loading { std::string path; size_t sz = WeaponList.size(); //resize texture vectors gs.bulletTex.resize(sz); gs.weaponTex.resize(sz); //Generate Textures glGenTextures(sz, &gs.bulletTex[0]); glGenTextures(sz, &gs.weaponTex[0]); //Populate sprites for(size_t k = 0; k < sz; k++){ //Bullet { path = WeaponList[k] + "/bullet.png"; if(!LoadTex(gs.bulletTex[k], path.c_str())) throw "Could not load bullet texture..."; path = WeaponList[k] + "/bullet.sprh"; gs.Bullet.push_back(Sprite(path.c_str(), gs.bulletTex[k])); } //Weapon { path = WeaponList[k] + "/weapon.png"; if(!LoadTex(gs.weaponTex[k], path.c_str())) throw "Could not load weapon texture..."; path = WeaponList[k] + "/weapon.sprh"; gs.Weapon.push_back(Sprite(path.c_str(), gs.weaponTex[k])); } } } //Bullet, Hits, Explosions Sprites { gs.HitTexture.resize(2, 0); glGenTextures(2, &gs.HitTexture[0]); LoadTex(gs.HitTexture[1], "assets/explosions/default.png"); gs.BulletHit.push_back(Sprite()); gs.BulletHit.push_back(Sprite("assets/explosions/default.sprh", gs.HitTexture[1])); } }
// Initializes texture information void init(void){ glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); glEnable(GL_DEPTH_TEST); makeTexImage(); /* Specifies the alignment requirement */ glPixelStorei(GL_UNPACK_ALIGNMENT, 1); /* Sets the wrap parameters in both directions */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); /* Sets the magnifying and minifying parameters */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); /* Specifies a two-dimensional texture image */ glTexImage2D(GL_TEXTURE_2D, 0, 4, ourImageWidth, ourImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, ourImage); /* Set texture environment parameters */ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); pic = LoadTex(name); }
static void Init( int argc, char *argv[] ) { GLint shade; GLint rBits, gBits, bBits; int filter = GL_NEAREST, comp = 3; int i; for (i=1; i<argc; i++) { if (strcmp(argv[i],"-dither")==0) glDisable(GL_DITHER); else if (strcmp(argv[i],"+dither")==0) glEnable(GL_DITHER); else if (strcmp(argv[i],"+smooth")==0) glShadeModel(GL_SMOOTH); else if (strcmp(argv[i],"+flat")==0) glShadeModel(GL_FLAT); else if (strcmp(argv[i],"+depth")==0) glEnable(GL_DEPTH_TEST); else if (strcmp(argv[i],"-depth")==0) glDisable(GL_DEPTH_TEST); else if (strcmp(argv[i],"-size")==0) { Size = atoi(argv[i+1]); i++; } else if (strcmp(argv[i],"-texture")==0) Texture = 0; else if (strcmp(argv[i],"+texture")==0) Texture = 1; else if (strcmp(argv[i],"-linear")==0) filter = GL_NEAREST; else if (strcmp(argv[i],"+linear")==0) filter = GL_LINEAR; else if (strcmp(argv[i],"-persp")==0) glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); else if (strcmp(argv[i],"+persp")==0) glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); else if (strcmp(argv[i],"-comp")==0) { comp = atoi(argv[i+1]); i++; } else printf("Unknown option: %s\n", argv[i]); } glGetIntegerv(GL_SHADE_MODEL, &shade); printf("Dither: %s\n", glIsEnabled(GL_DITHER) ? "on" : "off"); printf("ShadeModel: %s\n", (shade==GL_FLAT) ? "flat" : "smooth"); printf("DepthTest: %s\n", glIsEnabled(GL_DEPTH_TEST) ? "on" : "off"); printf("Size: %d pixels\n", Size); if (Texture) LoadTex(comp, filter); glGetIntegerv(GL_RED_BITS, &rBits); glGetIntegerv(GL_GREEN_BITS, &gBits); glGetIntegerv(GL_BLUE_BITS, &bBits); printf("RedBits: %d GreenBits: %d BlueBits: %d\n", rBits, gBits, bBits); }
void Art::Load() { walls = LoadTex("res/tex/walls.png"); items = LoadTex("res/tex/items.png"); font = LoadTex("res/tex/font.png"); floors = LoadTex("res/tex/floors.png"); sprites = LoadTex("res/tex/sprites.png"); skybox = LoadTex("res/tex/sky.png"); logo = LoadTex("res/gui/logo.png"); gamepanel = LoadTex("res/tex/gamepanel.png"); }
//============================================================================== // ディレクトリを全部ロード //------------------------------------------------------------------------------ void TextureManager::LoadDirectory(const char * Path, const char * GropName) { std::string sFilePass = Path; // 最後にスラッシュがない場合 if (sFilePass[sFilePass.size() - 1] != '/' && sFilePass[sFilePass.size() - 1] != '\\') { sFilePass += "/"; } // ディレクトリ用変数 HANDLE hFind; WIN32_FIND_DATA fd; // エラーチェック ASSERT(INVALID_HANDLE_VALUE != (hFind = FindFirstFile((sFilePass + "*.*").c_str(), &fd)), "ディレクトリが開きませんでした"); if (INVALID_HANDLE_VALUE == hFind) return ; // ディレクトリを全て回す for (; FindNextFile(hFind, &fd);) { LPDIRECT3DTEXTURE9 tex = nullptr; std::string filename = fd.cFileName; // 拡張子を見てロードできるか判断 unsigned int find = filename.find_last_of('.'); // 拡張子がない場合 if (find == std::string::npos) continue; // とりあえずコピー std::string fileExtension = filename.c_str() + (find + 1); // ロードフラグ bool loadFlag = false; // 拡張子を調べる for (int i = 0; i < cLoadMaxFile; i++) { find = fileExtension.find(cLoadFiles[i]); if (find != std::string::npos) { loadFlag = true; break; } } // ロードフラグがあったら読み込む if (loadFlag) { LoadTex((sFilePass + filename).c_str(), GropName); } } }
void CLS_ASSETS::init(){ int i; for( i = 0; i < MAXIMUM_NORMAL_TEX; i++ ) NORMAL_TEX[ i ] = NULL; for( i = 0; i < MAXIMUM_BG_TEX; i++ ) BG_TEX[ i ] = NULL; _NULL_TEX = LoadTex( "Data//Sprites//NORMAL//-1.png" ); }
//////////////////////////////////////////////////////////// /// Load HUD sprites //////////////////////////////////////////////////////////// void MainClient::_loadHudSprites(void) { gs.hud.Texture.resize(GameSprites::HUD::COUNT, 0); glGenTextures(GameSprites::HUD::COUNT, &gs.hud.Texture[0]); LoadTex(gs.hud.Texture[GameSprites::HUD::FRAME], "assets/interface/frame.png"); LoadTex(gs.hud.Texture[GameSprites::HUD::HEALTH], "assets/interface/health.png"); LoadTex(gs.hud.Texture[GameSprites::HUD::AMMO], "assets/interface/ammo.png"); LoadTex(gs.hud.Texture[GameSprites::HUD::CIRCLEBAR],"assets/interface/circlebar.png"); gs.hud.Object.push_back(Sprite(gs.hud.Texture[GameSprites::HUD::FRAME])); gs.hud.Object.push_back(Sprite(gs.hud.Texture[GameSprites::HUD::HEALTH])); gs.hud.Object.push_back(Sprite(gs.hud.Texture[GameSprites::HUD::AMMO])); gs.hud.Object.push_back(Sprite(gs.hud.Texture[GameSprites::HUD::CIRCLEBAR])); gs.hud.Object[GameSprites::HUD::CIRCLEBAR].pInfo.pivot = glm::vec3(0.0f); gfx::Link::Instance().spriteBuild(&gs.hud.Object[GameSprites::HUD::CIRCLEBAR]); gs.hud.Object[GameSprites::HUD::HEALTH].pInfo.pos = glm::vec3(-50.0f, -250.0f, 0.0f); gs.hud.Object[GameSprites::HUD::AMMO].pInfo.pos = glm::vec3(-50.0f, -275.0f, 0.0f); }
void Interface::init(){ SDL_Surface *surfAux = NULL; texCursor = LoadTex( "Data//Textures//Interface//cursor.png" ); texBotbar = LoadTex( "Data//Textures//Interface//stats-bar.png" ); texLivesLeft = NULL; std::stringstream ssaux; ssaux<<PLAYER.getLivesLeft(); surfAux = TTF_RenderText_Blended( Font_Amble_30,ssaux.str().c_str() ,WHITE ); if( surfAux != NULL ) { texLivesLeft = SDL_CreateTextureFromSurface( RENDER_MAIN, surfAux ); SDL_FreeSurface( surfAux ); surfAux = NULL; } else { cons_out("Interface fail: lifes"); } ssaux.str( "" ); ssaux<<PLAYER.getScore(); surfAux = TTF_RenderText_Blended( Font_Amble_30,ssaux.str().c_str() ,WHITE ); if( surfAux != NULL ) { texScore = SDL_CreateTextureFromSurface( RENDER_MAIN, surfAux ); SDL_FreeSurface( surfAux ); surfAux = NULL; } else { cons_out("Interface fail: score"); } _oldlives = PLAYER.getLivesLeft(); _oldscore = PLAYER.getScore(); }
int main( int argc, char **argv ) { FILE *fp1, fp2; int out; unsigned char *dat1 = NULL; int wid1 = 0; int hei1 = 0; unsigned char *dat2 = NULL; int wid2 = 0; int hei2 = 0; if (argc > 3) { dat1 = LoadTex( argv[1], wid1, hei1 ); dat2 = LoadTex( argv[2], wid2, hei2 ); out = 3; } else { dat1 = LoadTex( argv[1], wid1, hei1 ); out = 2; } unsigned char *data = dat1; if (!dat1) return 0; if (argc > 3 && dat2) { assert( wid1 == wid2 ); assert( hei1 == hei2 ); data = (unsigned char*) malloc( sizeof (unsigned char)*wid1*hei1*4 ); for (int i = 0; i < wid1*hei1; i++) { data[i*4] = dat1[i*3]; data[i*4+1] = dat1[i*3+1]; data[i*4+2] = dat1[i*3+2]; data[i*4+3] = dat2[i*3]; } } png_write( argv[out], data, wid1, hei1, dat2 != NULL, 8 ); if (argc > 3 && dat2) free( dat1 ); if (dat2) free( dat2 ); return 0; }
void SetupSprite(Sprite_T *s, const char *file, Rect *frames, short frame_num, Animation_T *animations, short anim_num) { int i; s->texId = LoadTex(file); for(i = 0;i < frame_num;i++) s->frames[i] = frames[i]; for(i = 0;i < anim_num;i++) s->animations[i]= animations[i]; return; }
void MainClient::_loadObjectSprites(void) { gs.MercTexture.resize(mercGFX::COUNT, 0); glGenTextures(mercGFX::COUNT, &gs.MercTexture[0]); CSimpleIniA texini; texini.LoadFile(info.texturefile.c_str()); std::string texpath; //Manualy load merc sprites into one default mercGFX object LoadTex(gs.MercTexture[mercGFX::IDLE], texini.GetValue("Merc", "still")); LoadTex(gs.MercTexture[mercGFX::RUN], texini.GetValue("Merc", "run")); LoadTex(gs.MercTexture[mercGFX::JET], texini.GetValue("Merc", "jets")); LoadTex(gs.MercTexture[mercGFX::JETFLAME], texini.GetValue("Merc", "jetflame")); LoadTex(gs.MercTexture[mercGFX::SHOOT], texini.GetValue("Merc", "shoot")); gs.MercSprite.Idle = Sprite("assets/sprite/merc/still.sprh", gs.MercTexture[mercGFX::IDLE]); gs.MercSprite.Run = Sprite("assets/sprite/merc/run.sprh", gs.MercTexture[mercGFX::RUN]); gs.MercSprite.Jet = Sprite("assets/sprite/merc/jet.sprh", gs.MercTexture[mercGFX::JET]); gs.MercSprite.JetFlame = Sprite("assets/sprite/merc/jetflame.sprh", gs.MercTexture[mercGFX::JETFLAME]); gs.MercSprite.Shoot = Sprite("assets/sprite/merc/shoot.sprh", gs.MercTexture[mercGFX::SHOOT]); }
bool BoxTexesLoad(void) { for (int i = 0; i < 6; i++) { char buf[256]; sprintf(buf, "data/graphics/floor%d.png", i); BoxTexes[i] = LoadTex(buf); if (BoxTexes[i].T == NULL) { return false; } } return true; }
void BULLET::init(){ /** --- INIT BULLETS -- *Init List *Load ALL textures **/ //Init List FirstBullet = new Entity_bullet; LastBullet = new Entity_bullet; FirstBullet->next = LastBullet; LastBullet ->next = NULL; timer = SDL_GetTicks(); //Init Bullet TEXTURES texBullet[0] = LoadTex( "Data//Textures//Bullets//1.png" ); texBullet[1] = LoadTex( "Data//Textures//Bullets//2.png" ); texBullet[2] = LoadTex( "Data//Textures//Bullets//3.png" ); texBullet[3] = LoadTex( "Data//Textures//Bullets//4.png" ); }
SDL_Texture* CLS_ASSETS::getTex_BG(int x){ stringstream ssaux; if( x == -1 ) return _NULL_TEX;//work work else if( BG_TEX[x] == NULL ) { ssaux << "Data//Sprites//BG//"; ssaux << x <<".png"; BG_TEX[x] = LoadTex( ssaux.str() ); } return BG_TEX[x]; }
void LoadTexturesFromData(std::vector<std::string> *tname, GLuint* Texture, GLuint type) { if(tname->empty()) return; glGenTextures(tname->size(), Texture); for(size_t k = 0; k < tname->size();k++){ if(!LoadTex(Texture[k], (*tname)[k].c_str())){ fprintf(stderr, "Failed loading %s!\n", (*tname)[k].c_str()); } else { fprintf(stdout, "Loaded: %s ...... \n", (*tname)[k].c_str()); } } }
void mesh::LoadMesh(string obj_file) { char token[100], buf[100], v[5][100]; // v[5] 表示一個 polygon 可以有 5個 vertex float vec[3]; int n_vertex, n_texture, n_normal; int cur_tex = 0; // state variable: 目前所使用的 material scene = fopen(obj_file.c_str(),"r"); s_file = obj_file; if (!scene) { cout<< string("Can not open object File \"") << obj_file << "\" !" << endl; return; } cout<<endl<<obj_file<<endl; while(!feof(scene)) { token[0] = NULL; fscanf(scene,"%s", token); // 讀 token if (!strcmp(token,"g")) { fscanf(scene,"%s",buf); } else if (!strcmp(token,"mtllib")) { fscanf(scene,"%s", mat_file); LoadTex(string(obj_database) + string(mat_file)); } else if (!strcmp(token,"usemtl")) { fscanf(scene,"%s",buf); cur_tex = matMap[s_file+string("_")+string(buf)]; } else if (!strcmp(token,"v")) { fscanf(scene,"%f %f %f",&vec[0],&vec[1],&vec[2]); vList.push_back(Vec3(vec)); } else if (!strcmp(token,"vn")) { fscanf(scene,"%f %f %f",&vec[0],&vec[1],&vec[2]); nList.push_back(Vec3(vec)); } else if (!strcmp(token,"vt")) { fscanf(scene,"%f %f",&vec[0],&vec[1]); tList.push_back(Vec3(vec)); } else if (!strcmp(token,"f")) { for (int i=0;i<3;i++) // face 預設為 3,假設一個 polygon 都只有 3 個 vertex { fscanf(scene,"%s",v[i]); //printf("[%s]",v[i]); } //printf("\n"); Vertex tmp_vertex[3]; // for faceList structure for (int i=0;i<3;i++) // for each vertex of this face { char str[20], ch; int base,offset; base = offset = 0; // calculate vertex-list index while( (ch=v[i][base+offset]) != '/' && (ch=v[i][base+offset]) != '\0') { str[offset] = ch; offset++; } str[offset] = '\0'; n_vertex = atoi(str); base += (ch == '\0')? offset : offset+1; offset = 0; // calculate texture-list index while( (ch=v[i][base+offset]) != '/' && (ch=v[i][base+offset]) != '\0') { str[offset] = ch; offset++; } str[offset] = '\0'; n_texture = atoi(str); // case: xxx//zzz,texture 設為 0 (tList 從 1 開始) base += (ch == '\0')? offset : offset+1; offset = 0; // calculate normal-list index while( (ch=v[i][base+offset]) != '\0') { str[offset] = ch; offset++; } str[offset] = '\0'; n_normal = atoi(str); // case: xxx/yyy,normal 設為 0 (nList 從 1 開始) tmp_vertex[i].v = n_vertex; tmp_vertex[i].t = n_texture; tmp_vertex[i].n = n_normal; tmp_vertex[i].m = cur_tex; } faceList.push_back(FACE(tmp_vertex[0],tmp_vertex[1],tmp_vertex[2])); } else if (!strcmp(token,"#")) // 註解 fgets(buf,100,scene); // printf("[%s]\n",token); } if (scene) fclose(scene); vTotal = vList.size(); nTotal = nList.size(); tTotal = tList.size(); fTotal = faceList.size(); printf("vetex: %d, normal: %d, texture: %d, triangles: %d\n",vTotal, nTotal, tTotal, fTotal); }
//////////////////////////////////////////////////////////// /// Load a map //////////////////////////////////////////////////////////// void MainClient::_loadMap(const char *p_MapPath) { if(map != NULL){ bgmfdelete(map); map = NULL; mPhysics->remAllStaticShapes(); } //Load the map map = bgmfopen(p_MapPath); //Map textures { //Generate polygon texture(s) float tsz = map->texpath.size(); float tw = tsz*128.0f; float th = 128.0f; sf::Image texturedata(tw, th); //Create the actual OpenGL texture { sf::Image rawImg; std::string fpath; for(size_t i=0;i<tsz;i++){ fpath = "assets/texture/" + map->texpath[i]; rawImg.LoadFromFile(fpath); texturedata.Copy(rawImg, 128*i, 0); } glGenTextures(1, &gs.map.Texture); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, gs.map.Texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tw, th, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturedata.GetPixelsPtr()); glDisable(GL_TEXTURE_2D); } } //Load Map Scenery { if(!gs.map.SceneryTextures.empty()){ glDeleteTextures(gs.map.SceneryTextures.size(), &gs.map.SceneryTextures[0]); gs.map.SceneryTextures.clear(); gs.map.Scenery.clear(); } int i = map->sprpath.size(); if(i){ gs.map.SceneryTextures.resize(i); glGenTextures(i, &gs.map.SceneryTextures[0]); std::string fpath; //Load the actual texture data for(int k=0;k<i;k++){ fpath = "assets/scenery/" + map->sprpath[k]; LoadTex(gs.map.SceneryTextures[k], fpath.c_str()); } //Fling sprite objects into existance for(unsigned k=0;k<map->header.sprc;k++){ i = map->sprite[k].id; fpath = "assets/scenery/" + map->sprheader[i]; Sprite spr(fpath.c_str(), gs.map.SceneryTextures[i]); spr.pInfo.pos = map->sprite[k].pos; gs.map.Scenery.push_back(spr); } } } //Polygon vertexes glm::vec2 _DefaultTC[4]; _DefaultTC[0] = glm::vec2(0.0f, 0.0f); _DefaultTC[1] = glm::vec2(0.0f, 1.0f); _DefaultTC[2] = glm::vec2(1.0f, 0.0f); _DefaultTC[3] = glm::vec2(1.0f, 1.0f); glm::vec3 v0,v1,v2; float texstep = 1.0f / map->texpath.size(); glm::vec2 swap; size_t i = 0; GLushort indeces = 0; gs.map.Index.clear(); map->hpc = 0; //Add polygons to the space for(bgmf_poly *p = &map->poly[0];p!=&map->poly[map->header.pc];p++) { v0 = p->data[0]; v1 = p->data[1]; v2 = p->data[2]; if(!map->mask[i].bit.hollow){ mPhysics->addStaticSegmentShape(v0, v1, MAPPOLYGON); mPhysics->addStaticSegmentShape(v1, v2, MAPPOLYGON); mPhysics->addStaticSegmentShape(v2, v0, MAPPOLYGON); } else if(map->mask[i].bit.hollow && !map->hpc){ map->hpc = indeces; } swap = _DefaultTC[0]; swap.x = swap.x * texstep + map->texture[i] * texstep; map->texcoord[i].data[0] = (swap); swap = _DefaultTC[1]; swap.x = swap.x * texstep + map->texture[i] * texstep; map->texcoord[i].data[1] = (swap); swap = _DefaultTC[2]; swap.x = swap.x * texstep + map->texture[i] * texstep; map->texcoord[i].data[2] = (swap); map->Data.push_back(MapVertex(v0, map->texcoord[i].data[0], map->color[i].data[0])); map->Data.push_back(MapVertex(v1, map->texcoord[i].data[1], map->color[i].data[1])); map->Data.push_back(MapVertex(v2, map->texcoord[i].data[2], map->color[i].data[2])); gs.map.Index.push_back(indeces); gs.map.Index.push_back(indeces+1); gs.map.Index.push_back(indeces+2); indeces += 3; for(unsigned k=3;k<p->data.size();k++){ v0 = p->data[k]; v1 = p->data[k-1]; v2 = p->data[k-2]; if(!map->mask[i].bit.hollow){ mPhysics->addStaticSegmentShape(v0, v1, MAPPOLYGON); mPhysics->addStaticSegmentShape(v1, v2, MAPPOLYGON); mPhysics->addStaticSegmentShape(v2, v0, MAPPOLYGON); } swap = _DefaultTC[k%4]; swap.x = swap.x * texstep + map->texture[i] * texstep; map->texcoord[i].data[k] = (swap); map->Data.push_back(MapVertex(v1, map->texcoord[i].data[k-1], map->color[i].data[k-1])); map->Data.push_back(MapVertex(v2, map->texcoord[i].data[k-2], map->color[i].data[k-2])); map->Data.push_back(MapVertex(v0, swap, map->color[i].data[k])); gs.map.Index.push_back(indeces); gs.map.Index.push_back(indeces+1); gs.map.Index.push_back(indeces+2); indeces += 3; } i++; } //Set up the map VBO { gs.map.Shdr = new Shader("assets/shader/default.vert", "assets/shader/default.frag"); glGenVertexArrays(1, &gs.map.VAO); glBindVertexArray(gs.map.VAO); glGenBuffers(1, &gs.map.VBO); glBindBuffer(GL_ARRAY_BUFFER, gs.map.VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(map->Data[0])*map->Data.size(), &map->Data[0], GL_STATIC_DRAW); glGenBuffers(1, &gs.map.IVBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gs.map.IVBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLushort)*gs.map.Index.size(), &gs.map.Index[0], GL_STATIC_DRAW); glVertexAttribPointer(gs.map.Shdr->GetAttrib("vPosition"), 3, GL_FLOAT, GL_FALSE, sizeof(MapVertex), BUFFER_OFFSET(0)); glEnableVertexAttribArray(gs.map.Shdr->GetAttrib("vPosition")); glVertexAttribPointer(gs.map.Shdr->GetAttrib("vUV"), 2, GL_FLOAT, GL_FALSE, sizeof(MapVertex), BUFFER_OFFSET(sizeof(glm::vec3))); glEnableVertexAttribArray(gs.map.Shdr->GetAttrib("vUV")); glVertexAttribPointer(gs.map.Shdr->GetAttrib("vColor"), 4, GL_FLOAT, GL_FALSE, sizeof(MapVertex), BUFFER_OFFSET(sizeof(glm::vec3)+sizeof(glm::vec2))); glEnableVertexAttribArray(gs.map.Shdr->GetAttrib("vColor")); } }