MFC+OPENGL Programmable Pipeline

Source: Internet
Author: User

[GitHub link]

Setpixelformat, Initialize Glew, create GL 4,2 context and other operations are encapsulated in MFC class Openglwidget. steps to use :

1. Include OpenGLWidget.h and OpenGLWidget.cpp in the project.

2. Inherit class Openglwidget, implement two virtual functions: Initialize () [responsible for loading data], renderscene () [responsible for rendering] two functions. For example, the following Leftwindow class:

#pragmaOnce#include"OpenGLWidget.h"#include<Cameras/phc.h>#include<OpenglWrappers/DemoMeshes/BlinnPhongMesh.h>classLeftwindow: Publicopenglwidget{redips::P HC*M_PHC =NewRedips::P HC ( $,1.0f,0.1f,10000); Redips::blinnphongmesh* M_mesh =nullptr; Public: Leftwindow () {}~Leftwindow () {
Delete M_mesh; Delete M_PHC;
} BOOLInitialize () {M_mesh=NewRedips::blinnphongmesh (NewRedips::triangles ("E:/documents/models/effier/new_iffier.obj"));
Auto Heart= M_mesh->model_ptr ()Aabb_r (). Heart (); M_PHC->lookat (Heart + REDIPS::FLOAT3 (0,0, -), Heart, REDIPS::FLOAT3 (0,1,0)); return true; } voidRenderscene () {M_mesh-&GT;UNIFORMFLOAT3 ("Lightcolor", REDIPS::FLOAT3 (1,1,1)); M_mesh-&GT;UNIFORMFLOAT3 ("Lightpos", m_phc->POS ()); M_mesh-&GT;UNIFORMFLOAT3 ("Camerapos", m_phc->POS ()); M_mesh-&GT;UNIFORMMAT44F ("Model", Redips::mat44f::eye (). PTR ()); M_mesh-&GT;UNIFORMMAT44F ("projection", m_phc->glprojection (). PTR ()); M_mesh-&GT;UNIFORMMAT44F ("View", m_phc->Glview (). PTR ()); M_mesh-Draw (); }};

3. Add the following code to the OnInitDialog () function, which creates a openglwidget in the current dialog box

New->create (null, NULL, WS_CHILD | ws_clipsiblings | Ws_clipchildren | ws_visible,                            CRect (00),                            This,   // This is the parent                            0);

MFC+OPENGL Programmable Pipeline

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.