Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


4 opengl windows in one app


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
16 replies to this topic

#1 TheMatrixXXX   Members   -  Reputation: 122

Like
Likes
Like

Posted 16 November 2001 - 10:55 PM

hi all can someone tell me why my app only show one of four windows after start? when i start another ogl app it works why not in one app? i need this to create a level editor thx --=[[TheMatrixXXX]]=--

Sponsor:

#2 Prosper/LOADED   Members   -  Reputation: 100

Like
Likes
Like

Posted 16 November 2001 - 10:57 PM

You need to create 4 different OGL context (one by window) and bind them before drawing.

#3 siaspete   Members   -  Reputation: 208

Like
Likes
Like

Posted 16 November 2001 - 11:03 PM

That can be quite heavy on memory since each context will need copies of the textures.

Often apps will just have one opengl context, one window, and manually handle the different parts inside using the stencil buffer or some other technique.

#4 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 16 November 2001 - 11:31 PM

if you use GLUT library, you can use subwindows creation utility
supplied with it.

#5 TheMatrixXXX   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 November 2001 - 12:55 AM

i have the handles in the form class ( i use borland c++ builder 5.0)
but i know thats heavy in memory

can you tell me how to use the glut library in borland c?
i get an error cause it is the M$ lib format

thx

--=[[TheMatrixXXX]]=--

#6 PsyVision   Members   -  Reputation: 130

Like
Likes
Like

Posted 17 November 2001 - 08:14 AM

I thought there was a converter or a lib fixer that came with borland to do that. Have a look in the dirs of ur compiler.

#7 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 17 November 2001 - 08:18 AM

glViewport?

#8 TheMatrixXXX   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 November 2001 - 10:08 AM

@anonymous poster:
what do you mean with "glViewport?" ?


how can i create different OGL contexts?
why don´t work it with the contexts in the form classes?
they are different i think cause that ar different windows


thx
--=[[TheMatrixXXX]]=--

#9 wolfman8k   Members   -  Reputation: 140

Like
Likes
Like

Posted 18 November 2001 - 07:17 AM

Anon''s right, why not use glViewport?

#10 TheMatrixXXX   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 November 2001 - 07:24 AM

i use glViewport
i have problems with the handles not with the viewport
i have one window of four because the next initialized window overwrites the previous handle i think

or what do you mean with glViewport? can i split a gl window in four parts like in a level editor?

thx
--=[[TheMatrixXXX]]=--

#11 Major   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 November 2001 - 07:52 AM

You can use the glutCreatSubWindow function

#define space 10 //space betwenn subwindow
Gluint window,first_subwindow,second_subwindow

window = glutCreateWindow("Main Window");
glutReshapeFunc(main_reshape);
glutDisplayFunc(main_display);
glutKeyboardFunc(main_keyboard);

first_subwindow= glutCreateSubWindow(window, space, space, 256, 256);
glutReshapeFunc(world_reshape);
glutDisplayFunc(world_display);
glutKeyboardFunc(main_keyboard);

second_subwindow = glutCreateSubWindow(window, space+256+space, space, 256, 256);
glutReshapeFunc(screen_reshape);
glutDisplayFunc(screen_display);
glutKeyboardFunc(main_keyboard);

I think the glutCreateSubWindow worls like this...


#12 Fruny   Moderators   -  Reputation: 1653

Like
Likes
Like

Posted 18 November 2001 - 10:12 AM

glViewport( x, y, width, height ) defines the area in the window where openGL does its rendering. So if you do something like

  
glViewport( 0, 0, 100, 100 );
doProjection( 100, 100 );
renderWindowA();

glViewport( 100, 0, 100, 100 );
doProjection( 100, 100 );
renderWindowB();

glViewport( 0, 100, 200, 100 );
doProjection( 200, 100 );
renderWindowC();


You will have 3 images rendered in your window according to the pattern:

AAABBB
AAABBB
AAABBB
CCCCCC
CCCCCC
CCCCCC


#13 TheMatrixXXX   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 November 2001 - 01:00 AM

@fruny
thx i will try it

--=[[TheMatrixXXX]]=--

#14 Fruny   Moderators   -  Reputation: 1653

Like
Likes
Like

Posted 19 November 2001 - 01:04 AM

Be careful to glFlush() and glutSwapBuffer() only once.

#15 TheMatrixXXX   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 November 2001 - 06:29 AM

@fruny:
what do you mean with doProjection?
i have my multiple viewport now but i don´t know how to draw on each one
how can i select them?
i know with the renderWindow but where i have to call these funcs ?
and can i use different views? (gluPerspective and 3xglOrtho)

thx
--=[[TheMatrixXXX]]=--

Edited by - TheMatrixXXX on November 19, 2001 1:31:32 PM

#16 Fruny   Moderators   -  Reputation: 1653

Like
Likes
Like

Posted 19 November 2001 - 07:01 AM

If you are doing a projection, it is usually dependent on the width to height ratio of your openGL viewport, no ? So, since I had different sized viewports, I called my doProjection function with the appropriate parameters.

And actually, you don't have several viewports, you have only one. GL will render where you tell it to. That's why I have several renderWindow() functions.

Follow this pattern:

    
{
glViewport( whole window );
glClear();

glViewport( a corner );
glWhateverProjection( a corner );
Render( a corner );

glViewport( another corner );
glWhateverProjection( another corner );
Render( another corner );

.
.
.

glFlush();
glutSwapBuffers(); // May have to restore the viewport to the whole window though...

}



If you want separate input processing for each viewport, you are better off with glut sub-windows, as Major pointed out.

Or you can put 4 calls to glutCreateWindow(), register callbacks for each, save the window handle, and use glutSetWindow() in the right places (e.g. before calls to glutPostRedisplay() ).

(Sorry if I sound confused, I've had 3 hours of sleep over the pas 2 days. )

Edited by - Fruny on November 19, 2001 2:04:18 PM

#17 TheMatrixXXX   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 November 2001 - 07:56 AM

thx i know what you mean

but i want to draw in orthographic views like in a level editor and view the world in a perspective view

i programmed it so far the only problem i have is that the app only show one of four windows and that is a problem of the handles someone told me.

thx
--=[[TheMatrixXXX]]=--




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS