Library Hesitation (OpenGL)

Started by
2 comments, last by Chumble 10 years, 7 months ago

Seems like I'm posting a topic here every week so if you're on this forum often, you've probably run into me at some point.

Anyways, I'm making a 2D networked game in Java as a project for learning the language. So far I have only used libraries that were immediately available to me. My thought process behind this was I wanted to learn Java at the most basic level before incorporating libraries to "do things for me" or simplify tasks.

I'm not sure at what point I should change this mindset. Currently my game allows for multiple people to join in, run around, and collide with trees (just got my collision boxes working yesterday, super pumped!). I don't really know what direction the game will go in, I'm just trying to set up a lot of back-end stuff... dynamic systems for which I can start layering on content.

I started thinking about lighting. Now, my experience with lighting has been .. limited. I created a 2D tile-based game in a proprietary programming language designed to create interfaces for medical software. My lighting calculation was incredibly crude and basically involved "Loop through every single tile. For each tile, calculate all tiles between this tile and the player. If there is an object on any tile in this set of tiles, then the player cannot see this tile". It created a very blocky LOS lighting calculation. Some optimizations were made to make sure I wasn't checking tiles twice but overall it took about .5 seconds to move from one tile to the next.

Now, with my current game, it's not really tile-based anymore. I mean.. there are TILES (which I really just use as squares of floor), but all objects, including players, can be moved on a per-pixel basis. Which really means I need pixel-based lighting. I also wouldn't mind incorporating some fancier shading effects, although I really don't know much about them.

This is really the FIRST time I've ever used a real language and created GRAPHICS. I used C++ for a while and did all console based applications. I started to learn DirectX stuff but got caught up with Windows programming. I don't really know .. how a lot of this stuff works. I understand DirectX and OpenGL are designed to help software communicate effectively with hardware... that's about where my understanding ends.

So.. OpenGL. I see lots of people recommending LWGL (I think it's called), assuming it got popular after Minecraft. Do I need to use that? Can I just.. use OpenGL directly? OpenGL is *already* a utility to help draw graphics and if this is my first time delving into something like that.. I would kinda rather not use a library to "do everything for me".

So .. questions:

1) Is it possible to learn OpenGL without incorporating another library to help make use of it? Does it make sense to do that?

2) I'm enjoying Java2D so far, but I don't wanna go so far into it that when I finally DO decide to do some fancier stuff, I need to re-write my graphics 'engine' (I can call my draw screen class a graphics engine, right? :-P )

3) More of a general question.. what does it mean to LEARN OpenGL (or DirectX for that matter)? Is OpenGL just a set of libraries in itself? Multiple languages can USE OpenGL.. how is that possible if they all have their own syntax? I am woefully in the dark about how this works.

Thanks for reading,

WhateverMyNameIsOnThisForum

Edit: Tuns out most of this stuff is discover-able with Google if you use the right terms. Seems like any language implementing OpenGL requires some sort of wrapper to utilize the functions. A more "standard" one for Java is JOGL. I guess the LWJGL is just another?

Advertisement

Yes, you can use JOGL and do the OpenGL stuff yourself. The LWJGL is a low-level game library, but it includes more than just OpenGL, with code included for a framework, input, sound, and all that other stuff you don't realize you need when you first start making a game.

As for what it means to "learn" opengl, I'm still trying to figure that out myself. :D

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

1) Is it possible to learn OpenGL without incorporating another library to help make use of it? Does it make sense to do that?

Maybe. OpenGL is a library (the L in OpenGL stands for library), specifically it's a C library. So to use it from another language you need some language-specific bindings that wrap the underlying C library. Java has a few bindings: LWJGL is one of those which provides a bunch of other stuff besides, JOGL is another that focuses just on wrapping OpenGL.

2) I'm enjoying Java2D so far, but I don't wanna go so far into it that when I finally DO decide to do some fancier stuff, I need to re-write my graphics 'engine' (I can call my draw screen class a graphics engine, right? :-P )

I wouldn't worry too much at this stage. Besides, it's pretty common to write a whole new renderer for each graphics backend.

3) More of a general question.. what does it mean to LEARN OpenGL (or DirectX for that matter)?

Good question, it really just means being familiar with the concepts of graphics: linear algebra, various kinds of buffer, textures, shaders, etc. Then how to apply those concepts to the specific API in question (OpenGL or Direct3D).

Is OpenGL just a set of libraries in itself?

It's a single library. You might say there are a few distinct APIs within that, or just one big monolithic set of API calls - however you choose to think of it really.

DirectX is a set of libraries, one of which is (or was) Direct3D which is its equivalent to OpenGL.

Multiple languages can USE OpenGL.. how is that possible if they all have their own syntax? I am woefully in the dark about how this works.

Ah, I answered that above. It's a C library really, but most languages have the capability to communicate with C libraries at which point it is up to somebody to create 'bindings' which are just a regular library for the language in question that actually wraps the underlying C library. Thus performing whatever conversion is required to make it work (but most languages look like C if you squint hard enough).

This has cleared up quite a bit for me :) Thanks guys. I think I'm gonna read through http://openglbook.com/ to get a better understanding of OpenGL, then later down the line when I decide to implement it, I'll see what I wanna do for a "binding".

Thanks!

This topic is closed to new replies.

Advertisement