Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Jo
Jan 24, 2005

:allears:
Soiled Meat
Nothing renders. Without it, lighting happens fine, tiling happens fine, etc.
It's only that one line.

Also, I've tried using a different texture that I know is loaded. That makes it blank, too.

EDIT: Even if I spend weeks on a problem, it always feels like I solve it moments after posting about it here. I really do ask here as a last resort. :argh:

Turns out I wasn't unbinding the texture before drawing the lights. Prior to this, I was accidentally binding the mapset texture to the lights. It looked fine (because it was being overlayed in the same place), but when I bound the mostly black texture of the font, things got screwey.

http://img.waffleimages.com/d200802421abaae3c428e2bfbb7eb92f089bc676/dynamicLighting.png

Jo fucked around with this message at 05:03 on Jun 29, 2008

Adbot
ADBOT LOVES YOU

Gary the Llama
Mar 16, 2007
SHIGERU MIYAMOTO IS MY ILLEGITIMATE FATHER!!!
I'd like to create an object-oriented game framework for my 2D games. (I'm using C++ and DX9.) I've got the basic classes down (Engine, Graphics, Game) and my window opening and initializing Direct3D. So yay for that...

Now I'm moving on to a Sprite class, but I'm having difficulty figuring out how to go about things. So far I have something like this, with a few functions for setting and getting the position, velocity, etc.

code:
Sprite.h
--------
LP3DXSPRITE		m_d3dSprite;
LPDIRECT3DTEXTURE9	m_pTexture;
D3DXVECTOR2		m_pos;
D3DXVECTOR2		m_vel;
RECT			m_size;
And what about when I create a Player class? Would it then have an instance of a Sprite object?

code:
Player.h
--------
Sprite* m_Sprite;
...
Should the Sprite class handle the rendering or the Player class? I've also seen people make an IRenderable interface but that seems needlessly complex for a simple 2D game. I've also seen examples of having no Sprite class at all, and just having each object (Player, Planet, Knight, Fireball, etc.) render itself.

It makes sense to me that a Sprite would handle it's own rendering. And yet somehow, I'm just not able to wrap my mind around it. Ugh.

I'd love to see some code examples. So far, all my Googling hasn't turned up much. A lot of crappy code and a lot of non-OOP stuff.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Gary the Llama posted:

Should the Sprite class handle the rendering or the Player class?
How you make your renderer really depends on what you're trying to do with it. If you've only got a few objects on screen with a really simple game, you can get away with spamming draw calls and rebinds and not tightly optimizing everything for efficiency.

You shouldn't have to rewrite code for things that render the same way, but that's not to say you can't have players and any other sort of sprite just call one common sprite draw routine and still be treated as renderables.

OneEightHundred fucked around with this message at 21:00 on Jun 30, 2008

TSDK
Nov 24, 2003

I got a wooden uploading this one

Gary the Llama posted:

Should the Sprite class handle the rendering or the Player class?
Neither. You should have a Renderer class that renders (or adds to a deferred render list) Sprite objects passed in. The Player class then has a pointer to a Sprite object. Roughly speaking:
code:
struct Sprite
{
    LP3DXSPRITE m_d3dSprite;
    LPDIRECT3DTEXTURE9 m_pTexture;
};

class Renderer
{
public:
    void RenderSprite( Sprite *pSprite, D3DXVECTOR2 pos, RECT size );
private:
    ...
};
extern Renderer *g_p_renderer;

class Player
{
public:
    void Update()
    {
        // Update velocity and position
    }
    void Render()
    {
        g_p_renderer->RenderSprite( m_pSprite, m_pos, m_size );
    }
private:
    Sprite *m_pSprite;
    D3DXVECTOR2 m_pos;
    RECT m_size;
};
The reason for doing the split like this is so that you've got a centralised location for when it comes to optimisation time and you want to do some renderable list sorting to minimise state and texture changes.

StickGuy
Dec 9, 2000

We are on an expedicion. Find the moon is our mission.

TSDK posted:

Neither. You should have a Renderer class that renders (or adds to a deferred render list) Sprite objects passed in. The Player class then has a pointer to a Sprite object.
I'm not sure how scalable this approach is when you have, for example, many different types of objects that require special rendering techniques. It would get a bit messy to have all of that in one place.

Paradoxish
Dec 19, 2003

Will you stop going crazy in there?

StickGuy posted:

