Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Azenris

Member Since 22 Oct 2005
Offline Last Active Apr 22 2014 06:54 AM

Posts I've Made

In Topic: Writing to a file

18 June 2012 - 01:48 PM

The while(1); just creates an infinite loop, essentially halting the program displaying the last error message.

The handle is checked before using strcpy (however it was done in the CreateHandle function I didn't give you the source on in the post).

I'll try the std::ios::binary as a second parameter, ty for the suggestion. Posted Image

II thought the (end + 1) would return the position past the . (i.e. the extension)
Ill double check it though.

EDIT:

Not treating the file as binary was the problem, THANKS! :)

In Topic: Colouring verticies vbos/shaders

16 June 2012 - 07:13 PM

Thank you, the naming issue was the problem. TY for all the help.

In Topic: Colouring verticies vbos/shaders

16 June 2012 - 11:55 AM

This shader is the only one being used yea, its nothing more than a demo to learn about GLSL... what a road block at step one Posted Image

I'm curious is everyone else getting the flashing triangle if they run the app?

I tried to change to shaders abit. First I changed the frag shader

in vec4 in_colour;

out vec4 out_colour;

void main(void)
{
	out_colour = in_colour;
}


to

in vec4 in_colour;

out vec4 out_colour;

void main(void)
{
	out_colour = vec4(1.0, 1.0, 0.0, 1.0);
}


The output was then a yellow triangle (no flickering in the colour)

I then tried a second experiment with changing the vertex shader. (after i changed the fragment shader back)

from

uniform mat4 projection_matrix;
uniform mat4 modelview_matrix;

in vec3 in_vertex;
in vec3 in_colour;

out vec4 out_colour;

void main(void)
{
	gl_Position = projection_matrix * modelview_matrix * vec4(in_vertex, 1.0);
	out_colour = vec4(in_colour, 1.0);
}

to

uniform mat4 projection_matrix;
uniform mat4 modelview_matrix;

in vec3 in_vertex;
in vec3 in_colour;

out vec4 out_colour;

void main(void)
{
	gl_Position = projection_matrix * modelview_matrix * vec4(in_vertex, 1.0);
	out_colour = vec4(1.0, 1.0, 0.0, 1.0);
}

This resulted in the original colour flickering. Does this mean anything to you? Maybe I wrote the fragment shader wrong? Does it look right to you? Its like the fragment shader is changing the colour even though all I do is take the input for the output.

In Topic: Colouring verticies vbos/shaders

08 June 2012 - 01:04 PM

Do you mean to modify my render to this

void CApplication::Render(void)
{	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glGetFloatv(GL_PROJECTION_MATRIX, projMatrix);
	glGetFloatv(GL_MODELVIEW_MATRIX, modelMatrix);
	
	shader.sendUniform("projection_matrix", projMatrix);
	shader.sendUniform("modelview_matrix", modelMatrix);

	glBindBuffer(GL_ARRAY_BUFFER, m_vbos[VERTEX_BUFFER]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

	glBindBuffer(GL_ARRAY_BUFFER, m_vbos[COLOUR_BUFFER]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);

	glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, 0);
}

I added the glBindBuffer/glVertexAttribPointer each frame. Doesnt seem to change anything.

I checked sizeof(CColour), it is 12 bytes. Here is what the class looks like


#ifndef HG_GEOMETRY_H
#define HG_GEOMETRY_H

#include "mgl.h"

#pragma pack(push, 1)

class CVertex
{
public:
	CVertex(GLfloat _x, GLfloat _y, GLfloat _z)
		: x(_x)
		, y(_y)
		, z(_z)
	{
	}

	GLfloat x;
	GLfloat y;
	GLfloat z;
};

class CColour
{
public:
	CColour(GLfloat _r, GLfloat _g, GLfloat _b)
		: r(_r)
		, g(_g)
		, b(_b)
	{
	}

	GLfloat r;
	GLfloat g;
	GLfloat b;
};

class CIndex
{
public:
	CIndex(GLuint _index)
		: index(_index)
	{
	}

	GLuint index;
};

#pragma pack(pop)

#endif

In Topic: Colouring verticies vbos/shaders

08 June 2012 - 10:45 AM

I noticed an error in the code i uploaded

shader.bindAttrib(0, "in vertex");
shader.bindAttrib(1, "in_colour");


It uses an incorrect name. However this causes no issues I think as the location 0 is always for verticies. I changed it anyway and the problem still persists.
I also added


if (glGetAttribLocation(shader.m_programID, "in_vertex") != 0)
   	 LOG->Send("Something gone wrong #1");
    if (glGetAttribLocation(shader.m_programID, "in_colour") != 1)
        LOG->Send("Something gone wrong #2");

just to make sure its bound ok.

Still not sure why the colour is flickering. I tried to google and couldnt find anything on it. :(

PARTNERS