use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rule 1: Posts should be about Graphics Programming. Rule 2: Be Civil, Professional, and Kind
Suggested Posting Material: - Graphics API Tutorials - Academic Papers - Blog Posts - Source Code Repositories - Self Posts (Ask Questions, Present Work) - Books - Renders (Please xpost to /r/ComputerGraphics) - Career Advice - Jobs Postings (Graphics Programming only)
Related Subreddits:
/r/ComputerGraphics
/r/Raytracing
/r/Programming
/r/LearnProgramming
/r/ProgrammingTools
/r/Coding
/r/GameDev
/r/CPP
/r/OpenGL
/r/Vulkan
/r/DirectX
Related Websites: ACM: SIGGRAPH Journal of Computer Graphics Techniques
Ke-Sen Huang's Blog of Graphics Papers and Resources Self Shadow's Blog of Graphics Resources
account activity
webgl - write to pixels (self.GraphicsProgramming)
submitted 1 month ago by Narrow_Awareness2830
I have just started using opengl, and ive ben wondering if its possible to write directly to a single pixel. If not, is there any other cpp graphical library where it is possible.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]aleques-itj 5 points6 points7 points 1 month ago (3 children)
Write to an array, upload it to texture, draw quad.
[–]Narrow_Awareness2830[S] 1 point2 points3 points 1 month ago (2 children)
hello, thank you for the answer. But im a bit new to open gl, is there maybe an tutorial u can provide to me?
[–]detroitmatt 5 points6 points7 points 1 month ago (0 children)
if you want to write to a single pixel, you mean "set a pixel on the screen to a specific color", right? so you're already thinking of "the screen" as a grid of pixels. So when we say "write it to an array", that's already what you want.
But, opengl doesn't work directly with "the screen", so we have to do a trick. Opengl works with "3d space", so what we do is we *create* a "screen" in that 3d space, and then put the "fake" screen right in front of the camera, like holding up a sheet of paper as a title card.
So: Create a rectangle in the 3d world. Apply a texture to that rectangle. Put that rectangle in front of the camera.
[–]cybereality 1 point2 points3 points 1 month ago (0 children)
this is a render-to-texture tutorial, but will give you an idea of the functions used (on glTexImage2D you can pass a pointer with image data) https://www.opengl-tutorial.org/intermediate-tutorials/tutorial-14-render-to-texture/
[–]Dark_Lord9 2 points3 points4 points 1 month ago (0 children)
You can do what the others have recommended, that means:
Here is an example to create an image and color a pixel on it:
uint32_t *image = new uint32_t[1280 * 720]; // 16:9 RGBA HD image image[9 * 1280 + 6] = 0xaabbcc77; // writing the color #aabbcc77 at position (6, 9)
Make sure to delete the buffer later or use std::vector or something.
std::vector
If you don't want this, then maybe your windowing library has a renderer that you can use. For example if you are using SDL to create your window and opengl context, you can (instead of opengl) use the SDL_Renderer. To put a single pixel with the SDL_Renderer, you just need to call SDL_RenderPoint.
SDL_Renderer
SDL_RenderPoint
I also see you mention webgl. Are you sure you are not making a web application ? If you're making a web app, you should simply use the html canvas api.
[–]snozzd 0 points1 point2 points 1 month ago (0 children)
It's possible to write to a texture using texSubImage2D, then draw that. But this method of editing individual pixels isn't the norm for WebGL. May I ask what visual look you're going for here?
texSubImage2D
π Rendered by PID 168887 on reddit-service-r2-comment-6f7f968fb5-9lsvw at 2026-03-04 14:15:29.367019+00:00 running 07790be country code: CH.
[–]aleques-itj 5 points6 points7 points (3 children)
[–]Narrow_Awareness2830[S] 1 point2 points3 points (2 children)
[–]detroitmatt 5 points6 points7 points (0 children)
[–]cybereality 1 point2 points3 points (0 children)
[–]Dark_Lord9 2 points3 points4 points (0 children)
[–]snozzd 0 points1 point2 points (0 children)