Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (117)
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   
  Show Posts
Pages: [1] 2 3
1  Java Game APIs & Engines / JOGL Development / Scan texture into memory line by line on: 2009-10-23 16:46:46
Hello guys,

I still have problems with my loading. I want to scan a texture from main memory into the graphics memory line by line.

An example would be a 64x128 image. Everytime my rendering thread displays a frame, I upload 1 line of the picture into memory until I finally have 128 lines uploaded, each with the width of 64 totalling in the original 64x128 image.

This would be fast, and could ensure for example a fluent loading animation, or prefetching of textures before loading a new world/stage/instance/whatever in my computer games without stalling animations or the flow of the game(transparent to the user).

Can someone please help me, I heard this can be done with gl.glTexSubImage2d, but I'm kinda lost...How can this be done in java code with JOGL?
2  Java Game APIs & Engines / JOGL Development / Re: Create texture with different GLContext(on another thread) on: 2009-09-29 17:40:57
ok in case of games the above wont do, im into CAD not a game engineer persecutioncomplex sorry

Im guessing CAD is for other purposes, like rendering 3dimages for picture/movies ? If so, then I guess amortized cost is more important than worstcase... In games I need to insure a constant low cost per frame, single stutters are unwelcome Cheesy
3  Java Game APIs & Engines / JOGL Development / Re: Create texture with different GLContext(on another thread) on: 2009-09-29 09:43:31
I dont have such code, but if you want a quick one try using an on-demand method. (dont know if it works for ur case) If you need to display a texture pixel load the region of this texture where (s,t) are part of it.

In the end you might not even load the whole thing if you dont need it (not seen)

Usually you want to display an entire sprite in a 2d image for example, so in modern computer games you still want the game to progress while loading models/sprites, so displaying a placeholder until sprites and models are loaded is the best procedure. Of course displaying a loading animation while loading is a way to avoid using placeholders, but that still hangs the loading screen if using a single thread.
4  Java Game APIs & Engines / JOGL Development / Re: Create texture with different GLContext(on another thread) on: 2009-09-29 07:06:11
If your textures are too big/heavy to be uploaded at once, then glTexSubImage2D will let you upload in chunks - I'd choose a maximum bytes per frame to upload and choose the maximum amount of scanlines that can fit within that. I think you'll find it's just as fast and a lot more reliable than trying to get multiple contexts working across multiple OSes and graphics cards.

Ok, I think this will be the way to go then, but this requires a bit more knowledge about JOGL than I have Smiley I was hoping for an easy way to do it, this kinda makes the TextureIO class obselete... Has anyone made classes for uploading scanlines and then assembling them with texsubimage2d?

if(true)
   return attachedFileWithSource;
if(false)
   return null;

Smiley
5  Java Game APIs & Engines / JOGL Development / Re: Create texture with different GLContext(on another thread) on: 2009-09-28 17:56:05
Keep the heavy lifting (io/decoding) in a background thread, and incrementally upload the data to OpenGL every frame in your render loop. You can either upload a single texture/object each frame, or even split texture uploads over multiple frames to keep your loading animation smooth.

Multiple contexts are a pain and a big source of compatibility bugs, and to be avoided at all costs imho.

As far as I know, it doesnt seem possible to copy a texture from main memory onto the graphics card in an interative manner. Of course I could upload scans of the image until an entire scan can be put together, but this seems overkill.

And using an entire frame to upload a texture is unacceptable. I already did this, and it takes as much time to transfer to the graphicscard as it does to load from the harddisk(IO).
6  Java Game APIs & Engines / JOGL Development / Re: Create texture with different GLContext(on another thread) on: 2009-09-28 15:40:22
Cant see why u need two contexts for loading textures?

When creating a texture on another thread you get a "GLException: no glContext current on this thread..." Also, if you dont use seperate threads, you cannot draw loading animations or do anything in the rendering thread until the texture has fully loaded.

So, to increase responsiveness I need multiple glContexts...

