View Full Version : I have three beginner questions

05-23-2015, 10:41 PM
Hey! So I have a couple burning questions. For reference this picture is what my game looks like... This is my first opengl project.
I am using glut, gltools, c++ visual studio and acouple other things. If you so desire here is the code with basically only the opengl stuff in it. I have trimmed a ton of code that is actually part of the game itself. ht tp://pas tebin.c om/kvRPJpgZ. You probably dont need to look at it unless you want to....

1. Shader Question

Basically I want a shader that has an array of point lights at various positions with varying intensities. Probably defined like this.

struct Light {
float x;
float y;
float z;
float intensity;

Light Lighting[20];

And basically based on the level geometry and lights, I would love to simulate basic lighting and shadows, also it would be cool to have a circle under the player (like the player is actually their).

How hard would this be to make? How would I pass it my level geometry and light array. (note even though each cuboid is its own QUADS batch it will be easy to make any kind of variable that stores the data).

I am using Glew, GLTools, GLShaderManager, GLBatch, visual studio 2010, probably whatever "GSHL".

If you could just let me know how complicated a shader like this would be let me know. Also if it is easy to find a shader that works like this online if you could link it.

Also what are the difference between the two types of shaders? (Vertex, and fragment).

2. Transparent QUAD BATCHES

So In my program I was experimenting with transparent geometry. And I noticed they looked a little funky
Now I realize this is probably pretty sound as far as the math... but it just doesn't feel right... Should it look differently?

3. Showing through geometry

So as I move thought the level their are sometimes issues where lines end up appearing through cubes. It is only for a short time and it is really quick. But I wish i could get rid of it. I have tried glEnable(GL_DEPTH_TEST); but it doesnt work. Here is the code that I use to draw a batch with an outline.

void DrawWireFramedBatch(GLBatch* pBatch, int c)
case 1:
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vRed);
//The rest of the code is just the same thing with different passed colors
// Draw the batch solid green


// Draw black outline
glPolygonOffset(-1.0f, -1.0f); // Shift depth values

// Draw lines antialiased

// Draw black wireframe version of geometry
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBlack);

// Put everything back the way we found it


Is their a problem with it?

Thankyou so much for reading this! I apologize for how many questions I have here, I suppose I should come sooner.