BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

OpenGL in separated forms

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics)
View previous topic :: View next topic  
Author Message
Wiz
Guest





PostPosted: Wed Oct 12, 2005 10:23 am    Post subject: OpenGL in separated forms Reply with quote



Hi everybody,

I would like to know how to show the same 3D images on OpenGL
Components
in different forms (e.g. Displaying the same 3D Images on Panel2 of
Form1 and
Panel2 of Form2 at the same time) WITHOUT using the 3rd party OpenGL
components.

So far, when I add the button to show OpenGL on Panel2 of Form2, ONLY
Panel2 of Form2
would display OpenGL Image, but NOT on Panel2 of Form1.


I heard that I need to play aroudn with MDI or so .... But I have No
clue how to do that.

Okay, Let's take a look on my Codes:

// ----------- Form 1 --------------------------

__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
InitializeControls();
Application->OnIdle = IdleLoop;
_control87(MCW_EM, MCW_EM); // Thisshould be called ONLY ONCE at
the constructor

m_hdc = GetDC(Form1->Panel2->Handle); // < - This is the problem
SetPixelFormatDescriptor();
m_hglrc = wglCreateContext(m_hdc);
wglMakeCurrent(m_hdc, m_hglrc);
SetupRC();
}

__fastcall TForm1::~TForm1()
{
::ReleaseDC(Panel2->Handle, m_hdc);
wglMakeCurrent(NULL, NULL);
wglDeleteContext(m_hglrc);
}

void __fastcall TForm1::IdleLoop(TObject* Sender, bool &Done)
{
Done = false;
RenderGLScene(); // Draw OpenGL HERE
SwapBuffers(m_hdc); // openGL call
}
void TForm1::SetupRC()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form2->Show(); // This is another problem
}
//---------------------------------------------------------------------------

// ----------- Form2 -----------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
// m_XAngle = 27;
// m_YAngle = -35;
m_XAngle = 0;
m_YAngle = 0;
m_ZAngle = 0;
m_ZTranslate = -5;
m_YTranslate = 0;
m_XTranslate = 0;

InitializeControls();

Application->OnIdle = IdleLoop;
_control87(MCW_EM, MCW_EM);
m_hdc = GetDC(Form2->Panel2->Handle);
SetPixelFormatDescriptor();
m_hglrc = wglCreateContext(m_hdc);
wglMakeCurrent(m_hdc, m_hglrc);
SetupRC();
}

__fastcall TForm2::~TForm2()
{
::ReleaseDC(Panel2->Handle, m_hdc);
// wglMakeCurrent(m_hdc, NULL);
wglMakeCurrent(NULL, NULL);
wglDeleteContext(m_hglrc);
}
void __fastcall TForm2::IdleLoop(TObject* Sender, bool &Done)
{
Done = false;
RenderGLScene();
SwapBuffers(m_hdc); // openGL call
}

// -----------------------------------------------------------

Is there ANYWAY to enable the OpenGL Display on Multiple Forms at the
same time?
If so, please show me how to do so.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.