Sign in to follow this  
Seabolt

OpenGL OpenGL is acting strangely

Recommended Posts

Seabolt    781
Hey guys,

So I'm currently rendering a triangle in OpenGL 2.0. I can get it to render but there are some strange things afoot that shouldn't be.

First strange behavior:
I'm required to use glFlush. Without it the screen will just show white when I clear to a dark blue. I will see my triangle if the last frame as I close the program. I know I shouldn't have to call glFlush to do that so I'm wondering why the GPU isn't executing the calls without it. I've tested this on multiple computers, and the behavior is the same, so this isn't a GPU specific issue.

Second strange behavior:
I recently bought a new laptop and moved everything over to it. The only changes I made program wise is I removed GLUT from the project, and took out all related dependencies. I also upgraded from VS 2008 to VS 2010. Also the laptop is 64 bit vs the previous 32 bit. With those being the only changes, my SwapBuffers() call will return false every time, BUT it will still render. I can resize my screen and move it and the triangle is still there and is reacting to the changes. I called GetLastError() and it returns 0, so the thread isn't posting any errors, yet it still returns false every frame.

Now I really don't want to go forward with these issues because I'd rather not build on a foundation of mud, so any help would be appreciated.

Here's the various code (its spread across a couple of modules):

[code]
//////////////////////////////////////////////////////////////////////////
// WinMain.cpp
// - Used to create the main loop of execution
//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
// Includes
//////////////////////////////////////////////////////////////////////////
#include <Windows.h>

#include "../Graphics/CDeviceManager.h"
#include "../Game/CGame.h"
//////////////////////////////////////////////////////////////////////////
// Global Variables
//////////////////////////////////////////////////////////////////////////

HWND g_hWnd = NULL; // The copy of the current handle to the window
HINSTANCE g_hInstance = NULL; // The current copy of the instance of this program
int g_nWindowWidth = 1280;
int g_nWindowHeight = 720;
CWindow g_cWindow;

//////////////////////////////////////////////////////////////////////////
// Forward Declarations
//////////////////////////////////////////////////////////////////////////

// MainWndProc
// - The callback function for the message loop windows uses
LRESULT CALLBACK
MainWndProc( HWND handleWindow, // The handle for the window
UINT unMessage, // The message ID for this iteration
WPARAM wParam, // Additional parameters
LPARAM lParam ); // Additional parameters

//////////////////////////////////////////////////////////////////////////

// WinMain
// - The first function called by windows; serves as the main loop for the program
int APIENTRY
WinMain( HINSTANCE hInstance, // The current instance of the program
HINSTANCE hPrevInstance, // The previous instance of the program
LPSTR lpCmdLine, // Any command line arguments
int nCmdCount ) // How many arguments the are
{
// Save our global copies
g_hInstance = hInstance;

// Create a window
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wcex.lpfnWndProc = (WNDPROC)MainWndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = (HCURSOR)LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = NULL;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = TEXT("Thunderclad Engine"); // Should be unique
wcex.hIconSm = NULL;

// Select window styles
UINT unStyle,unStyleX;
unStyleX = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
unStyle = WS_OVERLAPPEDWINDOW;

// Describe our window placement
WINDOWPLACEMENT wndPlacement;
wndPlacement.length = sizeof(WINDOWPLACEMENT);
wndPlacement.ptMaxPosition.x = 0;
wndPlacement.ptMaxPosition.y = 0;
wndPlacement.ptMinPosition.x = 0;
wndPlacement.ptMinPosition.y = 0;
wndPlacement.rcNormalPosition.bottom = g_nWindowHeight;
wndPlacement.rcNormalPosition.left = 0;
wndPlacement.rcNormalPosition.top = 0;
wndPlacement.rcNormalPosition.right = g_nWindowWidth;

// Create our instance of our main window
g_cWindow.Init( g_hWnd,
wndPlacement,
&wcex,
unStyle,
unStyleX,
g_nWindowWidth,
g_nWindowHeight,
TEXT("Thunderclad Engine"),
g_hInstance );

// Initialize the game here
CGame::GetInstance()->Initialize();

// Start the message loop
MSG msg;
while( CGame::GetInstance()->IsGameActive() )
{
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if( msg.message == WM_QUIT )
{
break;
}

TranslateMessage( &msg );
DispatchMessage( &msg );
}
else if( CGame::GetInstance()->IsGameActive() )
{
CGame::GetInstance()->Update();
CGame::GetInstance()->Render();
}
}

