Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 02 Nov 2008
Offline Last Active Today, 12:03 PM

#5309471 space game

Posted by on 05 September 2016 - 12:13 AM

I am still working on my text based and space based game. I have read a good book on c++ and did all the exercises in it. I have learned a lot out of it. I am really trying to become a better programmer.

Um....Good? Is there a question you have?

#5275450 Triangle rendered white only.

Posted by on 12 February 2016 - 01:59 PM

Nopes, unfortunately this didn't change the behaviour. 
I don't even know how to approach debugging shader output, any hints? Also what should be the Item Type of a glsl-shader under Visual Studio 2013? Currently my shader files are set to Custom Build Tool.

check for glGetError is returning zero.

for debugging openGL, you can use CodeXL http://developer.amd.com/tools-and-sdks/opencl-zone/codexl/ which will give you an in-depth look at the resources on the gpu your program has created, and you can try walking through what's wrong. (note, this is an amd product, i'm not sure if it works on NVidia, but it's apparently the successor to glDebugger).

#5250904 Need to be taught to make a 3D MMORPG

Posted by on 06 September 2015 - 04:39 PM

Ok well im starting to use unity's tutorials to make small games like a space invaders sort of game. Then they get harder and harder. If I do it this way shouldn't I be able to accomplish a 3D ORPG?

this all sounds very familiar, is that you LouisZ?

edit: just a joke folks.

#5249907 Should fanfic games be legal?

Posted by on 31 August 2015 - 09:01 AM

You may not be making a profit, but that doesnt mean you arent potentially damaging the IP's universe by making something of your creation, and labeling it as a fan sequel. This might not really be much of a problem with such an old IP, but it's still something to think about.

Depending on the owner of the IP, have you considered contacting them about using their IP in a non-profit way? Since there sounds to be little interest from the original developers, they may or may not be fine with you doing this.

Like alpha says, there are plenty of worlds we would like to use as a basis for our own creation, and it's really a tough question about if this should be considered ok or not. Personally i think so long as you do nothing to harm the brand, and make no profits from there work it should be ok, but always be ready(and prepared to accept) to stop if they say something.

#5246995 Time Based Movement: NPCs Spawning Too Slow when Framerates are High...

Posted by on 16 August 2015 - 06:32 PM

last_time = current_time; should be last_time += (1000.0f/60.0f);

edit: scratch that, i didn't realize you had that logic commented out. it's actually in your spawn timer:

m_spawn_timer = m_spawn_speed; should be m_spawn_timer+=m_spawn_speed;


Too explain, you are not carrying over whatever negative value the last spawn timer was at. let's say m_spawn_speed = 2; and m_delta_speed is 3. then in the next frame m_delta_speed is 1. in your current logic, m_spawn_timer would end up at 2, and by the second frame 1(which really should be 0) so now you've missed a spawning event. by incrementing by the frequency instead of resetting it, you don't lose any accumulation time.

#5244701 Error: pixel shader must minimally write all four components of SV_Target0

Posted by on 05 August 2015 - 12:25 PM

What do you expect to happen with that shader? You have to actually write a pixel out, i.e:

Wrong. If you are rendering to a depth buffer with no render targets bound you still need the pixel shader for alpha testing, but there is no need for any return value.
Well then, how about you tell us the correct way to fix his issue?

I'm on mobile so I can't research his exact issue, but what I'm gathering from the error is that regardless that you have no color buffer bound, the api still expects him to output something, which is likely discarded when no colorbuffer is bound.

#5244688 Error: pixel shader must minimally write all four components of SV_Target0

Posted by on 05 August 2015 - 11:08 AM

What do you expect to happen with that shader? You have to actually write a pixel out, i.e:
struct VS_OUT
        float4 PosH : SV_POSITION;
        float2 Tex  : TEXCOORD;
SamplerState Sampler : register(s0);
Texture2D DiffuseMap;
float4 main(VS_OUT pin) : SV_TARGET
        float4 Diffuse = DiffuseMap.Sample(Sampler, pin.Tex);
        //clip pixels having alpha value < 0.15 (nearly transparent)
        clip(Diffuse.a - 0.15f);
        return Diffuse:

#5244331 Constructor Initializer List and Heap Allocation

Posted by on 03 August 2015 - 11:36 AM

For the purpose of error-checking, a better alternative is, as you mention, initialize mem-pointers to nullptr in the constructor. Then implement another class function such as bool Init(). In that Init() call, you can perform required allocations and other initializations as desired. The benefit of a separate Init() call: you can return an error indication if any part of your initialization fails.

I'm pretty certain this goes against the RAII pattern. While i will say it can be better than a bad allocation in the constructor, i would say that this is an explicit case where exception handling is well suited.

