Categories
Game Creation Mastering Development

How to correctly reset vertex attributes after modification

I am trying to use the same vertex shader for two different use cases to preserve memory, but I am having issues where the modifications of one shader run are passed on to the next run, even after being reset. Specifically, I am trying to use the shader to both show a regular texture, while […]

Categories
Mastering Development

How to Get Red, Blue and Green at the opposite ends of this rotating cube in c++?

I am trying to get the 3 different colours 2 times (red, green, blue) on the opposite faces of a cube and I’m also trying to get it to look as if squares are within the faces of the cube while rotating it. The points are randomly generated after the vertices have been declared. The […]

Categories
Development Game Creation

Variance shadow map artifacts near the shadow edges

I’m trying to implement variance shadow mapping in my engine. I’m using WebGL 2 and now I have only one directional light source. It’s working, but it has a serious issue near the shadow edges and I don’t know how to solve it. The back of the cube isn’t entirely in shadow, the edges are […]

Categories
Development

Exception thrown at 0x00AEA76D in open_gl_prj_1.exe: 0xC0000005: Access violation reading location 0xCCCCCCD0

I work on visual studio community , when i run the code it shows a exception handling error there are no other existing errors i tried changing the exception handling setting in debug menu on visual studio community , nothing changed . I have no clue about the exception either. include<GL/glew.h> #include<GLFW/glfw3.h> #include<iostream> #include <fstream> […]

Categories
Development

Make void not execute so that it exists just for the sake of running a function when called

I have a movement script and inside it also contains the stamina part. I have a function to drain the stamina but I want to call it only when pressing a button. How can I change the void part so that its wont trigger just when I call the function it defines Here is my […]

Categories
Development

c++ lambda: is it possible to create new lambda by closing open arguments?

With EIFFEL agents (https://www.eiffel.org/doc/solutions/Event_Programming_with_Agents#Open_and_Closed_Arguments) one has open and closed arguments. To me this is similar to arguments and captures in lambdas. What I wonder is whether I can “close/capture” an open argument of a labda to get a new lambda with a different signature with fewer arguments. Something like this maybe: std::function<void(int, float, string) baseLambda […]

Categories
Development

OpenGL 3D object rendering

Activating this made my 2D stuff disappear. I guess this is 100% necessary for 3D? GLCall(glEnable(GL_DEPTH_TEST)); Positions for one side of a cube. If i understand everything correctly, i should still be able to draw a 2D object. Unsure if the z-coordinate should be between like 0.0f and 1.0f or has to be a pixel […]

Categories
Development

window is not shown in nuklear simple example

Hi I wrote this simple example with nuklear gui toolkit but window is not shown? What do I do? #define NK_IMPLEMENTATION #define NK_INCLUDE_DEFAULT_ALLOCATOR #define NK_INCLUDE_FONT_BAKING #define NK_INCLUDE_STANDARD_IO #include <nuklear.h> int main(int argc, char **argv) { struct nk_font_atlas font_atlas; nk_font_atlas_init_default(&font_atlas); nk_font_atlas_begin(&font_atlas); int img_width, img_height; // struct nk_font_config font_config; const char *font_path = “/home/…/font/file.ttf”; struct nk_font *font […]

Categories
Development

Orbiting And Spinning Rotation in OpenGL using GLM

I’m making a solar system in OpenGL and I want the planets to be able to orbit other planets as well as rotate around their own centers. This is the code I’m currently using to make the planets orbit a specific point: Model = glm::translate(Model, glm::vec3(-orbit_radius_, 0.0f, 0.0f)); Model = glm::rotate(Model, glm::radians(orbit_speed_) / 100.0f, glm::vec3(0.0f, […]

Categories
Development

Fragment shader draws faces on top of each other, even though it shouldn’t

I’m writing simple 3D world in OpenGL, that can render various stuff. I’m relatively new to OpenGL, and might not notice something, but there’s really big problem with (I guess) fragment shader. What it does is it ignores z-value, and draws faces in order that they were given by index buffer. What I mean by […]