Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


#ActualxXxRosexXxEE

Posted 08 February 2014 - 01:13 PM

Could someone tell me why the backbuffer or frontbuffer will not update the device context I've been stuck on this problem for 3days and It's driving me crazy!?
 
- Win7 64bit 
- OpenGL 3.311672 Compatibility Profile Context 
- Microsoft Visual Studio 2012  C++
 
The Pixel format is being assigned properly.
 
I've created the projections correctly,set the opengl clear color,swapped the buffers on the devicecontext in the "correct place".
 
What more does it want???...... 
 

 


#4xXxRosexXxEE

Posted 08 February 2014 - 01:11 PM

Could someone tell me why the backbuffer or frontbuffer will not update the device context I've been stuck on this problem for 3days and It's driving me crazy!?
 
- Win7 64bit 
- OpenGL 3.311672 Compatibility Profile Context 
- Microsoft Visual Studio 2012  C++
 
The Pixel format is being assigned properly.
 
I've created the projections correctly,set the opengl clear color,swapped the buffers on the devicecontext in the "correct place".
 
What more does it want???......

#include <Windows.h>
#include <GL/GL.h>
#include <iostream>
#include <string.h>
#include <tchar.h>


#pragma comment (lib, "opengl32.lib")


static TCHAR szWindowClass[] = _T("Windows32App");
static TCHAR szTitle[] = _T("OpenGL 3.3 Demo");


bool active = TRUE;
bool keys[256];
int DRAW_OPENGL(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glTranslatef(3.0f,0.0f,0.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f,0.0f);
glVertex3f(1.0f,-1.0f,0.0f);
glEnd();

return TRUE;

}


LRESULT CALLBACK WindowProcedure(HWND WindowHandle, UINT Messages, WPARAM wParam, LPARAM lParam)
{
//PAINTSTRUCT ps;
HDC hdc = NULL;
TCHAR greeting[] = _T("Test");
COLORREF NewColor = RGB(255,0,0);
switch(Messages)
{
case WM_ACTIVATE:
{
if(!HIWORD(wParam))
{
active = TRUE;
}
else 
{
active = FALSE;
}
return 0;
}
case WM_CREATE:
{


PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1, 
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32,
0,0,0,0,0,0
,0
,0
,0
,0,0,0,0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,0
};


hdc = GetDC(WindowHandle);


GLuint ChooseWindowFormat = ChoosePixelFormat(hdc,&pfd);


if(!SetPixelFormat(hdc,ChooseWindowFormat,&pfd))
{
MessageBox(NULL,L"Can't Set The PixelFormat.",L"ERROR",MB_OK|MB_ICONEXCLAMATION);
};


HGLRC DummyGLContext = wglCreateContext(hdc);
wglMakeCurrent(hdc, DummyGLContext);


MessageBoxA(0, (char*)glGetString(GL_VERSION), "OPENGL VERSION",0);
//wglDeleteContext(0);
glViewport(0,0,640,480);
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); 
glOrtho(0,640,0,480,-1,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); 
glClearColor(255,0,0,0);


}
break;
//case WM_PAINT:
//hdc = BeginPaint(WindowHandle, &ps);




//EndPaint(WindowHandle, &ps);
/* 


SetTextColor(hdc, NewColor);
TextOut(hdc,5,5,greeting, _tcslen(greeting));


*/
//break;
case WM_CLOSE:
DestroyWindow(WindowHandle);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;


default:
return DefWindowProc(WindowHandle,Messages,wParam,lParam);


}
return 0;
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int nCmdShow)
{




MSG Messages;
WNDCLASSEX WindowClass;
HDC hdc = NULL;
bool Running = true;
hInstance = GetModuleHandle(NULL);
WindowClass.cbSize = sizeof(WNDCLASSEX);
WindowClass.style  = CS_HREDRAW | CS_VREDRAW | CS_OWNDC ;
WindowClass.lpfnWndProc = WindowProcedure;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = hInstance;
WindowClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
WindowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WindowClass.hbrBackground = NULL;
WindowClass.lpszMenuName = NULL;
WindowClass.lpszClassName = szWindowClass;
WindowClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);


if(!RegisterClassEx(&WindowClass)) {


MessageBox(NULL,
_T("Window Creation Failed"),
_T("ERROR") ,
NULL);
return 1;
}


HWND WindowHandle = CreateWindow(
szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW, 
CW_USEDEFAULT, CW_USEDEFAULT,
640,480,
NULL,
NULL,
hInstance,
NULL
);


if(!WindowHandle)
{
MessageBox(NULL, 
_T("Window Registration Failed!"),
_T("ERROR"),
NULL);
return 1;
}


ShowWindow(WindowHandle, nCmdShow);
UpdateWindow(WindowHandle);


