Hey all I’m trying to draw a quad and move it by 100 units on the x axis every time I find a .obj file in a folder except it only draws the quad once and doesn’t move another time even tho I’m using a for loop? and the equation seems correct?.
I’m using OpenGL 3.3 / GLSL 3.30 / Boost libary / C++
any ideas to fixing this?
if(StorageToggle == true)
{
draw_rectangle(&storage);
//////////////////////////////
//Directory Reading Proccess
/////////////////////////////
//File Path
path p("Storage");
//String vector container
std::vector < std::string > list;
//Iteration Loop
try
{
for (directory_iterator it(p); it != directory_iterator(); ++it)
{
cout << *it << endl;
//find the it path names store it in s
string s = (*it).path().string();
//then push back list
list.push_back( s );
}
}
catch (const filesystem_error& ex)
{
cout << ex.what() << endl;
}
for(string_list::iterator it = list.begin(); it != list.end(); it++)
{
string &str = *it;
if(it->find(".obj") != std::string::npos)
{
SDL_Surface *surface2;
surface2 = IMG_Load("GUI/ObjGraphic.tga");
glGenTextures(1, &objtextureID);
glGenBuffers(1, &objvbo);
glBindBuffer(GL_ARRAY_BUFFER, objvbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(ObjGraphicVertices), ObjGraphicVertices , GL_DYNAMIC_DRAW);
glBindTexture(GL_TEXTURE_2D, objtextureID);
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, surface2->w,surface2->h, 0, GL_BGR, GL_UNSIGNED_BYTE, surface2->pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float),reinterpret_cast<const GLvoid *>(0 * sizeof(float)));
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 6 * sizeof(float),reinterpret_cast<const GLvoid *>(4 * sizeof(float)));
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
xvalue + 100.0f;
static const GLfloat TranslationMatrix[] = {
1.0, 0.0, 0.0, xvalue,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
};
glUniformMatrix4fv(translation, 1, TRUE, TranslationMatrix);
glDrawArrays(GL_QUADS, 0, 4);
}
}
}