the_Predator

Members
  • Content count

    15
  • Joined

  • Last visited

Community Reputation

310 Neutral

About the_Predator

  • Rank
    Member
  1. Vulkan Vulkan Resources

    Awesome, many thanks for the roundup!
  2. Issues With Sprite Batching

    The dynamic / static vertex example made it crystal clear.   Now to read up on interleaved arrays! Yey for moving forward!   Thanks a ton, this was one of the biggest hurdles I've come across so far.     Edit:   Oh, I already do this with my vertices. I suppose with multiple VBOs I'd want to group the dynamic parts separate from the static ones.
  3. Issues With Sprite Batching

    So all the different "multiple VBOs per VAO" strickly have to refer to the same vertices / the same object? I think I understand now,could you give me a real world example on how this might be useful, just so I can concretize the idea. Thanks in advance!
  4. Issues With Sprite Batching

    I've been reading the stuff you've posted and some more things, but the weird thing is, my shaders (at least the vertex shaders) DO share the same attributes and attribute indices. It still only sees the last VBO that's been bound. Or actually, more weirdly (after some tinkering), regardless of what order I batch the sprites (and consequently in which order I create and bind the VBOs), the shaders that is COMPILED last will get used.
  5. Issues With Sprite Batching

    Ah, so calls to glEnableVertexAttribArray and glVertexAttribPointer are VAO specific, not VBO specific? If that's the case... multiple programs in the same VAO work only if they are essentially be on the same object / same set of vertices? Thanks a lot for the link, I am still having some issues wrapping my head around all the various concepts an workflows.
  6. Hey guys,   I am taking some first steps using SDL and GLEW and I've hit a snag.   In short, I am trying to batch sprites. I group them by their shaders, and within those groups I group them by texture. I create one VBO for each shader, then stick all of that into a VAO. Drawing that VAO subsequently results in (apparently) only the last VBO being used.   This is the relevant VAO generation code: void SpriteBatch::CreateVertexArray()     {         if (Sprites.empty())         {             return;         }         Log::Print(V_LOG, "Creating a vertex array with %d sprite(s)", Sprites.size());         SortSprites();         if (VertexArrayID == 0)         {             glGenVertexArrays(1, &VertexArrayID);         }         glBindVertexArray(VertexArrayID);         CreateRenderBatches();         glBindVertexArray(0);     }     void SpriteBatch::CreateRenderBatches()     {         //Gotta iterate through all the sprites, create a vbo batch for every program, then reset vertices and offsets, but keep sprite index.         VBOBatches.clear();         int CurrentSprite = 0;         do         {             CreateSingleVBO(CurrentSprite);         } while (CurrentSprite < Sprites.size());         bIsDirty = false;     }     void SpriteBatch::CreateSingleVBO(int& SpriteIndex)     {                  std::vector<Vertex> Vertices;         int CurrentVertex = 0;         GLuint Offset = 0;        //RenderBatch is a struct with the following:         //       GLuint Offset;         //       GLuint NumVerticies;         //       GLuint TextureID;         //       GLint UniformTimeID;         //       GLint UniformProjectionMatrixID;         //       GLint UniformTextureID;         std::vector<RenderBatch> SingleVBOBatches;         GLuint ProgramID = Sprites[SpriteIndex]->GetProgramID();         GLuint CurrentTextureID = Sprites[SpriteIndex]->GetTextureID();         SingleVBOBatches.emplace_back(Offset, 6,             Sprites[SpriteIndex]->GetTextureID(),             Sprites[SpriteIndex]->GetUniformTimeID(),             Sprites[SpriteIndex]->GetUniformProjectionMatrixID(),             Sprites[SpriteIndex]->GetUniformTextureID());         std::vector<Vertex>& SpriteVerts = Sprites[SpriteIndex]->GetVertexData();         Vertices.insert(std::end(Vertices), std::begin(SpriteVerts), std::end(SpriteVerts));         CurrentVertex += 6;         Offset += 6;         SpriteIndex++;         for (; SpriteIndex < Sprites.size(); SpriteIndex++)         {             if (Sprites[SpriteIndex]->GetProgramID() != ProgramID)             {                 //New program, this VBO is ready, create it and move on to next                 break;             }             else if(Sprites[SpriteIndex]->GetTextureID() != CurrentTextureID)             {                 //Same program different texture. Create new batch.                 SingleVBOBatches.emplace_back(Offset, 6,                     Sprites[SpriteIndex]->GetTextureID(),                     Sprites[SpriteIndex]->GetUniformTimeID(),                     Sprites[SpriteIndex]->GetUniformProjectionMatrixID(),                     Sprites[SpriteIndex]->GetUniformTextureID());             }             else             {                 //Same program same texture, just gonna append the vertices below.                 SingleVBOBatches.back().NumVerticies+=6;             }             std::vector<Vertex>& SpriteVerts = Sprites[SpriteIndex]->GetVertexData();             Vertices.insert(std::end(Vertices), std::begin(SpriteVerts), std::end(SpriteVerts));             CurrentVertex += 6;             Offset += 6;         }         GLuint NewVBO = 0;         glGenBuffers(1, &NewVBO);         glBindBuffer(GL_ARRAY_BUFFER, NewVBO);          //SNipped out GenerateVBO below.         Sprites[SpriteIndex - 1]->GenerateVBO(NewVBO);         glBufferData(GL_ARRAY_BUFFER, Vertices.size() * sizeof(Vertex), Vertices.data(), GL_DYNAMIC_DRAW);         //glBufferData(GL_ARRAY_BUFFER, Vertices.size() * sizeof(Vertex), nullptr, GL_DYNAMIC_DRAW);         //glBufferSubData(GL_ARRAY_BUFFER, 0, Vertices.size() * sizeof(Vertex), Vertices.data());         VBOBatches.emplace_back(NewVBO, ProgramID, SingleVBOBatches);         Log::Print(V_LOG, "Generated a VBO %d", NewVBO);         return;     } ///////////////////////////     void Sprite::GenerateVBO(const GLuint& InVertexBufferID)     {         VertexBufferID = InVertexBufferID;         for (int i = 0; i < Attributes.size(); i++)         {             glEnableVertexAttribArray(i);         }         //Position attribute pointer         glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, VertexPosition));         //Color attribute pointer         glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex), (void*)offsetof(Vertex, VertexColor));         //UV attribute pointer         glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, VertexUV));     }   Finally, when I try to render it, I get this: void SpriteBatch::RenderBatches()     {         //Log::Print(V_LOG, "Number of batches: %d", VBOBatches.size());         glBindVertexArray(VertexArrayID);                  glActiveTexture(GL_TEXTURE0);         for (auto& VBO : VBOBatches)         {             Log::Print(V_LOG, "Using program %d", VBO.ProgramID);             glUseProgram(VBO.ProgramID);             for (auto& Batch : VBO.VBOBatches)             {                 glBindTexture(GL_TEXTURE_2D, Batch.TextureID);                 SetUniforms(Batch);                 glDrawArrays(GL_TRIANGLES, Batch.Offset, Batch.NumVerticies);             }         } The result is weird. If I have one program but multiple textures, it works just fine. However, the moment I have more programs, it seems as if only the last VBO added is being used, as all my sprites are grouped on wherever the last sprite is positioned.   I'm pretty sure I've omitted something crucial but I can't put my finger on it. Perhaps I am going about this the wrong way?
  7. Question About CS Degrees?

    You can't go wrong with a CS degree, as you'll cover enough ground in every aspect that touches game development that you won't have any issues specializing in this or that.
  8. Online courses / material to strengthen CV

    I can sign up for most services in Bosnia, Paypal works, PSN works, but that's about the extent of what I've tried.
  9. Online courses / material to strengthen CV

    Just to clarify - Bosnia isn't, and with the trends being as they are, never will be part of the EU, at least not in my life time. However, what I do know is that no matter where you come from, no one will reject you if you have money. Point being, I am currently working on establishing my own game development studio in Sarajevo... my country of residence doesn't really matter when online distribution is concerned. Wish me luck...
  10. Online courses / material to strengthen CV

    frob - yeah, that's usually the issue I got with agencies... at one point I actually qualified for a mobile development job, but I need corporate sponsorship for a UK visa, which ended up being a deal breaker. The one studio in my area is not correct listing, there are no studios in my area.   Thanks for the help though guys, much appreciated. I guess all I can keep doing is make stuff until someone likes it.
  11. Online courses / material to strengthen CV

    Yes, I do mean 2 years of experience as an Android developer. I have a full-time job at <snip>. I am writing this from the office. I do not have any issues finding a job - I am having issues finding a job in the gaming industry. And I actually DO want entry level jobs. No game developers worth its salt gives two shits about Java or pure Android development. For all the agencies told me, I might as well be a recent graduate.
  12. Heya,   I don't to bore anyone with too much text, so here is the basic info - I've got a BA in Computer Science, 2 years of experience as an Android developer, worked as a TA at my university teaching programming and computer graphics, with Unity basics and did freelance web development work before that.   I don't have any commercial game dev experience, all I've got are a few POC's / demos done in Unity. Most of my interviews end the same - "It's a highly competitive market and you don't have any experience".   I am trying to strengthen my overall profile, so I turned to online universities, courses, that kind of stuff. I know that coursera is a great site for these things and I'll be checking out this: https://www.coursera.org/course/gametheory2   But is there more? Is there any online "university" that isn't a scam?    Thanks in advance.   Best regards, Damir H.