I'm not sure how scalable this approach is when you have, for example, many different types of objects that require special rendering techniques. It would get a bit messy to have all of that in one place.

In a general sense you could keep that information in the actual Sprite (or RenderableObject or whatever the hell) structure. That would allow you to sort your sprites by rendering technique and still basically localize things in the way TSDK is suggesting. It'd actually be pretty trivial to do something like this if you're using programmable shaders.

StickGuy
Dec 9, 2000

We are on an expedicion. Find the moon is our mission.

Paradoxish posted:

In a general sense you could keep that information in the actual Sprite (or RenderableObject or whatever the hell) structure. That would allow you to sort your sprites by rendering technique and still basically localize things in the way TSDK is suggesting. It'd actually be pretty trivial to do something like this if you're using programmable shaders.
If you're following this approach, then I'd suggest it's better to have the Renderer be more of something that knows about sets of properties (e.g. shaders, textures, etc.) associated with graphics objects. It would then sort these objects somehow based on the graphics state and render they require, but still request that they render themselves. That way the renderer wouldn't have to care about whether some objects use display lists, VBOs, or other special techniques.

TSDK
Nov 24, 2003

I got a wooden uploading this one

StickGuy posted:

I'm not sure how scalable this approach is when you have, for example, many different types of objects that require special rendering techniques. It would get a bit messy to have all of that in one place.
Pretty scalable.

In principle, you can just think of the GPU and video memory as a set global variables that the code is setting. No matter how you separate out the code that sets the states and calls the rendering functions, all of the rendering calls have an effect on each other. You can't add in a HeatHaze object into a generic scene graph without considering the effect of the Bloom object that's already in there, or considering at what point your depth pre-pass is going to kick in and set up the depth buffer.

By splitting rendering effects up between classes, you're trying to pretend that each entity can be rendered in its own right without consideration to other objects, and so then you'll spend the last third of the project having to remember rules like 'the sky box must be the first object in the scene graph' and 'the water nodes must be after the player nodes'.

Both approaches are relatively common in game development, but I tend to prefer the centralised approach in general because it's a bit more 'honest' about what's actually going on, and usually offers better performance and scope for optimisation.

guenter
Dec 24, 2003
All I want out of life is to be a monkey of moderate intelligence who wears a suit. That's why I've decided to transfer to business school!
What's the benefit of the Direct3D effect framework? I'm using it but only trivialy. I understand one of the benefits is being able to specify multiple techniques per effect but that's about all I understand in terms of differences.

I don't really understand the concept of shader passes and I'm not sure if I'm just not doing anything complicated enough in order for their use to make sense to me or if it's because the effect framework is hiding something from me.

I also get the impression that an effect (n .fx file) is not at all the same thing as what people generally refer to as effects (ie. bump mapping or something).

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

guenter posted:

What's the benefit of the Direct3D effect framework? I'm using it but only trivialy. I understand one of the benefits is being able to specify multiple techniques per effect but that's about all I understand in terms of differences.
It has the essentials of a data-driven material system, which means it helps get the information of how to render surfaces out of the renderer code. That translates mainly to more flexibility in materials and not having to hard-code as much.

quote:

I also get the impression that an effect (n .fx file) is not at all the same thing as what people generally refer to as effects (ie. bump mapping or something).
The colloquial definition of "effect" is practically anything that makes something look better, which can happen as a single line of shader code or a mountain of code scattered throughout the renderer. So no. It's a poor choice of a name, but "material" wouldn't be any more correct when FX files can apply to any renderable, i.e. UI components and post-processing, not just "material" surfaces, and "shader" means something else in D3D-speak.

ZorbaTHut
May 5, 2005

wake me when the world is saved

OneEightHundred posted:

I'm not saying that there needs to be a better way to do a kick vote, if anything I think kick votes have repeatedly proven their uselessness. Compulsory voting would be far too easily abusable for griefing.

There are other forms of player moderation, like karma-type systems, but the only one that doesn't suck horribly is "have a shitload of admins." I'm trying to come up with a better way of letting the players clear the shitheads off servers, because if something like that exists, problematic cheaters would not get far, and it would have benefits in getting rid of other problems as well, i.e. griefers.

I've always been a fan of the Puzzle Pirates Blackspot system, in that it lets players punish others . . . but only players with significant standing in the game already, and abuse is punishable, and it's all logged.

newsomnuke
Feb 25, 2007

TSDK posted:

