Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (568)
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  
  lwjgl, where to start?  (Read 2233 times)
0 Members and 1 Guest are viewing this topic.
Offline Regenuluz
« Posted 2012-12-06 21:09:58 »

Right, so I've decided that it's time for me to do the whole lwjgl thing and take advantage of opengl and such.

But I have *no* idea where to start learning the basics of it.

How do I render simple shapes(Along the lines of Graphics2d.fillRect() etc.), load/render images/spritesheets, and draw text to the screen?

Links to basic tutorials that explains those things would be *awesome*!

Cheers! Smiley

Offline davedes
« Reply #1 - Posted 2012-12-06 21:36:28 »

A few links here to get you started.

Also, don't use SlickUtil.. instead learn to make your own texture loader, using Matthias' pure-java image decoders.

Online Mac70
« Reply #2 - Posted 2012-12-06 21:51:03 »

http://www.lwjgl.org/wiki/index.php?title=Main_Page#Getting_started

Very good and easy tutorials.

Check out my Devblog! Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Regenuluz
« Reply #3 - Posted 2012-12-06 22:49:41 »

A few links here to get you started.

Also, don't use SlickUtil.. instead learn to make your own texture loader, using Matthias' pure-java image decoders.

Those links are, by the looks of it, all about shaders and such. Which isn't exactly what I'm looking for just yet. As for texture loaders, well, currently I have *no* idea how to even load images into lwjgl and OpenGL... Soooo.... Tongue


The basics are not very good. They don't really explain anything. There's nothing on there, that tells my what the drawing code does, and why it works as it does.

I'll confess I didn't really look at the Legacy OpenGL tutorials, because they start off with FBO and VBO, and again there's no explanation of how the drawing code works.

And if that's the best there is.... Sad Maybe I should point out that I have *no* experience, what so ever, with OpenGL.

So what I'm looking for is something along the lines of "Here's how you draw a square in the color <color>, and this is why/how it works." and "Here's how you render text to the screen" and "Loading images(textures?) is done like this! And why!"..

Smiley
Offline davedes
« Reply #4 - Posted 2012-12-06 23:38:20 »

You need to be pretty proficient with Java and programming concepts, as well as basic concepts like images (do you know what RGBA stands for? do you understand what (x, y) represents in screen space?).

You also need to understand some concepts like matrix and vector math. If you don't know that, don't fret, because you can actually get quite far without it. Smiley You may just need to accept that, during your learning stage, there will be concepts you won't fully understand until later.

I am slowly working on a beginner's intro to LWJGL and the programmable pipeline. The full source code is (relatively) minimal, and should provide a good base for getting started. Or, if you want, you could just use the source as a simple sprite rendering API, and not worry about what's going on under the hood.

Take a look at the source here:
https://github.com/mattdesl/lwjgl-basics

Further, you can see the wiki where I'm working on a short tutorial series:

Display Creation
Texture Creation
Java NIO Buffers (you will use these to upload texture data to OpenGL)

There is no simple guide that gives you a short answer on how to "draw a sprite" in OpenGL, because it's not that easy. In modern OpenGL (aka 3.0+), you need to:
1. Decode the PNG into RGBA bytes.
2. Upload the bytes to OpenGL
3. Create a shader that will sample your texture.
4. Create a 4x4 matrix for 2D orthographic screen projection.
5. Pass the matrix to the vertex shader.
6. Specify the vertex attributes which define the two triangles of your sprite mesh.
7. Bind the texture and draw the elements.

Smiley OpenGL isn't really for the faint of heart... nor is it for those who want a simple answer.

Offline Regenuluz
« Reply #5 - Posted 2012-12-07 00:08:11 »

Yeah, I know what RGBA stands for, and I know how coordinates work on the screen. I also know matrix and vector math, seeing as I've been taught that in uni. ^_^

I'm already using it in the TD game I'm working on, in Java2d, but seeing as rendering and shading isn't exactly epic in j2d, then I thought I'd try out lwjgl and use opengl. (My fps drops when I have around 100 towers placed.. Each tower consists of 4 sprites, 1 base shadow, one base, one tower shadow, and of course the tower itself. The shadows are rendered semi transparent.)

I'm not exactly looking for any easy answers, but I am looking for more than just source code and a notion of what it does. I'd like to know how it does it.

"Here's 15 lines of code, and it draws a square" just doesn't really explain much. Smiley

Just briefly looking over your tutorial links, and they include about 100% more comments than any other tutorial I've looked at. Heck, most of them didn't even have any comments in the code.

So I'll take a closer look at your links tomorrow, after I've gotten some sleep. It's 1am here now. Tongue
Offline Varkas
« Reply #6 - Posted 2012-12-07 13:08:39 »

