Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  Why make a graphics context object?  (Read 1564 times)
0 Members and 1 Guest are viewing this topic.
Offline wessles

JGO Wizard


Medals: 66
Projects: 4
Exp: 3 years


Profile picture isn't relevant.


« Posted 2013-09-25 00:54:57 »

What is the point? In slick2d, you have the Graphics object, and it seems to just draw lines... And I was recently told that any good engine makes graphics abstract. So what is up with that? Why even make a graphics object?!

Offline Abuse

JGO Knight


Medals: 12


falling into the abyss of reality


« Reply #1 - Posted 2013-09-25 12:08:05 »

I'm no expert, but I believe that making changes to the graphics context state can be an expensive operation in some rendering pipelines.

Encapsulating the graphics context allows for more precise caching of operations thereby minimising state changes.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Troncoso

JGO Coder


Medals: 20



« Reply #2 - Posted 2013-09-25 12:14:26 »

I'll agree with what Abuse said. By building a graphics class to manage rendering settings, then you can majorly decrease gl calls and resource usage. And maybe take a look at Slick's Graphics class. There is quite a bit more going on than "just drawing lines".
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline wessles

JGO Wizard


Medals: 66
Projects: 4
Exp: 3 years


Profile picture isn't relevant.


« Reply #3 - Posted 2013-09-25 20:37:37 »

Ok, but what even is a graphics context when you get down to it?

Offline opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #4 - Posted 2013-09-26 03:22:02 »

Just a guess, but its just a way to access the low level rendering capabilities of a library. You can essentially create a new context anywhere in your code, where if you didn't have contexts... Well I don't know how you would handle rendering because you couldn't create a new instance of the rendering handler. The other thing is that when you create a new thread, you need to create a new context for that thread, so without contexts, you couldn't do much on separate threads. Again, just a guess because I've never researched it.

Offline wessles

JGO Wizard


Medals: 66
Projects: 4
Exp: 3 years


Profile picture isn't relevant.


« Reply #5 - Posted 2013-09-26 12:44:36 »

Yeah. Right now I am working on making a renderer, which can switch rendering techniques (i.e. Vertex Array, Immediate, Vertex Buffer Object etc.). For every rendering technique, there is a whole bunch of drawRect, drawTriangle, drawPoint(s), etc. I also made a geometry package, and a styled geometry package, which is just geometry with colors, textures, etc. With that, I made a Color class.

The reason I ask why to make a graphics context, is because I am making my engine and looking to other successful engines to see what made them good. Seems like graphics context is a must. I guess its just an unwritten rule?

Thanks for the responses!

Offline Troncoso

JGO Coder


Medals: 20



« Reply #6 - Posted 2013-09-26 14:28:28 »

It's all just lingo, mate. Call it what you want. The premise is that you have something to render your graphics, instead of re-inventing the wheel everytime you need something on the screen. So, yes, successful engines are successful due in part that they can draw graphics.
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #7 - Posted 2013-09-27 00:07:23 »

It is more that just that. The graphics context is an interface used to hide the underlying implementation. So you can start with LWJGL. Then you can add JOGL later and the user of your library can easily switch.

Offline Grunnt

JGO Wizard


Medals: 68
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #8 - Posted 2013-09-27 18:47:30 »

It is more that just that. The graphics context is an interface used to hide the underlying implementation. So you can start with LWJGL. Then you can add JOGL later and the user of your library can easily switch.

Indeed, it's basically use of the bridge pattern (I just learned Grin).

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.

Dwinin (28 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (73 views)
2014-09-10 06:39:09

Tekkerue (37 views)
2014-09-09 02:24:56

mitcheeb (57 views)
2014-09-08 06:06:29

BurntPizza (44 views)
2014-09-07 01:13:42

Longarmx (27 views)
2014-09-07 01:12:14

Longarmx (34 views)
2014-09-07 01:11:22

Longarmx (34 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
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!