Both approaches are relatively common in game development, but I tend to prefer the centralised approach in general because it's a bit more 'honest' about what's actually going on, and usually offers better performance and scope for optimisation.
It's also easier to change to a different rendering tech, as you have much less to reimplement.

Hanpan
Dec 5, 2004

Is there a XNA alternative for mac development? I'm really into making simple 2d games and have been dabbling in AS3 and Python, but I'm looking for something a little more powerful.

I'd also prefer something which could be used on both Mac and Windows after being compiled.

POKEMAN SAM
Jul 8, 2004

Hanpan posted:

Is there a XNA alternative for mac development? I'm really into making simple 2d games and have been dabbling in AS3 and Python, but I'm looking for something a little more powerful.

I'd also prefer something which could be used on both Mac and Windows after being compiled.

Have you looked at the options available for Python? I know there are a couple 3D engines under Python, and those would be cross-platform, generally.

stramit
Dec 9, 2004
Ask me about making games instead of gains.

Hanpan posted:

Is there a XNA alternative for mac development? I'm really into making simple 2d games and have been dabbling in AS3 and Python, but I'm looking for something a little more powerful.

I'd also prefer something which could be used on both Mac and Windows after being compiled.

If you want to make simple 2d games you should look into Slick for Java. It's a 2d games library which uses OpenGL, so the games should work on Win / *nix and OSX. It seems like it can make some pretty cool 2d games. You can even put your games in Java applets for web play. It's pretty cool if you aren't worried about using Java, and if you want to dabble in OpenGl you can do some pretty cool shader stuff in addition to whats provided in the libraries.

Have a look here: http://slick.cokeandcode.com/

Hanpan
Dec 5, 2004

My only real gripe with using Java is that performance is always going to be an issue and I'm not the most advanced coder in the world. It seems that Java / Flash / Python are my only real option for Mac development though.

Seat Safety Switch
May 27, 2008

MY RELIGION IS THE SMALL BLOCK V8 AND COMMANDMENTS ONE THROUGH TEN ARE NEVER LIFT.

Pillbug

Hanpan posted:

My only real gripe with using Java is that performance is always going to be an issue and I'm not the most advanced coder in the world. It seems that Java / Flash / Python are my only real option for Mac development though.
There's Unity, but it's certainly not free. It uses Mono internally, and I think it supports C# and JavaScript. There's only a handful of games using it, but it looks promising.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
You could try Ogre3D and Irrlicht.

Ferg
May 6, 2007

Lipstick Apathy

OneEightHundred posted:

You could try Ogre3D and Irrlicht.

I'd say Irrlicht over Ogre3D if he's looking for an XNA comparable framework. Ogre3D isn't exactly super super easy to use, and that's one of the benefits you'd get from XNA.

Hanpan
Dec 5, 2004

When I say 2D game, I mean everything will be sprite / pixel based. I assume Unity is not good for things like that.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
It's not really that hard to make a 2D game in a 3D engine, just keep the camera pointed down one axis and make sure you never give anything a velocity or position that'll move it off of that plane. Or put a pair of invisible walls up. Use camera-aligned sprites for graphics (which practically every 3D engine supports). If anything it gives you some artistic flexibility if you ever want to make any elements of it 3D even if the gameplay is strictly 2D.

POKEMAN SAM
Jul 8, 2004

Hanpan posted:

When I say 2D game, I mean everything will be sprite / pixel based. I assume Unity is not good for things like that.

Pygame, then, is pretty much exactly what you want.

Hanpan
Dec 5, 2004

Thanks guys, sorry for the lack of specifics in my question. I'll give pyGame a try.

Entheogen
Aug 30, 2004

by Fragmaster
is there any way to use glMultiDrawElements with VBOs? Specifically I would like to store my index and count arrays on GPU memory, but still use this call. Is this even possible?

EDIT: I checked and it worked with VBOs but indecies were still on client side.


vvvvvvvvvvvvvvvvvvvvvvvvvv
I use OpenGL bindings with Java and have noticed any performance issues, outside of my program taking a couple more seconds on initial load. From what little FPS measurements I did of Java and C++ equivalent OGL programs they were the same.

Entheogen fucked around with this message at 00:45 on Jul 8, 2008

stramit
Dec 9, 2004
Ask me about making games instead of gains.

Hanpan posted:

My only real gripe with using Java is that performance is always going to be an issue and I'm not the most advanced coder in the world. It seems that Java / Flash / Python are my only real option for Mac development though.

