Jump to content
  • Advertisement
Sign in to follow this  
CoolGames

OpenGL 0,0 location and slow DrawPixel

This topic is 5037 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!! Im new to OpenGL and didnt found any way on other homepages tuts to change the default location of coordinates 0,0 from button left to top left :( Second, I only want to use DrawPixel function to draw to the screen. I dont want any 3D stuff. But just a simple DrawPixel call with dimension of 500x500 and RGBA does take 850ms, even in release mode. 1000x1000 then already needs 2750ms... Whats wrong? The window-creation is used from NeHe-Tutorials, and works just fine. All other code is made myself. This code follows the window creation, which is a window-mode 32bit one.
	ShowWindow(Window,SW_SHOW);
	SetForegroundWindow(Window);
	SetFocus(Window);

	glViewport(0, 0, _Screen.m_Width, _Screen.m_Height);
	glRenderMode(GL_RENDER);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0.0, (GLdouble) _Screen.m_Width, 0.0, (GLdouble) _Screen.m_Height);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glTranslatef (0.375, 0.375, 0.);
	glLoadIdentity();
This code is in the window-handler:
	case WM_PAINT:
		{
			glRasterPos2i(0, 0);
			memset(m_pScreen->m_pData, 0xFF, m_pScreen->m_Height * m_pScreen->m_Width *4);

			UINT Time = GetTickCount();
			glDrawPixels(m_Screen.m_Width, m_Screen.m_Height, GL_RGBA, GL_UNSIGNED_BYTE, m_pScreen->m_pData);
			UINT NeededTime = GetTickCount() - Time;
			glFlush();
			SwapBuffers(m_pScreen->m_DeviceContext);
			return 0;
		}
Whats wrong with the code? Thanks guys!

Share this post


Link to post
Share on other sites
Advertisement
LOL, you don't use DrawPixel... That's slow as hell... The code is fine, you're just aware of how much information you're sending to your gfx card (read: a lot!)...

You will always draw in 3D with OpenGL, it's just a matter of how the camera's matrix is set up. You can use the orthographic view (like you're doing now) and draw triangles, quads and such instead of pixels... Of course, if you need it in pixels, that won't do you much good, but since you have not told us what you're drawing, then I cannot help you much more than this...

Share this post


Link to post
Share on other sites
There's nothing wrong with your code. glDrawPixels is notoriously slow on many implementations.

It sounds to me like you shouldn't really be using OpenGL at all, as it is primarily a 3D API. I would suggest looking into SDL instead, as it has much faster methods for manipulating raw pixel values in buffers.

Share this post


Link to post
Share on other sites
for the first question i believe
gluOrtho2D(0.0, (GLdouble) _Screen.m_Width, (GLdouble) _Screen.m_Height), 0.0);
should do it, though be aware in maths the bottom left is normally 0,0
what card do u have if its a nvidia one then drawpixels is pretty quick

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!