Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

NEED HELP! Window displays nothing :/ OpenGL & SDL

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
No replies to this topic

#1 CoffeeandCode   Members   

188
Like
0Likes
Like

Posted 18 April 2013 - 12:19 AM

Hello.

I have been working on a game engine for a couple of days now and I've had it rendering a colourful cube and playing sounds in OGG format, but, after refractoring my code-base to make things easier it no longer displays the cube! (This happened when I put the shader program and methods into a seperate class)

What could be the problem?

 

OpenGL/SDL2 context class:

class RenderContext{
	public:
		RenderContext();
		~RenderContext();

		void draw();

		//void swapbuffers();

		int16_t good;

		ShaderProgram *program;

	private:
		WindowSDL *window;
		FontLoading *fonts;
};

 

 

 

ShaderProgram blass:

class ShaderProgram{
	public:	
                ShaderProgram(){
		}

		ShaderProgram(const char *vsPath, const char *fsPath){
			int32_t compileStat, linkStat;
			uint32_t vertexS = glCreateShader(GL_VERTEX_SHADER);
			uint32_t fragS = glCreateShader(GL_FRAGMENT_SHADER);

			string vsSource = LoadFile(vsPath);
			string fsSource = LoadFile(fsPath);
			const char *source = vsSource.c_str();
			glShaderSource(vertexS, 1, &source, NULL);
			source = fsSource.c_str();
			glShaderSource(fragS, 1, &source, NULL);

			glCompileShader(vertexS);
			glGetShaderiv(vertexS, GL_COMPILE_STATUS, &compileStat);
			if(compileStat == 0){
				char BUFFER[256];
				glGetShaderInfoLog(vertexS, sizeof(BUFFER), NULL, BUFFER);
				cerr << "-!- Error compiling vertex shader: " << BUFFER << endl;
				good = false;
				return;
			}

			glCompileShader(fragS);
			glGetShaderiv(fragS, GL_COMPILE_STATUS, &compileStat);
			if(compileStat == 0){
				char BUFFER[256];
				glGetShaderInfoLog(fragS, sizeof(BUFFER), NULL, BUFFER);
				cerr << "-!- Error compiling fragment shader: " << BUFFER << endl;
				good = false;
				return;
			}

			program = glCreateProgram();
			glAttachShader(program, vertexS);
			glAttachShader(program, fragS);

			glLinkProgram(program);
			glGetProgramiv(program, GL_LINK_STATUS, &linkStat);
			if(!linkStat){
				cerr << "-!- Error linking program." << endl;
				good = false;
				return;
			}

			good = true;
		}

		void getUniform(uint32_t &location, const char *uniformName){
			location = glGetUniformLocation(program, uniformName);
			assert(location != 0xFFFFFFFF);
		}

		void bind(){
			glUseProgram(program);
		}

		void unbind(){
			glUseProgram(0);
		}

		~ShaderProgram(){
			glDeleteProgram(program);
			glUseProgram(0);
		}

		bool good;
		uint32_t program;
};

 


Included a screenshot of output now and a screenshot of output then.

Thanks.

 

Screenshot from 2013-04-16 23:12:34.png

Screenshot from 2013-04-18 18:12:26.png






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.