Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 07 Sep 2012
Offline Last Active Private

Topics I've Started

SwapBuffers issue

25 May 2013 - 02:39 PM

Hey guys.


I'm using double buffering with the flags:


void EnableDrawing (HGLRC *hRC)
    int iFormat;

    window_hDC = GetDC (hWnd);
    ZeroMemory (&pfd, sizeof (pfd));
    pfd.nSize = sizeof (pfd);
    pfd.nVersion = 1;
    pfd.iPixelType = PFD_TYPE_RGBA;
    pfd.cColorBits = 24;
    pfd.cDepthBits = 16;
    pfd.iLayerType = PFD_MAIN_PLANE;
    iFormat = ChoosePixelFormat (enigma::window_hDC, &pfd);

    if (iFormat==0) { show_error("Total failure. Abort.",1); }

    SetPixelFormat (window_hDC, iFormat, &pfd);
    *hRC = wglCreateContext(window_hDC );
    wglMakeCurrent(window_hDC, *hRC );

Then I'm trying to use SwapBuffers(window_hDC); to update a rending scene at certain intervals, but there is a problem with it just switching between buffer images instead of keeping a solid image on the screen. So it winds up looking like this:




Alternating between the two buffers instead of displaying a solid image.


Is this an issue caused by my card driver? Because I think this behaviour has actually changed, I never remember it doing this before - and I think I might have updated my driver at some point. In any case does anybody please know a way of possibly resolving or working around this? I need to keep a double buffer mechanism though.


Thanks for any help.



System Info:



ps. I know this isn't directly OpenGL but I thought it fitted best here, please move it if it's in the wrong forum sorry.

3d Primitive Alpha Issue

18 November 2012 - 04:15 PM

EDIT: solved

Texture Interpolation Problem With Transparent Pixels

08 September 2012 - 11:31 PM


Can somebody please tell me how I can stop texture interpolation from interpolating with fully transparent pixels? I am just using this code for interpolation:


At the moment my sprites that use transparency all have unnaturally coloured edges to them when I use interpolation, which isn't pretty :)


Create a new texture from two blended textures

07 September 2012 - 07:57 PM

Hi guys, I am trying to create a new texture from a background texture but with it's alpha values set from the colour gradient of another texture. Ie like this:

Posted Image

This is a framework of the C++ code I am using:

unsigned tex_aft(int tex, int copy_tex)
	//tex is the texture to set the alpha to, copy_tex is the texture to take the colour gradients from for the alpha values
	GLuint texture = tex, copy_texture = copy_tex;
	glBindTexture(GL_TEXTURE_2D, texture);
	int w, h;
	glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH, &w);
	glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_HEIGHT, &h);
	glBindTexture(GL_TEXTURE_2D, copy_texture);
	char* bitmap = new char[(h<<(lgpp2(w)+2))|2];  //lgpp2() function is used to get powers of two
	glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmap);
	GLuint tex_new;
	glGenTextures(1, &tex_new);
	glBindTexture(GL_TEXTURE_2D, tex_new);
	glTexImage2D(GL_TEXTURE_2D, 0, 4, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, void(bitmap));
	delete[] bitmap;
	return tex_new;

But from what I know you can't use glBlendFunc to blend bound textures like this, all this code winds up doing is returning a straight replica of the copy_tex. So does anybody here please know what code I could use to blend the two textures like I have described and create a new texture from this?

Thanks for any help.