Skip to main content

Posts

Showing posts with the label Opengl

OpenGL clear sprite

I created 10 sprites on the window and now I want to clear only one sprite out of 10 sprites. Now the function glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) clears the entire window of sprites, but I don't want to clear the entire window of drawn sprites. What function should I use to clear just one sprite and not clear the whole window and redraw 9 sprites in the window? by Evil JuniorCplusplus in StackOverflow on July 05, 2022 . Answer There is no such feature. Clear the screen, and redraw 9 sprites. Most computer games with moving objects clear the screen every single frame. by user253751 on July 05, 2022 .

Object not rendering after adding transformations

I'm adding transformations to my C OpenGL program. I'm using CGLM as my maths library. The program has no warnings or errors. Still however, when I compile and run the program, I simply get a window coloured my clear colour. The following is my program's main loop // Initialize variables for framerate counting double lastTime = glfwGetTime(); int frameCount = 0; // Program loop while (!glfwWindowShouldClose(window)) { // Calculate framerate double thisTime = glfwGetTime(); frameCount++; // If a second has passed. if (thisTime - lastTime >= 1.0) { printf("%i FPS\n", frameCount); frameCount = 0; lastTime = thisTime; } processInput(window); // Clear the window glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); // Bind textures on texture units glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture); glActiveTexture(GL_TEXTURE1); glBindTex...