openGL 2.0 with jpeg textures

Hi devs,

I have a problem texturing a plane with textures with opengl 2.0. I am able to make the aircraft with colors, but as soon as I try to apply textures, I'm not. Instead, I see a shaded gray screen. So I guess that the vertices of the geometry and the viewport, etc. are correct, but something wrong with the application of textures. Does anyone have a sample code snippet to bind the texture on a plane using opengl 2.0? I want to use the triangle strip.

Here are the steps I used to create a simple plan with a texture

-Once I've created the foreign window and initiated openGL.

-This is my plane vertices and texture coordinates

summits [0] = - 10.0f;
summits [1] = - 10.0f;
vertices [2] = - 10.0f;

summits [3] = 10.0f;
summits [4] = - 10.0f;
summits [5] = - 10.0f;

summits [6] = - 10.0f;
summits [7] = 10.0f;
summits [8] = - 10.0f;

summits [9] = 10.0f;
summits [10] = 10.0f;
summits [11] = - 10.0f;

textures [0] = 0;
textures [1] = 0;
textures [2] = 1;
textures [3] = 0;
textures [4] = 0;
textures [5] = 1;
textures [6] = 1;
textures [7] = 1;

const char * = vSource
"precision float mediump;
"uniform mat4 u_projection;
"attribute vec2 a_TexCoordinate;
"attribute vec4 a_position;
"attribute vec4 a_color;
"various vec4 v_color;
"various vec2 v_texCoordinate;
"Sub main().
"{"
"gl_Position = u_projection * a_position;
"v_texCoordinate = a_TexCoordinate;"

"v_color = a_color;"
"}";

const char * fSource =
"various lowp vec4 v_color;
"u_Texture sampler2D uniform;
"various vec2 v_TexCoordinate;
"Sub main().
"{"
"gl_FragColor = v_color;"
"gl_FragColor = texture2D (u_Texture, v_TexCoordinate);"
"}";

-J' compiled the fragment and vertex shader and related program

I created the projection with perspective view matrix

GLuint projectionLoc is glGetUniformLocation (program, "u_projection");.
GLfloat left = - 4.0f;
GLfloat right = 4.0f;
GLfloat low = - 3.0f;
GLfloat top = 3.0f;
GLfloat zNear = 4.0f;
GLfloat zFar = 50.0f;
GLfloat proj [16] = {2.0 * zNear / (right-left), //0}
0, //1
0, //2
0, //3
0, //4
2.0 * zNear / (up-down), //5
0, //6
0, //7
(right + left) / (right - left), //8
(top + bottom) /(top-bottom), //9
-(zFar+zNear) /(zFar-zNear), //10
-1, //11
0, / / 12
0, / / 13
-(2 * zFar * zNear) /(zFar-zNear), / / 14
0}; 15

-Generated vertex and filled with data
glGenBuffers (1, & vertexID);
glBindBuffer (GL_ARRAY_BUFFER, vertexID);
glBufferData (GL_ARRAY_BUFFER, sizeof (vertices), tops, GL_STATIC_DRAW);

-Generated in buffers for texture coordinates. It is perhaps here lies the problem.

glGenBuffers (1, & textureId);
glBindBuffer (GL_ARRAY_BUFFER, textureId);
glBufferData (GL_ARRAY_BUFFER, sizeof (textures), textures, GL_STATIC_DRAW);

-The extracted texture assets/images folder

UINT textureArray [1];

QString appFolder(QDir::homePath());)
appFolder.chop (4);
QString path = appFolder + ' / app/native/assets/images/left.jpg ';

-J' used the method CreateTextures of the http://perso.limsi.fr/jacquemi/IG-TD/texjpeg.cpp link

CreateTexture (textureArray, path.toAscii () .data (), 0);

-Set viewport and activated 2d, texture etc.

glViewport (0, 0, surface_width, surface_height);

Typical render pass
glClear(GL_COLOR_BUFFER_BIT |) GL_DEPTH_BUFFER_BIT);

glClearDepthf(1.0f);
glClearColor (0.0f, 1.0F, 0.0f, 1.0F);

glEnable (gldisable(gl_cull_face));

glEnable (GL_TEXTURE_2D);

glEnable (GL_BLEND);

-Permitted and bind the vertex data

glEnableVertexAttribArray (positionLoc);
glBindBuffer (GL_ARRAY_BUFFER, vertexID);
glVertexAttribPointer (positionLoc, 3, GL_FLOAT, GL_FALSE, 3 * sizeof (GLfloat), 0);

-Permitted and bind texture information. It is once again where the lies of the question can be

glEnableVertexAttribArray (textureLoc);
glBindBuffer (GL_ARRAY_BUFFER, textureId);
glVertexAttribPointer (textureLoc, 2, GL_FLOAT, GL_FALSE, 4 * sizeof (GLfloat), 0);