It's cool that you are using pygame, but I just wanted to clear something up. For pretty much any game you are going to be working on by yourself or in a small group that is not AAA Java is fine. Performance wise it is slower then C++, but given the scope of the game you are making this will not be a problem.

I work in the industry, and professionally I use C++ with Direct X, and it's great. The performance is nice and it allows for things that are impossible in languages like Java. But for all of my home projects I use Java. It's not as fast, but I find iteration and development time decreased by at least one order of magnitude when I program with it. I find it a lot easier to finish and deploy personal indie projects by using Java. And more of an audience can play them.

My personal feeling is that if you are careful Java is a much better way to aproach indie development then C++. I find it slower, but not slow at all.

Scaevolus
Apr 16, 2007

Stramit posted:

It's cool that you are using pygame, but I just wanted to clear something up. For pretty much any game you are going to be working on by yourself or in a small group that is not AAA Java is fine. Performance wise it is slower then C++, but given the scope of the game you are making this will not be a problem.
This is true. Also, Python is slower than both Java and C++. PyGame works because the performance critical bits (drawing sprites...) are written in C, while the game logic is written in Python.

stramit
Dec 9, 2004
Ask me about making games instead of gains.

Scaevolus posted:

This is true. Also, Python is slower than both Java and C++. PyGame works because the performance critical bits (drawing sprites...) are written in C, while the game logic is written in Python.

Which is also the same reason that OpenGL in Java is fast as well. It uses native code for all the OpenGL calls.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Entheogen posted:

is there any way to use glMultiDrawElements with VBOs? Specifically I would like to store my index and count arrays on GPU memory, but still use this call. Is this even possible?

EDIT: I checked and it worked with VBOs but indecies were still on client side.
NVIDIA and ATI both say the best thing to use is glDrawRangeElements. Off of fairly intensive testing (between myself and the person behind Sauerbraten), it is, even if you need to make repeated calls to it. OpenGL does not have the context switching overhead of D3D, so draw calls are cheap as long as you're not changing state, to the point where MultiDrawElements provides almost no speed benefit. DrawRangeElements does though, according to the vendors it's because it lets the GPU pack the indexes into 16-bit values.

OneEightHundred fucked around with this message at 07:21 on Jul 8, 2008

vanjalolz
Oct 31, 2006

Ha Ha Ha HaHa Ha

Hanpan posted:

Thanks guys, sorry for the lack of specifics in my question. I'll give pyGame a try.

Sorry to muddy the waters, but if you're after easy movement to XNA (being c# based and all) you could try sdl.net with mono on mac. I tried it and it was fairly nice, but quite sparse.

xgalaxy
Jan 27, 2004
i write code
I'm late to the party but the following is an excellent article covering all of the problems with the various timing methods.

http://www.geisswerks.com/ryan/FAQS/timing.html

xgalaxy fucked around with this message at 10:47 on Jul 11, 2008

Sigvatr
Jan 7, 2008

by elpintogrande
I am making graphics for games at my start up game studio here -> http://www.transhumandesign.com

But I am still interested in making games with other people.

Anyone here good at programming and feel like making games? For free or to sell, whatever.

Portfolio -> http://www.sigvatr.com/portfolio

Email me at me (at) sigvatr [dot] com if you're interested.

Jo
Jan 24, 2005

:allears:
Soiled Meat
EDIT:

Jo fucked around with this message at 17:48 on Jul 12, 2008

Namgsemterces
Sep 28, 2001

I shouldn't have fucked with the Pagans.
I'm writing a GUI library for XNA as part of a game that I'm writing as a hobby / learning experience. I made a Container class that is basically a scrollable window. I started using the ScissorRectangle propery of the graphics device to clip anything that gets outside of the bounds of the window. But since the containers can be rendered with rounded corners, I wanted it to be a bit more flexibile.

I had an idea to use HLSL and make a certain color a special transparent color. I could shape it to be rounded to fit on the corners of a window, and then when I make a pass through the effects, it would make anything that matches that special color into a transparent pixel. The GUI rendering is part of its own sprite batch, so anything in the game would still show up around the rounded edges.

The problem I ran into is this: it appears that the HLSL effect is applied to each sprite as it is drawn, and not applied to the spritebatch as a whole. So my technique doesn't work as planned and instead it just works like a normal transparent sprite.

Is there a way to apply the effect to the entire spritebatch after all the sprites have been drawn?

