Jump to content
  • Advertisement
Sign in to follow this  
AcidZombie24

Gl slow when i blit

This topic is 3625 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

I called thus func *once* per frame and my FPS went from 410fps to 33fps. Why?
	sw blt(const PtRect *dstRect, Texture *src, const PtRect *srcRect, RenderDevice::bltFlags flags=RenderDevice::bltDefault)
	{
		assert(src);
		GL_Texture *glsrc = dynamic_cast<GL_Texture*>(src);
		if (glsrc == 0)
			return -1;

		PtRect srcRect2(0, 0, src->width, src->height);
		if (srcRect == 0)
			srcRect = &srcRect2;

		PtRect dstRect2(0, 0, srcRect->makeWidth(), srcRect->makeHeight());
		if (dstRect == 0)
			dstRect = &dstRect2;

		glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, *glsrc->getTex());

		glBegin( GL_QUADS );
		glNormal3f( 0.0f, 0.0f, 1.0f );
		for (size_t i=0; i<350; i++)
		{
			glTexCoord2f( srcRect->left /src->width, srcRect->top/src->height);    glVertex2f(dstRect->left,  dstRect->top);
			glTexCoord2f( srcRect->right/src->width, srcRect->top/src->height);    glVertex2f(dstRect->right, dstRect->top);
			glTexCoord2f( srcRect->right/src->width, srcRect->bottom/src->height); glVertex2f(dstRect->right, dstRect->bottom);
			glTexCoord2f( srcRect->left /src->width, srcRect->bottom/src->height); glVertex2f(dstRect->left,  dstRect->bottom);
		}
		glEnd();
		return 0;
	}

Share this post


Link to post
Share on other sites
Advertisement
Perhaps because you're doing 350 batches per frames now? You should use vertex buffer objects and do all that in one batch.

Share this post


Link to post
Share on other sites
Why are you drawing your quad 350 times at the same position ?

More important, how big is the quad ? Cause if it's half a screen each time, 350 of them ain't going to be fast due to the amount of pixels being rasterized..

Y.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!