When I tried to learn OpenGL the frist time, I downloaded The Nehe tutorials ( http://nehe.gamedev.net/ )and printed me a copy of the API reference for reading. It was more or less the same like this: http://www.talisman.org/opengl-1.1/Reference.html

I had made a simple flat-shaded polygon based 3D display engine before, so I had a basic understanding of 3D math and the concepts.

That's not about LWJGL though, just the OpenGL part, but LWJGL is close enough in those parts so you can use the C-related information as well.

if (error) throw new Brick(); // Blog (german): http://gedankenweber.wordpress.com
Offline davedes
« Reply #7 - Posted 2012-12-07 18:28:34 »

When I tried to learn OpenGL the frist time, I downloaded The Nehe tutorials ( http://nehe.gamedev.net/ )and printed me a copy of the API reference for reading. It was more or less the same like this: http://www.talisman.org/opengl-1.1/Reference.html

I had made a simple flat-shaded polygon based 3D display engine before, so I had a basic understanding of 3D math and the concepts.

That's not about LWJGL though, just the OpenGL part, but LWJGL is close enough in those parts so you can use the C-related information as well.
The NeHe tutorials are very dated. They show old and deprecated techniques like display lists and built-in lighting/fog.

If you want to learn graphics programming, just stay away from NeHe, suck it up and learn how the programmable pipeline works... Understanding shaders will make you a much better 2D and 3D game developer. It will also enable you to program WebGL, Android and iOS games.

Offline ra4king

JGO Kernel


Medals: 347
Projects: 3
Exp: 5 years


I'm the King!


« Reply #8 - Posted 2012-12-09 05:09:35 »

Davedes also mentioned the Arcsynthesis tutorials in the first link he posted. Those are really excellent tutorials that explain....basically everything for absolute beginners. It's how I learned OpenGL when I was exactly in your shoes a few months ago Wink

Offline davedes
« Reply #9 - Posted 2012-12-09 21:33:22 »

Just an update, I've been chugging along on the "intro to shaders for 2D games" series:

Table of Contents
Lesson 1: Intro to shaders, uniforms, attributes, data types, etc
Lesson 2: Intro to texture sampling, basic image processing

Other things I have in the roster:
  • Circles, vignettes, grayscale, sepia tones, and other common effects
  • Blending, texture splatting
  • Normal lighting + workflow with Blender for rendering a normal pass which can then be used in 2D games
  • Blurs, blooms, etc
  • Light scattering aka "god rays"
Each lesson will include a LibGDX port at the end. Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Regenuluz
« Reply #10 - Posted 2012-12-09 21:46:24 »

It looks good. I haven't had a whole lot of time looking into it though, exams coming up. Hopefully I'll have more time next weekend. Smiley My exams are the 13th and 14th, so gonna spend the week preparing for them. Tongue

I've opened up your wiki in a tab though, so it wont be forgotten, along with a bunch of other opengl tabs. Smiley
Offline matheus23

JGO Kernel


Medals: 108
Projects: 3


You think about my Avatar right now!


« Reply #11 - Posted 2012-12-10 20:11:54 »

Gimmie! Or at least... please gimmie a link or similar! Smiley

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline davedes
« Reply #12 - Posted 2012-12-10 21:26:16 »

See here (open the .blend and select "View Raw" to download)

Offline matheus23

JGO Kernel


Medals: 108
Projects: 3


You think about my Avatar right now!


« Reply #13 - Posted 2012-12-10 21:29:33 »

See here (open the .blend and select "View Raw" to download)
huh... good I appreciated, or I else the site wouldn't have reloaded and I wouldn't have seen the edit... (<- this english sucks... was this valid syntax?)

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline GabrielBailey74
« Reply #14 - Posted 2012-12-11 05:16:46 »

I got pissed @ LWJGL earlier today....
In Java2D I can render a 2D 'TileMap', which is basically inside of 2 for loops:
1  
2  
3  
4  
5  
for (float x = 0.0f; x <= Display.getWidth(); x += offset) {
     for(float y = 0.0f; y <= Display.getHeight(); y += offset) {
          drawRect(x,y,w,h);
     }
}


Now when I tried doing that with the standard 2DProjection in LWJGL I got about...
3 FPS..

Where in Java2D i'd be getting average above 60 FPS.
I Rage closed my IDE rofl.

Offline sproingie

JGO Kernel


Medals: 202



« Reply #15 - Posted 2012-12-11 05:41:19 »

Java2D is batching your draws, whereas if you use the stone age glDrawRect, you get no such thing.  Use libgdx and draw a solid-colored sprite on a SpriteBatch and you'll get about 17 hojillion FPS.
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



« Reply #16 - Posted 2012-12-11 07:50:06 »

A very good site for learning the basics of lwjgl is thecodinguniverse.com. The guy, who runs the site is only 15 years old! Also, check out his youtube chanel: http://www.youtube.com/user/thecodinguniverse. He`s got some amazing videos there! Hope I helped  Smiley

Subscribe to me on YouTube: http://youtube.com/javaprogrammerguy
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.

Riven (6 views)
2014-10-02 14:36:20

Pippogeek (41 views)
2014-09-24 16:13:29

Pippogeek (32 views)
2014-09-24 16:12:22

Pippogeek (22 views)
2014-09-24 16:12:06

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

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

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

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

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

UprightPath (53 views)
2014-09-20 20:14:06
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!