• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
PGSCreativeDirector

How to make my own gui using opengl and SDL and C++ or whateva? :)

15 posts in this topic

hello im a novice at programming tired of crap and wanting to be less crap by creating things that i can work with but for me too do that i need to know where to start because everything is so dam non logical in the world of coding when theres no explanations or tutorials simplfied word by word on how to do what i want

so im assuming you want to know what i want :P

well this is it

How do i make a Graphical User interface that works ontop of OpenGL and SDL ?

no i do not want to use GLUT or freeGLUT or CEGUI or AntTweakBar

i want to make my own :)

And where did you find information on it because i cant find anything using google ("bet people do that to make it more harder for programmers") * coughs

and i dont want to hear how complex it is ,etc i just want somewhere to start that will give me anuff know how to do it for myself thanks
i really tryed hoping that i didnt have to ask but i guess theres no where else to go so

i aslo wanna state that i learn by learning word for word :) not from massive statements with comments which is just not flexible anuff imo

and ! :D i may sound like i dont know what im doing and thats because i do im guesser / reader :D it works

also i dont want to sound like im bashing just annoyed :)
0

Share this post


Link to post
Share on other sites
first you need to make objects such as buttons and menus.
If you're just doing this in SDL, you can blit these to the screen and when you flip the screen they will appear.
If you're using opengl with SDL, you need to make objects/plates and display them in ortho mode.

If you don't know what I am on about, you should learn SDL and OpenGL and it will all become clear.

0

Share this post


Link to post
Share on other sites
[quote name='PGSCreativeDirector' timestamp='1316169753' post='4862384']
so i create a class with a bunch of objects in it using what win32? :) or something else what do i use
[/quote]

For simple things like buttons you really only need to draw a textured quad , change the texture when the mouse moves over that quad or when you click on it (up to you how advanced you want it).

You don't need anything other than SDL (for mouse and keyboard events) and OpenGL (for drawing) to make your GUI.

More advanced controls are obviously more complex and a complete GUI system with customizable controls is a huge undertaking. (Most games don't really need a complete GUI system though, most will do just fine with a few buttons, sliders and input boxes)
0

Share this post


Link to post
Share on other sites
* You have to define what principles the GUI should follow: A traditional [url="http://en.wikipedia.org/wiki/Point-and-click"]point-&-click[/url] GUI? A [url="http://en.wikipedia.org/wiki/Crossing-based_interface"]crossing based[/url] GUI? A [url="http://en.wikipedia.org/wiki/ZUI"]ZUI[/url]? Or what else ...

* A UI does not only consist of a graphical front-end but also has to deal with user input. What input devices do you want to support? Some principles expect a particular kind of input device to be in use.

* Decide what kinds of "widgets" (or whatever the building blocks will be) you need to support.

* Shall internationalization be supported? Which text systems shall be supported?

* Clarify how the UI affects the application data model and how it is supported to read from the data model as well. Do you want to use data binding? Callbacks? Delegates? Signals and slots? Events?

* Shall the GUI be resolution independent?

* Shall the GUI support theming as is often desired (for GUI middleware) for games?

* Shall the GUI be animatable as is often desired for games?

* Shall the GUI (or at least input) be run in an own thread to be e.g. responsive independently on the frame rate? (Okay, this is [i]really[/i] advanced ;))


All this (and probably more) has an influence on answering the OP. "Making" a GUI in the sense of rendering is far after planning it.
0

Share this post


Link to post
Share on other sites
I would suggest some gui coding in java; you'll have better luck rolling your own gui components oce you've seen how they implement theirs.

0

Share this post


Link to post
Share on other sites
Experience of application GUI programming is certainly a good idea, to see how toolkits should be properly implemented - though he might as well try something in the language he's using rather than (possibly) learning a whole new one. For example, for C++, I'd recommend Qt.
0

Share this post


Link to post
Share on other sites
I would also recommend to first see how other GUI systems are implemented and then try to roll your own. I'm currently doing the same thing, mostly borrowing concepts from Qt and WPF.

You basic block would most likely be a Widget or Control which has several parameters (position, size, etc.. come in mind). I would keep the inheritance hierarchy very small (most widgets directly inherit from widget in my case) and perfer composition instead. Depending on your needs this will be a huge amount of work (I'm currently two weeks in and have a plan for at least another month of work).

0

Share this post


Link to post
Share on other sites
[quote name='PGSCreativeDirector' timestamp='1316167569' post='4862376']
hello im a novice at programming tired of crap and wanting to be less crap by creating things that i can work with but for me too do that i need to know where to start because everything is so dam non logical in the world of coding when theres no explanations or tutorials simplfied word by word on how to do what i want

so im assuming you want to know what i want :P

well this is it

How do i make a Graphical User interface that works ontop of OpenGL and SDL ?

no i do not want to use GLUT or freeGLUT or CEGUI or AntTweakBar

i want to make my own :)

