Duke4.net Forums: Drawing a triangle on top of Duke - Duke4.net Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Drawing a triangle on top of Duke

User is offline   nerozero 

#1

Hey guys,

I am trying to understand more how the drawing and buffers are handled in eduke and the shaders. To do this I thought I would try and draw a simple triangle on the screen but certain points are still confusing me in how they are handled in eduke as most things seem to be compiled at run time.

Here is my code for drawing a simple triangle that I am just hooking into polymer.cpp in a place I know that is getting called:

        glGenVertexArrays(1, &vao);
	glBindVertexArray(vao);
	
	glGenBuffers(1, &vbo);
	glBindBuffer(GL_ARRAY_BUFFER, vbo);
	// Create the buffer, but don't load anything yet
	glBufferData(GL_ARRAY_BUFFER, 7*3*sizeof(GLfloat), NULL, GL_STATIC_DRAW);
	// Load the vertex points
	glBufferSubData(GL_ARRAY_BUFFER, 0, 3*3*sizeof(GLfloat), vertices); 
	// Load the colors right after that
	glBufferSubData(GL_ARRAY_BUFFER, 3*3*sizeof(GLfloat),3*4*sizeof(GLfloat), colors);
	
	// Find the position of the variables in the shader
	positionID = glGetAttribLocation(shaderProgramID, "s_vPosition");
	colorID = glGetAttribLocation(shaderProgramID, "s_vColor");

	glVertexAttribPointer(positionID, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glVertexAttribPointer(colorID, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glUseProgram(shaderProgramID);
	glEnableVertexAttribArray(positionID);
	glEnableVertexAttribArray(colorID);

	glDrawArrays(GL_TRIANGLES, 0, 3);



Main points of confusion being the vertex variables as I couldn't find what I was looking for in the vertex shader code, seems the variables are T, B, N, nextFrameData and nextFrameNormal but not sure what they are, could anyone help me correct this in to something that would run in polymer.cpp and draw the triangle to the screen?

Thanks!

This post has been edited by nerozero: 22 September 2017 - 01:15 AM

1

User is offline   Hendricks266 

  • Weaponized Autism

  #2

I think that's a question only Plagman can answer.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options