Categories
Game Creation Mastering Development

Why is my OpenGL triangle not drawing on the screen?

I am currently following this tutorial to create a simple game engine, but I am doing it using SDL and C++. I am stumped, however, because I can’t get a triangle to draw on the screen, and I’m getting no errors from OpenGL. I have read tens of questions regarding the same problem, but I […]

Categories
Mastering Development

Modern OpenGL Black Screen with shader program and no errors

I have no errors but when I run the program all I have is a black screen and I am supposed to have two triangles: #include <iostream> //includes C++ i/o stream #include <GL/glew.h> //includes glew header #include <GL/freeglut.h> //includes freeglut header using namespace std; //Uses the standard namespace #define WINDOW_TITLE "3-1 Assignment" //Macro for window […]

Categories
Game Creation Mastering Development

Trouble generating a depth map (black screen)

I am having trouble generating a depth map for my scene. I tried to figure out this issue a 2 weeks ago and got nowhere after days of trying to fix it, so I took a break and tried to tackle it again today. I’m still stuck and with no ideas. Here’s the main code: […]

Categories
Mastering Development

OpenGL drawing a A triangle instead of a square

Im very new to OpenGL and I am trying to get a square on the screen. This code should draw a square, however it omits the last vertex and only draws a triangle. Where have I gone wrong?? Thanks for the help. #include <glad/gl.h> #define GLFW_INCLUDE_NONE #include <GLFW/glfw3.h> #include “linmath.h” #include <stdlib.h> #include <stdio.h> static […]

Categories
Mastering Development

Why is this glDrawElements call failing?

I am trying to integrate the advice from https://gamedev.stackexchange.com/questions/10727/fastest-way-to-draw-quads-in-opengl-es and How to draw with Vertex Array Objects and glDrawElements in PyOpenGL to render quads using an index buffer implemented by OpenGL.arrays.vbo.VBO, in a context provided by GLFW and using the helper class. (I am also, at least for now, relying on ctypes for raw data […]

Categories
Mastering Development

OpenGl compilation errors [duplicate]

I have this OpenGl code: #include <stdio.h> #include <assert.h> #include <stdlib.h> #include <GL/glew.h> #include <GL/glut.h> // Usage of degrees is deprecated. Use radians for glm functions. #define GLM_FORCE_RADIANS #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include “shaders.h” int mouseoldx, mouseoldy ; // For mouse motion GLfloat eyeloc = 2.0 ; // Where to look from; initially 0 -2, […]

Categories
Game Creation Mastering Development

OpenGL color attachments do not work

Trying to implement GBuffer. Only gAlbedoSpec color attachment (GL_COLOR_ATTACHMENT2) works properly. When i try to use another texture (gPosition or gNormal) in shader, texture(…) returns color from glClearColor. It means OpenGL doesn’t write data to other color attachments. How to fix it? GBuffer creation: glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glGenTextures(1, &gPosition); glBindTexture(GL_TEXTURE_2D, gPosition); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, […]

Categories
Game Creation Mastering Development

How to map texture across whole face?

I’m trying to map a texture to a square face in OpenGL 3.2, but the texture gets tiled in the upper right corner. I’ve tried changing the uv coordinates, vertices and shaders, but nothing seems to have the desired effect. Sorry if it’s a lot of code, I’ve done my best to extract only the […]

Categories
Game Creation Mastering Development

when to unbind vao in drawing loops

I am very new to open gl and am struggling to understand relation between vaos vbos and ibos like how is currently bound vao related to currently bound ibo? now i am trying to render 4 triangles with vertex data and index data for ibo as float vertices[] = { -0.5f, -0.5f, 2.0f, 1.0f, 0.0f, […]

Categories
Game Creation Mastering Development

Skybox textures is black

My skybox is displayed, but does not display the textures that I load from the image. Instead, it shows the transparent color if i set glTexImage2D how GL_RGBA, or black color if i set glTexImage2D how GL_RGB. I am using a render with MultisampledFbo support. My texture loading code looks like this: private int loadSkyboxTextures(){ […]