OpenGL within C++

Programming, for all ages and all languages.
Post Reply
User avatar
Assembler
Member
Member
Posts: 30
Joined: Fri Oct 27, 2006 5:26 am
Contact:

OpenGL within C++

Post by Assembler »

Hi Guys,
I've a question for C++ & OpenGL gurus.

I've a class called Bitmap having a member (array of bytes) called "buffer"
I need to call glDrawPixels() from a member function called "display()"

but "buffer" is not just a pointer, so how to pass "buffer" to glDrawPixels()

Code: Select all

class Bitmap
{
   private:
      int x, y;
      BYTE *buffer;
   public:
      void display();
}

void Bitmap::display()
{
  glDrawPixels(x, y , GL_BGR_EXT, GL_UNSIGNED_BYTE, buffer);
}
Any solutions rather than plotting pixel by pixel ???

Thanks alot
Systems and Computer Engineering Researcher
"Do you pine for the nice days of Minix-1.1, when men were men and wrote their own device drivers?" -- Linus Torvalds
http://sce.carleton.ca/~maslan
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

I could probably tell you the answer, but I am not familiar with the OpenGL API, so I am a bit confused as to what your problem actually is.

What does glDrawPixels() expect as its fourth parameter?

And while we're at the subject of type-safety, buffer is not an array, it's a pointer to BYTE...
Every good solution is obvious once you've found it.
supagu
Member
Member
Posts: 46
Joined: Sat Apr 07, 2007 1:24 am

Post by supagu »

http://www2.lifl.fr/~aubert/opengl_ref/ ... ls.3G.html

it does take a pointer to your image data.
Post Reply