Search Results

Search found 1174 results on 47 pages for 'square'.

Page 3/47 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • problem with my texture coordinates on a square.

    - by Evan Kimia
    Im very new to OpenGL ES, and have been doing a tutorial to build a square. The square is made, and now im trying to map a 256 by 256 image onto it. The problem is, im only seeing a very zoomed in portion of this bitmap; Im fairly certain my texture coords are whats wrong here. Thanks! package se.jayway.opengl.tutorial; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.ShortBuffer; import javax.microedition.khronos.opengles.GL10; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.opengl.GLUtils; public class Square { // Our vertices. private float vertices[] = { -1.0f, 1.0f, 0.0f, // 0, Top Left -1.0f, -1.0f, 0.0f, // 1, Bottom Left 1.0f, -1.0f, 0.0f, // 2, Bottom Right 1.0f, 1.0f, 0.0f, // 3, Top Right }; //Our texture. private float texture[] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, }; // The order we like to connect them. private short[] indices = { 0, 1, 2, 0, 2, 3 }; // Our vertex buffer. private FloatBuffer vertexBuffer; // Our index buffer. private ShortBuffer indexBuffer; //texture buffer. private FloatBuffer textureBuffer; //Our texture pointer. private int[] textures = new int[1]; public Square() { // a float is 4 bytes, therefore we multiply the number if // vertices with 4. ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4); vbb.order(ByteOrder.nativeOrder()); vertexBuffer = vbb.asFloatBuffer(); vertexBuffer.put(vertices); vertexBuffer.position(0); // a float is 4 bytes, therefore we multiply the number of // vertices with 4. ByteBuffer tbb = ByteBuffer.allocateDirect(texture.length * 4); vbb.order(ByteOrder.nativeOrder()); textureBuffer = tbb.asFloatBuffer(); textureBuffer.put(texture); textureBuffer.position(0); // short is 2 bytes, therefore we multiply the number if // vertices with 2. ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length * 2); ibb.order(ByteOrder.nativeOrder()); indexBuffer = ibb.asShortBuffer(); indexBuffer.put(indices); indexBuffer.position(0); } /** * This function draws our square on screen. * @param gl */ public void draw(GL10 gl) { // Counter-clockwise winding. gl.glFrontFace(GL10.GL_CCW); // Enable face culling. gl.glEnable(GL10.GL_CULL_FACE); // What faces to remove with the face culling. gl.glCullFace(GL10.GL_BACK); //Bind our only previously generated texture in this case gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); // Enabled the vertices buffer for writing and to be used during // rendering. gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); //Enable texture buffer array gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); // Specifies the location and data format of an array of vertex // coordinates to use when rendering. gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer); // Disable the vertices buffer. gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); //Disable the texture buffer. gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); // Disable face culling. gl.glDisable(GL10.GL_CULL_FACE); } /** * Load the textures * * @param gl - The GL Context * @param context - The Activity context */ public void loadGLTexture(GL10 gl, Context context) { //Get the texture from the Android resource directory InputStream is = context.getResources().openRawResource(R.drawable.test); Bitmap bitmap = null; try { //BitmapFactory is an Android graphics utility for images bitmap = BitmapFactory.decodeStream(is); } finally { //Always clear and close try { is.close(); is = null; } catch (IOException e) { } } //Generate one texture pointer... gl.glGenTextures(1, textures, 0); //...and bind it to our array gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); //Create Nearest Filtered Texture gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); //Different possible texture parameters, e.g. GL10.GL_CLAMP_TO_EDGE gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_REPEAT); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT); //Use the Android GLUtils to specify a two-dimensional texture image from our bitmap GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); //Clean up bitmap.recycle(); } }

    Read the article

  • simple collision detection

    - by Rob
    Imagine 2 squares sitting side by side, both level with the ground: http://img19.imageshack.us/img19/8085/sqaures2.jpg A simple way to detect if one is hitting the other is to compare the location of each side. They are touching if ALL of the following are NOT true: The right square's left side is to the right of the left square's right side. The right square's right side is to the left of the left square's left side. The right square's bottom side is above the left square's top side. The right square's top side is below the left square's bottom side. If any of those are true, the squares are not touching. If all of those are false, the squares are touching. But consider a case like this, where one square is at a 45 degree angle: http://img189.imageshack.us/img189/4236/squaresb.jpg Is there an equally simple way to determine if those squares are touching?

    Read the article

  • How to perform simple collision detection?

    - by Rob
    Imagine two squares sitting side by side, both level with the ground like so: A simple way to detect if one is hitting the other is to compare the location of each side. They are touching if all of the following are false: The right square's left side is to the right of the left square's right side. The right square's right side is to the left of the left square's left side. The right square's bottom side is above the left square's top side. The right square's top side is below the left square's bottom side. If any of those are true, the squares are not touching. But consider a case like this, where one square is at a 45 degree angle: Is there an equally simple way to determine if those squares are touching?

    Read the article

  • Computing orientation of a square and displaying an object with the same orientation

    - by Robin
    Hi, I wrote an application which detects a square within an image. To give you a good understanding of how such an image containing such a square, in this case a marker, could look like: What I get, after the detection, are the coordinates of the four corners of my marker. Now I don't know how to display an object on my marker. The object should have the same rotation/angle/direction as the marker. Are there any papers on how to achieve that, any algorithms that I can use that proofed to be pretty solid/working? It doesn't need to be a working solution, it could be a simple description on how to achieve that or something similar. If you point me at a library or something, it should work under linux, windows is not needed but would be great in case I need to port the application at some point. I already looked at the ARToolkit but they you camera parameter files and more complex matrices while I only got the four corner points and a single image instead of a whole video / camera stream.

    Read the article

  • C++ arrays select square number and make new vector

    - by John Smith
    I have to see which of the following from a vector is a square number then make another vector with only the square numbers For example: (4,15,6,25,7,81) the second will be (4,25,81) 4,25,81 because 2x2=4 5x5=25 and 9x9=81 I started like this: { int A[100],n,r,i; cout<<"Number of elements="; cin>>n; for(i=1;i<=n;i++) { cout<<"A["<<i<<"]="; cin>>A[i]; } for(i=1;i<=n;i++) { r=sqrt(A[i]); if(r*r==A[i]) } return 0; } but I am not really sure how to continue

    Read the article

  • Make a <div> square when there is a dynamically changing width based on percentage

    - by Nate
    I am working on a web app that will generate an NxN grid based on the user's selection of N. I want the total width of the grid to be relative (ie 100% of the available space) so that users can print on various paper sizes. I can easily calculate the width of the squares in the grid by % (ie: 100%/N), but I am having issues calculating the height. The height of a web page is always going to be infinite unless I artificially limit it which, like I said, I don't want to do. How can I make the squares in my grid be square versus rectangular when the height and width constraints of my grid are dynamic and not square? Thanks in advance!

    Read the article

  • Javascript Square bracket notation for global variables

    - by Yousuf Haider
    I ran into an interesting issue the other day and was wondering if someone could shed light on why this is happening. Here is what I am doing (for the purposes of this example I have dumbed down the example somewhat): I am creating a globally scoped variable using the square bracket notation and assigning it a value. Later I declare a var with the same name as the one I just created above. Note I am not assigning a value. Since this is a redeclaration of the same variable the old value should not be overriden as described here: http://www.w3schools.com/js/js_variables.asp //create global variable with square bracket notation window['y'] = 'old'; //redeclaration of the same variable var y; if (!y) y = 'new'; alert(y); //shows New instead of Old The problem is that the old value actually does get overriden and in the above eg. the alert shows 'new' instead of 'old'. Why ? I guess another way to state my question is how is the above code different in terms of semantics from the code below: //create global variable var y = 'old'; //redeclaration of the same variable var y; if (!y) y = 'new'; alert(y); //shows New instead of Old

    Read the article

  • Big square ads appear in lower right corner of both IE and Chrome

    - by BrianK
    In both IE and Chrome, large ads appear in the lower right corner of the browser window. Sometime they look reputable like for Microsoft, but sometimes they are big flashing boxes that say "You have won". Right now I am looking at "Need to lose 30 lbs?" I ran Microsofot Security Essentials and it didn't find anything. I then ran Windows Defender Offline (boot from CD). WDO found five things lincluding browser hijack that caused the wrong page to appear after clicking a link. It reported that it cleaned successfully, after which I ran a quick scan to confirm. After rebooting I still see the ads. Do I still have an infection? Any other tools to try? What about ComboFix? Thanks Update: Here's a screenshot - on superuser

    Read the article

  • Mysterious gray square outlines on certain desktop icons?

    - by user74757
    Recently, my hand slipped on my mouse/keyboard and I accidentally increased the icon size. After resetting it and fixing them, I noticed these incredibly annoying small gray outlines around only certain desktop icons. I have one third party program called 'Desktop Restore' that I use to save and restore icon layouts, but I have no reason to believe that it should have anything to do with it. My question is: Is this something in Windows 7? If so, what is it there for and how can I turn it off? Killing explorer.exe and restarting it doesn't fix the problem, not even rebooting...

    Read the article

  • what does square bracket syntax mean above a method in C#, ASP.NET

    - by Alexander
    I am just looking a bunch of codes that I am trying to learn from an open source project and sometimes I see a square brackets above a function such as: [EdmFunction("NerdDinnerModel.Store", "DistanceBetween")] public static double DistanceBetween(double lat1, double long1, double lat2, double long2) or [Bind(Include = "Title,Description,EventDate,Address,Country,ContactPhone,Latitude,Longitude")] [MetadataType(typeof(Dinner_Validation))] public partial class Dinner

    Read the article

  • ImageMagick PDF to JPEG conversion results in green square where image should be

    - by ceejayoz
    I'm attempting to convert a PDF to a JPEG using ImageMagick. The PDF: baby_aRCWTU.pdf The command: convert -density 260 -profile 'SWOP.icc' -profile 'sRGB.icm' 'baby_aRCWTU.pdf' 'baby_aRCWTU.jpg' The resulting JPEG: baby_aRCWTU.jpg As you can see, the text is rendered nicely, but the embedded image shows up as a green square. Any ideas? This occurs with and without the colour profiles. edit: reposted due to broken links

    Read the article

  • Diamond square algorithm.

    - by Gabriel A. Zorrilla
    I'm trying to write the Diamond-Square algorithm in Java to generate a random map but can't figure out the implementation... Anyone with some Java code (or other language) so i can check how the loop is made would be greatly appreciated! Thanks!

    Read the article

  • Regular expression to extract text between either square or curly brackets

    - by ObiWanKenobi
    Related to my previous question, I have a string on the following format: this {is} a [sample] string with [some] {special} words. [another one] What is the regular expression to extract the words within either square or curly brackets, ie. {is} [sample] [some] {special} [another one] Note: In my use case, brackets cannot be nested. I would also like to keep the enclosing characters, so that I can tell the difference between them when processing the results.

    Read the article

  • Convert template from "rounded corners" to "square"

    - by marco92w
    I've downloaded the following template: http://www.styleshout.com/templates/preview/Refresh11/index.html But unfortunately, it has rounded corners and shades. I want it to have square corners and the shades should be removed, too. It should look like this: But I'm not good enough at (X)HTML and CSS so I didn't manage to achieve this. Could you please help me? How could I remove the rounded corners? Please don't say "Take another template" ;) It's also for learning purposes :)

    Read the article

  • Texture coordintes for a polygon and a square texture

    - by user146780
    basically I have a texture. I also have a lets say octagon (or any polygon). I find that octagon's bounding box. Let's say my texture is the size of the octagon's bounding box. How could I figure out the texture coordinates so that the texture maps to it. To clarify, lets say you had a square of tin foil and cut the octagon out you'd be left with a tin foil textured polygon.I'm just not sure how to figure it out for an arbitrary polygon. Thanks

    Read the article

  • Python: writing a program to compute the area of a circle and square

    - by user1672504
    I have a question with an assignment. I'm not sure how to write this program and I really need help! Could someone help me with this? This is the assignment: Write a program that asks the user to enter two values: an integer choice and a real number x. If choice is 1, compute and display the area of a circle of radius x. If choice is 2, compute and display the are of a square with sides of length x. If choice is neither 1, nor 2, will display the text Invalid choice. Sample run: Enter choice: 2 Enter x: 8 The area is: 64.0 Sample run: Enter choice: 1 Enter x: 8 The area is: 201.06176 My attempt: choice = input ('Enter Choice:') choice_1 = int (choice) if (choice_1==1): radius = (int) print('Enter x:',radius) pi = 3.14159 area = ( radius ** 2 ) * pi print ( 'The Area is=' , area )

    Read the article

  • PHP: form input field names containing square brackets like field[index]

    - by gidireich
    Hi, I've seen lot of code that handle forms, which creates input fields with names containing square brackets. I understand that this is being somehow converted to PHP arrays when a PHP script examines the $_POST variable. My questions about this: What is the mechanism behind? At which point this names that merely contain brackets are converted to arrays? Is this a feature of the HTPP protocol? Of web servers? Of the PHP language? Continuing the previous question, is this a commonly used hack or a normal programming tool? What are (all) the rules of using brackets in input field names? Can multidimensional arrays be created this way? Thanks, Gidi

    Read the article

  • Javascript search and replace sequence of characters that contain square brackets

    - by Ruth
    Hello all I'm trying to search for '[EN]' in the string 'Nationality [EN] [ESP]', I want to remove this from the string so I'm using a replace method, code examaple below var str = 'Nationality [EN] [ESP]'; var find = "[EN]"; var regex = new RegExp(find, "g"); alert(str.replace(regex, '')); Since [EN] is identified as a character set this will output the string 'Nationality [] [ESP]' but I want to remove the square brackets aswell. I thought that I could escape them using \ but it didn't work Any advice would be much appreciated

    Read the article

  • Opengl Triangle instead of square

    - by Dave
    Im trying to create a spinning square inside of xcode using opengl but instead for some reason I have a spinning triangle? I'm doing this inside of sio2 but I dont think this is the problem. Here is the triangle: http://img220.imageshack.us/img220/7051/snapzproxscreensnapz001.png Here is my code: void templateRender( void ) { const GLfloat squareVertices[] ={ 100.0f, -100.0f, 100.0f, -100.0f, -100.0f, 100.0f, 100.0f, 100.0f, }; const unsigned char squareColors[] = { 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 0, 255, 255, }; glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT ); // Your rendering code here... sio2WindowEnter2D( sio2->_SIO2window, 0.0f, 1.0f ); { glVertexPointer( 2, GL_FLOAT, 0, squareVertices ); glEnableClientState(GL_VERTEX_ARRAY); //set up the color array glColorPointer( 4, GL_UNSIGNED_BYTE, 0, squareColors ); glEnableClientState( GL_COLOR_ARRAY ); glTranslatef( sio2->_SIO2window->scl->x * 0.5f, sio2->_SIO2window->scl->y * 0.5f, 0.0f ); static float rotz = 0.0f; glRotatef( rotz, 0.0f, 0.0f, 1.0f ); rotz += 90.0f * sio2->_SIO2window->d_time; glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } sio2WindowLeave2D(); }

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >