473,396 Members | 1,921 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,396 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 11226
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.