// Clean up our classes
CGame::GetInstance()->Destroy();
CDeviceManager::GetInstance()->Destroy();
g_cWindow.Destroy();

// return from the program
return msg.wParam;
}

// MainWndProc
// - This will be the message proc for the main window
LRESULT CALLBACK
MainWndProc( HWND handleWindow, // The handle to the window
UINT unMessage, // The message to process
WPARAM wParam, // An additional parameter
LPARAM lParam ) // An additional parameter
{
g_hWnd = handleWindow;

switch( unMessage )
{
case WM_CREATE:
g_cWindow.SetWindowHandle( handleWindow );
g_cWindow.SetHDC( GetDC( handleWindow ) );
CDeviceManager::GetInstance()->Initialize( &g_cWindow );
break;

case WM_ERASEBKGND:
return false;

case WM_SIZE:
// Resize the window
CDeviceManager::GetInstance()->Resize( LOWORD( lParam ),
HIWORD( lParam ) );
return 0;
break;
case WM_CLOSE:
// Free up resources if the red x is pressed
CGame::GetInstance()->Destroy();
CDeviceManager::GetInstance()->Destroy();
g_cWindow.Destroy();
break;
default:
return DefWindowProc( handleWindow,
unMessage,
wParam,
lParam );
}

return 0;
}[/code]


[code]

//////////////////////////////////////////////////////////////////////////
// CWindow.cpp
// - Defines the functions for our window class
//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
// Includes
//////////////////////////////////////////////////////////////////////////
#include "CWindow.h"
#include <Windows.h>
#include <tchar.h>
#include <assert.h>

//////////////////////////////////////////////////////////////////////////
// Constructor
//////////////////////////////////////////////////////////////////////////
CWindow::CWindow()
{
m_handleWindow = NULL;
m_handleInstance = NULL;
m_bIsFullScreen = false;
m_wndPlacement;
m_wndClassDescription;

// Zero out our structures
ZeroMemory( &m_wndClassDescription, sizeof( WNDCLASSEX ) );
ZeroMemory( &m_wndPlacement, sizeof( WINDOWPLACEMENT ) );
}

//////////////////////////////////////////////////////////////////////////
// Destructor
//////////////////////////////////////////////////////////////////////////
CWindow::~CWindow()
{
// Free any resources allocated
}

//////////////////////////////////////////////////////////////////////////
// Function Definitions
//////////////////////////////////////////////////////////////////////////

void
CWindow::Init( HWND &out_handleWindow, // The handle to the window
WINDOWPLACEMENT in_wndPlacement, // The class that describes the window's placement
const WNDCLASSEX* in_wndClassDescription, // The class that describes the class's functionality
UINT in_unWindowStyle, // The window style
UINT in_unWindowExStyle, // The windowEx style
int in_nWindowWidth, // The window width
int in_nWindowHeight, // The window height
LPCWSTR in_szProgramName, // The name of the program
HINSTANCE in_handleCurrentInstance ) // The current instance of the program
{

// Store our copies
SetWindowWidth( in_nWindowWidth );
SetWindowHeight( in_nWindowHeight );
IsFullScreen( false );

// Store our copies of relevant info
m_wndClassDescription = *in_wndClassDescription;
m_handleInstance = in_handleCurrentInstance;
m_lpWindowName = in_szProgramName;
m_unWindowStyle = in_unWindowStyle;
m_unWindowStyleEX = in_unWindowExStyle;

// First we must register the class
assert( RegisterClassEx( &m_wndClassDescription ) != 0 );

RECT windowRect; // Grabs Rectangle Upper Left / Lower Right Values
windowRect.left=(long)0; // Set Left Value To 0
windowRect.right=(long)GetWindowWidth(); // Set Right Value To Requested Width
windowRect.top=(long)0; // Set Top Value To 0
windowRect.bottom=(long)GetWindowHeight(); // Set Bottom Value To Requested Height

// Get a pixel perfect window
AdjustWindowRectEx( &windowRect, m_unWindowStyle, FALSE, m_unWindowStyleEX );

// Then we must create the window from the data provided;
SetWindowHandle( CreateWindowEx( m_unWindowStyleEX,
m_wndClassDescription.lpszClassName,
in_szProgramName,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | in_unWindowStyle,
0,
0,
GetWindowWidth(),
GetWindowHeight(),
NULL,
NULL,
m_handleInstance,
NULL ) );

assert( GetWindowHandle() != NULL );


// Show the window and start updating it
ShowWindow( GetWindowHandle(), SW_SHOW );
UpdateWindow( GetWindowHandle() );
}