while(Running == true)
{
while(PeekMessage(&Messages,NULL,0,0,PM_NOREMOVE)) 
{
if(GetMessage(&Messages, NULL, 0, 0))
{
TranslateMessage(&Messages); 
DispatchMessage(&Messages);
}
else 
{
return Messages.wParam;
}
}

DRAW_OPENGL();

SwapBuffers(hdc);

}
}

Also I'm not redoing my indentation when I clearly copyed and pasted it in ;).


#3xXxRosexXxEE

Posted 08 February 2014 - 01:11 PM

Could someone tell me why the backbuffer or frontbuffer will not update the device context I've been stuck on this problem for 3days and It's driving me crazy!?
 
- Win7 64bit 
- OpenGL 3.311672 Compatibility Profile Context 
- Microsoft Visual Studio 2012  C++
 
The Pixel format is being assigned properly.
 
I've created the projections correctly,set the opengl clear color,swapped the buffers on the devicecontext in the "correct place".
 
What more does it want???......

#include <Windows.h>
#include <GL/GL.h>
#include <iostream>
#include <string.h>
#include <tchar.h>


#pragma comment (lib, "opengl32.lib")


static TCHAR szWindowClass[] = _T("Windows32App");
static TCHAR szTitle[] = _T("OpenGL 3.3 Demo");


bool active = TRUE;
bool keys[256];
int DRAW_OPENGL(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glTranslatef(3.0f,0.0f,0.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f,0.0f);
glVertex3f(1.0f,-1.0f,0.0f);
glEnd();

return TRUE;

}


LRESULT CALLBACK WindowProcedure(HWND WindowHandle, UINT Messages, WPARAM wParam, LPARAM lParam)
{
//PAINTSTRUCT ps;
HDC hdc = NULL;
TCHAR greeting[] = _T("Test");
COLORREF NewColor = RGB(255,0,0);
switch(Messages)
{
case WM_ACTIVATE:
{
if(!HIWORD(wParam))
{
active = TRUE;
}
else 
{
active = FALSE;
}
return 0;
}
case WM_CREATE:
{


PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1, 
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32,
0,0,0,0,0,0
,0
,0
,0
,0,0,0,0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,0
};


hdc = GetDC(WindowHandle);


GLuint ChooseWindowFormat = ChoosePixelFormat(hdc,&pfd);


if(!SetPixelFormat(hdc,ChooseWindowFormat,&pfd))
{
MessageBox(NULL,L"Can't Set The PixelFormat.",L"ERROR",MB_OK|MB_ICONEXCLAMATION);
};


HGLRC DummyGLContext = wglCreateContext(hdc);
wglMakeCurrent(hdc, DummyGLContext);


MessageBoxA(0, (char*)glGetString(GL_VERSION), "OPENGL VERSION",0);
//wglDeleteContext(0);
glViewport(0,0,640,480);
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); 
glOrtho(0,640,0,480,-1,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); 
glClearColor(255,0,0,0);


}
break;
//case WM_PAINT:
//hdc = BeginPaint(WindowHandle, &ps);




//EndPaint(WindowHandle, &ps);
/* 


SetTextColor(hdc, NewColor);
TextOut(hdc,5,5,greeting, _tcslen(greeting));


*/
//break;
case WM_CLOSE:
DestroyWindow(WindowHandle);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;


default:
return DefWindowProc(WindowHandle,Messages,wParam,lParam);


}
return 0;
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int nCmdShow)
{




MSG Messages;
WNDCLASSEX WindowClass;
HDC hdc = NULL;
bool Running = true;
hInstance = GetModuleHandle(NULL);
WindowClass.cbSize = sizeof(WNDCLASSEX);
WindowClass.style  = CS_HREDRAW | CS_VREDRAW | CS_OWNDC ;
WindowClass.lpfnWndProc = WindowProcedure;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = hInstance;
WindowClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
WindowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WindowClass.hbrBackground = NULL;
WindowClass.lpszMenuName = NULL;
WindowClass.lpszClassName = szWindowClass;
WindowClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);


if(!RegisterClassEx(&WindowClass)) {


MessageBox(NULL,
_T("Window Creation Failed"),
_T("ERROR") ,
NULL);
return 1;
}


HWND WindowHandle = CreateWindow(
szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW, 
CW_USEDEFAULT, CW_USEDEFAULT,
640,480,
NULL,
NULL,
hInstance,
NULL
);


if(!WindowHandle)
{
MessageBox(NULL, 
_T("Window Registration Failed!"),
_T("ERROR"),
NULL);
return 1;
}


ShowWindow(WindowHandle, nCmdShow);
UpdateWindow(WindowHandle);


