• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.


  • Content count

  • Joined

  • Last visited

Community Reputation

341 Neutral

About MichaelBarth

  • Rank
  1. Ah alright. So that sounds good for now, however later down the line if I go to implement networking, that sounds like something I'm going to need. Well I could revisit this later then, unless you or anybody else has anything to say about it. It shouldn't be too hard to rework so long as I move the bulk of it to my Transform class instead of individual objects. Anyway, thank you all so much! You've been a great help.!
  2. Alright cool. What I'm getting from this is that the view matrix is essentially the same as a model matrix, just here we're handling it through some kind of input. So I guess the next thing is gimbal lock. Is it really such a scary thing that people make it out to be? Because that's probably the only reason I wanted to use Quaternions. Is this something I really need to worry about?
  3. Ah, this is so cool once you understand where things are. It does fully work now. However, I still feel like my method of clamping the yaw and pitch values is a bit silly. I'm wondering if I should refer to them in degrees instead of radians, then translate them to radians when passing it onto glm::rotate. Hm, well anyway, this is what I ended up with: void Camera::Update() { m_mat4ViewMatrix = glm::mat4(); m_flYaw += 0.02f * g_pInput->GetMouseDeltaX() * g_pEngine->GetDeltaTime(); m_flPitch += 0.02f * g_pInput->GetMouseDeltaY() * g_pEngine->GetDeltaTime(); float flYawDegrees = glm::degrees( m_flYaw ); float flPitchDegrees = glm::degrees( m_flPitch ); if ( flYawDegrees < 0.0f ) m_flYaw = glm::radians( flYawDegrees + 360.0f ); else if ( flYawDegrees > 360.0f ) m_flYaw = glm::radians( flYawDegrees - 360.0f ); if ( flPitchDegrees < 0.0f ) m_flPitch = glm::radians( flPitchDegrees + 360.0f ); else if ( flPitchDegrees > 360.0f ) m_flPitch = glm::radians( flPitchDegrees - 360.0f ); m_mat4ViewMatrix = glm::rotate( m_mat4ViewMatrix, m_flYaw, Vector3f( 0.0f, 1.0f, 0.0f ) ); m_mat4ViewMatrix = glm::rotate( m_mat4ViewMatrix, m_flPitch, Vector3f( m_mat4ViewMatrix[ 0 ][ 0 ] , m_mat4ViewMatrix[ 1 ][ 0 ], m_mat4ViewMatrix[ 2 ][ 0 ] ) ); m_mat4ViewMatrix = glm::translate( m_mat4ViewMatrix, GetPosition() ); m_vForward = Vector3f( m_mat4ViewMatrix[ 0 ][ 2 ], m_mat4ViewMatrix[ 1 ][ 2 ], m_mat4ViewMatrix[ 2 ][ 2 ] ); m_vUp = Vector3f( m_mat4ViewMatrix[ 0 ][ 1 ], m_mat4ViewMatrix[ 1 ][ 1 ], m_mat4ViewMatrix[ 2 ][ 1 ] ); m_vLeft = Vector3f( m_mat4ViewMatrix[ 0 ][ 0 ], m_mat4ViewMatrix[ 1 ][ 0 ], m_mat4ViewMatrix[ 2 ][ 0 ] ); m_vBackward = -m_vForward; m_vRight = -m_vLeft; if ( g_pInput->IsButtonPressed( "Forward" ) ) { SetPosition( GetPosition() + m_vForward * 0.01f * g_pEngine->GetDeltaTime() ); } else if ( g_pInput->IsButtonPressed( "Backward" ) ) { SetPosition( GetPosition() + m_vBackward * 0.01f * g_pEngine->GetDeltaTime() ); } if ( g_pInput->IsButtonPressed( "Left" ) ) { SetPosition( GetPosition() + m_vLeft * 0.01f * g_pEngine->GetDeltaTime() ); } else if ( g_pInput->IsButtonPressed( "Right" ) ) { SetPosition( GetPosition() + m_vRight * 0.01f * g_pEngine->GetDeltaTime() ); } } Well I'm happy this works. Anything I should look out for?
  4. I had to modify that a little bit to get it to somewhat work, but even that is wonky. This is the current code: m_mat4ViewMatrix = glm::mat4(); m_flFrameYaw += 0.02f * g_pInput->GetMouseDeltaX() * g_pEngine->GetDeltaTime(); m_flFramePitch += 0.02f * g_pInput->GetMouseDeltaY() * g_pEngine->GetDeltaTime(); m_mat4ViewMatrix = glm::rotate( m_mat4ViewMatrix, m_flFrameYaw, Vector3f( 0.0f, 1.0f, 0.0f ) ); m_mat4ViewMatrix = glm::rotate( m_mat4ViewMatrix, m_flFramePitch, Vector3f( m_mat4ViewMatrix[ 0 ][ 0 ] , m_mat4ViewMatrix[ 0 ][ 1 ], m_mat4ViewMatrix[ 0 ][ 2 ] ) ); m_mat4ViewMatrix = glm::translate( m_mat4ViewMatrix, GetPosition() ); Aside from the fact the mouse input is still weird, this still doesn't account for computing a forward direction based on the camera's current rotation or yaw. This method also continually increases\decreases the pitch and yaw values until I guess it would hit the maximum float value and wrap around. So I would need to clamp this somehow. It would seem like using a Quaternion would make this more manageable. However, with this code, the triangle isn't continually rotating when I put the mouse back towards the normal view. However, when I move my mouse away from the triangle, it gets really wonky. As per my model matrix code, yes I would like to change that, however I just changed it to return a glm::translate value so I can rule out my model matrix being the culprit. This is my scene before I move the mouse (I added a floor to make it more apparent): And this is after: If I try to very carefully just look across ONE axis, either up and down, or left and right, it does look somewhat normal. But if I move the mouse in both directions, it gets skewed like this. Again if I try to move my mouse back towards the center, it looks normal again, whereas before the triangle was staying rotated. Anything else that doesn't look right? I can show some of my other code, for example this is my shader's update function: void GenericShader::Update( const Transform &transform ) { Matrix4f modelViewProjection = g_pRenderer->GetViewPort()->GetPerspectiveProjection() * transform.GetModelMatrix(); glUniformMatrix4fv( m_mapUniforms[ "transform" ], 1, GL_FALSE, &modelViewProjection[ 0 ][ 0 ] ); glUniform4f( m_mapUniforms[ "color" ], m_vColor.r, m_vColor.g, m_vColor.b, m_vColor.a ); } This is my viewport code: bool ViewPort::InitPerspectiveViewPort( float flFOV, float flAspect, float flZNear, float flZFar, ICamera *pCamera ) { if ( pCamera == nullptr ) return false; m_pCamera = pCamera; // TODO: Add window resize handling m_mat4PerspectiveMatrix = glm::perspective( flFOV, flAspect, flZNear, flZFar ); return true; } void ViewPort::UpdateViewPort() { m_pCamera->Update(); } Matrix4f ViewPort::GetPerspectiveProjection() { return m_mat4PerspectiveMatrix * m_pCamera->GetViewMatrix(); } And lastly, here's my actual vertex shader code: #version 330 layout (location = 0) in vec3 position; uniform vec4 color; uniform mat4 transform; out vec4 color0; void main () { gl_Position = transform * vec4( position, 1.0 ); color0 = color; } *Phew, I'm sorry I'm throwing so much code out there, but it's possible I'm making some other mistake I'm not aware of. But I really feel like this is just an issue with the mouse movement\rotation.
  5. Hi there! I'm really struggling here trying to wrap my brain around these different kinds of math involving Quaternions, Matrices, Vectors and whatnot. But right now, I'm just trying to create an FPS style camera using Quaternions. I'm using GLM as my math library with OpenGL. Don't let the naming in the code I show fool you, as I just can't stand the abbreviated vec3, quat, mat4, and whatnot, so I'm typedeffing them. Right now I seem to have mouse rotation mostly working, but the more I move the mouse, the more it seems like the triangle on the screen, rolls. I am normalizing the Quaternion, so I'm not sure what's going on here. All the places I've looked about mouse input seemed to have a lot of spaghetti looking code, so I don't know if I'm doing this quite right. Translating mouse delta values to rotations isn't quite clear to me. This is the triangle before I move the mouse: And here it is after I move the mouse around a little bit: Now to dive in the code. This is currently my Camera's update function void Camera::Update() { if ( g_pInput->IsButtonPressed( "Forward" ) ) { SetPosition( GetPosition() + m_vForward * 0.01f * g_pEngine->GetDeltaTime() ); } else if ( g_pInput->IsButtonPressed( "Backward" ) ) { SetPosition( GetPosition() + -m_vForward * 0.01f * g_pEngine->GetDeltaTime() ); } if ( g_pInput->IsButtonPressed( "Left" ) ) { Vector3f m_vLeft = glm::cross( m_vUp, m_vForward ); SetPosition( GetPosition() + m_vLeft * 0.01f * g_pEngine->GetDeltaTime() ); } else if ( g_pInput->IsButtonPressed( "Right" ) ) { Vector3f m_vRight = glm::cross( m_vForward, m_vUp ); SetPosition( GetPosition() + m_vRight * 0.01f * g_pEngine->GetDeltaTime() ); } m_flFrameYaw = 0.02f * g_pInput->GetMouseDeltaX() * g_pEngine->GetDeltaTime(); m_flFramePitch = 0.02f * g_pInput->GetMouseDeltaY() * g_pEngine->GetDeltaTime(); Quaternion qFrame = Quaternion( Vector3f( m_flFramePitch, m_flFrameYaw, m_flFrameRoll ) ); m_flFramePitch = 0.0f; m_flFrameYaw = 0.0f; m_flFrameRoll = 0.0f; m_qRotation = qFrame * m_qRotation; m_qRotation = glm::normalize( m_qRotation ); Matrix4f mat4Rotate = glm::toMat4( m_qRotation ); Matrix4f mat4Translate = glm::translate( GetPosition() ); m_mat4ViewMatrix = mat4Rotate * mat4Translate; } My input code at the start of the function is a bit old as I was just using glm's lookat function before, but now I want update my position based on the Quaternion rotation. So one of my questions is, how do I translate the Quaternion rotation into a Vector representing a direction? I'm guessing that's what I want to do so when I press the "forward" button I move some amount + a forward direction Vector. My other question is am I doing the mouse rotation wrong? For the sake of transparency, here's my Input class definitions, the relevant part being the Update() Input::Input() { m_pCurrentKeyboardState = nullptr; m_pOldKeyboardState = nullptr; } Input::~Input() { if ( m_pCurrentKeyboardState ) delete m_pOldKeyboardState; } bool Input::Init() { m_pCurrentKeyboardState = SDL_GetKeyboardState( &m_iNumKeys ); m_pOldKeyboardState = new Uint8[ m_iNumKeys ]; // TODO: Create config file with dynamic button mapping m_mapButtons[ "Forward" ] = SDL_SCANCODE_W; m_mapButtons[ "Backward" ] = SDL_SCANCODE_S; m_mapButtons[ "Left" ] = SDL_SCANCODE_A; m_mapButtons[ "Right" ] = SDL_SCANCODE_D; m_mapButtons[ "Jump" ] = SDL_SCANCODE_SPACE; m_mapButtons[ "Quit" ] = SDL_SCANCODE_ESCAPE; m_mapButtons[ "TurnLeft" ] = SDL_SCANCODE_LEFT; m_mapButtons[ "TurnRight" ] = SDL_SCANCODE_RIGHT; return true; } // May want to do checks to see if a button name is valid bool Input::IsButtonPressed( const std::string &strButtonName ) { return ( m_pCurrentKeyboardState[ m_mapButtons[ strButtonName ] ] == 1 ); } bool Input::IsButtonReleased( const std::string &strButtonName ) { return !IsButtonPressed( strButtonName ); } bool Input::IsButtonJustPressed( const std::string &strButtonName ) { return ( m_pCurrentKeyboardState[ m_mapButtons[ strButtonName ] ] == 1 && m_pOldKeyboardState[ m_mapButtons[ strButtonName ] ] == 0 ); } bool Input::IsButtonJustReleased( const std::string &strButtonName ) { return ( m_pCurrentKeyboardState[ m_mapButtons[ strButtonName ] ] == 0 && m_pOldKeyboardState[ m_mapButtons[ strButtonName ] ] == 1 ); } void Input::Update() { m_flMouseDeltaX = 0.0f; m_flMouseDeltaY = 0.0f; // Note: We allocate the old keyboard state in the Init function // Also no need to call SDL_GetKeyboardState as the state ponter is updated when events are processed, hence SDL_PumpEvents() std::memcpy( m_pOldKeyboardState, m_pCurrentKeyboardState, sizeof( Uint8 ) * m_iNumKeys ); SDL_PumpEvents(); while ( SDL_PollEvent( &m_event ) ) { switch ( m_event.type ) { case SDL_MOUSEMOTION: m_flMouseDeltaX = ( float ) m_event.motion.xrel; m_flMouseDeltaY = ( float ) m_event.motion.yrel; break; } } } As you can see I'm using SDL, SDL 2.0.5 to be exact. Ideally I would like to calculate the mouse delta values without polling events like that, but whatever works I guess. Lastly, I think it's worth mentioning how I compute the model matrix. This is currently done using Vectors, but I would like to do it with Quaternions for consistency sake. inline Matrix4f GetModelMatrix() const { Matrix4f posMatrix = glm::translate( m_vPosition ); Matrix4f rotXMatrix = glm::rotate( m_vRotation.x, Vector3f( 1.0f, 0.0f, 0.0f ) ); Matrix4f rotYMatrix = glm::rotate( m_vRotation.y, Vector3f( 0.0f, 1.0f, 0.0f ) ); Matrix4f rotZMatrix = glm::rotate( m_vRotation.z, Vector3f( 0.0f, 0.0f, 1.0f ) ); Matrix4f scaleMatrix = glm::scale( m_vScale ); Matrix4f rotMatrix = rotZMatrix * rotYMatrix * rotXMatrix; return posMatrix * rotMatrix * scaleMatrix; } I've already thrown a lot of code up, so I guess I'll leave it at that for now. If there's nothing that anybody finds particularly wrong, I can show stuff like the shader code and whatnot. However I'm sure that's okay. Any help is greatly appreciated though.
  6. I see. I wasn't aware that there was a distinction between the two. Though that's confusing since a GUI framework would also be a series of libraries.    I suppose to explain better, the application I'm interested in porting is a level editor of sorts. It's not directly tied into the game engine it works with, heck it doesn't even have real-time rendering of lights and whatnot. In terms of UI, it's a lot like 3DS Max with 4 viewports that are inter-changeable with typically one 3D view. I feel like Qt would work really well with this, I just wasn't sure about its licensing, though it seemed like I could use it without having to release the source code so long as it's dynamically linked to. However I would like to do this the "right way" so to speak. I don't want to start down one path and find out later when I want to implement some sort of feature, that I need to work against some weird layer of abstraction that something like Qt might have.   Obviously if I use one of these plain GUI libraries it seems like I'll have a lot more work to do, but I won't have to work against the library since I'm defining its implementation. nuklear seemed quite interesting. It's C, so it's going to kill my brain a bit, but one of the people I work with loves plain C. Though even he thinks I should just go with Qt.   Hm... I'm really just not sure what to go for. For long term development, which way is the better way to go? 
  7. I have heard about that before, but doesn't that adapt its theming to that of the OS and that's why Code::Blocks doesn't really have theming which so annoys me.       Often game oriented UI libs will not render themselves to anything. They'll provide a list of primitives (commands if you will) that you'll need to render on your own. Stuff like imGUI, Nuklear or libRocket do this. This is ideal since you dont have a black box messing up your rendering state.   That makes sense. I guess I just hope that MFC follows those same standards. If not, porting this is just going to be so FUN. I'll take a look at these.   Oh and I can't believe I completely forgot to mention the language I'm using, though I guess it might be obvious. C\C++.
  8. Hello!   I know there's a GUI lib thread on this forum page no less, but my situation and requirements are different and a bit more specific.   Essentially, there's this old tool I have that's written with the Win32 API\MFC and it works. But, being that, it's not cross platform and is not very easy to work with. I want to port it to another API\GUI system to change that.   I plan to use the tool for non-commercial use, but that's not to say somebody else couldn't come along and want to use it for that. Unfortunately, I can't release the source code, not because I don't want to, but simply because I legally can't.   Knowing that, here are the requirements I have for a GUI library:   Cross-Platform Supports embedding both DirectX and OpenGL into 3D viewports (maybe even Vulkan for the future?) Something that can supply the same functionality or better than Win32\MFC Something that also supports theming (Come on, got to have a dark theme, right?) Can be BUILT with Visual Studio (2013), even if it might want you to use another application to work with like Qt Creator (Yes, I know I want this to be cross platform, but I want this tool to be compatible with our current workflow) Free Doesn't require my code to be open source C\C++ (Forgot to mention this, editing it in!)   Bonus: Could be used commercially while falling in line with the above requirements Can run on the latest service pack of Windows XP Has its own input handling system (Keyboard+Mouse) so I don't need an extra thirdparty library just for that.     Now I know one of my requirements is for embedding DirectX to use for viewports, and that's because the code for that is already there in the application. I'd rather start with something that already works than have to worry about re-working the rendering at the start of the porting process.   Also one of my bonus points is being able to run on the latest service pack of Windows XP, and that's because ideally I'd like to port with the same functionality and not lose anything. If I have to settle for Vista+, that's okay, but I figured I'd add that in there.   If somebody knows of a library that will work for what I need, please let me know! I know I'm asking for quite a lot. I appreciate any input!
  9. Ah, thank you both very much, that clears it up for me. I'm not worried about DX10+, as the Source Engine I believe only supports up to DX9, but that makes a lot of sense.
  10. Hi there! I hope I'm in the proper spot here. I've been trying for the life of me to try to figure out how a parallax shader works and have been trying to implement in the Source Engine. Needless to say I'm really held back by not having any math knowledge involving tangents, matrices, and whatnot.   But anyway, the question I'm asking is a little more simple than all that, and that's about the syntax of "const" in HLSL. There seem to be some shader header files that reference matrices and vectors that are labeled as const. Such as: const HALF3 g_EyePos : register(c10); I dunno if that's part of the HLSL language by default, I just know that in VS it says HALF3 is just a redefinition of float3. But why would something like g_EyePos, which clearly references eye position or camera position, be marked as const? Isn't that something that would be changing quite often? When I looked up the const syntax on Microsoft's website it says that it means it can't be changed in the shader.   Does it mean just that? That it can't be changed in the shader, but it's value may constantly be updated like in the C++ shader code through that c10 register? (I'm sorry, I don't know what you call it, so I'm calling it the c10 register, I know slightly more about GLSL than I do HLSL) Or does it mean it does not update at all?   Sorry for something that's probably a simple question, I just don't understand.
  11. Well there's a reason I made my avatar here of Homer Simpson. D'oh.   Regardless, I was coming at this wrong. All I should be affecting is the actual rendering, because that's what matters, not how much my game updates, though a fixed update function makes sense.   For anybody interested in yet another one of these threads, here ya go, here's the code that made this work:   Loop: while (!m_bQuit) { while (SDL_PollEvent(&event)) { if ((event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) || event.type == SDL_QUIT) Terminate(); } AMBehavior::MasterUpdate(); if (Time->ShouldRender()) Renderer->Draw(); } Time Code ( No Traveling Allowed (That's a joke) ): bool TimeMgr::ShouldRender() { if (ticks >= 1.0f / AMEngine->GetMaxFPS()) { ticks -= 1.0f / AMEngine->GetMaxFPS(); return true; } return false; } void TimeMgr::Update() { elapsedTime = (float)SDL_GetTicks(); ticks += deltaTime = (elapsedTime - prevElapsedTime) / 1000.0f; prevElapsedTime = elapsedTime; } Then finally, where I calculate the FPS, in my renderer!: void RenderingEngine::Update() { frameTicks += Time->deltaTime; } void RenderingEngine::Draw() { FPS++; if (frameTicks >= 1.0f) { frameTicks = 0.0f; std::cout << "FPS: " << FPS - 1 << std::endl; FPS = 0; } ...
  12. Hi there!   I've been trying to work on writing my own game engine. The sad part is, while I've figured out libraries to load models, I have 3D sound, I just don't know how to freaking handle frame timing.   Basically, my graphics card begins to shriek when running at high frames, which is fixed by VSync or limiting frames. Or maybe I'm a terribly bad programmer, I dunno, perhaps both.   Regardless, to the code!   Here is the basic loop I have set up at the moment: while (!m_bQuit) { Time->Think(); while (SDL_PollEvent(&event)) { if ((event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) || event.type == SDL_QUIT) Terminate(); } if (Time->ShouldUpdate()) { AMBehavior::MasterUpdate(); Renderer->Draw(); } } AMBehavior's MasterUpdate() iterates through a list of objects that inherit from it and call their respective update functions. Time inherits from AMBehavior, but I also gave it a Think() to operate outside of MasterUpdate() so time can be managed, and I can print out a frame count.   Here are the 3 relevant functions I have for my time manager: bool TimeMgr::ShouldUpdate() { if (ticks >= 1000.0f / AMEngine->GetMaxFPS() / 1000.0f) { ticks = 0.0f; return true; } return false; } void TimeMgr::Update() { FPS++; if (frameTicks >= 1.0f) { frameTicks = 0.0f; std::cout << "FPS: " << FPS << std::endl; FPS = 0; } } void TimeMgr::Think() { elapsedTime = (float)SDL_GetTicks(); ticks += deltaTime = (elapsedTime - prevElapsedTime) / 1000.0f; frameTicks += deltaTime; prevElapsedTime = elapsedTime; } Aside from some of the calculations being inefficient, this does work... Sort of.   You see when I have the engine's max FPS set to 60, it works as I would expect, FPS shows as 59.   However, when I set the engine's max FPS to say 300, my calculated FPS is only about 250.   If I set my max to 3000, I see my calculated value be about 1000, even though I know I can get more frames than that. What gives? Am I using deltaTime incorrectly here? What stupid silly thing am I doing wrong?
  13. OpenGL

    I do actually.     See I was wondering about that, that seemed weird. So welding vertices huh? I'll have to research that. Thank you so much! That makes perfect sense!
  14. Hello everyone, I hope that this is an okay place to post this as it is specific to the OBJ file, but I'm using OpenGL to map the coordinates.   But anyway, I've tried every which way I can think of to map the texture coordinates of this simple cube. And no matter what I do, the texture coordinates are at least screwed up on 4 or more of its faces.   In Blender, the cube is like so:     But in my program, it comes out looking like this:       I have gotten it to the point where at least one face looked correct, but that doesn't help because I want the rest of them to be correct obviously.   I hope you can follow my monstrous code, but first I'll share my shader code:   Vertex Shader: #version 330 layout(location = 0) in vec3 position; layout(location = 1) in vec2 texCoord; out vec2 texCoord0; uniform mat4 transform; void main() { gl_Position = transform * vec4(position, 1.0); texCoord0 = texCoord; } Fragment Shader: #version 330 in vec2 texCoord0; uniform sampler2D sampler; void main(void) { gl_FragColor = texture2D(sampler, texCoord0.xy); } So very simple shaders. The only thing I could think of is using the deprecated gl_FragColor, but I would think that would still work, but moving on to the code.   These are my Mesh and Vertex classes: class Vertex { public: Vertex(Vector3f position, Vector2f texCoord); Vector3f position; Vector2f texCoord; Vector3f normal; }; class Mesh : public GameObject { public: Mesh(); Mesh(Shader *shader, std::vector<Vertex> Vertices, std::vector<int> Indices); Mesh(Shader *shader, std::string fileName); void Update(); void Render(); float Temp; private: enum { VERTEX_VB, TEXCOORD_VB, NUM_BUFFERS }; void Initialize(Shader *shader, std::vector<Vertex> Vertices, std::vector<int> Indices); std::vector<Vertex> Vertices; std::vector<int> Indices; std::vector<int> IndicesTexCoord; std::vector<Vector2f>texCoords; int iSize; Shader *shader; std::vector<GLfloat> GetVerticesPositionData(); std::vector<GLfloat> GetVerticesTexCoordData(); GLuint m_IndexBufferObject; GLuint m_VertexArrayObject; GLuint m_VertexArrayBuffers[NUM_BUFFERS]; }; Mind you I'm not really using the Vertex texCoord really, and I haven't even begun calculating normals yet.   Here is the code where I'm reading the OBJ file: Mesh::Mesh(Shader *shader, std::string fileName) { if (fileName.substr(fileName.find_last_of(".") + 1) != "obj") { std::cout << "Error: unsupported model format!\n"; } else { std::vector<Vector3f> _positions; std::vector<Vector2f> _texCoords; std::ifstream file(fileName); float x, y, z; while (!file.eof()) { std::string buffer; std::string line; std::vector<std::string> tokens; std::getline(file, line); std::stringstream ss(line); while (ss >> buffer) { tokens.push_back(buffer); } if (tokens.size() == 0 || tokens[0] == "#") continue; else if (tokens[0] == "v" && tokens[1] != "") { x = (float)atof(tokens[1].c_str()); y = (float)atof(tokens[2].c_str()); z = (float)atof(tokens[3].c_str()); //std::coutTexCoords << "X: " << x << " Y: " << y << " Z: " << z << std::endl; _positions.push_back(Vector3f(x, y, z)); //Vertices.push_back(Vector3f( // x, // y, // z)); } else if (tokens[0] == "vt") { float x = (float)atof(tokens[1].c_str()); float y = (float)atof(tokens[2].c_str()); texCoords.push_back(Vector2f( x, y)); //texCoords.push_back(x); //texCoords.push_back(y); _texCoords.push_back(Vector2f(x, y)); //std::cout << "U: " << x << " V: " << y << std::endl; } else if (tokens[0] == "f") { //std::cout << "f: " << atoi(tokens[1].c_str()) - 1 << " " << atoi(tokens[2].c_str()) - 1 << " " << atoi(tokens[3].c_str()) - 1 << std::endl; Indices.push_back(atoi(tokens[1].c_str()) - 1); Indices.push_back(atoi(tokens[2].c_str()) - 1); Indices.push_back(atoi(tokens[3].c_str()) - 1); tokens[1].erase(tokens[1].begin(), tokens[1].begin() + tokens[1].find_first_of("/") + 1); tokens[2].erase(tokens[2].begin(), tokens[2].begin() + tokens[2].find_first_of("/") + 1); tokens[3].erase(tokens[3].begin(), tokens[3].begin() + tokens[3].find_first_of("/") + 1); IndicesTexCoord.push_back(atoi(tokens[1].c_str()) - 1); IndicesTexCoord.push_back(atoi(tokens[2].c_str()) - 1); IndicesTexCoord.push_back(atoi(tokens[3].c_str()) - 1); } } file.close(); for (unsigned int i = 0; i < _positions.size(); i++) Vertices.push_back(Vertex(_positions[i], _texCoords[i])); } Initialize(shader, Vertices, Indices); } As you can see I'm using my IndicesTexCoord to push back the values of f 2/TEXCOORD# in the OBJ file which as far as I know tells which vertex what texture coordinate to use.   And here's my Initialize function: void Mesh::Initialize(Shader *shader, std::vector<Vertex> Vertices, std::vector<int> Indices) { this->shader = shader; this->Vertices = Vertices; this->Indices = Indices; iSize = Indices.size(); std::vector<GLfloat> vertexBufferData = GetVerticesPositionData(); std::vector<GLfloat> texCoordData = GetVerticesTexCoordData(); if (vertexBufferData.size() > 0) { glGenVertexArrays(1, &m_VertexArrayObject); glBindVertexArray(m_VertexArrayObject); glGenBuffers(NUM_BUFFERS, m_VertexArrayBuffers); glGenBuffers(1, &m_IndexBufferObject); glBindBuffer(GL_ARRAY_BUFFER, m_VertexArrayBuffers[VERTEX_VB]); glBufferData(GL_ARRAY_BUFFER, sizeof(vertexBufferData[0]) * vertexBufferData.size(), vertexBufferData.data(), GL_STATIC_DRAW); if (texCoordData.size() > 0) { glBindBuffer(GL_ARRAY_BUFFER, m_VertexArrayBuffers[TEXCOORD_VB]); glBufferData(GL_ARRAY_BUFFER, sizeof(texCoordData[0]) * texCoordData.size(), texCoordData.data(), GL_STATIC_DRAW); } if (Indices.size() > 0) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_IndexBufferObject); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices[0]) * Indices.size(), Indices.data(), GL_STATIC_DRAW); } } } As you can see it all comes down to this GetVerticesTexCoordData() function: std::vector<GLfloat> Mesh::GetVerticesTexCoordData() { std::vector<GLfloat> texCoordData; for (unsigned int i = 0; i < Indices.size(); i++) { texCoordData.push_back(texCoords[IndicesTexCoord[i]].x); texCoordData.push_back(texCoords[IndicesTexCoord[i]].y); } return texCoordData; } Right here is where I'm sure I'm screwing up my calculation somehow.   I'm really pounding my head here and if somebody that can follow whatever it is I'm doing could please help me somehow, I'd GREATLY appreciate it. Because I just can't figure this out no matter which way I smash my head against the keyboard. O.o   I'd really appreciate any help. One last thing, since it's possible I may be screwing up my rendering somehow, I'll post my render code as well: void Mesh::Render() { if (Vertices.size() > 0) { if (shader) shader->bindShader(); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glBindBuffer(GL_ARRAY_BUFFER, m_VertexArrayBuffers[VERTEX_VB]); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); glBindBuffer(GL_ARRAY_BUFFER, m_VertexArrayBuffers[TEXCOORD_VB]); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void*)0); if (Indices.size() > 0) glDrawElements(GL_TRIANGLES, iSize, GL_UNSIGNED_INT, 0); else glDrawArrays(GL_TRIANGLES, 0, 3); glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); } } Again, I'd REALLY appreciate any help.
  15. Hi there. I've been pounding my head against the wall with this one. I've tried wxWidgets, couldn't get to compile. I tried GTK+, couldn't find meaningful directions and therefore couldn't get it to compile. I tried Qt, and that's the only one I managed to get to actually work, but couldn't get it to integrate with OpenGL because of an odd lack of information.     Basically, all I'm trying to do is find a library that can be compiled or is already compiled for 64 bit usage of MinGW-w64. I want to then use the library to create an OpenGL viewport that's embedded in the application, but is still able to have things like buttons, labels, and the like.   I want something cross platform so that I could also do this on Linux, but I'm on WIndows for now.   Does anybody know of a good solid library that works in a 64 bit environment? Perhaps one that's already pre-compiled? I wanted to use Code::Blocks and GitHub for a project to make it easier for cross platform development, so I could develop no matter which OS I'm on and develop in either 64 bit or 32 bit.