Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5950393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:23:14+00:00 2026-05-22T17:23:14+00:00

UPDATED If you want the full source code of this application in questioned, you

  • 0

UPDATED

If you want the full source code of this application in questioned, you can fork it from my github repository : OpenGLModeler

I’ve built a Visual C++.NET 2008 application that display three viewport. All was just fine, until I implemented the Texturing functionality. As you can see from my Screenshot here, only the front viewport got its texture rendered. This is my code for handling its drawing method, base on the type of viewport defined. I can provide you with the full source code if you want, but here is the snippet :

public:
        GLvoid ReSizeGLScene(GLsizei width, GLsizei height){        // Resize and initialise the gl window
        MySetCurrentGLRC();
        if (height==0)                                      // Prevent A Divide By Zero By
        {
            height=1;                                       // Making Height Equal One
        }

        glViewport(0,0,width,height);                       // Reset The Current Viewport

        glMatrixMode(GL_PROJECTION);                        // Select The Projection Matrix
        glLoadIdentity();                                   // Reset The Projection Matrix


        // Calculate The Aspect Ratio Of The Window
        switch(cameraType){
            case 1:                 
                gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); 
                gluLookAt(
                    -4,4,4,//eye
                    0,0,0,//center
                    0,1,0);//up
                break;
            case 2://front : texture rendered correctly
                glOrtho(-2,2,-2,2,-50,50);
                gluLookAt(
                    0,0,2,//eye 0,0,2
                    0,0,0,//center 0,0,0
                    0,1,0);//up 0,1,0
                break;
            case 3://top
                glOrtho(-2,2,-2,2,-50,50);
                gluLookAt(
                    0,2,0,//eye
                    0,0,0,//center, 0
                    0,0,-1);//up
                break;
        }


        glMatrixMode(GL_MODELVIEW);                         // Select The Modelview Matrix
        glLoadIdentity();                                   // Reset The Modelview Matrix


        UINT flags = SWP_NOZORDER | SWP_NOACTIVATE;
        SetWindowPos((HWND)this->Handle.ToPointer() , 0, 0, 0, 
                   width, height, flags);

    }

EDITED : explain modified code
I borrow this code from codeproject, and modify it to have multi viewport functionality. These are I think the important modification : first, the instantiation of OpenGL Viewport:

    glPerspective = gcnew COpenGL(picPerspective, picPerspective->Width, picPerspective->Height,1);
        glFront = gcnew COpenGL(picFront, picFront->Width, picFront->Height,2);
        glTop = gcnew COpenGL(picTop, picTop->Width , picTop->Height,3);            

The last argument of the COpenGL is the type of viewport : perspective(1), front(2) and top(3). And the second modification is the way I draw the scene. It using a timer, like this :

    private: System::Void timerRefreshPicture_Tick(System::Object^  sender, System::EventArgs^  e) {
             UNREFERENCED_PARAMETER(sender);
             UNREFERENCED_PARAMETER(e);

             glPerspective->Render(daftarObject);
             glPerspective->SwapOpenGLBuffers();

             glTop->Render(daftarObject);
             glTop->SwapOpenGLBuffers();

             glFront->Render(daftarObject);
             glFront->SwapOpenGLBuffers();
         }

I try to disable the code that draw the glFront, and yes, the glTop got its textured correctly. And the same happen if I disabled the glTop. I suspect this code :

virtual System::Void MySetCurrentGLRC()
    {
        if(m_hDC)
        {

            if((wglMakeCurrent(m_hDC, m_hglrc)) == NULL)
            {
            MessageBox::Show("wglMakeCurrent Failed");
            }
            //wglShareLists(m_hglrc,m_hglrc);<== not working
        }
    }

How can I use wlgShareList in this code? Thanks

An OpenGL Scene with Two Objects

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:23:15+00:00Added an answer on May 22, 2026 at 5:23 pm

    If you have multiple GL contexts, you need to share textures between the contexts to enable them being created in a context and displayed in another.

    You may take a look at wglShareLists which is to be called after you create your ‘secondary’ contexts (‘main’ context being the first context created).

    You can call wglShareLists after having created your various contexts :

    glPerspective = gcnew COpenGL(picPerspective, picPerspective->Width, picPerspective->Height,1);
    glFront = gcnew COpenGL(picFront, picFront->Width, picFront->Height,2);
    glTop = gcnew COpenGL(picTop, picTop->Width , picTop->Height,3);
    
    wglShareLists( glPerspective->m_hglrc, glFront->m_hglrc );            
    wglShareLists( glPerspective->m_hglrc, glTop->m_hglrc );            
    

    Note that it’s important that ‘glFront’ and ‘glTop’ contexts do not contain any existing texture when calling wglShareLists.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

N.B THIS QUESTION HAS BEEN UPDATED, READ FURTHER DOWN Hi, I want to create
Can you recommend a full-text search engine? (Preferably open source) I have a database
I am not hoping for a full source code, but i will be grateful
I can't seem to get this to work, Basically, what I want to do
I want to get an overview of files that are updated in TFS (that
If I want to keep an xml file updated with all the images that
User Region Points Last_Updated 1 5 0 1-Nov-09 I want this row 2 1
I have a textbox and want an event triggered whenever it is updated, whether
I have an entity with a ModifiedDateTime property which I want to be updated
I have a directory that will be getting updated frequently, I want to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.