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 (564)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Only one block in chunk being drawn when using textures  (Read 4700 times)
0 Members and 1 Guest are viewing this topic.
Offline Longor1996
« Reply #30 - Posted 2013-03-31 20:48:56 »

If you wan't to give every cube it's own texture, you have to use glBegin/glEnd inside the nested loop.
And this will give you very big performance drops!

As I said: Use a texture atlas! Then you have to bind the atlas only once right before drawing the chunks and that's it.

- Longor1996

Sorry for my bad English! That's because i am from Germany.
Offline steg90

Senior Member


Medals: 1



« Reply #31 - Posted 2013-03-31 20:52:31 »

Can this be done even when using displaylists?

Thanks,
Steve
Offline Longor1996
« Reply #32 - Posted 2013-03-31 20:56:09 »

Can this be done even when using displaylists?

Thanks,
Steve

Yes. You just have to bind an texture atlas,
and then specify the texture coordinates per face in a way that only a defined portion af the atlas is visible.

Say, you atlas contains 4 textures, and has a power-of-two size of 32x32.
Then the code to use only the texture in the top left corner of the atlas is:
1  
2  
3  
4  
5  
6  
7  
8  
glTexCoord(0,0);
glVertex(0,0);
glTexCoord(0.5,0);
glVertex(1,0);
glTexCoord(0.5,0.5);
glVertex(1,1);
glTexCoord(0,0.5);
glVertex(0,1);



- Longor1996

Sorry for my bad English! That's because i am from Germany.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline steg90

Senior Member


Medals: 1



« Reply #33 - Posted 2013-03-31 20:56:52 »

Many thanks again @Longor1996, learning so much from you!
Offline Longor1996
« Reply #34 - Posted 2013-03-31 22:41:08 »

Im always happy to help!

Oh, and there is a lot more of things that you can do to optimize your voxel-engine.
But some of them are invented by myself and therefore secret!

- Longor1996

Sorry for my bad English! That's because i am from Germany.
Offline steg90

Senior Member


Medals: 1



« Reply #35 - Posted 2013-04-01 07:59:59 »

Thanks @Longor1996

Well, once I get more done to it I will look at optimising ;-)
Offline Vermeer

JGO Coder


Medals: 16



« Reply #36 - Posted 2013-04-01 17:53:48 »

Hi steg,

Hope your project is going well. I posted my entire code in my thread, it uses a texture atlas 16x16 sprites

It's 512 x512 texture,  so 1/16 = 0.0625 for each offset texture. Gives you quite a few block to play with. For grass, the offsets are just changed so you can draw the sides an top differently. See -- GrassBlock !
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 800
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #37 - Posted 2013-04-01 18:10:37 »

This forum is not a chat room.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline steg90

Senior Member


Medals: 1



« Reply #38 - Posted 2013-04-01 18:23:16 »

Ok, sorry about that.

Think I've worked out texture atlas.

I've got a texture atlas of 1024x1024, textures are 64x64.

So, that is 1024 / 64 = 16 textures wide

1024 / 64 = 16 textures high

Then I just do 1 / 16 to give texture  x-coordinate (i.e. 0.0625f )
and this is the same for texture y-coordinate.

So, to get 4th texture, I use this:

1  
2  
3  
4  
5  
6  
7  
8  
GL11.glTexCoord2f(4.0f * 0.0625f, 1 * 0.0625f);
GL11.glVertex3f(-0.1f, 0.1f, -0.1f);   // Top Left Of The Texture and Quad
GL11.glTexCoord2f(4.0f * 0.0625f, 0.0f * 0.0625f);
GL11.glVertex3f(-0.1f, 0.1f, 0.1f);   // Bottom Left Of The Texture and Quad
GL11.glTexCoord2f(5 * 0.0625f, 0.0f * 0.0625f);
GL11.glVertex3f( 0.1f, 0.1f, 0.1f);   // Bottom Right Of The Texture and Quad
GL11.glTexCoord2f(5 * 0.0625f, 1 * 0.0625f);
GL11.glVertex3f( 0.1f, 0.1f, -0.1f);   // Top Right Of The Texture and Quad


Hope this may help somebody?!

Thanks,
Steve
Offline steg90

Senior Member


Medals: 1



« Reply #39 - Posted 2013-04-01 18:26:10 »

@Vermeer,

It is going slowly, lol, been busy working.

Thanks with regards to textures, worked it out now, going to use atlas so only one texture bind.

Will have a look at your code if I get chance, although I do enjoy trying to work things out - oh and the help on these forums is invaluable!

It is great to see so many people working on these cube worlds, sure has given me an insight into using OpenGL.  Thanks everyone!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Vermeer

JGO Coder


Medals: 16



« Reply #40 - Posted 2013-04-01 19:06:00 »

I do enjoy trying to work things out - oh and the help on these forums is invaluable!

It is great to see so many people working on these cube worlds, sure has given me an insight into using OpenGL.  Thanks everyone!


Yes the fun is figuring it out, you learn it that way. But sometimes it can be frustrating when it just won't work. This forum is so helpful and inspiring when things just won't work how you want.  I agree thanks everyone! Smiley
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 800
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #41 - Posted 2013-04-01 19:07:54 »

This forum is not a chat room.

Why don't you guys exchange email addresses, instead of accounting for about a quarter of JGO postings.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Pages: 1 [2]
  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.

Grunnt (20 views)
2014-09-23 14:38:19

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

BurntPizza (31 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 (29 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 (75 views)
2014-09-10 13:57:51

TehJavaDev (107 views)
2014-09-10 06:39:09
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!