Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

1745 Excellent

1 Follower

About McGrane

  • Rank

Personal Information

  • Role
  • Interests

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. McGrane

    Weird Error Loading Texture

    Ok, never-mind.. re-reading the post for my inevitable bad spelling and grammar i see the issue... glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textureID); glUniform1i(glGetUniformLocation(shaderID, "textureData"), textureID); The glGetUniformLocation should not be taking the textureID- this both solves the issue and makes sense to me. Thanks gamedev anyway, solved my problem
  2. Hey My laptop recently decided to die, so Ive been transferring my project to my work laptop just to get it up to date, and commit it. I was banging my head against the wall all day, as my textures where not displaying in my program- I was getting no errors and no indication of why it was occurring so I have been just trying to figure it out- I know the image loading was working ok, as im using image data elsewhere, I was pretty confident that the code was fine also, as ive never had an issue with displaying textures before, so I thought it might be the drivers on this laptop, (my old one was just using the built in IntelHD, while this laptop has a NVIDIA graphics card) but all seems to be up to date. Below are my basic shaders: Vertex Shader #version 330 core layout(location = 0) in vec3 position; layout(location = 1) in vec3 color; layout(location = 2) in vec3 normal; layout(location = 3) in vec2 texCoord; uniform mat4 Projection; uniform mat4 Model; out vec3 Color; out vec3 Normal; out vec2 TexCoord; void main() { gl_Position = Projection * Model * vec4( position, 1.0 ); Color = color; Normal = normal; TexCoord = vec2( texCoord.x, texCoord.y); } Fragment Shader #version 330 core in vec3 Color; in vec3 Normal; in vec2 TexCoord; uniform sampler2D textureData; void main() { vec4 textureColor = texture( textureData, TexCoord ); vec4 finalColor = textureColor * vec4( Color, 1.0f); gl_FragColor = finalColor; } Calling Code glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textureID); glUniform1i(glGetUniformLocation(shaderID, "textureData"), textureID); Now this is the part i dont understand, I worked through my program, until I got to the above 'Calling Code'. This just displays a black texture.. my original issue. Out of desperation, I just tried changing the name in glGetUniformLocation from "textureData" to "textureData_invalid" to see if my error checks would through up something, but in actual fact, it is now displaying the texture as expected. Can anyone fathom a guess as too why this is occurring.. im assuming the random text is just picking up the correct location by c++ witchcraft, but why is the original one not getting picked up correctly and/or not working as expected I realize more code is probably needed to see how it all hangs together.. but it seems to come down to this as the issue
  3. McGrane

    Rip internet 2017-12-14

    They tried to bring in a water charge in Ireland in the last year or two inline with EU regulations, and are now currently refunding the minority of people who paid bills as a mass boycott ensued- I could imagine the backlash of something similar happening in this case. I'm pretty sure the EU has regulated for net neutrality in some form here any way- so ive no real concern of this happening anytime soon in Europe. I admittedly haven't been following this too much, as it doesn't really affect me, but the impression im getting is that no one in the public wishes for this to happen, but yet the government are going to do it anyway, regardless of all the protesting.. It seems to be public corruption, that no one seems to be able to stop, which is worrying. Maybe it will backfire, and will open competition - I could only image if one company started advertising services where they would not throttle connections etc. they would suck up customers- and then to stay competitive, the other ISP's would have to follow suit- but from the comments above, it doesnt look like there is much choice in ISP's around America- maybe this will also change
  4. Yeah, so in the above, you are creating a shader- and then telling opengl to use this shader: glUseProgram(shaderProgram); If you wish to use another shader, you do the same as you have done above in creating, compiling and linking another shader. You may want to extend your above to read shaders from text files instead of implementing them in code, and maybe making a shader class to encapsulate all these methods to just make it easier for maintainability. However to just get this working as is, say you have two shaders, and have compiled the into shaderProgram1 and shaderProgram2 then too use them you could just do something like: If you haven't already, check out https://learnopengl.com/ there are sections on shaders, and code examples for how he has set up his shader classes - along with alot of other great information
  5. Without seeing how you are currently doing it, I can only really give a generic example, but you basically just want to create all your shaders, select the shader you wish to use - render all items that use this shader, switch to the next shader, render all items that use that shader, and so on Switching shaders can be expensive, so thats why you will want to do all items for each shader before moving to the next, rather then switching shaders depending on what your rendering at the time. If you can show a small bit of code of how you are currently doing this, im sure you will get more specific anwers
  6. McGrane

    Tilemap rendering 2D RPG

    You should assign your indexer to an int, and step through it to ensure it is getting what you expect, there isint much information in what you showed - but i suspect its your m_layerColumns id suspect that this is accessing the wrong value, depending on what its value actually is ( isint shown )
  7. McGrane

    Tilemap rendering 2D RPG

    As Endurion mentioned, the problem lies in your index: Once you move your tileX or tileY - it goes out of bounds. You should maybe instead use something like: for (int y = 0; y < m_layerRows; y++) { for (int x = 0; x < m_layerColumns; x++) { tileValue = m_tileMap[(y * m_layerColumns) + x]; ... } } And use another method to translate your map, maybe even something like: m_sourceRectangle.left = (int)(m_currentDrawPosition.x + (long)((tileValue % textureColumns) * m_tileDimensions.x); Im not sure what you are using to do your rendering, but if its opengl or directx or using shaders, maybe just use the modelview to translate the whole map. Id get a whole map working and moving as you want first, and then maybe think of optimizing it to only display the parts you want when you need to, it may never come up Also apologizes if i just misunderstood what you wanted, i honestly just had a min to scan over the code
  8. McGrane

    Favourite cocktails?

    Just from an Irish perspective i couldn't help but comment - This is the first time I have ever seen someone say they enjoy canned Guinness Don't get me wrong, I love a pint of Guinness, but the cans just don't compare ( in my opinion ), they have tried a few ways, including the draught cans, but I never thought they came close. The shelves are full of them here, as they don't sell well. *Rant over* As far as cocktails, no real favorite, ill try them all once - or maybe twice
  9. McGrane


    Getting closer - the reason it is not red, and/or other issues you may see may be due to your error handling. As you mentioned, you are seeing a linker error, but you are not doing anything but outputting the error, and then carrying on, this could be cascading the problem to the next shader, and causing unknown issues. The easiest way to handle this is to turn your compileShaders method into a boolean method, and return false once an error is detected (after outputting your error somewhere) - this way your program will stop at the stage it fails, rather then going on to do whatever craziness it might do after a section fails.. A shader failure is not something you really need to try to recover from, as if its incorrect its incorrect- you fix it, recompile, and hopefully it will move onto the next shader, and you fix it then and so on.. If you havent already, check out https://learnopengl.com/ Its a great resource for getting you up and going in opengl, and is quite easy to follow, unlike alot of the opengl tutorials out there
  10. McGrane


    Apologies, you are correct, i had said 12x rather then 9x. Are you getting any warnings in your code, I would expect the returning of the address shown below would cause a warning: You are returning the address of a local variable, which may also cause an issue, in this case you could just return what the value actually is. Maybe just step through your program and see what you get for your shader ID's VAO etc. when you generate them, and compare them when they are later called, for example with the above mentioned, see if the below is what is expected
  11. McGrane


    Just on this, although it appears correct, when you pass an array like this, you are passing a pointer to its first element, if you check the sizeof function, it will say the size of your array is only 4 bytes so when you pass your array using glBufferData, you are saying to pass the 4 bytes. Your coordinates array is 12 floats - which is 12 x 4 bytes = 48 bytes. So you are not sending the whole array
  12. McGrane


    At a very quick glance over you code, I suspect this is an issue (there may be more), you appear to be passing in the sizeof( pointer ) - what you need here is the size of the array you are passing in - so something like sizeof(float)*countVertices If the above doesnt help, maybe just add some error checks to ensure that your shaders are compiling and linking as expected- I know you dont want to add error checks yet, but maybe just start with these
  13. I have my doubts that anyone is going to download ( im not going to download some random zip file from a forum ) and fix your code for you considering you haven't said what the problem is, how you attempted to fix it, or what part you don't understand / is broken. Its a huge time investment considering you haven't invested the time in explaining the problem Maybe put your code on github or something similar that someone can just browse to safely, and explain your problem in more depth, and you are more likely to get help in my opinion
  14. McGrane

    The missing triangle.

    I know the article you referenced mentions that they wish to use Xwindow and makes points of how easy it is, but could I just suggest you use something like glfw if your main aim is to just do graphics programming - and once you get used to it you could switch back to X if you wish. Your above code also seems to mix legacy OpenGL and modern opengl quite a bit, and commenting on what parts are wrong would take more time then i have at the minute, can i suggest reading through learnopengl.com It is a great starting point and talks through most if not all issues you are seeing - even if you want to get your own program running and carry on with those tutorials - just have a look at the hello triangle page, and it will show you how to correctly set up your buffers and render to the screen
  15. My first post was probably something similar, although Ive never had much interest in MMO RPGs, it was probably a FPS or something along those lines. The same advice would have been given to me, and I also just shrugged my shoulders at the people, we all probably have. I'm not discouraging you. I, like most people here would like you to prove me wrong. I think when we all start we all have a little bit of a Expert Beginner complex. When i do see posts like yours, i always see them with a little fondness and nostalgia as like most of us its where my journey in gamedev started. The point of doing smaller projects is that you will learn these concepts quicker, and then build up to larger projects. Your code is like lego, you can reuse pieces and blocks of code in your project, but you need a strong base if you want to build something huge - its harder to go back and fix it after you realize the design was wrong from the start. This is all off topic from the original question, so I'm going to leave it at that and wish you all the best with your game.
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!