And where did you find information on it because i cant find anything using google ("bet people do that to make it more harder for programmers") * coughs

and i dont want to hear how complex it is ,etc i just want somewhere to start that will give me anuff know how to do it for myself thanks
i really tryed hoping that i didnt have to ask but i guess theres no where else to go so

i aslo wanna state that i learn by learning word for word :) not from massive statements with comments which is just not flexible anuff imo

and ! :D i may sound like i dont know what im doing and thats because i do im guesser / reader :D it works

also i dont want to sound like im bashing just annoyed :)
[/quote]

There are a few ways of doing this. The level of complexity and the amount of work that goes into it depends on what features you want. What will your GUI consist of? Screens, buttons, labels, and toggle switches are simple to implement yourself.

Think up a couple of use cases.
1

Share this post


Link to post
Share on other sites
I've been on this mission for a long time as well. One can't argue with the suggestions to use other GUI libraries to get a handle on different API's. Once I did this, I found the GWEN UI. You can grab the entire codebase, I learned tons sifting through it.

http://code.google.com/p/gwen/
0

Share this post


Link to post
Share on other sites
I have to point out. Maybe you should design you hud and menus for your game prior to making gui code. That's if you are making a game. This will allow you to be very precise about the feature set you require.
From there you can design it to be extendable for future generic use in any game you want to make but for now, you'll have the feature set you need for your game.

UI systems can get very complicated and then require alot of support assets (images, video, icons) to make use of their more advanced features. You run the same risk as people sitting down and coding generic game engines instead of the engine they need for their specific game.

A prime example: Will you need Scroll bar functionality? really? will you actually need it?

it's a default part of most UIs you see in applications, but in your game.. will there actually be enough stuff in any menu or text field requiring scrolling?
1

Share this post


Link to post
Share on other sites
[url="http://sol.gfxile.net/imgui/"]This site[/url] walks through the basics of creating an immediate mode GUI using SDL -- take a look, it might be what you're after!
1

Share this post


Link to post
Share on other sites
HI PGSCreativeDirector,

I'm a advocate for developing your own GUI. If you consider the notion that [i][url="http://www.gamedev.net/topic/606675-the-entire-3d-game-world-is-a-graphical-user-interface"]the entire 3D Game-world is a Graphical User Interface[/url][/i], you can apply your techniques developed for GUI event handling, messaging, and process optimization to other game entities. I'm currently developing my 15th iteration of a GUI taking an Entity/Component Approach (Ref [url="http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/"]1[/url],[url="http://www.gamasutra.com/blogs/MeganFox/20101208/6590/Game_Engines_101_The_EntityComponent_Model.php"]2[/url],[url="http://garage.gaspowered.com/?q=su_301"]3[/url]) .

I'm developing my 2D/3D GUI system using [url="http://sourceforge.net/projects/wgois/"]OIS[/url] for input, [url="http://bulletphysics.org/wordpress/"]Bullet[/url] for collision detection, [url="http://www.ogre3d.org/"]OGRE[/url] (DX/OpenGL) for rendering. I use a Entity/Component Model in which Widgets are containers that loosely couple input, collision, and visual components. You can combine these the components in different variations to create different types of widgets, and [i]layer[/i] Widgets on top one another to create more complex Gadgets (composite Widget).

If theres any advice I can offer, I would say that the input and collision components are the primary mechanism for User-Interaction. The visual component is secondary, a representation controlled by the state of the interaction. So, I'd suggest you solve how to 1) manage input , 2) create collision shapes, 3) render visuals, respectively.
0

Share this post


Link to post
Share on other sites
You should start as i did
you have a manager class that has a list of screens and only renders and unpdate the selected screen, create a control base class that has a rectangle(all controls are rectangles) and delegates to any event you want to add, this base class has to have a method update a a method draw, in the method update check if the mouse is on the rectangle and fire the added events here is a sample in c#, if you don't want to use glut for text use glFonts.


[code]

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;


namespace ShadowEngine.VisualControls
{
public delegate void OnClick();
public delegate string Function();
public delegate string FunctionParameter(object objeto);


public abstract class Control
{
protected string accesibleName = "null";
protected OnClick onClick;
protected Rectangle areaRectangle;
protected Color fontColor = Color.White;
protected int zOrder;
protected int displayList;
protected IntPtr textFont;
protected bool discard;

public string Name
{
get { return accesibleName; }
}
}
}


using System;
using Tao.OpenGl;
using System.Drawing;
using ShadowEngine.Sound;

namespace ShadowEngine.VisualControls
{
public class Button : Control, IControl
{
bool isPressed;
string text = "";
string textHoverS, texPressedS, texNormalS;
int textHover, texPressed, texNormal, texCurrent;
int textWidth;
Vector2 textPosition = new Vector2(0, 0);
Vector2 buttonPos;


public Button(Rectangle rectangle, string text, OnClick onClick)
{
buttonPos.X = rectangle.X;
buttonPos.Y = rectangle.Y;
base.zOrder = 0;
this.text = text;
this.areaRectangle = rectangle;
base.onClick = onClick;
texNormalS = "normal.jpg";
texPressedS = "pressed.jpg";
textHoverS = "hover.jpg";
texCurrent = texNormal;
textWidth = Sprite.FontWidth(Glut.GLUT_BITMAP_HELVETICA_18, text);
textPosition = new Vector2(areaRectangle.X + (areaRectangle.Width - textWidth) / 2,
areaRectangle.Y + ((areaRectangle.Height - 15) / 2) + 14);
this.textFont = Glut.GLUT_BITMAP_HELVETICA_18;

}


public Button(Rectangle rectangle, OnClick onClick, string texHover,
string texPressed, string texNormal, IntPtr textFont)
{
buttonPos.X = rectangle.X;
buttonPos.Y = rectangle.Y;
base.zOrder = 0;
this.areaRectangle = rectangle;
this.onClick = onClick;
this.texNormalS = texNormal;
this.texPressedS = texPressed;
this.textHoverS = texHover;
this.textFont = textFont;
this.fontColor = Color.White;
}

public bool Discard()
{
return base.discard;
}

public int ZOrder()
{
return zOrder;
}

public Vector2 GetPos()
{
return buttonPos;
}

public void SetPos(Vector2 vect)
{
buttonPos = vect;
areaRectangle.X = vect.X;
areaRectangle.Y = vect.Y;
textPosition = new Vector2(areaRectangle.X + (areaRectangle.Width - textWidth) / 2,
areaRectangle.Y + ((areaRectangle.Height - 15) / 2) + 14);
}

public Rectangle GetRectangle()
{
return areaRectangle;
}

public string AccesibleName()
{
return accesibleName;
}

public void Create()
{
textHover = ContentManager.GetTextureByName(textHoverS);
texPressed = ContentManager.GetTextureByName(texPressedS);
texNormal = ContentManager.GetTextureByName(texNormalS);
texCurrent = texNormal;
}

public void Update(Cursor cursor)
{
if (areaRectangle.Contains(cursor.Position))
{
texCurrent = textHover;
if (cursor.State == Glut.GLUT_DOWN)
{
isPressed = true;
texCurrent = texPressed;
}
else

if (isPressed)
{
if (cursor.State == Glut.GLUT_UP)
{
isPressed = false;
texCurrent = texNormal;
if (onClick != null)
{
AudioPlayback.PlayOne("click.wav");
base.onClick.Invoke();
}
}
}
}
else
{
isPressed = false;
texCurrent = texNormal;
}
}

public void Draw()
{
Sprite.DrawSprite(areaRectangle, texCurrent);
Sprite.DrawText(textPosition.X, textPosition.Y, text, textFont, fontColor);
}
}
}


[/code]
0

Share this post


Link to post
Share on other sites
Another possibility is to look at embedding webkit. Then you can write a HTML5 UI, similar to how many commercial games use flash. You also get some neat feature like vector graphics, canvas2D and maybe even video (wouldn't it be great if games allowed you to pause and rewind videos). Since you have a full HTML5 renderer you can get more of game themed UI. It might add a bit of overhead though.

I did something like that with QT's QWebView. Unfortunately the webkit build in QT is currently missing some graphical features like shadows, blur and so on.

Otherwise QT itself can be overlayed over a OpenGL context (also it's possible for the QT widgets to be rendered in a 2D scene). There's some official demo code for that:
[url="http://labs.qt.nokia.com/2008/06/27/accelerate-your-widgets-with-opengl/"]http://labs.qt.nokia.com/2008/06/27/accelerate-your-widgets-with-opengl/[/url]
[url="http://labs.qt.nokia.com/2008/12/02/widgets-enter-the-third-dimension-wolfenqt/"]http://labs.qt.nokia.com/2008/12/02/widgets-enter-the-third-dimension-wolfenqt/[/url]
[url="http://labs.qt.nokia.com/2006/10/27/gloverlay/"]http://labs.qt.nokia.com/2006/10/27/gloverlay/[/url]

Only problem is that QT by default won't exactly look very gameish, but it's great for editing tools or technical stuff.

There's Awesomium (a webkkit binding lib aimed at games, used in Eve online) which has sadly gone commercial (although if you look around you can find an older GPL'd fork) and there's also Berkelium which uses Chromium rather than webket direct, unfortunately it's a massive pain to build/develop since you need to compile all of Chromium rather than just using libwebkit.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0