Another option if exceptions are unwarranted is not to directly call your constructor, instead call an intermediary function which does the actual allocation/checks, and then passes that data to your actual object constructor, or reports an error if allocations failed.

#5243626 How does each pixel in Shadow Map correspond to each pixel in scene?

Posted by on 30 July 2015 - 01:13 PM

you render the scene from your lights perspective, and save the depth buffer. you then take another render of your scene from your cameras perspective, but you also tell it the light's position as well, so when you translate your point by your camera matrix, you also translate it by your light's matrix as well. now you have 2 pixels, one for where it would be if seen by the light, and one for your camera. you then can compare if that pixel's light position depth is > then the pixel the light saw at that position. if it is, that means it's shadowed, if it isn't, that means it is visible to the light, and not shadowed.

#5243611 Is flash still relevant for mobile platforms?

Posted by on 30 July 2015 - 12:04 PM

As far as I know Apple haven't wanted to support flash for some time. So is there any point in making a flash game for iOS/Android? Also if you did use flash for say Android, how would you use C++ with it?

I do believe adobe air allows you to package flash games to be distributed for iOS/android(but don't take my word on that, it's just what i've gleamed over time). The workflow flash offers is pretty decent for 2D games, so I'd still recommend it even today, but for web based games, i'd recommend HTML5 over flash.
As for integrating C++ with flash, I have no idea if this is even possible to be perfectly honest.

#5243283 Old-School 3D Wireframe Modelling Tool

Posted by on 28 July 2015 - 04:55 PM

why can't you simply set draw mode to wireframe?

..and use Blender you mean?


why can't you simply set draw mode to wireframe?
(OpenGL: glPolygonMode, DX11: rastdescriptor.fillmode)

Create/model, not draw.

I assume his end goal is to draw those models like they were wireframed. instead of adding the overhead of generating a bunch of redundant vertices for his model in line mode, to instead just use built in api features for drawing models as wiremeshs.
if this is not his end goal, then disregard my comment.

#5243279 Old-School 3D Wireframe Modelling Tool

Posted by on 28 July 2015 - 04:48 PM

Hi, I would like to make some simple 3D wireframe models - such as Elite spaceships, Mercenary buildings, Battlezone etc. I'm talking 80-90's retro wireframe modles here.
Rather than writing my own, I'd like to find something out there which will let me create relatively simple models and export vertex and line information to a simple file format or even C arrays etc.
I don't really want to use something as complicated as Blender if I can avoid it.
Can somebody recommend such a tool?

why can't you simply set draw mode to wireframe?
(OpenGL: glPolygonMode, DX11: rastdescriptor.fillmode)

#5243276 Defining a struct in a header so that I can use my varaible anywhere

Posted by on 28 July 2015 - 04:35 PM

I'm trying to define a struct within my header file to use  the new struct variable  all over my code. I'm having some difficulties doing this. Any examples please? I looked around before coming here but nothing is working. A bare bone example would be appreciated.

I'm ganna go another route, and assume you mean to do the following:

#ifndef MYHEADER_H
#define MYHEADER_H

struct Struct{
   int x;
extern Struct mStruct;
#include "MyHeader.cpp"
Struct mStruct = {0}; //note we initialize it's members to 0.
#include "MyHeader.h"
#include <iostream>

int main(int argc, char **argv){
    std::cout << mStruct.x << std::endl;
The keyword your looking for is extern, it's basically like forward-declaring a function, but for a global variable. you define it in a single implementation file(in this case MyHeader.cpp), and when linking is done the linker will find it and use it for other implementation files.

With that said, I do not advocate the use of extern, and that using it generally means something bad is going on(this is really true if you are using any global variables). as such i don't advocate it's use at all.

edit: ninja'd by frob.

#5243273 Am i missing something, can i sweep like this?

Posted by on 28 July 2015 - 04:27 PM

there is a problem with this method: missing small objects. what happens if object B is small enough to fit between your raycasts?
it's an idea i toyed with before, but imo it has potentials for missis.

#5243270 Organizing rendering code

Posted by on 28 July 2015 - 04:21 PM

So I could use an abstract class from which API specific code inherits:
But using virtual functions in rendering code could bring performance issues to something very time-critical such as the rendering.

Honestly, i think your severely overestimating the performance impact a virtual call has. yes it's a bit of indirect with looking at vtables, but I'm extremely doubtful this is going to ever be your bottleneck.
yet again it comes back to a case of pre-mature optimzations, demonstrate it is an actual issue before looking for complex patterns that results in overcomplicating your design because you think that it might be an issue.