• Advertisement

saman_artorious

Member
  • Content count

    24
  • Joined

  • Last visited

Community Reputation

145 Neutral

About saman_artorious

  • Rank
    Member
  1. rotate a bitmap image

    I do not know how to rotate bitmap BGR image of size 800 * 600 * 3 by 90 degrees. If it was an image with a header, the solution would be: QImage srcImg(":/icon.png"); QPoint center = srcImg.rect().center(); QMatrix matrix; matrix.translate(center.x(), center.y()); matrix.rotate(90); QImage dstImg = srcImge.transformed(matrix); QPixmap dstPix = QPixmap::fromImage(dstImg); I read the whole image in a 800 * 600 * 3 image. Next, before I render it to the screen, I need to rotate it by 90 degrees.
  2.   I want to get RGB values from a 24 bit BGR data. This data is from a raw image without a header. I don't know how to convert the index of the buffer to its corresponding RGB values. here is what I have done:     window_width  = 800;     window_height = 600;     size = window_width * window_height;     pixels = new float[size*3];     for(int i = 0, j = 0; i < size*3, j < size; i += 3, j++)     {         pixels[i+2] = bytes[i];     }     updateGL(); void GlWidget::paintGL() {     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);     glDrawPixels(window_width,window_height,GL_RGB,GL_FLOAT,pixels); } what am i missing?
  3. bind a bitmap raw data as texture to gl

    this shows how to bind an image to texture and not a bitmap.
  4. hi, I am receiving a bitmap of size 800 by 600 with RGB 24 bits. When I receive this bitmap from the other machine, I need to bind it to gl widget. what crossed my mind is to do the following, however I am not quite sure if it is correct:     initializeGLFunctions();     GLuint vboId;     glBindBuffer(GL_ARRAY_BUFFER, vboId);     glBufferSubData(GL_ARRAY_BUFFER, 0, 800 * 600 * 3 * sizeof(int), &buffer[0]);     glBindBuffer(GL_ARRAY_BUFFER, 0); is this the right way to bind bitmap to gl? I would also thank if you mention how to declare the vboId in the second line.
  5. I want to create a texture when I receive a byte array. This byte array is converted first to QImage and after I bind it to the texture. When I run the program, it shows it for a second and then it jumps out. Do you know why?   This is where I receive the byte array: void GlWidget::pixmapCatchFromForm(QByteArray bytes) {     QImage image((const uchar* )bytes.constData(), glWidth, glHeight, QImage::Format_ARGB32);     texture = bindTexture(image);     qDebug() << texture; // returns 1 } and here I render: void GlWidget::paintGL() { //! [5] glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); QMatrix4x4 mMatrix; QMatrix4x4 vMatrix; QMatrix4x4 cameraTransformation; cameraTransformation.rotate(alpha, 0, 1, 0); cameraTransformation.rotate(beta, 1, 0, 0); QVector3D cameraPosition = cameraTransformation * QVector3D(0, 0, distance); QVector3D cameraUpDirection = cameraTransformation * QVector3D(0, 1, 0); vMatrix.lookAt(cameraPosition, QVector3D(0, 0, 0), cameraUpDirection); //! [6] shaderProgram.bind(); shaderProgram.setUniformValue("mvpMatrix", pMatrix * vMatrix * mMatrix); shaderProgram.setUniformValue("texture", 0); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture); glActiveTexture(0); shaderProgram.setAttributeArray("vertex", vertices.constData()); shaderProgram.enableAttributeArray("vertex"); shaderProgram.setAttributeArray("textureCoordinate", textureCoordinates.constData()); shaderProgram.enableAttributeArray("textureCoordinate"); glDrawArrays(GL_TRIANGLES, 0, vertices.size()); shaderProgram.disableAttributeArray("vertex"); shaderProgram.disableAttributeArray("textureCoordinate"); shaderProgram.release(); }
  6. OpenGL encircle any point on the screen

    I solved the problem. I calculated the central coordinate of the target circle and added it to the original drawing which is rendered at (0,0).  
  7. How can I draw a circle surround any given point on the screen? Normally, OpenGL draws the circle centered at (0,0). My position indicator consists of pixels rendered as rectangles. The number of pixels is a multiplication of angle and range given to me. For example, if ppi shall be drawn for 360 degree and range 1000, then I draw 360 * 1000 pixels on the screen. Accordingly, any point is detected with its relevant angle and range. Let's say a point exists at 50 degree and range 500. How can I encircle that point now?
  8. render image raw data to texture

    VNC is a good way, but, I don't think that it supports compression/decompression. That's why I need to write the app myself. Thanks for your idea though, I found it very useful.
  9. transfering x,y coordinates from one machine to another

    I don't think so, what I was afraid of, and what the fellows told me was if the resolution and monitor sizes differ, relative or percentage values could not be accurate.   for example, x:60 y:10 on a machine one with resolution: 1024:768 19 inch may not absolutely refer to the same point on machine 2 with resolution: 1360:768 same size. By the way, we came to an agreement to use the same widget size and resolution for two machines. However, I still like to know if the relative case can also direct me towards accurate results.
  10. render image raw data to texture

    OpenGL requires a texture, because the texture has more informations like how to handle accesses outside the normal co-ordinates range, how to do sub-texel sampling, and so on. However, you can load texel data into the full texture (glTexImage2D) or into a rectangular part of it (glTexSubImage2D). You can load raw data or already compressed data (although the later feature requires a specific minimum API version / extension).   Thanks for the hint. You know, I have done the same things, However, what I do not desire is high CPU consumption due to updating the screen 25 times per second. I receive 25 frames per second, load raw data into texture and then update the screen. This method takes much consumption, around 80% of CPU. A fellow, On the other hand, suggested me to use VLC Plugin for displaying the frames, you do have any information about using VLC plugin? by the way, I think I cannot progress with OPenGL anymore now.
  11. undefined reference

    I am trying to run a program : http://ogldev.atspace.co.uk/www/tutorial16/tutorial16.html However, I get undefined reference to some function mentioned below, which is weird, because all those function and their headers are included in the tutorial source. /tmp/ccsp9wYo.o: In function `RenderSceneCB()': tutorial16.cpp:(.text+0x14): undefined reference to `Camera::OnRender()' tutorial16.cpp:(.text+0x128): undefined reference to `Pipeline::GetTrans()' tutorial16.cpp:(.text+0x215): undefined reference to `Texture::Bind(unsigned int)' /tmp/ccsp9wYo.o: In function `SpecialKeyboardCB(int, int, int)': tutorial16.cpp:(.text+0x27e): undefined reference to `Camera::OnKeyboard(int)' /tmp/ccsp9wYo.o: In function `PassiveMouseCB(int, int)': tutorial16.cpp:(.text+0x2bd): undefined reference to `Camera::OnMouse(int, int)' /tmp/ccsp9wYo.o: In function `main': tutorial16.cpp:(.text+0xa9b): undefined reference to `Camera::Camera(int, int)' tutorial16.cpp:(.text+0xba3): undefined reference to `Texture::Texture(unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' tutorial16.cpp:(.text+0xbce): undefined reference to `Texture::Load()' collect2: ld returned 1 exit status This is very weird, Can anyone running Linux do me a favor to try to run this program, I want to see where the problem comes from. (Don't forget to install libMagick with apt-get install libmagick++-dev)
  12. render image raw data to texture

    Really? I didn't know I can do that. What I have already asked you is to get the raw data, create texture and map it at the background. Can I directly load raw data without using textures?
  13. render image raw data to texture

    A iine like GLuint GLCAM_TEX; is missing at the beginning of the code snippet.     The texture is "saved" when invoking glTexImage2D, so to say. In fact, OpenGL is instructed to take the pixel data and to make a texture from it. The data is expected to be in pData array, copied there from the data stream received from the socket.     Now I'm coming to a kind of sermon... ;)   I'm under the impression that you more or less literally take what you get. With all due respect, that way is prone to fail miserably. Please, oblige yourself and try to understand how the provided code snippet works. There a dozens of tutorial how to texture with OpenGL on the internet. There are the manual pages for the OpenGL API, too. And here (and elsewhere) is a forum with people willing to help.   E.g. the glTexImage2D deals with the extent, data type, and component structure of the raw as well as of the texture data. You can't make this right if you don't know how glTexImage2D works. Look at the GL_UNSIGNED_BYTE specifier in the invocation above, and then look at the type of pData, which is an array of unsigned int. Well, there is no clear definition of what "unsigned int" actually means, but be sure that it does not match GL_UNSIGNED_BYTE. This is mentioned here not to blame the poster (he's done a good job to help you), but to show that an understanding of things is necessary also when adopting foreign code snippets.   Another point is that you're speaking of "a widget to render the texture to". Well, OpenGL doesn't define anything like a widget, and you gave no information of what API you use to define those widget. So we can't know what the solution could be. Maybe you mentioned it in another of your posts (I recently saw a second post from you), but you should write each thread so that it is self-contained (or, at least, references another post that contains enough information).   Thanks You, I will do review the function usages. You know, this code we have above, is what we do on our side. On the other side, the machine send the raw data. Could you please guide me what function I need to know to do that part as well.
  • Advertisement