473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

glDrawPixels

I've been searching and reading articles and examples for the past 2 weeks, but no luck.

Could some one please show me a good example of how to use the glDrawPixels Function to display pixels onto the screen with GL_FLOAT and GL_UNSIGNED_BYTE (using unsigned char) or just explain to me what I'm doing wrong. I've pasted my DrawScene Function Below.

Im trying to turn the 100 pixels to red, and display them
Expand|Select|Wrap|Line Numbers
  1. int DrawScene()
  2. {
  3.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  4.     glLoadIdentity();
  5.     //Here i use the float setup
  6.     float fPixel[100][4];
  7.     for(int x=0; x<100;x++)
  8.     {
  9.         fPixel[x][0]=0xff;
  10.         fPixel[x][1]=0x00;
  11.         fPixel[x][2]=0x00;
  12.         fPixel[x][3]=0xff;
  13.     }
  14.     glDrawPixels(20, 20, GL_RGBA, GL_FLOAT, fPixel);
  15.     SwapBuffers(hdc);
  16.     return 0;
  17. }
  18.  
Now with GL_UNSIGNED_BYTE
Expand|Select|Wrap|Line Numbers
  1. int DrawScene()
  2. {
  3.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  4.     glLoadIdentity();
  5.     unsigned char pixel[100][4]
  6.     for(int x=0; x<100;x++)
  7.     {
  8.         pixel[x][0]=0xff;
  9.         pixel[x][1]=0x00;
  10.         pixel[x][2]=0x00;
  11.         pixel[x][3]=0xff;
  12.     }
  13.     glDrawPixels(20, 20, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
  14.     SwapBuffers(hdc);
  15.  
  16.     return 0;
  17. }
  18.  
Neither of these work for me. Any Suggestions? Thank you
Sep 14 '08 #1
2 11222
ok so i figured out that it was just cuz the buffers weren't being swapped, in the Programs loop, I don't know why this is but If some one could inform me on why this must be, for worth of intellegence, that'd be great. But now i have another problem, which is glReadPixels, I continute to Get an Invalid Operation Error when i've read documentation after documentation on what could cause this, no answers seem to come.

Im using this:
Expand|Select|Wrap|Line Numbers
  1. glReadPixels(0, 0, 640, 480, GL_RGBA, GL_UNSIGNED_BYTE, pPixels);
  2.  
With pPixels as a pointer to an unsigned character.

I've Tried using various forms of glPixelStorei with the GL_PACK_ALIGNMENT but that doesn't seem to effect the situation at all.
Sep 16 '08 #2
Ok im not smart, I got it all figured out. The calling function "glReadPixels" was on a different thread than that of the Device Context, So by Using SendMessage to the Main thread to Read the Pixels into a global buffer I was able to keep processing what needed to be in the thread. BOMB oh yeah, so Just a Lesson learned on calling function using variables on seprate threads.
Sep 16 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Vin | last post by:
Hi, I save the drwan stuff on a GLView using CsGL like this: Size s = Size; s.Width = 540; s.Height = 435; Bitmap b = new Bitmap(s.Width, s.Height, PixelFormat.Format32bppArgb); BitmapData...
6
by: Jon Slaughter | last post by:
Is it faster to modify array of ints as 32-bit pixel data and then somehow turn that into a bitmap or use lockbits? I'm having a little performance issues with lock bits unfortunately. I figure...
14
by: Gangreen | last post by:
Hi, I was asked to create an anticheatprogram for a game of the medal of honor series. The code i post is a thread that should start medal of honor and read it's STDOUT. But, when i execute this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.