Also, I havent gone back to coding it, i still need to try out the stuff from earlier posts Smiley
7  Java Game APIs & Engines / JOGL Development / Re: Create texture with different GLContext(on another thread) on: 2009-09-23 18:50:35
Two options:
1. Load the texture on a separate thread into memory (but don't send it to JOGL yet), then notify rendering thread.  On next render quick dump the texture in memory to the graphics card.

2. Have a 1x1 GLPbuffer.  When creating your rendering glcontext, tell it to share with the glpbuffer's context.  Use the GLPbuffer's context for texture loading, just make sure the rendering context doesn't use the texture until the pbuffer has completely created it.

Yes I get the basic idea, sounds good with the GLPbuffer, but I really need some code examples on creating multiple contexts, because I can't seem to make it work. Also how to create a GLPbuffer and such?

Also, is GLPbuffer supported by all graphics cards?

*edit*
Btw, method 1. I tried already, it only yields around 2 times faster a result, and about half of the work needs to be done on the rendering thread = stalling the rendering loop...this is not acceptable Smiley (too oldschool Tongue)
8  Java Game APIs & Engines / JOGL Development / Re: Create texture with different GLContext(on another thread) on: 2009-09-23 08:17:34
Bump guys Sad I'm really stuck...
9  Java Game APIs & Engines / JOGL Development / Create texture with different GLContext(on another thread) on: 2009-09-22 09:22:28
Hello,

I made a threaded loader for the IO part of reading the texture from a harddisk, but ended up having trouble with JOGL, because one context cannot be used in different threads simultaneously...

So my problem is:

How do I create a new context in which I can create a texture object with JOGL, load texture data into the object(store the texture on the graphicscard) and then later share it with the rendering-context?


To sum up I need:
  • Separate Rendering GLContext (for rendering Thread)
  • Separate texture loading GLContext(for loading Thread)
  • Ability to access both glcontexts at the same time, and finally to pass on the generated texture from loading-context -> rendering context
10  Java Game APIs & Engines / JOGL Development / Re: TextureIO.newTexture() slow? (moving image to texture buffer on graphics card) on: 2009-09-16 08:14:21
Yes that's what I was thinking, but I hope it's doing something silly, because it seems VERY strange that hdd-access is faster than memory-transfer between fast volatile-RAM memory.

Hmm, but yeah I think I can manage generating my own textures in OpenGL since it looks the same as displaylists which I have experience with.
11  Java Game APIs & Engines / JOGL Development / Re: TextureIO.newTexture() slow? (moving image to texture buffer on graphics card) on: 2009-09-15 18:41:47
Bump...I really need help on this issue Smiley
12  Java Game APIs & Engines / JOGL Development / TextureIO.newTexture() slow? (moving image to texture buffer on graphics card) on: 2009-09-15 11:29:57
Hello everyone,

I wanna make a threaded loading of textures in my engine, but the transfer of textures from main memory to the memory on graphics card is slower than reading from my harddrive.... This sounds weird....

Look at my example:

1  
2  
3  
4  
5  
6  
7  
8  
9  
            double time = System.currentTimeMillis();
            BufferedImage bi = ImageIO.read(getClass().getResource(fileName));
            TextureData texData = new TextureData(bi.getType(), bi.TYPE_INT_ARGB, false, bi);
            System.out.println("time to load tex from hdd:" + (System.currentTimeMillis() - time));
            time = System.currentTimeMillis();
//            text = TextureIO.newTexture(bi, false);
           text = TextureIO.newTexture(texData);

            System.out.println("time to load tex into graphics card:" + (System.currentTimeMillis() - time));


This results in the following test output:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
time to load tex from hdd:116.0
time to load tex into graphics card:382.0
time to load tex from hdd:49.0
time to load tex into graphics card:280.0
time to load tex from hdd:38.0
time to load tex into graphics card:67.0
time to load tex from hdd:92.0
time to load tex into graphics card:71.0
time to load tex from hdd:40.0
time to load tex into graphics card:52.0
time to load tex from hdd:32.0
time to load tex into graphics card:51.0
time to load tex from hdd:32.0
time to load tex into graphics card:53.0
time to load tex from hdd:33.0
time to load tex into graphics card:52.0
time to load tex from hdd:33.0
time to load tex into graphics card:54.0


Please help me, im stuck with this. I am certain that the transfer from main memory to graphics-memory should be way faster than Harddisk Access......
13  Games Center / Archived Projects / Re: FJump release! on: 2009-06-03 17:40:16
Hi

Please could you use Java Webstart? It would be easier for everyone Wink If you need an example, watch mine Wink

I will when I get the time, but I'm reading for the exams right now(should be) hehe Smiley
14  Games Center / Archived Projects / Re: FJump release! on: 2009-06-03 16:31:59
I could do a mac version, but I have no way to test it since I dont own or know anyone with a mac. In the end it would simply require adding the respective native files in a folder and it should be ready... I can try to upload an experimental mac version Smiley

I'll come back once it's done.

*edit*

Ok I really have no idea how to make it run under mac, I'm just working blindly, can someone tell me what should be changed for it to run on mac?

**edit**

I uploaded an experimental mac version on the downloads section. If someone can check it out for me that would be cool Smiley
15  Games Center / Archived Projects / FJump release! on: 2009-06-03 15:25:41
Hello everyone,

I invite you to try my new Java game FJump. It is a simple game based on the idea of the xjump game(and probably other games before that).

You jump your way to the top of a tower(and the online highscore!)

The main feature in this game is the online highscore that will make you and your friends go crazy against each other(and against the best guys on the internet!).

The game is in beta, but should be working on most computers.

Here a some screenies and a link to the webpage:





[size=20pt]Make sure you try this addicting jump-game![/size]

Webpage:
http://imada.sdu.dk/~felhar07/fjump/


Please lave comments in this thread if you like/dislike the game, heck even if you just tried it and found it average! There is no forum or tagwall yet, but there will be when I get around to it Cheesy
16  Discussions / General Discussions / Re: listening for Tab-key? on: 2009-02-17 11:15:03
it works like a charm Smiley Thanks alot
17  Discussions / General Discussions / listening for Tab-key? on: 2009-02-16 18:56:01
Hello everyone,

i am using the KeyListener interface to listen for input in my java/jogl game.

It has been serving me quite well until recently when I wanted to use the tab button. onKeyPressed(KeyEvent ke) doesnt seem to fire whenever I press tab. This is probably due to the tab key being recognized elsewhere and caught before it reaches my canvas.

How can I listen for the TAB key with javas KeyListener interface?

(Using ubuntu 8.10)
18  Java Game APIs & Engines / JOGL Development / Re: Non-power-of-two textures with TextureIO on: 2009-02-15 13:06:51
It's very, very easy to pack textures - look here for a handy rectangle-packing class. Just remember to specify a border of 1 when you construct the packer to avoid adjacent textures blending into each other.
It probably won't make any difference to performance, but it will give you a warm feeling of efficiency-increasing satisfaction inside.

Ahh yeah, good old knap-sack huh? Smiley Right now it's wasted work for me, but thanks I will look at it if i find the need Cheesy
19  Java Game APIs & Engines / JOGL Development / Re: Non-power-of-two textures with TextureIO on: 2009-02-15 09:23:06
Ok, it seems it might be easiest to just make sure my textures are in power of two dimensions, rather than loading rectangular textures in at this point. It is a solo project, so I might just accept the empty space in my textures rather than trying to fit several spritesheets in one. Currently I have 300+ fps in my game, so it won't be a problem. This is on a very old machine to boot, so other optimizations will only interest me later if at all.
20  Java Game APIs & Engines / JOGL Development / Non-power-of-two textures with TextureIO on: 2009-02-14 18:16:21
Hey guys,

what is a safe way to load in non-power of two textures, so that it will work on any machine?

The funny thing about my laptop is, when running my application on linux(ubuntu 8.10) I can use non power of two textures without problems, but when running on windows xp, it goes all wrong and rounds up to the nearest power of two for my textures.

This bothers mer quite some, and yes my drivers are updated in windows.

http://mr.myogl.org/ says that I dont have the non_power_of_two ext thing, and not the rectangle ext either. Here is the link: http://www.myogl.org/?target=show&id=150

Can someone help me?
21  Game Development / Game Mechanics / Re: Simple question (time based movement) on: 2009-02-12 20:29:50
...Another common way to solve this, is to separate the rendering and updating of the game. So there will always (for example) 50 updates per second ...

This doesn't really make sense to me. No matter what, in a single thread program I wont be able to do that in a good way. If the program is sequential, the logic will always be limited by the rendering method, as they must be part of the same loop.

But really, from your posts I find multiplying the deltavalue each time the best solution. What would you do to pass this value to almost every class in your program? Singleton approach or just a simple static class?
22  Game Development / Game Mechanics / Simple question (time based movement) on: 2009-02-12 18:50:13
Everyone does this:

Your game logic cannot rely on FPS, as it may(read: will) vary on different hardware. Hence I am thinking you must know the FPS in order to calculate the movement on each game-logic step. Now to my question(s ):

  • Is it normal to just calculate the movement based on velocity divided by FPS for example?
  • If above method is correct, what is good programming practice when almost every class needs to know the current FPS of the game?(I'm guessing a static class, containing a continuously updated public FPS field)

I hope you can help me. Plz don't flame me for asking a simple question, the answer is not obvious to me.
23  Java Game APIs & Engines / JOGL Development / Re: JOGL- change hue of Texture on: 2009-02-10 19:30:20
Thats what I call a quick response Smiley. I can't test it now, but I will when I get home!

*edit*

You might be interested to know that I used some of your code and it worked. That is to say, I ended up only using the getR/G/B(int) functions because of the way the Color.HSVtoRGB/RGBtoHSV functions work.

That aside, it works flawlessly. I have 10 little monsters, each in their own color, following me in a nice little line. This is very satisfying, and will provide me with easy reusable content for my little monster breeder game Smiley

I will be posting it whenever/ if ever I get a beta ready Cheesy Thanks for everyones help
24  Java Game APIs & Engines / JOGL Development / Re: JOGL- change hue of Texture on: 2009-02-10 19:04:26
Ok everyone thanks for your help. I used the java 2d stuff, namely the BufferedImage and Raster + WritableRaster. This is a really easy way to manipulate texture data.

Does anyone have a hue formula? I have access to each pixel in an int array of RGBA values ranging [0..255].

How would I compute the values with the changed hue? I found the wiki article, but it didn't help me much. The Color class contains RGBtoHBS(or something like that), does anyone know a good way to compute hue with this info?
25  Java Game APIs & Engines / JOGL Development / Re: JOGL- change hue of Texture on: 2009-02-08 12:49:17
If you wanted to do it at runtime you could split your original RGB image into three greyscale textures (one for each channel). Then at runtime tint them with vertex colours and blend them over the top of each other to get the correct combination of the individual channels. Three times the memory and fill rate but it'd work on all hardware.

Maybe if you told us what you're trying to achieve? It might be easiest to use a fragment shader for proper hue manipulation and fall back to something cheap like vertex colours and/or tinting with GL_SECONDARY_COLOR on old/crap hardware.

Of course you are right, i need to specify what my purpose is:

I am making a small 2d game, and I don't have any good graphical skills. Hence I need to use the same spritesheet multiple times, only changing the hue so it doesnt all look exactly the same. I just need to create a opengl texture with a changed hue once for each type of monster/player.

So it doesn't have to be done runtime, and hence can be slow/ineffective. Is there a good example of using a fragment pixel shader? I never found a good tutorial for pixel-shaders in jogl even though I needed one before(for full screen blurring effect).

26  Java Game APIs & Engines / JOGL Development / Re: JOGL- change hue of Texture on: 2009-02-08 12:20:47
You could load the picture in a buffered image and use java2d for manipulation. This http://www.curious-creature.org/2006/09/20/new-blendings-modes-for-java2d/ seems to have what you need. But maybe you could just use opengl blending and mix two textures to achieve what you want.

How would you use blending to achieve my goal? I don't see how using appropriate blending can offer a hue effect?
27  Java Game APIs & Engines / JOGL Development / Re: JOGL- change hue of Texture on: 2009-02-08 11:57:20
You can only do that using a pixel shader - there's no nice easy simple fixed pipeline function to do it.

Cas Smiley

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  
27  
28  
29  
30  
31  
32  
33  
34  
35  
package com.gameengine.gutils;

import javax.media.opengl.*;
import com.sun.opengl.util.texture.*;
import com.sun.opengl.util.*;
import java.io.*;
 
public class TextureLoader{
 
 
   /**
   * Texture loader utilizes JOGL's provided utilities to produce a texture.
   *
   * @param fileName relative filename from execution point
   * @return a texture binded to the OpenGL context
   */

 
   public Texture load(String fileName){
      Texture text = null;
      try{
//                                            TextureIO.setTexRectEnabled(true);text = TextureIO.newTexture(getClass().getResource("/com/gameengine/res/sprites/"+fileName),false,TextureIO.PNG);
        ///com/gameengine/res/sprites/
           ///client/res/img/
           text = TextureIO.newTexture(getClass().getResource("/com/gameengine/res/sprites/"+fileName),false,TextureIO.PNG);
         text.setTexParameteri(GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
         text.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
      }catch(Exception e){
         System.out.println(e.getMessage());
         System.out.println("Error loading texture " + fileName);
      }
      return text;
   }
 
}
 


Ok, is there a way to have my loader do it? I really just need a quick and dirty method. hmm I haven't had any great experience with pixel shaders, altough i'm very interested in shading.

If someone can point me to a tutorial or something.

One condition... it must run on low low spec computers. As in intels crap graphics cards.
28  Java Game APIs & Engines / JOGL Development / JOGL- change hue of Texture on: 2009-02-08 11:21:50
Hello guys,

can someone show me an example of drawing a textured quad where the hue(color) has been altered.

I know you can dim the lights, i.e. setting glColor4d(0.4,0.4,0.4,1); which would dim all the colors altogether.

What I need is a way to change the hue. If you know how to do it, you also know exactly what hue means. Shifting all the colors with the same index, ultimately replacing each colored pixel in a similar way across the entire texture.

I hope you guys can help me.
29  Java Game APIs & Engines / Java Sound & OpenAL / Re: OGG and WAV sound-framework, interested? on: 2009-01-20 12:43:00
FYI: YAGE. That one is for the D Programming Language. Something to keep in mind.

That's very unfortunate if they have the same name as my engine XD ....I never heard of that one lol.

oh well, I guess i need to change the name for my project Sad
30  Java Game APIs & Engines / Java Sound & OpenAL / Re: OGG and WAV sound-framework, interested? on: 2009-01-19 09:13:32
Hi Felix,

I don't think I have the experience in Joal / gl to help you out, but I'd definitely be interesting in reading the code for and using your engine to learn from it!

Best,
Jessety


Hey there jpavel,

I have just started a sourceforge project for it, but I need to find time to upload the code in an acceptable state.

http://yage.sourceforge.net/

Here is the link to my project "Yet Another Game Engine", but its empty right now. I will post somewhere on this forum when the small engine is uploaded and ready for people to try/read  Smiley
Pages: [1] 2 3
 

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

The first screenshot will be displayed as a thumbnail.

radar3301 (12 views)
2014-09-21 23:33:17

BurntPizza (30 views)
2014-09-21 02:42:18

BurntPizza (22 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

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

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

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

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

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

Tekkerue (50 views)
2014-09-09 02:24:56
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!