// ReCreateWindow
void
CWindow::ReCreateWindow()
{
// Destroy this window and Unregister it
assert( DestroyWindow( m_handleWindow ) != NULL );
WNDCLASSEX temp = m_wndClassDescription;
UnregisterClass( m_wndClassDescription.lpszClassName, m_handleInstance );

// Re register and position it
// First we must register the class
assert( RegisterClassEx( &m_wndClassDescription ) != 0 );

RECT windowRect; // Grabs Rectangle Upper Left / Lower Right Values
windowRect.left=(long)0; // Set Left Value To 0
windowRect.right=(long)GetWindowWidth(); // Set Right Value To Requested Width
windowRect.top=(long)0; // Set Top Value To 0
windowRect.bottom=(long)GetWindowHeight(); // Set Bottom Value To Requested Height

// Get a pixel perfect window
AdjustWindowRectEx( &windowRect, m_unWindowStyle, FALSE, m_unWindowStyleEX);

m_handleWindow = CreateWindowEx( m_unWindowStyleEX,
m_wndClassDescription.lpszClassName,
m_lpWindowName,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | m_unWindowStyle,
0,
0,
GetWindowWidth(),
GetWindowHeight(),
NULL,
NULL,
m_handleInstance,
NULL );
UINT error = GetLastError();
assert( m_handleWindow != NULL );


// Show the window and start updating it
ShowWindow( m_handleWindow, SW_SHOW );
UpdateWindow( m_handleWindow );
}

// Destroy
// - Destroys this window
void
CWindow::Destroy()
{
if( m_handleWindow != NULL )
{
// Destroys this window and removes it from the message pump
DestroyWindow( m_handleWindow );
m_handleWindow = NULL;
}

UnregisterClass( m_wndClassDescription.lpszClassName, m_handleInstance );
}

[/code]


[code]

// COpenGLDeviceManager.cpp
// - This file will define all methods declared in COpenGLDeviceManager.h

//////////////////////////////////////////////////////////////////////////
// Includes
//////////////////////////////////////////////////////////////////////////
#include "COpenGLDeviceManager.h"

//////////////////////////////////////////////////////////////////////////
// Constructor
//////////////////////////////////////////////////////////////////////////
COpenGLDeviceManager::COpenGLDeviceManager()
{
//////////////////////////////////////////////////////////////////////////
// Platform Specific initialization (Windows)
#if USING_WINDOWS
m_handleWindowHandle = NULL;
m_handleGLRenderContext = NULL;
m_handleDeviceContext = NULL;

ZeroMemory( &m_tPixelFormat, sizeof(PIXELFORMATDESCRIPTOR) );
#endif
//////////////////////////////////////////////////////////////////////////
}


//////////////////////////////////////////////////////////////////////////
// Destructor
//////////////////////////////////////////////////////////////////////////
COpenGLDeviceManager::~COpenGLDeviceManager()
{
m_handleWindowHandle = NULL;
m_handleDeviceContext = NULL;
m_handleGLRenderContext = NULL;

ZeroMemory( &m_tPixelFormat, sizeof( PIXELFORMATDESCRIPTOR ) );
}

