Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Sizing a JFrame correctly... on: 2008-07-15 18:04:54
100 by 200 is not wide enough for the title bar, so I bumped it up to 200x200. Using that code my window's content pane is 202 pixels in both directions, and the content pane doesn't know how large it is when it's initialized.

The way my game works is that I each menu screen or gameplay screen is a different JPanel, and I switch the current ContentPane in the JPanel to the appropriate game screen. One of these JPanels needs to know it's own size

I can throw in a hack where I have a public variable in the JFrame that represents the intended size and then have the ContentPane use that in place of getHeight and getWidth, but that doesn't seem like a good solution.  Undecided
2  Game Development / Newbie & Debugging Questions / Sizing a JFrame correctly... on: 2008-07-15 11:07:02
I want to set the size of my JFrame to a specific height and width. However, I don't want the border to be included in the sizing calculations. I want to size the window based off the content of the window.

For example, if I want my content panel to be 800x600, calling this doesn't work:

this.setSize(800, 600); // "this" is the frame

It sets the size, but the content area has about 30 pixels cut off from the height and 6 or so from the width.

I also tried

this.getContentPane().setSize(800, 600);

And that didn't work either. That just made the JFrame the minimum possible size. My understanding is that adding this.pack(); should solve that problem, but I must be misunderstanding what pack() does because it doesn't seem to solve the problem at all.

I've also tried swapping out setSize with setPreferredSize, and also throwing in setMinimumSize, but nothing I do seems to work reliably.

Another related problem is that sometimes even when I manually set the size of the JFrame the contentpane doesn't know what size it is. I'll call this.getHeight() or something similar from within the contentpane and it returns 0.

What am I doing wrong here?
3  Java Game APIs & Engines / JOGL Development / Re: Problems loading texture and a question about sprites on: 2008-06-23 05:00:40
Thanks, I think I have it now. It was a combination of problems, which is why whenever I fixed one thing it still didn't work. I'll be able to get them loaded now.

<3
4  Java Game APIs & Engines / JOGL Development / Re: Problems loading texture and a question about sprites on: 2008-06-22 11:36:15
Could you post a simple program or something that just loads up a texture from a file and displays it? I've tried reading through the API and looking for tutorials, but I'm having no luck. I keep getting unrelated exceptions whenever I try the Jogl ports of NeHe's tutorials.
5  Java Game APIs & Engines / JOGL Development / Re: Problems loading texture and a question about sprites on: 2008-06-19 21:17:57
I'm not on my home computer, but I remember what I did. I've tried a few different things. I'm not worried abou binding the texture or anything between the glBegin or glEnd, the problem is that the texture I try to generate is always a null pointer.

1  
2  
Texture myTex1 = TextureIO.newTexture(myBufImg, true); // returns null
Texture myTex2 = TextureIO.newTexture(new File(filename), true); // returns null


I've tried a few different things, but I can't get the texture loaded. If I could do that I'm sure I could get it drawn to the screen.
6  Java Game APIs & Engines / JOGL Development / Re: Problems loading texture and a question about sprites on: 2008-06-19 19:24:13
I skimmed the link you posted, but I don't think its quite what I'm looking for.

And it doesn't mention anything about how to load the textures either =/
7  Java Game APIs & Engines / JOGL Development / Problems loading texture and a question about sprites on: 2008-06-19 02:53:48
I'm trying to use TextureIO.newTexture(...)  to read a texture so I can use it for some sprites but whenever I call the function I get a null pointer returned, not matter what set of parameters I feed to it. Does anyone know why it's happening or how to fix it?

Also, should I be using GL_QUADS with textures on them for my sprites, or should I be using something like glDrawPixels? I've used OpenGL in C++ for a class, but I've never done anything like make a game. I've mostly used it for making 3D stuff. If I were to use glDrawPixels, how would I get them in a format that the function can use?
8  Java Game APIs & Engines / Java 2D / Improving performance in my game on: 2008-06-19 02:43:09
I'm writing a sprite based fighting game and whenever I draw large sprites with transparency, like the stage itself, the game slows way down. When I draw a few smaller sprites it works fine though. I just read the .png files with ImageIO.read(filename) and then when I draw them I just use the standard g.drawImage(...) function.

While googling around for a solution I saw suggestions to use -Dsun.java2d.opengl=True, but I keep getting the error message "Could not enable OpenGL pipeline for default config on screen 0" which appears to be because I have an intel chipset.

The other option that I know of is to replace the rendering code I currently have with JOGL. I've got JOGL set up on my computer and I can run it just fine. I've done OpenGL programming in C++ for about a year (I had two elective courses at my school in graphics programming in openGL), but I've been having trouble loading textures. I can load images just fine, but when I try to turn them into a texture with TextureIO.newTexture(...) I get a null pointer.

I don't even know if that's the way to do it correctly though, it's hard to find up to date tutorials. Anyone have tips or code I can look at or tutorials on how to get 2D sprites to run effeciently?
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (25 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (13 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (44 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

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

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

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
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!