Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (121)
games submitted by our members
Games in WIP (577)
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  
  translate  (Read 1760 times)
0 Members and 1 Guest are viewing this topic.
Offline bedelf

Junior Duke




Are you suggesting coconuts migrate?


« Posted 2003-05-30 03:56:38 »

Is there some particular reason 0 is the bottom of the screen for a y translation? Or is that just how things work in 3d? I'm drawing some tiles but I have to do

gl.translatef(
widthIterator*tileSize
(screenHeight-tileSize)+(heightIterator*tileSize)
0.0f );

otherwise it draws from the bottom up. Tongue I guess this just seems wierd to me after doing java2d stuff for so long.

                       gl.begin( GL.QUADS );
                       gl.texCoord2f( 0.0f, 0.0f ); gl.vertex2f( 0.0f, 0.0f );
                       gl.texCoord2f( 1.0f, 0.0f ); gl.vertex2f( 16.0f, 0.0f );
                       gl.texCoord2f( 1.0f, 1.0f ); gl.vertex2f( 16.0f, 16.0f );
                       gl.texCoord2f( 0.0f, 1.0f ); gl.vertex2f( 0.0f, 16.0f );
                       gl.end();

So the first vertex2f is acually the lower left? For some reason that just seems ODD.

Though I guess I could always draw my tiles from the bottom of the visible map anyways. It's hard to me to change my ways damnit. Tongue

Ok I'm done bitching. Wink
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2003-05-30 06:13:07 »

OpenGL doesn't know or care where you put your origin - but the default is (x,y) at the bottom left as you mention. To flip it, you'll need to set the modelview matrix accordingly before you draw anything. Off the top of my head it'd be a -1 scale of the y axis and translate your camera accordingly. You may be able to set this more conviniently by tinkering with the projection matrix in a similar way, but the math escapes me at the moment.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline bedelf

Junior Duke




Are you suggesting coconuts migrate?


« Reply #2 - Posted 2003-05-30 06:29:47 »

Coolbeans, I'll look into that later.

Right now for one reason or another having the SpriteEngine(spgl) render() after drawing my tiles just makes everything go white. Things going wrong is an experience not wholly unfamiliar to me. ;P All I can see the sprite engine doing is putting some crap in some vertex arrays and drawing, so I dunno.

Still figuring this crap out, just slowly. Really, really slowly.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #3 - Posted 2003-05-30 06:37:27 »

I assume you mean your textures become white? Thats usually an indication that you've got an invalid or unexpected texture state/setup. As a quick fix you might try a couple of pushAttrib and popAttrib around the code that breaks your tile drawing, other than that check you're resetting texture states before you draw each frame.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline bedelf

Junior Duke




Are you suggesting coconuts migrate?


« Reply #4 - Posted 2003-05-30 06:42:21 »

gl.enable( GL.TEXTURE_2D );
gl.matrixMode( GL.PROJECTION );
gl.loadIdentity();
gl.glu.ortho2D( 0, width, 0, height );
gl.scalef( 1, -1, 1 );
gl.translatef( 0, -height, 0 );
gl.matrixMode( GL.MODELVIEW );
gl.loadIdentity();
gl.viewport( 0, 0, width, height );

This seems to work.

Edit: ya I was missing something, so now the tiles show but the sprite doesn't. Smells like progress though, thanks. Wink
Offline bedelf

Junior Duke




Are you suggesting coconuts migrate?


« Reply #5 - Posted 2003-05-30 13:38:40 »

So what could cause something to not show up? I'm still thinking far too much in 2d but, right now it's not doing anything super funky, if I comment out my tile drawing code, the sprite shows up, but when I draw my tiles and then the sprite, it doesn't show up on top? Is there something I'm not doing here?

Well mabey since I almost fell asleep at the keys writing that, I should just go to sleep and worry about it when I wake up. Tongue
Offline elias

Senior Duke





« Reply #6 - Posted 2003-05-30 18:23:37 »

You are aware of the fact that translations etc. are cumulative? That is, remember to do a loadIdentity() before drawing each element.

- elias

Offline bedelf

Junior Duke




Are you suggesting coconuts migrate?


« Reply #7 - Posted 2003-05-30 22:16:34 »

ya. I just got up so I'll dig around a bit.

edit: ew, well, now that you mention it, that fixed my problem.. For whatever reason I guess I assumed it was resetting to draw the sprites. Cas is using vertex arrays in there so I'm acually not entirely sure whats going on in terms of translation. Though looking at it now it doesn't seem even half as complex as it did 3 days ago, so I guess I just need to dig in now.

Thanks guys, I think I might be ok for a few days. (lies) Wink
Offline princec

JGO Kernel


Medals: 409
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #8 - Posted 2003-05-31 11:17:39 »

Haha! Now I've just gone and tweaked all the sprite code anyway Smiley

New addition: there's a ticks-per-frame thing gone into the sprite engine. I was calling tick() on every sprite twice per frame instead of just telling the sprite engine that 2 ticks should pass for every call to tick(). Should improve performance a shade on those ol' celerons at 30Hz.

Texture packer tool has changed a bit too, with a way to exclude directories from the list of pngs that it loads, and a way to specify what renderer is used for a particular spriteimage.

Cas Smiley

Offline bedelf

Junior Duke




Are you suggesting coconuts migrate?


« Reply #9 - Posted 2003-05-31 12:34:08 »

evil. Wink
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.

theagentd (20 views)
2014-10-25 15:46:29

Longarmx (53 views)
2014-10-17 03:59:02

Norakomi (47 views)
2014-10-16 15:22:06

Norakomi (35 views)
2014-10-16 15:20:20

lcass (39 views)
2014-10-15 16:18:58

TehJavaDev (70 views)
2014-10-14 00:39:48

TehJavaDev (69 views)
2014-10-14 00:35:47

TehJavaDev (61 views)
2014-10-14 00:32:37

BurntPizza (74 views)
2014-10-11 23:24:42

BurntPizza (47 views)
2014-10-11 23:10:45
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!