//////////////////////////////////////////////////////////////////////////
// TEMP REMOVE THIS CODE
#include <math.h>
void BuildPerspProjMat(float *m, float fov, float aspect,
float znear, float zfar)
{
float xymax = znear * tan(fov);
float ymin = -xymax;
float xmin = -xymax;

float width = xymax - xmin;
float height = xymax - ymin;

float depth = zfar - znear;
float q = -(zfar + znear) / depth;
float qn = -2 * (zfar * znear) / depth;

float w = 2 * znear / width;
w = w / aspect;
float h = 2 * znear / height;

m[0] = w;
m[1] = 0;
m[2] = 0;
m[3] = 0;

m[4] = 0;
m[5] = h;
m[6] = 0;
m[7] = 0;

m[8] = 0;
m[9] = 0;
m[10] = q;
m[11] = -1;

m[12] = 0;
m[13] = 0;
m[14] = qn;
m[15] = 0;
}
//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
// Function Definitions
//////////////////////////////////////////////////////////////////////////
STATUS
COpenGLDeviceManager::Initialize( CWindow* programWindow )
{
m_bIsFullScreen = programWindow->IsFullScreen();

//////////////////////////////////////////////////////////////////////////
// Platform Specific Initialization (Windows)
#if USING_WINDOWS

// Store the HWND
m_handleWindowHandle = programWindow->GetWindowHandle();

// Do a NULL check if we are in Debug
ASSERT_NULL( m_handleWindowHandle );

// Get the Device Context
m_handleDeviceContext = programWindow->GetHDC();

// Null check the DC
ASSERT_NULL( m_handleDeviceContext );

//////////////////////////////////////////////////////////////////////////
// Set the pixel format
m_tPixelFormat.nSize = sizeof( PIXELFORMATDESCRIPTOR ); // Size of the PFD
m_tPixelFormat.nVersion = 1; // Set the version number
m_tPixelFormat.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
m_tPixelFormat.iPixelType = PFD_TYPE_RGBA; // Set the color format
m_tPixelFormat.cColorBits = 32; // Set the color depth
m_tPixelFormat.cDepthBits = 24; // Set the depth buffer depth
m_tPixelFormat.iLayerType = PFD_MAIN_PLANE; // Set the layer for the app

// See if there is a pixel format that will match our requests
int nPixelFormat = 0;
ASSERT_FALSE( nPixelFormat = ChoosePixelFormat( m_handleDeviceContext,
&m_tPixelFormat ) );

ASSERT_FALSE( SetPixelFormat( m_handleDeviceContext,
nPixelFormat,
&m_tPixelFormat ) );

//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
// So far so good... Now we try to create our RenderContext (HRC)
HGLRC tempContext = wglCreateContext( m_handleDeviceContext );
ASSERT_NULL( tempContext );
DWORD pleaseBeIt = GetLastError();

// See if the tempContext will work
ASSERT_FALSE( wglMakeCurrent( m_handleDeviceContext, tempContext ) ); CHECK();

pleaseBeIt = GetLastError();

//GLenum error = glewInit();
//if( error != GLEW_OK )
//{
// fprintf(stderr, "Error: %s\n", glewGetErrorString(error));
//}

//DWORD lastError = GetLastError();

if( false )//wglewIsSupported( "WGL_ARB_create_context" ) == 1 )
{
//lastError = GetLastError();
//// Define our attributes for using OpenGL 3.0 and forward
//int attribs[] = {
// WGL_CONTEXT_MAJOR_VERSION_ARB, 3,//we want a 3.0 context
// WGL_CONTEXT_MINOR_VERSION_ARB, 1,
// //and it shall be forward compatible so that we can only use up to date functionality
// WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
// 0}; //zero indicates the end of the array

// lastError = GetLastError();
// m_handleGLRenderContext = wglCreateContextAttribsARB( m_handleDeviceContext, 0, attribs ); CHECK();
// ASSERT_NULL( m_handleGLRenderContext );
// ASSERT_FALSE( wglMakeCurrent( NULL, NULL ) ); lastError = GetLastError(); // CHECK();
// ASSERT_FALSE( wglDeleteContext( tempContext ) ); // CHECK();
// ASSERT_FALSE( wglMakeCurrent( m_handleDeviceContext, m_handleGLRenderContext ) ); CHECK();
}
else // If we can't use 3.1
{
m_handleGLRenderContext = tempContext;
}
//////////////////////////////////////////////////////////////////////////

TVector3F position;
TMatrixF rotation;
rotation.MakeIdentity();
position.X = position.Y = position.Z = 0.0f;
m_tempCamera.Initialize( m_tempCamera.CreateViewMatrix( position, rotation ),
m_tempCamera.CreateProjectionMatrix( 1280 / 720,
45, 10, 100 ), CCamera::FREE_ROAM );
#endif

return OK;
}