glUniformMatrix4fv (projectionLoc, 1, false, proj);
glUniform1i(textureLoc,0);

-Drew tables with GL_TIANGLE_STRIP

glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);

Disable the berries of the attribute
glDisableVertexAttribArray (positionLoc);
glDisableVertexAttribArray (colorLoc);
glDisableVertexAttribArray (textureLoc);

-Stamps exchanged

int rc = eglSwapBuffers (egl_disp, egl_surf);
If (rc! = EGL_TRUE) {}
fprintf (stderr, "Swap buffer failed\n");
} else {}
fprintf (stderr, "Swap buffer passed\n");
}

-Thanks in advance

~ {A * beep * osh}

Try to capitalize the "t" in this line

"various vec2 v_texCoordinate;

in your vertex shader and see if that helps.

Tags: BlackBerry Developers

Similar Questions

  • Code base openGL 2.0 with waterfalls

    Hi devs,

    I am new to the BB 10 and also in C++ development.

    Can someone help me set up the openGL code 2.0 with waterfalls (with overlay or underlay). In the documentation, samples are in openGL 1.1 with waterfalls or Core with 2.0. I just need a sort of triangle of basic Hello of a sample.

    Thank you

    OK I cracked! I had to comment under opengl function to make it work.  To use screen_create_window or screen_create_window_type or screen_create_window_type_pv according to the display. It's my guess. Thank you guys for your support. Now the real development begins!

    if (screen_create_window(&mScreenWindow, mScreenCtx)){
            fprintf(stderr,"Error while creating screen window");
        }
        else{
            fprintf(stderr,"Screen Window created\n");
        }
    
  • How can I reconnect believed with jpeg

    They used to be in the opening, but I have taken the plunge in Photos for all 142 000 photos...

    I used Powerphotos (Fortunately there) to find duplicates.  It identifies raw / jpeg pairs as duplicates, but in some cases they are always connected, and the appropriate badge appears.  In other cases, they appear to be detached.  So I need to join them again.  Photos help is silent...

    (I've got duplicates of pre opening days when I used Photoshop Elements library... digital photo collection, started in 2000 and has had a number of homes.)

    In other cases, they appear to be detached.  So I need to join them again.  Photos help is silent...

    You can combine the pairs once again export and re-import.

    • Export to a folder on your desktop with the JPEG and RAW file "file > export > export original unmodified.
    • Make sure that the file names are the same and only the filename extension deferred.
    • Delete versions in the photos of the library and empty the recently deleted album.
    • Then reimport the pair of photos.

    The picture should now appear again as stacked pair RAW + JPEG.

  • Bug: OpenGL @ 480 p with the new Apple TV 4

    I have a Panasonic 480 p plasma monitor. Apple TV 4 is supposed to be compatible with 480 p, however, there seems to be a bug in the operating system during the launch of the games that are based on the OpenGL (I guess it's OpenGL).

    Everything works fine until I have run a game that is 3D - then the screen goes black and I get the message "no signal" TV. I have to switch to a different entry, click on the remote a few times and then switch to the Apple TV input to get video is displayed again. It seems that during the initial loading of the game, the AppleTV sends a resolution of 1080 p (I guess) that cannot display my TV.

    It happens with any game that uses the 3D is not a problem of developer 3rd party.

    Here is a video of what happens:

    https://www.YouTube.com/watch?v=je3L7YuH560

    I hope that someone from Apple sees this and it may degenerate into OS developers!

    We are all of the users like you.  Give your comments directly to Apple.  http://www.Apple.com/feedback/AppleTV.html

    Good day.

  • How can I create and display the cuboid with a texture?

    I want to create and display and animate (rotation and Flex) a cuboid with a specific texture for any side. Can someone help me?

    You should probably look into a 3D engine like Sandy3D or Away3D.

  • How to create a transparent 3D object with some textured tasks (CS6)?

    So I want to find a way to create a 3D object without being all white and opac... I tried to decrease the opacity, but it decreases the other textures (layers) too...

    Thanks for the help!

    In the library of materials, make a click on the right where is the folder icon and choose 'New Texture'. Photoshop will open a new file for you. To design the texture of opacity, you should only use grayscale: Black will be transparent, white opacque, gray will be semitrasparent (the lighter to, the more opaque). Close and save you texture once you're done, you should see your object 3d with the transparent and opaque areas.

  • 5 Lightroom import not shooting information with JPEG files

    When I shoot in raw 5 Lightroom doesn't have no problem importing my shooting information.  I try the super fine jpeg on an Olympus MDGs em 10 mark ii.  Lightroom matter very good photos, but there is no shooting of information that accompanies the photos.  Anyone know of a fix?  Thank you.

    Triple-check that you do not have an import of metadata preset active.  In the import window, right column, under apply during import, make sure that metadata are set to None before importing JPEG files:

    If this does not help, please download a JPEG sample directly from the camera (not imported by LR) card to Dropbox or similar and post the link here. We will check that indeed the EXIF metadata that are compatible with LR 5.

  • I can do a slideshow without flash using Flash with JPEG gif files?

    Given that Flash .swf is not supported in iOS. I wanted to make a simple slideshow with high quality JPEG files. How can I do this?

    Wait instead of Flash using jQuery.  There are a variety of solutions redy-made, just search Google or visit the Dreamweaver forum and ask there.

  • Add Zoom PDF functionality once App already been published in a single edition with jpeg settings

    Hi all

    I've already finished my publication (V1), but he does like a jpeg with no pinch and zoom function.

    I want to update the app afer it again with PDF (V2) function, which is the best way to do it? I don't want to buy a new serial number because it is the same application, but I have to do a new folio to access this feature?

    Thanks a lot for your help.

    OK, I found the solution to re-import just the elements in a new folio, export the new .zip in the producer Folio and update of the asset in the generator of spectator.

    I have still some bugs to solve, but it's OK.

  • Color change with jpeg export

    The color of the exported jpeg image is different from the color of images in Lightroom cc. The image is set to Adobe Standard in Lightroom. I export in sRGB. The exported jpeg image is darker and more saturated. I have a NEC of good quality screen that is regularly calibrated. Operating system is Windows 10.

    What Viewer you use to display the exported JPG file? Microsoft software tends to be less assured than it should be.

  • 1 of about 30 directories with JPEGs would not import into LR 5.7.  Operating system is Windows 10.  How can I import the missing directory?  I tried to import more precisely, but I get an error message on the format of the pix.

    I had a directory on 5.7 LR, but she and everyone else on LR 5.7 got accidentally deleted.  I have re - import all but one of the missing directories.  One missing won't matter with DNG, added / COPY.  My OS is Windows 10.  How can I import this a directory.  I checked the properties of the missing directory with those who imported and they are all the same.

    You can combine catalogs by opening the 'master' catalogue (the one that you want to contain ALL your photos) and then using the command file-> import from another catalogue and pointing to the catalog on the other. If there is more than one catalogue of 'other', this action must be repeated as many times as necessary.

  • Work with jpeg + RAW files

    I use a Canon 70 d camera. I like to shoot in the format RAW + jpeg.

    How to open the two upward during the use of the 13 items?

    I'm looking for the setting so that if ever I open a file I see a jpeg and raw file.

    A few questions:

    Mac or Windows?

    You "import" from the card reader or the camera through the Downloader of the Organizer?

    If so, you checked the check box automatically stack raw and JPEG in the edition/preferences/card reader or the camera?

    If so, to see both versions, use the "detailed" view (shortcut Ctrl D) that shows the battery on the thumbnail icon.

  • timelapse with JPEG

    Hi I have 4 or 5 sequences a GoPro in JPEG images and I would like to import into Premier Pro as of the time but for now, they are obviously very high resolution and I was wondering what was the best workflow for the downsizing to the HD, creating the most beautiful image, they are already in 16:9. Any ideas?

    Batch resize in Photoshop.

    This video shows you how to:

    VIDEO COPILOT | After effects, Plug-ins, tutorials and stock footage for Post Production professional

  • Need help with the texture of the hatching

    I'd appreciate some tips or tricks (Win7, PS CS6).  I try just for fun to recreate a texture similar to this:

    Crosshatch effect.JPG

    (This is a screenshot of http://www.myfonts.com/fonts/ahmet-altun/gulyesa-script/)

    I tried to start by noise on a background layer and using different filters (motion blur, hatch, fiber), but the closest I have is the following, which is not what I want. :

    fibres.JPG

    I well remember seeing a tutorial once in these forums, but I'm not and I don't remember how it's done.

    Here is the tutorial! :

    http://CreativeTechs.com/tips/tip_resources/Photoshop-techniques/Photoshop-techniques-008. PDF

    (you're going to want to "woven wire")

    link to useful texture/models:

    http://www.Peachpit.com/articles/article.aspx?p=170987

    -janelle

  • model with veneer texture effect

    I need to make a template that looks like kitchen or bathroom tiles. The squares are of course quite simple, but I wanted to give the broth a little texture, I used effect > texture > texture veneer, and then sets the model. When I apply the model he created some huge white areas, I believe caused by the effect of texture veneer. I tried to put on a mask of clipping around the thing whole brefore defining the model, but it did not help. Without effect, it just seems how it should. Anyone know of a way around this?

    Select the object that you used initially to define the pattern sample.

    Effects > DocumentRasterEffectsSettings: set the value of the Add_Around object to zero.

    Now use this object to redefine the shade of reason. (You can AltDrag it and drop on the original pattern shade.)

    IE7

Maybe you are looking for