We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › how to use glDrawPixels();
Page Index Toggle Pages: 1
how to use glDrawPixels();? (Read 2730 times)
how to use glDrawPixels();?
Aug 18th, 2009, 3:55pm
 
please somebody have a simple exemple to use glDrawPixels();?

Because a try to use set() in OpenGl but it is very slow and crapy...


Thank you very munch...
Re: how to use glDrawPixels();?
Reply #1 - Aug 18th, 2009, 5:40pm
 
http://msdn2.microsoft.com/en-us/library/ms537062.aspx

gl.glDrawPixels( width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, IntBuffer.wrap(tmpPixels) );


that should work
I'm sorry, but.
Reply #2 - Aug 19th, 2009, 4:23am
 
Have you a small exemple, with mouseX and mouseY by exemple...
Re: how to use glDrawPixels();?
Reply #3 - Aug 19th, 2009, 4:31am
 
its simple. i assume you have a reference to the GL object from processing since you are asking about using opengl functions..

so just load a PImage, and use the line in the post above.

GL gl;
PImage img;

void setup()
{
 img = loadImage( filename );
}

void draw()
{
 gl = ((PGraphicsOpenGL)g).beginGL();

 // pass the pixels from pimage.
gl.glDrawPixels( width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, IntBuffer.wrap(img.pixels) );

 ((PGraphicsOpenGL)_parent.g).endGL();
}
Re: how to use glDrawPixels();?
Reply #4 - Aug 19th, 2009, 4:52am
 
I try to make this code : but, I have "Cannot find anything named "_parent""...

No i'm a beginner for Opengl, that why is a little bit hard... But a try!
Smiley

Thank you for your help.

/////////////////////////////////////////////////////////////////////////
import processing.opengl.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;

GL gl;
PImage img;

void setup()
{
 size(800,600,OPENGL);
 img = loadImage("yo.png");
}

void draw()
{
 gl = ((PGraphicsOpenGL)_parent.g).beginGL();

 // pass the pixels from pimage.
 gl.glDrawPixels( width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, IntBuffer.wrap(img.pixels) );

 (PGraphicsOpenGL.g).endGL();
}
Re: how to use glDrawPixels();?
Reply #5 - Aug 19th, 2009, 4:54am
 
sorry, i've copied it from my framework and didn't see that..

just remove the "parent." part.



gl = ((PGraphicsOpenGL)g).beginGL();
Re: how to use glDrawPixels();?
Reply #6 - Aug 19th, 2009, 4:57am
 
Yes, now i hope the last, have a problem with the IntBuffer. "cannot find anything named IntBuffer".

Re-thank.
Re: how to use glDrawPixels();?
Reply #7 - Aug 19th, 2009, 4:58am
 
u need to import to package that has it.. google for it
Re: how to use glDrawPixels();?
Reply #8 - Aug 19th, 2009, 5:03am
 
ok, package it's probaly,

import javax.nio.*;

it have IntBuffer, but i have expecting EOF, found 'PImage';

That strange..

////the code////////////

import processing.opengl.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import javax.nio.*

GL gl;
PImage img;


void setup()
{
 size(800,600,OPENGL);
 img = loadImage("yo.png");
}


void draw()
{
 gl = ((PGraphicsOpenGL)g).beginGL();

 // pass the pixels from pimage.
 gl.glDrawPixels( width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, IntBuffer.wrap(img.pixels) );

 (PGraphicsOpenGL.g).endGL();
}

Re: how to use glDrawPixels();?
Reply #9 - Aug 19th, 2009, 5:23am
 
That right.

thank!

//////////////////////////////////////////////////
import processing.opengl.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import java.nio.*;

PImage img;
GL gl;


void setup()
{
 size(800,600,OPENGL);
 img = loadImage("yo.png");
}


void draw()
{
 gl = ((PGraphicsOpenGL)g).beginGL();

 // pass the pixels from pimage.
 gl.glDrawPixels( width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, IntBuffer.wrap(img.pixels));


 ((PGraphicsOpenGL)g).endGL();
}
Page Index Toggle Pages: 1