STATUS
COpenGLDeviceManager::Destroy()
{
//////////////////////////////////////////////////////////////////////////
// Platform Specific Destroy
#if USING_WINDOWS
// Check to see if we can safely release and delete our RenderContext
if( m_handleGLRenderContext )
{
ASSERT_FALSE( wglMakeCurrent( m_handleDeviceContext, NULL ) );
ASSERT_FALSE( wglDeleteContext( m_handleGLRenderContext ) );
m_handleGLRenderContext = NULL;
}

// Check and see if we can safely release our DeviceContext
if( m_handleDeviceContext )
{
ASSERT_FALSE( ReleaseDC( m_handleWindowHandle, m_handleDeviceContext ) );
m_handleDeviceContext = NULL;
}
#else
#endif

return OK;
}

STATUS
COpenGLDeviceManager::Resize( i4 nScreenWidth, i4 nScreenHeight )
{
CHECK();
glViewport (0, 0, nScreenWidth, nScreenHeight); CHECK();

glMatrixMode( GL_PROJECTION ); CHECK();
glLoadMatrixf( m_tempCamera.GetProjectionMatrix().MatrixArray ); CHECK();
glMatrixMode( GL_MODELVIEW ); CHECK();
glLoadMatrixf( m_tempCamera.GetViewMatrix().MatrixArray );

return OK;
}

STATUS
COpenGLDeviceManager::Present()
{
//////////////////////////////////////////////////////////////////////////
// Platform Specific Present
#if USING_WINDOWS

CHECK();
glFlush(); CHECK();
DWORD test = GetLastError();
SwapBuffers( m_handleDeviceContext ); CHECK();

// Invalidate the window to draw
RECT clientRect;
GetClientRect( m_handleWindowHandle, &clientRect );
InvalidateRect( m_handleWindowHandle, &clientRect, FALSE );
#else
#endif
//////////////////////////////////////////////////////////////////////////
return OK;
}

STATUS
COpenGLDeviceManager::Clear( i4 unBuffersToClear )
{
//////////////////////////////////////////////////////////////////////////
// Determine which buffers to clear
GLbitfield glBitToClear = 0;
if( COLOR_BUFFER_MASK( unBuffersToClear ) )
{
glBitToClear |= GL_COLOR_BUFFER_BIT;
}

if( DEPTH_BUFFER_MASK( unBuffersToClear ) )
{
glBitToClear |= GL_DEPTH_BUFFER_BIT;
}

if( STENCIL_BUFFER_MASK( unBuffersToClear ) )
{
glBitToClear |= GL_STENCIL_BUFFER_BIT;
}
//////////////////////////////////////////////////////////////////////////

glClearColor(0.0f, 0.2f, 0.4f, 1.0f); CHECK(); // The color to clear the background to

// Finally we can clear the buffers
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

return OK;
}
[/code]


[code]

// COpenGLRenderer.cpp
// - This class will define the functions declared in COpenGLRenderer.h

//////////////////////////////////////////////////////////////////////////
// Includes
//////////////////////////////////////////////////////////////////////////
#include "COpenGLRenderer.h"
#include "Vertices.h"

//////////////////////////////////////////////////////////////////////////
// Constructor
//////////////////////////////////////////////////////////////////////////
COpenGLRenderer::COpenGLRenderer()
{

}

//////////////////////////////////////////////////////////////////////////
// Destructor
//////////////////////////////////////////////////////////////////////////
COpenGLRenderer::~COpenGLRenderer()
{

}

//////////////////////////////////////////////////////////////////////////
// Function Definitions
//////////////////////////////////////////////////////////////////////////

// Initialize
// - This will handle all the initialization needed for the renderer
STATUS
COpenGLRenderer::Initialize()
{
CHECK();
glEnable(GL_DEPTH_TEST); CHECK(); // Enable depth testing
glDepthFunc( GL_LEQUAL ); CHECK(); // Reject anything less than or equal to the current depth
glClearDepth( 1.0f ); CHECK(); // We clear to full depth
glClearStencil( 0 ); CHECK(); // We clear the stencil buffer to false
glCullFace(GL_BACK); CHECK(); // Enable culling
glClearColor(0.0f, 0.2f, 0.4f, 1.0f); CHECK(); // The color to clear the background to
return OK;
}

// Destroy
// - This will free all the memory used by the renderer
STATUS
COpenGLRenderer::Destroy()
{
return OK;
}

