Radlabgaming

Members
  • Content count

    10
  • Joined

  • Last visited

Community Reputation

132 Neutral

About Radlabgaming

  • Rank
    Member
  1. OpenGL C++ OpenGL loading Object Issue

      okay figured it out partial, will update post if I get stuck more!
  2. Hello everyone!   I am having a small issue that has halted my progress on learning how to use opengl.  I am basically trying to load a .obj file using a .obj file loader I built and it seems to be working correctly (in terms of loading). With that being said, when I go to draw the 3d object to the screen it creates a large red square. GLenum err = glewInit(); if (err != GLEW_OK) { std::cout << "NOT WORKING" << std::endl; } const char* vertexShaderSource = "#version 330\n\ in vec4 position;\ void main(void) {\ gl_Position = position;\ }"; // compile fragment shader source const GLchar* fragmentShaderSource = "#version 330\n\ out vec4 fragColor;\ void main(void) {\ fragColor = vec4(1.0,0.3,0.3,0.15);\ }"; /* Creating Shader */ this->programId = glCreateProgram(); this->vId = glCreateShader(GL_VERTEX_SHADER); this->fId = glCreateShader(GL_FRAGMENT_SHADER); /* Get Shader Size */ int vertexShaderLength = strlen(vertexShaderSource); int fragmentShaderLength = strlen(fragmentShaderSource); /* Loading and binding shader */ glShaderSource(this->vId, 1, &vertexShaderSource, NULL); glShaderSource(this->fId, 1, &fragmentShaderSource, NULL); /* Compile Shaders */ glCompileShader(vId); int iIsOk = 0; glGetShaderiv(this->vId, GL_COMPILE_STATUS, &iIsOk); if (!iIsOk) { return; } int iIsOk2; glCompileShader(fId); glGetShaderiv(this->fId, GL_COMPILE_STATUS, &iIsOk2); if (!iIsOk2) { std::cout << "U SUCK!" << std::endl; std::cout << glGetError() << std::endl; } /* Attach Shaders */ glAttachShader(this->programId, this->vId); glAttachShader(this->programId, this->fId); /* Bind Attributes from Shader */ glBindAttribLocation(this->programId, 0, "position"); glBindFragDataLocation(this->programId, 0, "fragcolor"); /* Linkg program */ glLinkProgram(this->programId); /* Use and bind attribute */ glUseProgram(this->programId); this->positionId = glGetAttribLocation(this->programId, "position"); glUseProgram(0); /* VAO Time */ glGenVertexArrays(1, &this->vaoId); glBindVertexArray(this->vaoId); /* VBO Time assigning to VAO */ glGenBuffers(1, &this->vboId); glBindBuffer(GL_ARRAY_BUFFER, this->vboId); glBufferData(GL_ARRAY_BUFFER, vertcies.size() * sizeof(sf::Vector3f), &vertcies[0], GL_STATIC_DRAW); glEnableVertexAttribArray(this->positionId); glVertexAttribPointer(this->positionId, 2, GL_FLOAT, GL_FALSE, sizeof(sf::Vector3f), 0); /* Close out bindings */ glBindVertexArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); DRAW: glUseProgram(this->programId); glBindVertexArray(this->vaoId); glDrawArrays(GL_TRIANGLES, 0, this->vertcies.size()); glBindVertexArray(0); glUseProgram(0); I uploaded an image of what the red box displayed as. I am curious if I am missing something in the openGL code or what I am doing wrong? I am able to display a triangle correctly, but when I go to load my .obj files this is the stuff I get displayed.   The above is all the openGL code I have in the project, is there a simple error in my code...or forgetting something?     Thanks so much, been stuck for about a week on this!  
  3. OpenGL SFML - VAO issue

    Hey Bob!   Thanks for the reply I went ahead and switched those up and am getting the same issue.   Thanks!
  4. OpenGL SFML - VAO issue

    Hey guys! I have spent the last day trying to debug this and I am beyong stuck. I am getting an error when trying to use VAO's inside of SFML and not sure if it is SFML or it is my own opengl code GLenum err = glewInit(); if (err != GLEW_OK) { std::cout << "NOT WORKING" << std::endl; } g_vertex_buffer_data.push_back({ -1.0f, -1.0f, 0.0f }); g_vertex_buffer_data.push_back({1.0f, -1.0f, 0.0f}); g_vertex_buffer_data.push_back({ 0.0f, 1.0f, 0.0f }); const char* vertexShaderSource = "#version 330\n\ in vec4 position;\ void main(void) {\ gl_Position = position;\ }"; // compile fragment shader source const GLchar* fragmentShaderSource = "#version 330\n\ void main(void) {\ gl_FragColor = vec4(1.0,1.0,1.0,1.0);\ }"; /* Creating Shader */ this->programId = glCreateProgram(); this->vId = glCreateShader(GL_VERTEX_SHADER); this->fId = glCreateShader(GL_FRAGMENT_SHADER); /* Get Shader Size */ int vertexShaderLength = strlen(vertexShaderSource); int fragmentShaderLength = strlen(fragmentShaderSource); /* Loading and binding shader */ glShaderSource(this->vId, 1, &vertexShaderSource, NULL); glShaderSource(this->fId, 1, &fragmentShaderSource, NULL); /* Compile Shaders */ glCompileShader(vId); glCompileShader(fId); /* Attach Shaders */ glAttachShader(this->programId, this->vId); glAttachShader(this->programId, this->fId); /* Linkg program */ glLinkProgram(this->programId); /* Use and bind attribute */ glUseProgram(this->programId); this->positionId = glGetAttribLocation(this->programId, "position"); glUseProgram(0); /* VAO Time */ glGenVertexArrays(1, &this->vaoId); glBindVertexArray(this->vaoId); /* VBO Time assigning to VAO */ glGenBuffers(1, &this->vboId); glBindBuffer(GL_ARRAY_BUFFER, this->vboId); glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data) * sizeof(sf::Vector3f), &g_vertex_buffer_data[0], GL_STATIC_DRAW); glEnableVertexAttribArray(this->positionId); glVertexAttribPointer(this->positionId, 2, GL_FLOAT, GL_FALSE, sizeof(sf::Vector3f), 0); /* Close out bindings */ glBindVertexArray(0) glBindBuffer(GL_ARRAY_BUFFER, 0); Then the draw function: glUseProgram(this->programId); glBindVertexArray(this->vaoId); glDrawArrays(GL_TRIANGLES, 0, 3); glBindVertexArray(0); glUseProgram(0); gameWindow.glPushStates(); The error code I get is:   opengl error in user code (1282)?   Any help would be greatly apprciated
  5. Thank you guys for the feedback! I will be displaying a demo game that was built on the engine as well as the example code to help show how the system works! I will keep this post updated as progress moves on with it! :D
  6. Hello!   I am in the process of finishing up a simple 2D game engine and am looking for some other people to test / use it. It is has some prebuilt templates for the most common 2D types of games and includes audio, visuals, networking, and etc.  Basically it is a simplified engine allowing you to build 2D games with a very small learning curve and doesn't include all the bulkyness that other engines have like unity and Unreal.      I guess my question is where would you guys suggest to find people interested in trying out the engine for feedback and etc. Do I pay people?     Thanks!
  7. Top-down collision

    I actually have had this question in the past and experienced big problems with getting this correctly dealt with. I finally came upon a solution that I use quite frequently... It might not be the best but it works for me.   Steps of checking collision:   Get location of current character Move the character (behind the scenes) to the next position check for collision  of the new position.  If collision...check which direction (left, right, up, down) Set character back to the old location If no collision... move character   Let me know if you need more of a actual code example and I can get you one typed up!
  8. Why using std::string when you can create it yourself...

    haha truly amazing and a well earned spot in Coding Horrors!! 
  9. Showcase Monday!

    Looks nice... And spooky!! ;)
  10. Working on my new beta game! Space Masters Blasters
  11.  Space Masters Blasters    Space Masters Blasters is a classic 2D shootem up vertical game based in the near future! As the world is being invaded it is up to Sellex and his companions to launch into space and fight off the enemy ships before it is too late. Join up with Sellex and fight off the invaders in over 25 different ships, a local co-op option, and best of all a competitive scoring system!     Get a beta copy now!  http://radlabgaming.itch.io/space-masters-blasters to support the game and get an instant download of our beta version!       Extra Features   [*] Full Controller Support [*] Over 20+ types of spacecrafts! [*] Different Speeds! [*] Different Weapons! [*]  Plus more configurations per aircraft! [*] Best of all... plenty of achievements! [*] Challenging Co-Op (coming soon) [*] Competitive Leader Boards (Local and Online) (coming soon) [*] Multiple Power Ups that include time warps, teleportation, and much more! (coming soon)   Thank you for your support and any feedback would be great! :-)