Hi everyone,
I am trying to use OpenGl with C++ and am having problems with multiple
viewports. The problem happens when I try to display bitmaps in twp
different viewports.
I tried various combinations. The code seems to behave when I am
drawing triangles etc. However, when I try doing something with
bitmaps, it fails.
Here is the code in a nutshell:
glMatrixMode(GL_MODELVIEW);
glViewport(m_xPos, m_yPos, m_width,m_height);
glLoadIdentity();
glDrawPixels(bmp.bmWidth, bmp.bmHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE,
bmp.bmBits);
// same code, but different set of values for the position...
glMatrixMode(GL_MODELVIEW);
glViewport(m_xPos, m_yPos, m_width,m_height);
glLoadIdentity();
glDrawPixels(bmp.bmWidth, bmp.bmHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE,
bmp.bmBits);
SwapBuffers(hDC);
Now, the two bitmaps seem to get drawn on the same viewport... I would
appreciate any help anyone can give me regarding this...
Cheers,
xargy
|
|
0
|
|
|
|
Reply
|
pankajdaga (63)
|
12/7/2005 2:37:19 PM |
|
Actually, the bitmaps get drawn on the lower left side of the screen. I
guess I need to do some transformation before drawing the bitmap. I
thought setting the viewport should do that!
|
|
0
|
|
|
|
Reply
|
xargon
|
12/7/2005 2:39:07 PM
|
|
I tried using some tricks with glOrtho, but still no luck...
So, in the code here: m_xPos = 500; m_YPos = 200; m_width and m_height
are 200 resp.
So, I do:
glMatrixMode(GL_MODELVIEW);
glViewport(m_xPos, m_yPos, m_width,m_height);
glLoadIdentity();
glOrtho(m_xPos, m_xPos + m_width, m_height, m_height + m_yPos, -1,
1);
glDrawPixels(bmp.bmWidth, bmp.bmHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE,
bmp.bmBits);
I hope someone can help me here...
Thanks,
xargy
|
|
0
|
|
|
|
Reply
|
xargon
|
12/7/2005 3:03:43 PM
|
|
xargon wrote:
> I tried using some tricks with glOrtho, but still no luck...
>
> So, in the code here: m_xPos = 500; m_YPos = 200; m_width and m_height
> are 200 resp.
>
> So, I do:
> glMatrixMode(GL_MODELVIEW);
> glViewport(m_xPos, m_yPos, m_width,m_height);
> glLoadIdentity();
>
> glOrtho(m_xPos, m_xPos + m_width, m_height, m_height +
m_yPos, -1,
> 1);
> glDrawPixels(bmp.bmWidth, bmp.bmHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE,
> bmp.bmBits);
>
> I hope someone can help me here...
>
The "glOrtho" must go in the GL_PROJECTION matrix,
not the GL_MODELVIEW matrix
glViewport(...);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(...);
glMatrixMode(GL_MODELVIEW);
Next you need a call to glRasterPos() before you can
draw a bitmap.
glrasterPos(...);
glDrawPixels(...);
--
<\___/>
/ O O \
\_____/ FTB. For email, remove my socks.
In science it often happens that scientists say, 'You know
that's a really good argument; my position is mistaken,'
and then they actually change their minds and you never
hear that old view from them again. They really do it.
It doesn't happen as often as it should, because scientists
are human and change is sometimes painful. But it happens
every day. I cannot recall the last time something like
that happened in politics or religion.
- Carl Sagan, 1987 CSICOP keynote address
|
|
0
|
|
|
|
Reply
|
fungus
|
12/7/2005 3:30:08 PM
|
|
Hi,
Thanks for the reply! Do you think the arguments to the glOrtho call is
ok?
Thanks,
xargy
|
|
0
|
|
|
|
Reply
|
xargon
|
12/7/2005 3:38:04 PM
|
|
|
4 Replies
265 Views
(page loaded in 0.005 seconds)
Similiar Articles: multiple viewport problem with bitmap - comp.graphics.api.opengl ...Hi everyone, I am trying to use OpenGl with C++ and am having problems with multiple viewports. The problem happens when I try to display bitmaps in ... Multiple overlapping viewports - comp.graphics.api.opengl ...multiple viewport problem with bitmap - comp.graphics.api.opengl ... Maybe it's very simple problem but I need your ... Multiple overlapping viewports - comp.graphics.api ... Bitmap help - comp.os.ms-windows.programmer.win32multiple viewport problem with bitmap - comp.graphics.api.opengl ..... xPos + m_width, m_height, m_height + m_yPos, -1, 1); glDrawPixels(bmp.bmWidth, bmp.bmHeight, GL ... glViewport? - comp.graphics.api.openglmultiple viewport problem with bitmap - comp.graphics.api.opengl ... Here is the code in a nutshell: glMatrixMode(GL_MODELVIEW); glViewport(m_xPos, m_yPos, m_width,m ... Drawing bitmap with glOrtho at a specific depth - comp.graphics ...glDrawPixels problem - comp.graphics.api.opengl I'm not able to draw at screen a figure ... opengl multiple viewport problem with bitmap - comp.graphics.api.opengl ... Multiple textures on one object - not multitexturing - comp ...multiple viewport problem with bitmap - comp.graphics.api.opengl ... Hi everyone, I am trying to use OpenGl with C++ and am having problems with multiple viewports. SwapBuffers() - comp.os.ms-windows.programmer.win32multiple viewport problem with bitmap - comp.graphics.api.opengl ..... glViewport(m_xPos, m_yPos, m_width,m_height); glLoadIdentity(); glDrawPixels(bmp.bmWidth, bmp ... glDrawPixels problem - comp.graphics.api.openglmultiple viewport problem with bitmap - comp.graphics.api.opengl ... glDrawPixels problem - comp.graphics.api.opengl OpenGl data to TBitmap - comp.graphics.api.opengl ... print large page - comp.text.pdfMiguel PS wrote: > I have a problem a long time ago ... You simply calculate the "viewport" of each page in ... SAMPLE: PRTLGPCT.EXE: Print a Large Bitmap on Multiple Pages The ... Using 3D Textures - the best way - comp.graphics.api.opengl ...The aliasing problems are usually because of the slice ... With a multiple-gigabyte dataset, anything you do will ... is using texture (glTexSubImage2D). ... use the viewport ... multiple viewport problem with bitmap - comp.graphics.api.opengl ...Hi everyone, I am trying to use OpenGl with C++ and am having problems with multiple viewports. The problem happens when I try to display bitmaps in ... Same scene to multiple viewports? - opengl - Mofeel Groupsmultiple viewport problem with bitmap Hi everyone, I am trying to use OpenGl with C++ and am having problems with multiple viewports. The problem happens when I try to ... 7/24/2012 9:21:03 AM
|