Jump to content
  • Advertisement

cebugdev

Member
  • Content count

    231
  • Joined

  • Last visited

Community Reputation

636 Good

About cebugdev

  • Rank
    Member

Personal Information

  • Role
    Programmer
  • Interests
    Programming

Recent Profile Visitors

10043 profile views
  1. since our game is p2p, one vs one game, we are planning to implement our game in a peer to peer manner wherein there is no central game server but instead the users will just host it on his phone and the challenger will just connect to his him thru sockets. There will be a central database to handle stats, authentication, etc. (implemented thru firebase). more or less looks like this So here are the flow in a nutshell. 1. when user logs in to the game, his IP address will be logged in the firebase database. 2. the user is presented with a list of users online to challenge. when use clicks on a player, the user issues a challenge. when the challenged player accepts the challenge, the user connects to him directly. Now, my issue. This works if both or all users are in the same network since their IP will be unique, but if say for example, we are playing across internet, there is a chance that 1 or two users will have the same IP (when using public IP) when two players are in the same network (ex: office wifi) Situation 1: both user1 and user2 uses mobile data, both of them has public IP (no issue) Situation 2: user1 uses mobile data, user2 uses office wifi, user2 shared the same public IP to his officemate. user1 and user2 play against each other with no issue, but what happen if, say user3 who shares the same wifi with user2 also wants to connect and challenge somebody in the game, he uses the same IP address therefore there is an issue if we somebody needs to connect to that IP address since two users share the same public IP. Also, to help the discussion we are using native (linux) sockets in C++ in both iOS and Android. Any tips on how to handle this? How does applications working with peer to peer handle this?
  2. a simple assignment such as bellow int main() { double variable = 1.4; double value = variable; return 0; } the value of both variable and value is 1.399999999999999 Why is this? BUT when setting this double value = 1.5; Gives correct result!! why? Any idea on how to resolve this or atleast a workaround?
  3. Hi all, I know that most inverted texture issue is because of inverted coordinate system but this case maybe different. so here are the facts. 1. I am rendering a 2D sprite using a quad and a texture in orthographic projection. I was just following the code from learnopengl.com here https://learnopengl.com/In-Practice/2D-Game/Rendering-Sprites have a look at initRenderData() void SpriteRenderer::initRenderData() { // Configure VAO/VBO GLuint VBO; GLfloat vertices[] = { // Pos // Tex 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f }; ... } Please take note that this was rendered in orthographic projection, which means the coordinates of this quads are in screenspace (top left are 0,0 and bottom right are width,height) and please observed the texture coordinate as well, instead of 0,0 at the bottom left, with width, height at top right the coordinates is inverted instead. SO if we are using orthographic projection, does this mean texture coordinates are inverted as well? Is this assumption correct? 2. When rendering this quad straight, everything is OK and rendered with proper orientation void Sprite2D_Draw(int x, int y, int width, int height, GLuint texture) { // Prepare transformations glm::mat4 model = glm::mat4(1.0f); //initialize to identity // First translate (transformations are: scale happens first, // then rotation and then finall translation happens; reversed order) model = glm::translate(model, glm::vec3(x, y, 0.0f)); //Resize to current scale model = glm::scale(model, glm::vec3(width, height, 1.0f)); spriteShader.Use(); int projmtx = spriteShader.GetUniformLocation("projection"); spriteShader.SetUniformMatrix(projmtx, projection); int modelmtx = spriteShader.GetUniformLocation("model"); spriteShader.SetUniformMatrix(modelmtx, model); int textureID = spriteShader.GetUniformLocation("texture"); glUniform1i(textureID, 0); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture); glBindVertexArray(_quadVAO); glBindBuffer(GL_ARRAY_BUFFER, _VBO); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (GLvoid*)0); glDrawArrays(GL_TRIANGLES, 0, 6); glBindBuffer(GL_ARRAY_BUFFER, 0); } draw call glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); //display to main screen Sprite2D_Draw(0, 0, 500, 376, _spriteTexture); result BUT when rendering that image into a frame buffer, the result is inverted! here is the code #if 1 frameBuffer.Bind(); glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); //... display backbuffer contents here //draw sprite at backbuffer 0,0 Sprite2D_Draw(0, 0, 1000, 750, _spriteTexture); //----------------------------------------------------------------------------- // Restore frame buffer frameBuffer.Unbind(SCR_WIDTH, SCR_HEIGHT); #endif glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); //display to main screen Sprite2D_Draw(0, 0, 500, 376, frameBuffer.GetColorTexture()); result, why? for reference here is the FBO code int FBO::Initialize(int width, int height, bool createDepthStencil) { int error = 0; _width = width; _height = height; // 1. create frame buffer glGenFramebuffers(1, &_frameBuffer); glBindFramebuffer(GL_FRAMEBUFFER, _frameBuffer); // 2. create a blank texture which will contain the RGB output of our shader. // data is set to NULL glGenTextures(1, &_texColorBuffer); glBindTexture(GL_TEXTURE_2D, _texColorBuffer); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, _width, _height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL ); error = glGetError(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // 3. attached our texture to the frame buffer, note that our custom frame buffer is already active // by glBindFramebuffer glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texColorBuffer, 0 ); error = glGetError(); // 4. we create the depth and stencil buffer also, (this is optional) if (createDepthStencil) { GLuint rboDepthStencil; glGenRenderbuffers(1, &rboDepthStencil); glBindRenderbuffer(GL_RENDERBUFFER, rboDepthStencil); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, _width, _height); } error = glGetError(); // Set the list of draw buffers. this is not needed? //GLenum DrawBuffers[1] = { GL_COLOR_ATTACHMENT0 }; //glDrawBuffers(1, DrawBuffers); // "1" is the size of DrawBuffers error = glGetError(); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { return -1; } // Restore frame buffer glBindFramebuffer(GL_FRAMEBUFFER, 0); return glGetError();; } void FBO::Bind() { // Render to our frame buffer glBindFramebuffer(GL_FRAMEBUFFER, _frameBuffer); glViewport(0, 0, _width, _height); // use the entire texture, // this means that use the dimension set as our total // display area } void FBO::Unbind(int width, int height) { glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, width, height); } int FBO::GetColorTexture() { return _texColorBuffer; } this is how it was initialized FBO frameBuffer; frameBuffer.Initialize(1024, 1080); spriteShader.Init(); spriteShader.LoadVertexShaderFromFile("./shaders/basic_vshader.txt"); spriteShader.LoadFragmentShaderFromFile("./shaders/basic_fshader.txt"); spriteShader.Build(); hayleyTex = LoadTexture("./textures/smiley.jpg"); Sprite2D_InitData(); Any one knows what is going on in here?
  4. hi all, i am trying to implement a textbox with scroll where you can display as many text as you can and just use the scroll bar to see the rest of the image, same as to how listbox works, etc I have implemented this using 2D SDL by displaying the messages in an extra framebuffer/texture and just bitBlk the portion of it to the main screen depending on offset. I am porting my 2D SDL code to straight OpenGL ES 2.0 by creating extra framebuffer(FBO) and render to texture, now my question is how to select a portion of that texture to be rendered only in OpenGL ES 2.0 (more like how is bitblk can be implemented in OpenGL ES 2.0)? I was thinking to using scissors but im not sure if this is the right solution. Also, I am using OpenGL ES 2.0 (Mobile) so not all libraries from desktop OpenGL is available. In Summary 1. How to do bitblk in OpenGL ES.0 for textures rendered in orthographic projection (2D)?
  5. Hi, ive been wondering how to texture a GL_LINES in OpenGL, the thing is im using OpenGL ES 2.0, so it may be possible for desktop OpenGL 3.3+ but im not sure if it is possible to texture a line in OpenGL ES 2.0
  6. originally, i just use GL_LINE_STRIP to render lines and it has been evident in different device the difference in width of the lines, plus i cannot texture it! so i decided to use triangles to render my lines so i can have control on its width and add some textures,, i can already convert a line segment based from two given points, or two lines using 3 points using textured quad, I want to do the joints of these quads next, since the app needs to draw using the mobile touchscreen, so it is fitting to have a circular cap/joints instead of those pointy joints. I saw some lessons and tutorials and they suggest as simple as adding a circle in the joint end, is that really how simple it is done? Let me know if you guys have any tips and further suggestions, or link to a source/tutorial (OpenGL/OGL ES). much appreciated!
  7. Hi, we are planning to contract a 3rd party art provider to work on our games, we have already secured the funding and budget, however since this is our first rodeo ride with 3rd party doing assets for us, can you guys give advice on how to handle such things? 1. Will they take credits to the game as well or not? maybe arrange special discount that they will be included in the credits for a certain discount or something? 2. can they use their art as portfolio to their company as well or not? I know that most of the answer will be "depends on your contract or agreement" but what would be the best scenario/contract/agreement for this. Any professional advice is a great help! Thanks!
  8. Hi guys, we are working on a game right now, our engine is using OpenGL ES 2.0, and we want to establish a Pokemon Go style map where a 3D character walks around a 3D map via GEO location, Let me know some tips on how to do this using native Android and OpenGL ES. Do I use the default map API or should i re-render the maps in 3D? is there any tutorial, resources, books, links that discusses how to do this?
  9. hi all, how to implement this type of effect ? Also what is this effect called? this is considered volumetric lighting? what are the options of doing this? a. billboard? but i want this to have the 3D effect that when we rotate the camera we can still have that 3d feel. b. a transparent 3d mesh? and we can animate it as well? need your expert advise. additional: 2. how to implement things like fireball projectile (shot from a monster) (billboard texture or a 3d mesh)? Note: im using OpenGL ES 2.0 on mobile. thanks!
  10. i'd like to have a little control on how the lines will be rendered, ex: texturing it or adding a glow, ive been around the thread also in gamedev.net and they suggested that to have a full control in rendering we will not use the default GL_LINES but instead rendered it as triangles, I cant find any tutorials on how to do this or atleast a sample, can you guys give me a code snippet on how to do this? what i have right now are points rendered using GL_LINES and pairs of X,Y screen coordinates (ortho/2d projection) from mouse click. example, (0,0) (10,10), (10,10), (20,20), ... if you guys can point me to any tutorials, code snippets, please do i want to achieve line like this (drawn using mouse): https://www.gamedev.net/uploads/monthly_2017_11/S2.png.202e4f4c3d4255fe5ded81438a6e79b7.png
  11. cebugdev

    opengl es texturing line

    if that's the case, can you guys point me to any resources or tutorials on how to render lines as triangles efficiently without using so m any vertices?
  12. i have an application that allows drawing thru touch just like paint and using opengl es (mobile), currently, the line is just drawing with simple/default line style of opengl using GL_LINE_STRIP, i want to have different pen style on it, just like attached, so my question, is it possible to texture an opengl Line (GL_LINE_STRIP) so i can achieve my desired effect (see attached)? i know its possible to texture an OpenGL point via point sprite, but i have not found anything related to texturing an opengl Line. is this possible?
  13. Hi all, im loading an FBX file using Assimp and everything is OK including the animation but there is one certain FBX file that seems that the other meshes are not in the proper place. see attached screenshot (not align mesh.png), the correct ones should be the blades should be on the side of the character and not going thru its center. i have used assimp viewer and load and view the FBX file can it can be loaded and viewed correctly, which means Assimp can load the FBX format properly. Assimp Viewer output: the FBX file has 4 meshes, all the other 3 mesh including the entire body mesh has been positioned correctly except for the second mesh (index 1) which is the blade. I have been going thru my code again and again and can't find the problem, what could have i missed? here is my assimp loader code (without the animation and bone processing part as this problem happen with static mesh loading) bool AssimpMesh::Load(const std::string& Filename) { CleanUp(); m_pScene = m_Importer.ReadFile(Filename.c_str(), aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_JoinIdenticalVertices); bool Ret = false; if (m_pScene) { m_GlobalInverseTransform = AiToGLMMat4(m_pScene->mRootNode->mTransformation); m_GlobalInverseTransform = glm::inverse(m_GlobalInverseTransform); Ret = InitFromScene(m_pScene, Filename); } else { printf("Error parsing '%s': '%s'\n", Filename.c_str(), m_Importer.GetErrorString()); } return Ret; } bool AssimpMesh::InitFromScene(const aiScene* pScene, const std::string& Filename) { m_Entries.resize(pScene->mNumMeshes); m_Textures.resize(pScene->mNumMaterials); // Initialize the meshes in the scene one by one for (unsigned int i = 0; i < pScene->mNumMeshes; i++) { m_Entries[i].MaterialIndex = pScene->mMeshes[i]->mMaterialIndex; m_Entries[i].NumIndices = pScene->mMeshes[i]->mNumFaces * 3; const aiMesh* paiMesh = pScene->mMeshes[i]; std::vector<glm::vec3> Positions; std::vector<glm::vec3> Normals; std::vector<glm::vec2> TexCoords; std::vector<unsigned int> Indices; std::vector<VertexBoneData> Bones; Bones.resize(pScene->mMeshes[i]->mNumVertices); InitMesh(i, paiMesh, Positions, Normals, TexCoords, Bones, Indices); MeshEntry* entry = &m_Entries[i]; glGenVertexArrays(1, &entry->m_VAO); glBindVertexArray(entry->m_VAO); // Create the buffers for the vertices attributes glGenBuffers(ARRAY_SIZE_IN_ELEMENTS(entry->m_Buffers), entry->m_Buffers); // Generate and populate the buffers with vertex attributes and the indices glBindBuffer(GL_ARRAY_BUFFER, entry->m_Buffers[POS_VB]); glBufferData(GL_ARRAY_BUFFER, sizeof(Positions[0]) * Positions.size(), &Positions[0], GL_STATIC_DRAW); glEnableVertexAttribArray(POSITION_LOCATION); glVertexAttribPointer(POSITION_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, entry->m_Buffers[TEXCOORD_VB]); glBufferData(GL_ARRAY_BUFFER, sizeof(TexCoords[0]) * TexCoords.size(), &TexCoords[0], GL_STATIC_DRAW); glEnableVertexAttribArray(TEX_COORD_LOCATION); glVertexAttribPointer(TEX_COORD_LOCATION, 2, GL_FLOAT, GL_FALSE, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, entry->m_Buffers[NORMAL_VB]); glBufferData(GL_ARRAY_BUFFER, sizeof(Normals[0]) * Normals.size(), &Normals[0], GL_STATIC_DRAW); glEnableVertexAttribArray(NORMAL_LOCATION); glVertexAttribPointer(NORMAL_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, entry->m_Buffers[BONE_VB]); glBufferData(GL_ARRAY_BUFFER, sizeof(Bones[0]) * Bones.size(), &Bones[0], GL_STATIC_DRAW); glEnableVertexAttribArray(BONE_ID_LOCATION); glVertexAttribIPointer(BONE_ID_LOCATION, 4, GL_INT, sizeof(VertexBoneData), (const GLvoid*)0); glEnableVertexAttribArray(BONE_WEIGHT_LOCATION); glVertexAttribPointer(BONE_WEIGHT_LOCATION, 4, GL_FLOAT, GL_FALSE, sizeof(VertexBoneData), (const GLvoid*)16); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, entry->m_Buffers[INDEX_BUFFER]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices[0]) * Indices.size(), &Indices[0], GL_STATIC_DRAW); glBindVertexArray(0); } if (!InitMaterials(pScene, Filename)) { return false; } return true; } bool AssimpMesh::InitFromScene(const aiScene* pScene, const std::string& Filename) { m_Entries.resize(pScene->mNumMeshes); m_Textures.resize(pScene->mNumMaterials); // Initialize the meshes in the scene one by one for (unsigned int i = 0; i < pScene->mNumMeshes; i++) { m_Entries[i].MaterialIndex = pScene->mMeshes[i]->mMaterialIndex; m_Entries[i].NumIndices = pScene->mMeshes[i]->mNumFaces * 3; const aiMesh* paiMesh = pScene->mMeshes[i]; std::vector<glm::vec3> Positions; std::vector<glm::vec3> Normals; std::vector<glm::vec2> TexCoords; std::vector<unsigned int> Indices; std::vector<VertexBoneData> Bones; Bones.resize(pScene->mMeshes[i]->mNumVertices); InitMesh(i, paiMesh, Positions, Normals, TexCoords, Bones, Indices); MeshEntry* entry = &m_Entries[i]; glGenVertexArrays(1, &entry->m_VAO); glBindVertexArray(entry->m_VAO); // Create the buffers for the vertices attributes glGenBuffers(ARRAY_SIZE_IN_ELEMENTS(entry->m_Buffers), entry->m_Buffers); // Generate and populate the buffers with vertex attributes and the indices glBindBuffer(GL_ARRAY_BUFFER, entry->m_Buffers[POS_VB]); glBufferData(GL_ARRAY_BUFFER, sizeof(Positions[0]) * Positions.size(), &Positions[0], GL_STATIC_DRAW); glEnableVertexAttribArray(POSITION_LOCATION); glVertexAttribPointer(POSITION_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, entry->m_Buffers[TEXCOORD_VB]); glBufferData(GL_ARRAY_BUFFER, sizeof(TexCoords[0]) * TexCoords.size(), &TexCoords[0], GL_STATIC_DRAW); glEnableVertexAttribArray(TEX_COORD_LOCATION); glVertexAttribPointer(TEX_COORD_LOCATION, 2, GL_FLOAT, GL_FALSE, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, entry->m_Buffers[NORMAL_VB]); glBufferData(GL_ARRAY_BUFFER, sizeof(Normals[0]) * Normals.size(), &Normals[0], GL_STATIC_DRAW); glEnableVertexAttribArray(NORMAL_LOCATION); glVertexAttribPointer(NORMAL_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, entry->m_Buffers[BONE_VB]); glBufferData(GL_ARRAY_BUFFER, sizeof(Bones[0]) * Bones.size(), &Bones[0], GL_STATIC_DRAW); glEnableVertexAttribArray(BONE_ID_LOCATION); glVertexAttribIPointer(BONE_ID_LOCATION, 4, GL_INT, sizeof(VertexBoneData), (const GLvoid*)0); glEnableVertexAttribArray(BONE_WEIGHT_LOCATION); glVertexAttribPointer(BONE_WEIGHT_LOCATION, 4, GL_FLOAT, GL_FALSE, sizeof(VertexBoneData), (const GLvoid*)16); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, entry->m_Buffers[INDEX_BUFFER]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices[0]) * Indices.size(), &Indices[0], GL_STATIC_DRAW); glBindVertexArray(0); } if (!InitMaterials(pScene, Filename)) { return false; } return true; } void AssimpMesh::InitMesh(unsigned int MeshIndex, const aiMesh* paiMesh, std::vector<glm::vec3>& Positions, std::vector<glm::vec3>& Normals, std::vector<glm::vec2>& TexCoords, std::vector<VertexBoneData>& Bones, std::vector<unsigned int>& Indices) { const aiVector3D Zero3D(0.0f, 0.0f, 0.0f); // Populate the vertex attribute vectors for (unsigned int i = 0; i < paiMesh->mNumVertices; i++) { const aiVector3D* pPos = &(paiMesh->mVertices[i]); const aiVector3D* pNormal = &(paiMesh->mNormals[i]); const aiVector3D* pTexCoord = paiMesh->HasTextureCoords(0) ? &(paiMesh->mTextureCoords[0][i]) : &Zero3D; Positions.push_back(glm::vec3(pPos->x, pPos->y, pPos->z)); Normals.push_back(glm::vec3(pNormal->x, pNormal->y, pNormal->z)); TexCoords.push_back(glm::vec2(pTexCoord->x, pTexCoord->y)); } LoadBones(MeshIndex, paiMesh, Bones); // Populate the index buffer for (unsigned int i = 0; i < paiMesh->mNumFaces; i++) { const aiFace& Face = paiMesh->mFaces[i]; assert(Face.mNumIndices == 3); Indices.push_back(Face.mIndices[0]); Indices.push_back(Face.mIndices[1]); Indices.push_back(Face.mIndices[2]); } } void AssimpMesh::Render() { for (unsigned i = 0; i < m_Entries.size(); i++) { const unsigned MaterialIndex = m_Entries[i].MaterialIndex; assert(MaterialIndex < m_Textures.size()); if (m_Textures[MaterialIndex]) { m_Textures[MaterialIndex]->Bind(/*GL_TEXTURE0*/); } MeshEntry* entry = &m_Entries[i]; glBindVertexArray(entry->m_VAO); glDrawElements(GL_TRIANGLES, m_Entries[i].NumIndices, GL_UNSIGNED_INT, (void*)0); glBindVertexArray(0); } } I'm stuck on this one for hours already as it is just basic static mesh loading and i cannot find the problem what could i have missed or overlooked? (I attached the FBX file as well) Hellmech_Priest.FBX
  14. hi guys, are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well. Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic let me know if you guys have recommendations. Thank you in advance!
  15. oh god youre correct, silly me, i originally thought that the last parameter is for the number of data. Thanks man!
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!