JavierGonz

Members
  • Content count

    4
  • Joined

  • Last visited

Community Reputation

115 Neutral

About JavierGonz

  • Rank
    Newbie
  1. #SelknamDefense is Awesome, I'm just playing the beta, try it! http://www.bad-games.com/
  2. OpenGL Editing pixel of a texture

    And my shader setup   vertexSrc = "attribute vec4 position; attribute vec4 inputTextureCoordinate; varying vec2 textureCoordinate; void main() { gl_Position = position; textureCoordinate = inputTextureCoordinate.xy;}"; fragmentSrc = "varying highp vec2 textureCoordinate; uniform sampler2D videoFrame; precision mediump float; void main() { gl_FragColor = texture2D(videoFrame, textureCoordinate); }";   //Position of the triangle (x,y,z) why 4 D:! //the value is for example, 0.4f is 40% of the glViewPort. float size = 1.0f; vertexArray[0]  =  -size; vertexArray[1]  =   size; vertexArray[2]   =  0.0f; vertexArray[3]  =  -size; vertexArray[4]  =  -size; vertexArray[5]   =  0.0f; vertexArray[6]  =   size; vertexArray[7]  =  -size; vertexArray[8]   =  0.0f; vertexArray[9]  =   size; vertexArray[10]  =  size; vertexArray[11]  =  0.0f;   // Get dimensions from IwGL int w = SCREEN_WIDTH; int h = SCREEN_HEIGHT;   //Set the place where we will draw, in this case is a rectangle of wxh with starting position at (0,0). glViewport(0, 0, w, h) ; glClearColor(0, 0, 0, 1); //Create a program to attach vertex and fragments shaders (Source code) to it. GLuint shaderProgram = glCreateProgram(); //Loading source codes. GLuint vertexShader = createShader(GL_VERTEX_SHADER, vertexSrc); GLuint fragmentShader = createShader(GL_FRAGMENT_SHADER, fragmentSrc);   //Attach a source code to the whole program (ShaderProgram) glAttachShader(shaderProgram, vertexShader); glAttachShader(shaderProgram, fragmentShader);   //Set the location of the "position" variable defined before. //If I remove this, the code works exactly the same way. I think OpenGL set por default //to 0 the first variable in the code. glBindAttribLocation(shaderProgram, 0, "position");   //Linking phase, create a whole functionally program with all attached shaders. glLinkProgram(shaderProgram);   //It's like executing a .exe in windows. glUseProgram(shaderProgram);
  3. OpenGL Editing pixel of a texture

    Here are my drawing routines, and my shaders.   Drawing routine: //We clear the COLOR_BUFFER_BIT, this is the buffer that handle color issues. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);   //Set the Vertex Attribute with VertexArray glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, vertexArray); glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);   // Call IwGL swap instead of egl directly IwGLSwapBuffers();
  4. OpenGL Editing pixel of a texture

    Thanks for the replies.   The problem is the same after the changes, Just the red color is rendering.   // Clear screen for(int y = 0; y < SCREEN_HEIGHT; ++y) for(int x = 0; x < SCREEN_WIDTH; ++x) { if(x % 2 == 0) { screenData[y][x][0] = 179; screenData[y][x][1] = 53; screenData[y][x][2] = 53; } else { screenData[y][x][0] = 255; screenData[y][x][1] = 255; screenData[y][x][2] = 255; } }   glPixelStorei(GL_UNPACK_ALIGNMENT, 1); //Generate a texture and holds the ID in blackboard glGenTextures(1, &blackboard); //Set the current texture in order to modify it glBindTexture(GL_TEXTURE_2D, blackboard); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1280, 720, 0, GL_RGB, GL_UNSIGNED_BYTE, screenData);
  5. Hello,   I'm trying to edit the pixels of a texture in order to create a program like Paint (windows). The idea is that the user can use the mouse to draw in a screen.   This is my code, I create an array of pixels and set it with white and red pixels. But when I try to render the texture I can only see a red quad. (It's only rendering one color) I'm using OpenGL 2.0 for(int y = 0; y < SCREEN_WIDTH; ++y) for(int x = 0; x < SCREEN_HEIGHT; ++x) { if(x % 2 == 0) { screenData[y][x][0] = 179; screenData[y][x][1] = 53; screenData[y][x][2] = 53; } else { screenData[y][x][0] = 255; screenData[y][x][1] = 255; screenData[y][x][2] = 255; } }   glPixelStorei(GL_UNPACK_ALIGNMENT, 1); //Generate a texture and holds the ID in blackboard glGenTextures(1, &blackboard); //Set the current texture in order to modify it glBindTexture(GL_TEXTURE_2D, blackboard); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1280, 720, 0, GL_RGB, GL_UNSIGNED_BYTE, &screenData);