xnewix's Profile User Rating: -----

Reputation: 2 Apprentice
Group:
Contributors
Active Posts:
208 (0.09 per day)
Joined:
23-May 09
Profile Views:
4,892
Last Active:
User is offline Jul 02 2015 05:31 PM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Windows
Favorite Browser:
Internet Explorer
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
25

Latest Visitors

Icon   xnewix has not set their status

Posts I've Made

  1. In Topic: Error, exception conversion to VBO C++/Opengl

    Posted 30 Jun 2015

    Ok so I started again, and placed all shader code in the main function.function. I'm starting to think that it's the way I have set up the relationship between the shaders and the VBO that is causing the problem. If I just include the Shader the program runs, if I include just the VBO's it also runs, but both together and it revolts.

    
    int main(int argc, char **argv) {
    
    	SDL_Init(SDL_INIT_EVERYTHING);
    
    	SDL_Window *window = SDL_CreateWindow("SDL2/OpenGL Demo",
    		SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
    		640, 480,
    		SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN
    		);
    
    	SDL_GLContext glcontext = SDL_GL_CreateContext(window);
    
    	bool running = true;
    	Uint32 start;
    	SDL_Event event;
    	init();
    
    	OpenglVersion oglversion;
    	oglversion.openglversion_output();
    
    	if (glewInit() != GLEW_OK)
    	{
    		std::cerr << "Failed to initialize GLEW." << std::endl;
    		exit(-1);
    	}
    
            //Create TmpShader
    	GLuint program;
    	GLuint testshader = glCreateShader(GL_VERTEX_SHADER);
    
    	std::string vertShaderStr = readFile("verts.txt");
    	const char *vertShaderSrc = vertShaderStr.c_str();
    
    	glShaderSource(testshader, 1, &vertShaderSrc, NULL);
    	glCompileShader(testshader);
    
    	// Create Vertex Program
    	program = glCreateProgram();
    	glAttachShader(program, testshader);
    
    	glLinkProgram(program);
    
    	//CShaderProgram cshaderprogram("verts.txt", "colours.txt");
    	//cshaderprogram.LoadShader("verts.txt", "colours.txt");
    
    	GLuint positionID;
    
    
            //VBO
    	std::vector<int> vertexarray  { -25, 0, -50, 25, 0, -50, 25, 100, -50, -25, 100, -50};
    	std::vector<int> indicesarray { 0, 1, 2, 3 };
    
    	GLuint points_vboId  = 0;
    	GLuint indices_vboId = 0;
    
    	glGenBuffersARB(1, &points_vboId);
    	glBindBufferARB(GL_ARRAY_BUFFER_ARB, points_vboId);
    	glBufferDataARB(GL_ARRAY_BUFFER_ARB, vertexarray.size()*sizeof(GL_INT), &vertexarray[0], GL_DYNAMIC_DRAW_ARB);
    
    	glGenBuffersARB(1, &indices_vboId);
    	glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indices_vboId);
    	glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indicesarray.size()* sizeof(GL_INT), &indicesarray[0], GL_DYNAMIC_DRAW_ARB);
    	
    	//cgrid.GenerateBuffers();
    	
    
    




    	
    	while (running){
    		start = SDL_GetTicks();
    		while (SDL_PollEvent(&event)) {
    			switch (event.type) {
    			case SDL_QUIT:
    				running = false;
    				break;
    			case SDL_MOUSEBUTTONDOWN:
    				mousein = true;
    				SDL_ShowCursor(SDL_DISABLE);
    				break;
    			case SDL_KEYDOWN:
    				if (event.key.keysym.sym == SDLK_p) {
    					mousein = false;
    					SDL_ShowCursor(SDL_ENABLE);
    					break;
    				}
    				if (event.key.keysym.sym == SDLK_ESCAPE) {
    					running = false;
    					break;
    				}
    			}
    		}
    
    		glClear(GL_COLOR_BUFFER_BIT);
    		
    
    		glEnableClientState(GL_VERTEX_ARRAY);	
    
    		spacecamera.Control(window, 0.2, 0.2, mousein);
    		spacecamera.UpdateCamera();
    		
    		//cgrid.DrawBuffers();
    		
    		
    	    glEnableVertexAttribArray(0);
    		
    		// Quad render using triangle strip
    		glBindBufferARB(GL_ARRAY_BUFFER_ARB, points_vboId);
    
    		// Index
    		// Num of Componants
    		// Type
    		// Normalized
    		// Stride 0, no gaps
    		// Pos
    		
    		positionID = glGetAttribLocation(program, "s_vPosition");
    
    		glVertexAttribPointer(positionID, 3, GL_INT, GL_FALSE, 0, 0); // 0
    
    		glUseProgram(program);
    		glEnableVertexAttribArray(positionID);
    
    		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indices_vboId);				
    		
    		//glDrawArrays(GL_QUADS, 0, 4);
    		glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, NULL);
    
    		// glDisableVertexAttribArray(0);		
    		glDisableClientState(GL_VERTEX_ARRAY);
    		
    
    		SDL_GL_SwapWindow(window);
    	}
    	SDL_Quit();
    	return 0;
    }
    
    
    
  2. In Topic: Error, exception conversion to VBO C++/Opengl

    Posted 29 Jun 2015

    After posting I noticed that, so I tried every variation under the sun, and still the same error.
  3. In Topic: C++ open source project for beginners

    Posted 20 Aug 2014

    both, you can either post on my share your project topic on this site contribute to the github repository.

    github tutorial thing

    Coty91 do you know how to use github? at the moment I think you should be able to make a fork, then edit the code that way, once finished you then create pull/merge request.

    if there is anything about the code you want to discuss it can be done through the comments or written into the file.
  4. In Topic: C++ open source project for beginners

    Posted 19 Aug 2014

    okay good, how do you feel about writing a file parser to load blenders .obj files; this task is mostly c++ so you won't need to know any SDL or Opengl.

    Issues link

    you should also be able to comment on these too. I guess that can be used for discussion.

    the program itself needs to be able to store the following.

    comments
    faces
    vertices
    normals
    texture coordinates

    Explanation of .obj file
  5. In Topic: C++ open source project for beginners

    Posted 17 Aug 2014

    Double Post.

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me
Website URL:
Website URL  http://ageofgreeks.darkbb.com/forum.htm

Friends

Comments

Page 1 of 1
  1. Photo

    ce0swald Icon

    23 Jun 2010 - 19:15
    FYI... Your website is down.
Page 1 of 1