Jump to content

  • Log In with Google      Sign In   
  • Create Account


ScherzkeCks

Member Since 15 Aug 2013
Offline Last Active Sep 30 2013 03:06 PM
-----

Posts I've Made

In Topic: [Solved]Can't render Text

30 September 2013 - 03:08 PM

Alright, I solved it. And because somebody might search this in the future I will post the solution here:

 

I had to use a VertexArrayObject for the text, then it would draw just fine.

 

I was under the impression, that you don't have to use VAOs but I guess I was wrong.


In Topic: [Solved]Can't render Text

24 September 2013 - 03:57 PM

Yeah, but then it has to be something in between that code and the objectdrawing code which works too.

 

But I am not doing anything in between other than what is written in the code above. The drawText method gets called literally right after the renderObjects() call. 

But even if I just call the drawText() code it doesn't work

 

Just for your information, I am using GLFW instead of SDL but that shouldn't matter as far as I can tell. 


In Topic: [Solved]Can't render Text

22 September 2013 - 04:29 AM

Well I am down to just glClear() the TextDrawing code and the buffer swapping. Also the vertex-Shader only outputs white now. Still only a black screen.


In Topic: [Solved]Can't render Text

21 September 2013 - 04:44 AM

tried both, nothing changed.

 

Could it be some kind of wrong calls to change states? I will post the only other part of code that makes opengl calls after the creation of the window, maybe I am doing something wrong when switching from Model-Drawing to Text-Drawing.

 

This code gets called right before i call the drawText() function (This part works just fine)

void Render::renderObjects()
{

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glUseProgram(programID);

	//Texture-Sampler Location
	GLuint textureSampler = glGetUniformLocation(programID,"myTextureSampler");

	GLint vpLocation = glGetUniformLocation(programID,"VP");
	glm::mat4 vp = GameManager::getSingleton()->getCamera()->getCameraMatrix();
	glUniformMatrix4fv(vpLocation,1,GL_FALSE,&vp[0][0]);

	GLint modelMatrixLocation = glGetUniformLocation(programID,"model");

	std::vector<RenderObject *> objectsToRender;

	objectsToRender = GameManager::getSingleton()->getROManager()->getObjectsToRender();



	for (int i = 0; i < objectsToRender.size(); ++i)
	{
		RenderObject *currentObject = objectsToRender.at(i);
		GLuint vertexArrayObjectName = currentObject->getVertexArrayName();
		if (vertexArrayObjectName == 0)
		{
			//Create vertexarrayobject and buffers etc.
			GLfloat* vertices = NULL;
			GLfloat* normals = NULL;
			GLuint* indices = NULL;
			GLfloat* uvCoordinates = NULL;
			int verticesCount;
			int indicesCount;
			short textureWidth, textureHeight;
			char* textureData = NULL;
			try {
				currentObject->getData(&vertices, &normals, &indices, &uvCoordinates, &verticesCount, &indicesCount, &textureWidth, &textureHeight, &textureData);
			}
			catch (RenderObjectException* e) {
				printf("%s\n", e->what());
				//TODO: remove from objectHandler and further error-Handling
				continue;
			}

			//Texture
			GLuint textureID;
			glGenTextures(1, &textureID);
			glBindTexture(GL_TEXTURE_2D, textureID);
			//glTexStorage2D(GL_TEXTURE_2D,4, GL_RGB, textureWidth, textureHeight);
			//glTexSubImage2D(GL_TEXTURE_2D,0,0,0,textureWidth,textureHeight,GL_BGR, GL_UNSIGNED_BYTE, textureData);
			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, textureWidth, textureHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, textureData); // <- tutorial version but mutable

			glGenerateMipmap(GL_TEXTURE_2D);

			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
			//glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
			//glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );

			currentObject->setTextureID(textureID);

			//creating vertexarray
			glGenVertexArrays(1,&vertexArrayObjectName);
			glBindVertexArray(vertexArrayObjectName);

			currentObject->setVertexArrayName(vertexArrayObjectName);

			//create the buffers belonging to this vertexarray
			GLuint vboId;
			glGenBuffers(1,&vboId);
			glBindBuffer(GL_ARRAY_BUFFER,vboId);
			glBufferData(GL_ARRAY_BUFFER,verticesCount * sizeof(GLfloat) * 4,vertices, GL_STATIC_DRAW);
			glVertexAttribPointer(RENDER_POSITION_LOCATION,4,GL_FLOAT,GL_FALSE,0,0);
			glEnableVertexAttribArray(RENDER_POSITION_LOCATION);

			//normalBuffer
			GLuint normalBuffer;
			glGenBuffers(1,&normalBuffer);
			glBindBuffer(GL_ARRAY_BUFFER,normalBuffer);
			glBufferData(GL_ARRAY_BUFFER, verticesCount * 4 * sizeof(GLfloat),normals, GL_STATIC_DRAW);
			glVertexAttribPointer(RENDER_NORMALS_LOCATION,4,GL_FLOAT,GL_FALSE,0,NULL);
			glEnableVertexAttribArray(RENDER_NORMALS_LOCATION);

			//uvCoordinatesBuffer
			GLuint uvCoordinatesID;
			glGenBuffers(1,&uvCoordinatesID);
			glBindBuffer(GL_ARRAY_BUFFER,uvCoordinatesID);
			glBufferData(GL_ARRAY_BUFFER,verticesCount * sizeof(GLfloat) * 2,uvCoordinates,GL_STATIC_DRAW);
			glVertexAttribPointer(RENDER_UV_LOCATION,2,GL_FLOAT,GL_FALSE,0,0);
			glEnableVertexAttribArray(RENDER_UV_LOCATION);

			GLuint indicesID;
			glGenBuffers(1,&indicesID);
			glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,indicesID);
			glBufferData(GL_ELEMENT_ARRAY_BUFFER,indicesCount * sizeof(GLuint),indices,GL_STATIC_DRAW);

			glBindVertexArray(0);


		}


		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, currentObject->getTextureID());
		glUniform1i(textureSampler,0);

		glm::mat4  modelMatrix = currentObject->getModelMatrix();

		glUniformMatrix4fv(modelMatrixLocation,1,GL_FALSE,&modelMatrix[0][0]);

		glBindVertexArray(vertexArrayObjectName);

		glDrawElements(GL_TRIANGLES,currentObject->getIndicesCount(),GL_UNSIGNED_INT,0);

		glBindVertexArray(0);
		

	}
	
}


In Topic: Not sure where to start.

20 September 2013 - 05:34 AM

 I want us to focus on making the games and not getting images, sprites, sound, etc. working properly. Since I'm not sure on the skills of the people joining I'm not sure what to do for the project.

 

Hearing that I feel that writing your own engine is not what your are looking for, but instead want to get started with the functionality of the game right away.

So you probably should search for Engines that are not too complex. Unity is probably the most known right now but I personally have never worked with it.


PARTNERS