while(Running == true)
{
while(PeekMessage(&Messages,NULL,0,0,PM_NOREMOVE)) 
{
if(GetMessage(&Messages, NULL, 0, 0))
{
TranslateMessage(&Messages); 
DispatchMessage(&Messages);
}
else 
{
return Messages.wParam;
}
}

DRAW_OPENGL();

SwapBuffers(hdc);

}
}

Also I'm not redoing my indentation when a I clearly copyed and pasted it in ;).


#2xXxRosexXxEE

Posted 08 February 2014 - 01:09 PM

Could someone tell me why the backbuffer or frontbuffer will not update the device context I've been stuck on this problem for 3days and It's driving me crazy!?
 
- Win7 64bit 
- OpenGL 3.311672 Compatibility Profile Context 
- Microsoft Visual Studio 2012  C++
 
The Pixel format is being assigned properly.
 
I've created the projections correctly,set the opengl clear color,swapped the buffers on the devicecontext in the "correct place".
 
What more does it want???......

#include <Windows.h>
#include <GL/GL.h>
#include <iostream>
#include <string.h>
#include <tchar.h>


#pragma comment (lib, "opengl32.lib")


static TCHAR szWindowClass[] = _T("Windows32App");
static TCHAR szTitle[] = _T("OpenGL 3.3 Demo");


bool active = TRUE;
bool keys[256];
int DRAW_OPENGL(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glTranslatef(3.0f,0.0f,0.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f,0.0f);
glVertex3f(1.0f,-1.0f,0.0f);
glEnd();

return TRUE;

}


LRESULT CALLBACK WindowProcedure(HWND WindowHandle, UINT Messages, WPARAM wParam, LPARAM lParam)
{
//PAINTSTRUCT ps;
HDC hdc = NULL;
TCHAR greeting[] = _T("Test");
COLORREF NewColor = RGB(255,0,0);
switch(Messages)
{
case WM_ACTIVATE:
{
if(!HIWORD(wParam))
{
active = TRUE;
}
else 
{
active = FALSE;
}
return 0;
}
case WM_CREATE:
{


PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1, 
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32,
0,0,0,0,0,0
,0
,0
,0
,0,0,0,0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,0
};


hdc = GetDC(WindowHandle);


GLuint ChooseWindowFormat = ChoosePixelFormat(hdc,&pfd);


if(!SetPixelFormat(hdc,ChooseWindowFormat,&pfd))
{
MessageBox(NULL,L"Can't Set The PixelFormat.",L"ERROR",MB_OK|MB_ICONEXCLAMATION);
};


HGLRC DummyGLContext = wglCreateContext(hdc);
wglMakeCurrent(hdc, DummyGLContext);


MessageBoxA(0, (char*)glGetString(GL_VERSION), "OPENGL VERSION",0);
//wglDeleteContext(0);
glViewport(0,0,640,480);
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); 
glOrtho(0,640,0,480,-1,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); 
glClearColor(255,0,0,0);


}
break;
//case WM_PAINT:
//hdc = BeginPaint(WindowHandle, &ps);




//EndPaint(WindowHandle, &ps);
/* 


SetTextColor(hdc, NewColor);
TextOut(hdc,5,5,greeting, _tcslen(greeting));


*/
//break;
case WM_CLOSE:
DestroyWindow(WindowHandle);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;


default:
return DefWindowProc(WindowHandle,Messages,wParam,lParam);


}
return 0;
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int nCmdShow)
{




MSG Messages;
WNDCLASSEX WindowClass;
HDC hdc = NULL;
bool Running = true;
hInstance = GetModuleHandle(NULL);
WindowClass.cbSize = sizeof(WNDCLASSEX);
WindowClass.style  = CS_HREDRAW | CS_VREDRAW | CS_OWNDC ;
WindowClass.lpfnWndProc = WindowProcedure;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = hInstance;
WindowClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
WindowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WindowClass.hbrBackground = NULL;
WindowClass.lpszMenuName = NULL;
WindowClass.lpszClassName = szWindowClass;
WindowClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);


if(!RegisterClassEx(&WindowClass)) {


MessageBox(NULL,
_T("Window Creation Failed"),
_T("ERROR") ,
NULL);
return 1;
}


HWND WindowHandle = CreateWindow(
szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW, 
CW_USEDEFAULT, CW_USEDEFAULT,
640,480,
NULL,
NULL,
hInstance,
NULL
);


if(!WindowHandle)
{
MessageBox(NULL, 
_T("Window Registration Failed!"),
_T("ERROR"),
NULL);
return 1;
}


ShowWindow(WindowHandle, nCmdShow);
UpdateWindow(WindowHandle);


while(Running == true)
{
while(PeekMessage(&Messages,NULL,0,0,PM_NOREMOVE)) 
{
if(GetMessage(&Messages, NULL, 0, 0))
{
TranslateMessage(&Messages); 
DispatchMessage(&Messages);
}
else 
{
return Messages.wParam;
}
}

DRAW_OPENGL();

SwapBuffers(hdc);

}
}

#1xXxRosexXxEE

Posted 08 February 2014 - 01:08 PM

Could someone tell me why the backbuffer or frontbuffer will not update the device context I've been stuck on this problem for 3days and It's driving me crazy!?
 
- Win7 64bit 
- OpenGL 3.311672 Compatibility Profile Context 
- Microsoft Visual Studio 2012  C++
 
The Pixel format is being assigned properly.
 
I've created the projections correctly,set the opengl clear color,swapped the buffers on the devicecontext in the "correct place".
 
What more does it want???......

#include <Windows.h>
#include <GL/GL.h>#include <iostream>
#include <string.h>
#include <tchar.h>


#pragma comment (lib, "opengl32.lib")


static TCHAR szWindowClass[] = _T("Windows32App");
static TCHAR szTitle[] = _T("OpenGL 3.3 Demo");


bool active = TRUE;
bool keys[256];
int DRAW_OPENGL(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glTranslatef(3.0f,0.0f,0.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f,0.0f);
glVertex3f(1.0f,-1.0f,0.0f);
glEnd();

return TRUE;

}


LRESULT CALLBACK WindowProcedure(HWND WindowHandle, UINT Messages, WPARAM wParam, LPARAM lParam)
{
//PAINTSTRUCT ps;
HDC hdc = NULL;
TCHAR greeting[] = _T("Test");
COLORREF NewColor = RGB(255,0,0);
switch(Messages)
{
case WM_ACTIVATE:
{
if(!HIWORD(wParam))
{
active = TRUE;
}
else 
{
active = FALSE;
}
return 0;
}
case WM_CREATE:
{


PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1, 
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32,
0,0,0,0,0,0
,0
,0
,0
,0,0,0,0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,0
};


hdc = GetDC(WindowHandle);


GLuint ChooseWindowFormat = ChoosePixelFormat(hdc,&pfd);


if(!SetPixelFormat(hdc,ChooseWindowFormat,&pfd))
{
MessageBox(NULL,L"Can't Set The PixelFormat.",L"ERROR",MB_OK|MB_ICONEXCLAMATION);
};


HGLRC DummyGLContext = wglCreateContext(hdc);
wglMakeCurrent(hdc, DummyGLContext);


MessageBoxA(0, (char*)glGetString(GL_VERSION), "OPENGL VERSION",0);
//wglDeleteContext(0);
glViewport(0,0,640,480);
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); 
glOrtho(0,640,0,480,-1,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); 
glClearColor(255,0,0,0);


}
break;
//case WM_PAINT:
//hdc = BeginPaint(WindowHandle, &ps);




//EndPaint(WindowHandle, &ps);
/* 


SetTextColor(hdc, NewColor);
TextOut(hdc,5,5,greeting, _tcslen(greeting));


*/
//break;
case WM_CLOSE:
DestroyWindow(WindowHandle);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;


default:
return DefWindowProc(WindowHandle,Messages,wParam,lParam);


}
return 0;
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int nCmdShow)
{




MSG Messages;
WNDCLASSEX WindowClass;
HDC hdc = NULL;
bool Running = true;
hInstance = GetModuleHandle(NULL);
WindowClass.cbSize = sizeof(WNDCLASSEX);
WindowClass.style  = CS_HREDRAW | CS_VREDRAW | CS_OWNDC ;
WindowClass.lpfnWndProc = WindowProcedure;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = hInstance;
WindowClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
WindowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WindowClass.hbrBackground = NULL;
WindowClass.lpszMenuName = NULL;
WindowClass.lpszClassName = szWindowClass;
WindowClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);


if(!RegisterClassEx(&WindowClass)) {


MessageBox(NULL,
_T("Window Creation Failed"),
_T("ERROR") ,
NULL);
return 1;
}


HWND WindowHandle = CreateWindow(
szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW, 
CW_USEDEFAULT, CW_USEDEFAULT,
640,480,
NULL,
NULL,
hInstance,
NULL
);


if(!WindowHandle)
{
MessageBox(NULL, 
_T("Window Registration Failed!"),
_T("ERROR"),
NULL);
return 1;
}


ShowWindow(WindowHandle, nCmdShow);
UpdateWindow(WindowHandle);


while(Running == true)
{
while(PeekMessage(&Messages,NULL,0,0,PM_NOREMOVE)) 
{
if(GetMessage(&Messages, NULL, 0, 0))
{
TranslateMessage(&Messages); 
DispatchMessage(&Messages);
}
else 
{
return Messages.wParam;
}
}

DRAW_OPENGL();

SwapBuffers(hdc);

}
}

 


PARTNERS