Hey all I'm trying to draw a quad every time I find a .obj file in a folder except it only draws the quad once ? even tho I'm using a for loop

Started by
0 comments, last by the_visualist 12 years ago
Hello I'm trying to figure out how to draw a quad constantly till the end of the for loop.

I'm using Boost/C++/OpenGL 3.3/GLSL 330

I'm doing that in this code almost but for some reason its not actually drawing the quad constantly but only once. I don't really know why since I'm using a for loop and constantly creating/drawing the quad I know it may not be the most efficiently way but I just want it to work.


any ideas?




path p(" Storage");

std::vector < std::string > list;

try
{
for (directory_iterator it(p); it != directory_iterator(); ++it)
{

cout << *it << endl;

string s = (*it).path().string();

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)
{

cout << "Found .Obj" << endl;


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);
static const GLfloat TranslationMatrix[] = {

1.0, 0.0, 0.0, 600.0,
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);


}
}

}
Advertisement
Not sure if I understand your question completely, but I will give it a try:
Seems like you are always drawing it on the same position, which means all your quads are basically above each other - results in looking like one quad. Use glTranslatef to (for example) move each quad a bit more to the right.

This topic is closed to new replies.

Advertisement