// DrawBuffer
// - This will draw a single vertex buffer
void
COpenGLRenderer::DrawVertexBuffer( CVertexBuffer* pBufferToDraw )
{
glLoadIdentity();
glPushMatrix();
glEnableClientState( GL_VERTEX_ARRAY ); CHECK();
glEnableClientState( GL_NORMAL_ARRAY ); CHECK();
glEnableClientState( GL_COLOR_ARRAY ); CHECK();

glVertexPointer(3,
GL_FLOAT,
pBufferToDraw->GetDeclaration()->GetSizeOfVertex(),
pBufferToDraw->GetVertices() ); CHECK();
glNormalPointer( GL_FLOAT,
pBufferToDraw->GetDeclaration()->GetSizeOfVertex(),
static_cast<uchar1*>(pBufferToDraw->GetVertices()) + sizeof( f4 ) * 3 ); CHECK();
glColorPointer( 4,
GL_FLOAT,
pBufferToDraw->GetDeclaration()->GetSizeOfVertex(),
static_cast<uchar1*>(pBufferToDraw->GetVertices()) + sizeof( f4 ) * 6 ); CHECK();

glDrawArrays( GL_TRIANGLES, 0, 3 ); CHECK();
glPopMatrix();
}


[/code]


The CHECK() macro just checks the glGetError value for non zero, none of these are being hit.

Share this post


Link to post
Share on other sites
mhagain    13430
That sounds an awful lot like you're getting a single-buffered context. I know you're asking for double-buffered, but you should probably use DescribePixelFormat just to verify.

Share this post


Link to post
Share on other sites
Seabolt    781
Hmmm you might be on to something there. The major difference is that the PIXELFORMATDESCRIPTOR that I'm storing has a dwFlags value of 37 and the one returned by DescribePixelFormat is 32804. I zero the memory out on the structure before I set the format, so is that just something that Windows does when I set it trying to find an appropriate value? That's a very vague question I know.

Share this post


Link to post
Share on other sites
V-man    813
case WM_ERASEBKGND:
return false;

http://www.opengl.org/wiki/Platform_specifics:_Windows#It.27s_flickering.21_Why.3F

Share this post


Link to post
Share on other sites
karwosts    840
PFD dwFlags 37 is :
PFD_DOUBLEBUFFER
PFD_DRAW_TO_WINDOW
PFD_SUPPORT_OPENGL


32804 is:
PFD_DRAW_TO_WINDOW
PFD_SUPPORT_OPENGL
PFD_SUPPORT_COMPOSITION

So it appears that your window doesn't support double buffer?

Share this post