Edit: After some more digging, I think I found the answer to my own question. Render the scene onto a separate buffer, get that as a texture, then render it onto the main buffer and apply the effect.
http://msdn.microsoft.com/en-us/library/bb313868.aspx

Namgsemterces fucked around with this message at 05:39 on Jul 15, 2008

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Namgsemterces posted:

I had an idea to use HLSL and make a certain color a special transparent color.
You could use the alpha channel for that...

Namgsemterces
Sep 28, 2001

I shouldn't have fucked with the Pagans.

OneEightHundred posted:

You could use the alpha channel for that...

Thanks, but you didn't understand my question. If I try to cover up an area inside my clipping rectangle but outside of the area I want rendered (note: I'm talking about non-rectangular shapes, like a rounded rectangle) with something of alpha 0, the part I want covered up would still show up because the alpha 0 would be meaningless. I need to overwrite that rounded area with something that is opaque and then later change that opaque color to an alpha 0. Basically, I'm talking about a mask.

It would be easier to explain with images, but I'm feeling lazy and I already found a working answer, so I'm not going to bother.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Namgsemterces posted:

Thanks, but you didn't understand my question. If I try to cover up an area inside my clipping rectangle but outside of the area I want rendered (note: I'm talking about non-rectangular shapes, like a rounded rectangle) with something of alpha 0, the part I want covered up would still show up because the alpha 0 would be meaningless. I need to overwrite that rounded area with something that is opaque and then later change that opaque color to an alpha 0. Basically, I'm talking about a mask.
You'd write to the framebuffer with 1.0 alpha and render with a blend function that multiplies the source color with the destination alpha.

Of course, you could also use the stencil buffer, which is designed for this sort of thing.

TSDK
Nov 24, 2003

I got a wooden uploading this one

Namgsemterces posted:

Basically, I'm talking about a mask.
Sounds like you should be using the stencil buffer, but it's hard to tell without some diagrams of what you're trying to accomplish.

Namgsemterces
Sep 28, 2001

I shouldn't have fucked with the Pagans.

OneEightHundred posted:

You'd write to the framebuffer with 1.0 alpha and render with a blend function that multiplies the source color with the destination alpha.

Of course, you could also use the stencil buffer, which is designed for this sort of thing.

I did some quick reading on the stencil buffer and it looks like that's the best method. I'll scrap that other stuff. Thanks.

Squido
May 21, 2005
Ask me about being a paedophile.
Hullo, My friend and I are both looking to make a 2d top down scrolling shooter but with 3d graphics. I am looking for advice on what programming language to use.
We are both artists with only basic programming knowledge and due to our problems in finding a programmer nearby we have decided to learn to code it ourselves. I've read the sticky and looked into Pygame, but the screenshots on their site seem to be lacking in much 3d. We are willing to learn pretty much anything, but would like it to be the most appropriate and useful to us perhaps in the future.

The game will probably have a fairly static camera the majority of the time, with the majority of objects on the screen being 3d. As per the genre there would be alot of poo poo going on, I have heard some languages are slightly slower than others, I have no idea if this would effect us though I would guess it would depend more upon the quality of programming and how resource heavy the art assets were.

Obviously I am doing my own research, but i'd like thoughts from some people who know what they're talking about, any advice is appreciated thanks!

Adbot
ADBOT LOVES YOU

Professional Lamer
May 11, 2004

by mons al-madeen

Squido posted:

Hullo, My friend and I are both looking to make a 2d top down scrolling shooter but with 3d graphics. I am looking for advice on what programming language to use.
We are both artists with only basic programming knowledge and due to our problems in finding a programmer nearby we have decided to learn to code it ourselves. I've read the sticky and looked into Pygame, but the screenshots on their site seem to be lacking in much 3d. We are willing to learn pretty much anything, but would like it to be the most appropriate and useful to us perhaps in the future.

The game will probably have a fairly static camera the majority of the time, with the majority of objects on the screen being 3d. As per the genre there would be alot of poo poo going on, I have heard some languages are slightly slower than others, I have no idea if this would effect us though I would guess it would depend more upon the quality of programming and how resource heavy the art assets were.

Obviously I am doing my own research, but i'd like thoughts from some people who know what they're talking about, any advice is appreciated thanks!

If the camera is fairly static, have you considered having a 2D game with pre-rendered sprites (taken from 3D models) or is that not possible? It could save you a lot of trouble in the long run, but if that's not possible you could look into XNA.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply