Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3755866
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:45:50+00:00 2026-05-19T09:45:50+00:00

I wrote a little thingy with Processing that I now would like to make

  • 0

I wrote a little thingy with Processing that I now would like to make a Mac OS X Screen Saver of. However, diving in to OpenGL was not as easy as I thought it would be.

Basically I want to loop through all pixels on screen and based on that pixels color set another pixels color.

The Processing code looks like this:

void setup(){
  size(500,500, P2D);
  frameRate(30);
  background(255);
}

void draw(){
 for(int x = 0; x<width; x++){
  for(int y = 0; y<height; y++){
     float xRand2 = x+random(2);
     float yRand2 = y+random(2);

     int xRand = int(xRand2);
     int yRand = int(yRand2);

     if(get(x,y) == -16777216){
     set(x+xRand, y+yRand, #FFFFFF);
     }
     else if(get(x,y) == -1){
     set(x+xRand, y+yRand, #000000);
     }
   }
 }
}

It’s not very pretty and nor is it very effective. However, I’d like to find out how to do something similiar with OpenGL. I don’t even know where to start.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:45:51+00:00Added an answer on May 19, 2026 at 9:45 am

    The basic idea of OpenGL is that you never set the values of individual pixels manually, because that’s often too slow. Instead you render triangles and do all kinds of tricks with them, like textures, blending, etc.

    In order to freely program what each individual pixel does in OpenGL, you need to use a technique called shaders. And that’s not very easy if you haven’t done anything similar before. The idea of shaders is that GPU executes them instead of CPU, which results in very good performance and takes the load off from the CPU. But in your case it is probably a better idea to do it with CPU and not with shaders and OpenGL, as that approach is much easier to start with.

    I recommend you use a library like SDL (or possibly glfw), which lets you do things with pixels without hardware acceleration. You can still do it with OpenGL too, though. By using the function glDrawPixels. That function draws raw pixel data to the screen. But it’s probably not very fast.

    So start by reading some tutorials about SDL, for example.

    Edit: If you want to use shaders, the difficulty with them (among other things) is that you can’t specify coordinates to which set pixel values. And you can’t get pixel values directly from the screen either. One way to do it with shaders would be the following:

    • Set up two textures: texture A and texture B
    • Bind one of the textures as a target that you render everything to
    • Bind another one of the textures as an input texture for the shader
    • Render a full-screen quadrangle using your shader and show the result on the screen
    • Swap textures A and B so you became to use your previous result as your next input
    • Render again
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write an application using processing-JS , and I'd like to be
I'm writing a small app to do a little processing on some cells in
here's a little code I wrote. This next class waits for a connection and
I have a little sample application I was working on trying to get some
I've got a fancy-schmancy worksheet style view in a Rails app that is taking
So I've got a for loop that processes a list of IDs and has
I'm just starting to get into backbone.js. It looks like it's pretty involved and
I'm just trying to get a little familiar with Fortran (because I can) so
I'm trying to write code that can print only filled text boxes in the
When I realized I needed to create an index for approximately 50 XHTML pages,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.