Link to post
Share on other sites
mhagain    13430
ChoosePixelFormat doesn't actually guarantee that you're going to get the format you ask for; instead you're going to get a "best match" format so you should always double-check that what you get is what you actually want. It's also possible to bypass ChoosePixelFormat, loop through the formats available and pick one yourself (with a possible fallback to ChoosePixelFormat if you can't find what you want).

Share this post


Link to post
Share on other sites
Seabolt    781
That's strange that it's not supporting double[b] [/b]buffering... I'm going to search for reasons as to why that might be, but any suggestions you guys have would be appreciated as well :)

Share this post


Link to post
Share on other sites
mhagain    13430
First thing I'd do is double-check your driver - it may be a generic Microsoft or OEM driver that doesn't come with OpenGL support, so you might need a driver update. Assuming that's OK and you still don't get double-buffering, then try looping through the pixel formats as I suggested and ensure that your driver is actually exposing one that supports double buffering.

Try those first, then come back with the info and we'll see where to go from there.

Share this post


Link to post
Share on other sites
Seabolt    781
So I can find a couple of PixelFormats that have double buffering, but they all had strange color bit information. Idk if that's my fault or if for some reason my IntelHD Graphics card really can't support RGBA pixel format or 32bit color buffer. It seems fairly unlikely, especially since it's really new and I updated my drivers... :/

Share this post


Link to post
Share on other sites
Seabolt    781
Actually it looks like I can get all my desired functionality. Why did ChoosePixelFormat play with my emotions so? Thanks you very much mhagain, I've been fighting this bug for a month now, for something as trivial as this. Hahaha it makes me feel stupid as hell.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By Arulbabu Donbosco
      There are studios selling applications which is just copying any 3Dgraphic content and regenerating into another new window. especially for CAVE Virtual reality experience. so that the user opens REvite or CAD or any other 3D applications and opens a model. then when the user selects the rendered window the VR application copies the 3D model information from the OpenGL window. 
      I got the clue that the VR application replaces the windows opengl32.dll file. how this is possible ... how can we copy the 3d content from the current OpenGL window.
      anyone, please help me .. how to go further... to create an application like VR CAVE. 
       
      Thanks
    • By cebugdev
      hi all,

      i am trying to build an OpenGL 2D GUI system, (yeah yeah, i know i should not be re inventing the wheel, but this is for educational and some other purpose only),
      i have built GUI system before using 2D systems such as that of HTML/JS canvas, but in 2D system, i can directly match a mouse coordinates to the actual graphic coordinates with additional computation for screen size/ratio/scale ofcourse.
      now i want to port it to OpenGL, i know that to render a 2D object in OpenGL we specify coordiantes in Clip space or use the orthographic projection, now heres what i need help about.
      1. what is the right way of rendering the GUI? is it thru drawing in clip space or switching to ortho projection?
      2. from screen coordinates (top left is 0,0 nd bottom right is width height), how can i map the mouse coordinates to OpenGL 2D so that mouse events such as button click works? In consideration ofcourse to the current screen/size dimension.
      3. when let say if the screen size/dimension is different, how to handle this? in my previous javascript 2D engine using canvas, i just have my working coordinates and then just perform the bitblk or copying my working canvas to screen canvas and scale the mouse coordinates from there, in OpenGL how to work on a multiple screen sizes (more like an OpenGL ES question).
      lastly, if you guys know any books, resources, links or tutorials that handle or discuss this, i found one with marekknows opengl game engine website but its not free,
      Just let me know. Did not have any luck finding resource in google for writing our own OpenGL GUI framework.
      IF there are no any available online, just let me know, what things do i need to look into for OpenGL and i will study them one by one to make it work.
      thank you, and looking forward to positive replies.
    • By fllwr0491
      I have a few beginner questions about tesselation that I really have no clue.
      The opengl wiki doesn't seem to talk anything about the details.
       
      What is the relationship between TCS layout out and TES layout in?
      How does the tesselator know how control points are organized?
          e.g. If TES input requests triangles, but TCS can output N vertices.
             What happens in this case?
      In this article,
      http://www.informit.com/articles/article.aspx?p=2120983
      the isoline example TCS out=4, but TES in=isoline.
      And gl_TessCoord is only a single one.
      So which ones are the control points?
      How are tesselator building primitives?
    • By Orella
      I've been developing a 2D Engine using SFML + ImGui.
      Here you can see an image
      The editor is rendered using ImGui and the scene window is a sf::RenderTexture where I draw the GameObjects and then is converted to ImGui::Image to render it in the editor.
      Now I need to create a 3D Engine during this year in my Bachelor Degree but using SDL2 + ImGui and I want to recreate what I did with the 2D Engine. 
      I've managed to render the editor like I did in the 2D Engine using this example that comes with ImGui. 
      3D Editor preview
      But I don't know how to create an equivalent of sf::RenderTexture in SDL2, so I can draw the 3D scene there and convert it to ImGui::Image to show it in the editor.
      If you can provide code will be better. And if you want me to provide any specific code tell me.
      Thanks!
    • By Picpenguin
      Hi
      I'm new to learning OpenGL and still learning C. I'm using SDL2, glew, OpenGL 3.3, linmath and stb_image.
      I started following through learnopengl.com and got through it until I had to load models. The problem is, it uses Assimp for loading models. Assimp is C++ and uses things I don't want in my program (boost for example) and C support doesn't seem that good.
      Things like glVertexAttribPointer and shaders are still confusing to me, but I have to start somewhere right?
      I can't seem to find any good loading/rendering tutorials or source code that is simple to use and easy to understand.
      I have tried this for over a week by myself, searching for solutions but so far no luck. With tinyobjloader-c and project that uses it, FantasyGolfSimulator, I was able to actually load the model with plain color (always the same color no matter what I do) on screen and move it around, but cannot figure out how to use textures or use its multiple textures with it.
      I don't ask much: I just want to load models with textures in them, maybe have lights affect them (directional spotlight etc). Also, some models have multiple parts and multiple textures in them, how can I handle those?
      Are there solutions anywhere?
      Thank you for your time. Sorry if this is a bit confusing, English isn't my native language
  • Popular Now