Lwjgl puts opengl functions in a class corresponding to the version (or extension) that the function belongs to. So GL11 contains all the functions defined by OpenGL v1.1 (ie. base opengl). All additional functions introduced in OpenGL v1.2 are in GL12, etc. Similarly any functions defined as an extension go in a class named after the extension (eg. ARBVertexBufferObject).
If a computer supports OpenGL, then it will always support GL11 functions. For anything above that you should check ContextCapabilities.
Often it’s useful to choose a suitable base level (eg. GL20), check if that’s available on start-up and then use whatever GL20 and lower functions you need afterwards.
[quote]Second of all, how do I even reference from a method like so:
[/quote]
You don’t, you just call the functions directly since they’re static.
Someone needs to find me a literal full explanation of how this thing works, I have no idea what I’m doing. Most of the tutorials I’ve found assume I know all of the terminology and what-not. It usually involves “conceptual code” as if I know how to convert to actual code. lol.
EDIT: For anyone who may read this, I found this. It’s helping me a bit with terminology, but the above problem still persists at the moment
Here it is: http://www.arcsynthesis.org/gltut/
One thing you can probably get rid of is that last glHint, since it’s meaningless in every modern driver I’m aware of. The rest, you’ll need to pick up an OpenGL tutorial to learn what everything does. It’s doing a lot, nothing that can be answered in a few forum posts.
That’s the thing, all of the tutorials explain everything in the most complicated way possible with absolutely nothing visual for me to mentally grasp. Most of the time the shader tutorials don’t have screenshots of what you’re making either, so you have no idea on whether or not you’re wasting your time or not.
I wish I had comforting words there, but learning OpenGL from online tutorials really is a damned tricky thing, requiring you to go between lots of different ones to pick up basics. Then there’s learning it in Java, which have hardly any tutorials written using it. While LWJGL clones the OpenGL C API almost perfectly in java, the various books still tend to assume C++, and porting things like matrix classes from them can be very tricky if you don’t already have C++ experience.
I found the original Red Book, obsolete as it is, to be an immensely helpful resource, but it’s no help for learning the programmable pipeline. It could be that learning the fixed function pipeline then unlearning it for shaders is still the best way to ease into it.
Well, the lighting I want is really simple. I just want black if there’s no light, and circles of light where there is. If you can just point out functions in the direction of doing this, I can just kind of bullcrap my way through.
I could do this the simple way, and make shading voxel style myself, but it’d look bad with the sketched graphics.
Yes, that looks like you have mismatched lwjgl jar + source setup in eclipse. The debug info from the .class file it’s running says that the function is at line 2052, but when eclipse tries to find that in the source attachment you’ve given it it doesn’t exist.
I’d suggest upgrading your lwjgl (jars + source + docs) to the latest so you know they’re all the exact same version.
You are trying to use OpenGL before it’s been initialized (this also happens when you try to render from a different thread). GL calls should be made from the same (rendering) thread.
The solution to your problem is to move your GL11 calls to your game’s init() method.
Why the ScalableGame? Also, if you haven’t already, be sure to update to the latest slick dev branch code. Then you can use getContainer().exit() instead of manually destroying the display/AL. I’ll try to put up a tutorial on pulling dev branch code in the next couple days, and hopefully get a merge in soon so the code is downloadable in binary form on Slick’s website.
Okay. Scalable is so I can resize the window, and stretch it if I want too. Weird situation. lol. It needs A LOT of fine tuning.
Anyway, since you seem to know a lot about this stuff, can you answer a question I put on here earlier?
“Well, the lighting I want is really simple. I just want black if there’s no light, and circles of light where there is. If you can just point out functions in the direction of doing this, I can just kind of bullcrap my way through.”
Also, why the need for 3D perspective, depth testing, etc? Are you making a 3D game? You’ll have a rough time with Slick2D if you try to integrate certain utilities (like, say, Image or ScalableGame) alongside low-level GL calls. If you plan to do 3D, I’d recommend either avoiding Slick2D altogether (instead choosing Slick-Util or a different library), or using SlickCallable to be safe. Even then, ScalableGame + GL calls will give you trouble (as it warns in ScalableGame JavaDoc).
[quote]“Well, the lighting I want is really simple. I just want black if there’s no light, and circles of light where there is. If you can just point out functions in the direction of doing this, I can just kind of bullcrap my way through.”
[/quote]
I’m just jumping into this thread now, but there are some ways to do this in Slick2D without relying on low-level OpenGL calls.
The easiest is to use an alpha map, and you won’t need to worry about math or combining lights or what have you. One of the downsides to this is that it requires extra passes, which may lead you to fillrate limitations. The result is nice, though:
Is that what you’re looking for? Or are you looking for a more “low-res” / retro look? e.g. In Terraria; each tile is affected.
I’m just jumping into this thread now, but there are some ways to do this in Slick2D without relying on low-level OpenGL calls.
The easiest is to use an alpha map, and you won’t need to worry about math or combining lights or what have you. One of the downsides to this is that it requires extra passes, which may lead you to fillrate limitations. The result is nice, though:
Is that what you’re looking for? Or are you looking for a more “low-res” / retro look? e.g. In Terraria; each tile is affected.
[/quote]
The game is 2D, and all the graphics are sketched out/pixel drawn by me, so I need something that would fit this:
What do you mean “dynamic”? Do they need to interact with walls? (i.e. will walls affect the lighting)
Alpha maps should be easier, and resizing is just a matter of drawing the map at a different size. If I get a chance I’ll throw together an example, although there should be some rudimentary code lying around slick forums already.
I’d like walls to affect lighting, but, if it’s one of those overcomplicated not worth it type deals I think I’ll just go with alpha maps. Haha. I’d appreciate that example too, if you get around to it.
Eventually this will make its way into the Slick wiki. If I’m ambitious, I’ll also add tutorials/code for two other examples: lighting tiles per-vertex and lighting via shaders.
The gist of the technique:
for each light {
set draw mode to MODE_ALPHA_MAP
clear alpha map
draw alpha map image at light position
set draw mode to MODE_ALPHA_BLEND
set clip (glScissor) to ignore pixels outside of the lit area
draw tile map as per usual
clear clip
}
set draw mode to MODE_NORMAL
Alpha maps won’t be very efficient if you plan to have many lights at once (in that instance, you could improve efficiency by “baking” the lights, i.e. rendering static lights to an offscreen image). Also, the lighting won’t interact with walls or corridors. If your game is very particular, you might be able to hack around with some different alpha maps to fake that “dynamic” aspect, but it would probably be easier to just use per-vertex lighting or shaders.
I’m going to use this more than likely, but if you happen to know of any good shader tutorials that’s as informative and helpful for visual learners as yours is, please do share. Haha