Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  CurrentContext  (Read 670 times)
0 Members and 1 Guest are viewing this topic.
Offline cborders

Junior Member





« Posted 2005-10-08 15:54:20 »

Ok, Here is the effect that Iam after and there may be a much better way to do it, so let me know!  I want to pop up a splash screen and have it display all of the loading information then *bam* the game starts in full screen mode.  The trouble I am having is that in LWJGL when I creates the display is automatically pops up the window.  I remembered hearing someone talk about hacking together a GL context using Pbuffers so I gave that a shot and lit goes through all of the initialization and everything correctly, and then *BAM* a full screen window pops us, but there is nothing in the window.  I believe this to be due to the fact that the Display is not using the context created using the Pbuffer.  How can I load the context into the Display, or am I going about this in a completely wrong way?!
Offline cborders

Junior Member





« Reply #1 - Posted 2005-10-09 02:01:22 »

ROCK!!!  I got it to work!!

Here's my set up:
I have a Game class, a SplashScreen class and a Loader class.  Upon calling the loader class it creates an instance of the SplashScreen class and passes it to the constructor of the Game class.  This allows the game class to update the progress bar and the current task display on the splash screen.  The trouble I was having was that when I created the display is stomped out the splash screen and was just black throughout the loading, so what I did was create a Pbuffer to get an OpenGL context and then do all of my initialization on that context (except for gluPerspective, it didn't like that one so I broke off an initViewport() method that does that stuff and I call it later).  Then at the last minute I create the display by passing in a PixelFormat that is the same as the one I used to create the Pbuffer and I pass the Pbuffer in as the "shared drawable."  It took a good couple of hours to get it sorted out(maybe I'm just slow!), but now that I have it seems easy!

Anyway, here is some code so you can see what I mean:

Here is my init() method, notice that the last thing I do is create the display!!!
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
private void init()
{
   try
    {
      pbuf = new Pbuffer(1, 1, pix, null, null);
      pbuf.makeCurrent();
   }
   catch (LWJGLException e1)
    {
      e1.printStackTrace();
   }
   try
   {
      IL.create();
   }
   catch(LWJGLException e)
   {
      e.printStackTrace();
   }
   initGL();
   loadTextures();
   loadModels();
   createDisplay();
   splashScreen.destroy();
}


Then here I create the display by passing in the PixelFormat that I used to create the Pbuffer and the Pbuffer itself.  Then I do the initViewport() stuff and since the Pbuffer has done it's job I can get rid of it!
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
try
{
   Display.create(pix, pbuf);
   initViewport();
   pbuf.destroy();
   System.out.println("Created OpenGL.");
}
catch (Exception e)
{
   System.err.println("Failed to create OpenGL due to " + e);
   System.exit(1);
}


I am so happy with how things are going!  I am getting this stuff sorted finally!  Maybe now I can work on making it pretty!   Wink
Offline cborders

Junior Member





« Reply #2 - Posted 2005-10-09 18:56:55 »

As it turns out not all states are shared between shared instances (found this out the hard way while playig with textures) so I had to change my code to look like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
private void init()
{
   try
   {
      pbuf = new Pbuffer(1, 1, pix, null, null);
      pbuf.makeCurrent();
   }
   catch (LWJGLException e1)
   {
      e1.printStackTrace();
   }
   try
   {
      IL.create();
   }
   catch(LWJGLException e)
   {
      e.printStackTrace();
   }
   loadTextures();
   loadModels();
   createDisplay();
   initGL();
   initViewport()
   splashScreen.destroy();
}
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

UprightPath (20 views)
2014-09-20 20:14:06

BurntPizza (26 views)
2014-09-19 03:14:18

Dwinin (40 views)
2014-09-12 09:08:26

Norakomi (70 views)
2014-09-10 13:57:51

TehJavaDev (95 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29

BurntPizza (52 views)
2014-09-07 01:13:42

Longarmx (39 views)
2014-09-07 01:12:14

Longarmx (45 views)
2014-09-07 01:11:22
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!