Click here to Skip to main content
14,662,527 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Richard MacCutchan18-Mar-16 22:57
mveRichard MacCutchan18-Mar-16 22:57 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Bram van Kampen19-Mar-16 13:41
MemberBram van Kampen19-Mar-16 13:41 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Richard MacCutchan19-Mar-16 22:09
mveRichard MacCutchan19-Mar-16 22:09 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Bram van Kampen22-Mar-16 13:34
MemberBram van Kampen22-Mar-16 13:34 
AnswerRe: Vagarities of Multiple threads in Windows Pin
leon de boer19-Mar-16 21:35
Memberleon de boer19-Mar-16 21:35 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Bram van Kampen22-Mar-16 13:33
MemberBram van Kampen22-Mar-16 13:33 
GeneralRe: Vagarities of Multiple threads in Windows Pin
leon de boer25-Mar-16 23:57
Memberleon de boer25-Mar-16 23:57 
QuestionOpenGL control on split MFC form Pin
Member 1228273814-Mar-16 10:08
MemberMember 1228273814-Mar-16 10:08 
I am trying to build an MFC application the uses a form with two panes, one for controls and the other for an OpenGL graphics window.  I followed 2 code project for this task.
1.	15338/SDI-with-split-window by kencocomputers
2.	Setting up OpenGL in an MFC control from codeguru C10975
The split window application part worked fine but I cannot initialize the openGL  context in the graphics pane.   
The classes in the project are:
1.	CAboutDlg
2.	CFormLeft
3.	CFormRight
4.	CMainForm
5.	CMFC_SurfaceViwerApp
6.	COpenGLControl
CFormLeft and CFormRight views are created in the CManFrame  function 
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)

Specifically with:
if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CFormLeft), CSize(300, 100), pContext) ||
		!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CFormRight), CSize(100, 100), pContext))
{
		m_wndSplitter.DestroyWindow();
		return FALSE;
}

My question is how to actually implement the OpenGL Window; I suspect that it requires some code like: 
void COpenGLControl::oglInitialize()
{
	// Initial Setup:
	//
	static PIXELFORMATDESCRIPTOR pfd =
	{
		sizeof(PIXELFORMATDESCRIPTOR),
		1,
		PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
		PFD_TYPE_RGBA,
		32,    // bit depth
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		16,    // z-buffer depth
		0, 0, 0, 0, 0, 0, 0,
	};
	// Get device context only once.
	hdc = GetDC()->m_hDC;

	// Pixel format.
	m_nPixelFormat = ChoosePixelFormat(hdc, &pfd);
	SetPixelFormat(hdc, m_nPixelFormat, &pfd);

	// Create the OpenGL Rendering Context.
	hrc = wglCreateContext(hdc);
	wglMakeCurrent(hdc, hrc);

	// Basic Setup:
	//
	// Set color to use when clearing the background.
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glClearDepth(1.0f);

	// Turn on backface culling
	glFrontFace(GL_CCW);
	glCullFace(GL_BACK);

	// Turn on depth testing
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);

	// Send draw request
	OnDraw(NULL);
}
 But how does it activate? I put a call inside the oglCreate() function but nothing happened.


void COpenGLControl::oglCreate(CRect rect, CWnd *parent)
{
	CString className = AfxRegisterWndClass(CS_HREDRAW |
		CS_VREDRAW | CS_OWNDC, NULL,
		(HBRUSH)GetStockObject(BLACK_BRUSH), NULL);

	CreateEx(0, className, L"OpenGL", WS_CHILD | WS_VISIBLE |
		WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rect, parent, 0);

	// Set initial variables' values
	m_oldWindow = rect;
	m_originalRect = rect;

	hWnd = parent;
	oglInitialize();
}


I would appreciate any help I can get. Thanks 

John H. Chumley

AnswerRe: OpenGL control on split MFC form Pin
Richard MacCutchan14-Mar-16 23:48
mveRichard MacCutchan14-Mar-16 23:48 
QuestionDefault argument for DISP_FUNCTION_ID Pin
Member 1214953910-Mar-16 16:44
MemberMember 1214953910-Mar-16 16:44 
AnswerRe: Default argument for DISP_FUNCTION_ID Pin
Bram van Kampen16-Mar-16 15:45
MemberBram van Kampen16-Mar-16 15:45 
QuestionBoth EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
ForNow10-Mar-16 10:19
MemberForNow10-Mar-16 10:19 
AnswerRe: Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
Bram van Kampen10-Mar-16 14:39
MemberBram van Kampen10-Mar-16 14:39 
GeneralRe: Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
ForNow10-Mar-16 15:20
MemberForNow10-Mar-16 15:20 
GeneralRe: Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
Richard MacCutchan11-Mar-16 3:52
mveRichard MacCutchan11-Mar-16 3:52 
AnswerRe: Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
Richard MacCutchan10-Mar-16 21:21
mveRichard MacCutchan10-Mar-16 21:21 
AnswerRe: Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
leon de boer19-Mar-16 21:50
Memberleon de boer19-Mar-16 21:50 
GeneralRe: Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
ForNow20-Mar-16 12:45
MemberForNow20-Mar-16 12:45 
QuestionHow Much of WM_USER+X is used by MFC Pin
Bram van Kampen9-Mar-16 14:14
MemberBram van Kampen9-Mar-16 14:14 
AnswerRe: How Much of WM_USER+X is used by MFC Pin
Jochen Arndt9-Mar-16 21:38
professionalJochen Arndt9-Mar-16 21:38 
AnswerRe: How Much of WM_USER+X is used by MFC Pin
Richard MacCutchan9-Mar-16 22:17
mveRichard MacCutchan9-Mar-16 22:17 
GeneralRe: How Much of WM_USER+X is used by MFC Pin
Bram van Kampen10-Mar-16 14:03
MemberBram van Kampen10-Mar-16 14:03 
GeneralRe: How Much of WM_USER+X is used by MFC Pin
Richard MacCutchan10-Mar-16 21:15
mveRichard MacCutchan10-Mar-16 21:15 
GeneralRe: How Much of WM_USER+X is used by MFC Pin
Jochen Arndt10-Mar-16 21:38
professionalJochen Arndt10-Mar-16 21:38 
GeneralRe: How Much of WM_USER+X is used by MFC Pin
Richard MacCutchan10-Mar-16 21:50
mveRichard MacCutchan10-Mar-16 21:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.