I want to build a LevelEditor and would need the sprites (their images) stored in a Texture Atlas of cocos2d in a NSTableView. Any idea how one could approach that?
You can achieve this by creating a CCSprite for each image in your texture atlas and then rendering them into a CCRenderTexture. CCRenderTexture has the ability to save its texture as a NSImage.
More info on how to do this: http://www.cocos2d-iphone.org/forum/topic/27769
Related
I am doing video texturing to a rectangle surface created. I need to create 2 more rectangle of say different size and then copy a part of the texturing video running on the 1st surface (for eg: middle part of the video ) and play it on the new surface created. Is this possible using OpenGL ES ? Through my native video surface renderer, I can do this functionality and can map it to OGLES application. I was just wondering whether it is possible to do directly from OGL app itself, by copying selected rectangle from one of the video texturing surface ?
If your texture is full motion video, you should not copy the texture data because that will be too slow too keep up with video frame rates. You should avoid using glTexImage2D() and instead use the EGL Image Extensions as detailed in my third article here:
http://montgomery1.com/opengl/
But either way, once you have the image in a texture and the texture is bound with glBindTexture(), then any number of rectangles you draw will be textured with that same currently-bound texture, without more copying. These rectangles are actually geometry constructed of triangles and not "surfaces". The framebuffer is the surface. The texture coordinates can be different for each rectangle, which allows you to crop and/or scale the texture mapping uniquely for each.
I'm looking for a tutorial on how to draw a .PNG using DirectX 10, although I'm having no luck. Anyone know where I can find more information on this? I want to create a 2D game
You can load a png as a texture and render it the same way you render other images. For the transparency you can use Alphablending which you enable with Renderstates. (Tutorial, only googled not tested)
you can use D3DX10CreateShaderResourceViewFromFile to create a shader-resource view from a PNG file. This tutorial explains how it works.
In short:
Create a shader to draw a rectangle
Create vertex layout
Create a vertex buffer which stores the vertices of the rectangle
Create a sampler to sample the texture
Create a texture object
Draw the scene
I recently started looking at cocos2d game development.
What's the difference between sprite and texture?
Maybe I could through in 'bitmap' in there. What is a bitmap?
They all seem to be the same thing as 2d image.
A texture is an in-memory image that the device can draw onto the screen.
A sprite actually draws the texture, or just a specific rectangle of the texture, on the screen. The sprite can be scaled, rotated, positioned, skewed, tinted (colorized) among other things.
Multiple sprites can share the same texture. The texture is only loaded to memory once regardless of how many sprites are using the same texture. Moreover with CCSpriteBatchNode you can "batch" the drawing of all sprites that are using the same texture to achieve better performance.
A bitmap is a general term for a computer image where each pixel is represented by one or more bits. There's also the image format BMP which is/was popular on Windows. Most people would just say "image" these days as there are other forms of "bitmaps" that are not images. For example in AI code you often have bitmaps (arrays of bits) that represent state information of the AI or pathfinding algorithms for all areas of the game world. Ie each area in the world could have a "blocking" bit, or a "resource" bit that helps the AI making decisions.
See also Wikipedia:
Texture Mapping
Bitmap
you can load texture into memory, for example your file with image is texture. sprite is object with set of parameters, several of them are pointer to the texture, size and texture coordinate.
you can load texture 2048x2048 into memory, then create sprite with part of this texture.
I am drawing background Sprite
1) CCRenderTexture...draw texture using it
2)The taking sprite from this
So i need to add some images or sprite(from images) on to the texture..
so is there any API by which we can add to texture and then getting sprite (texture + images)..
or i have to draw on texture using open gl commands???
Thanks in advance
CCRenderTexture is a CCNode. As with every CCNode you can just add sprites as children and position them wherever you want. For animation to them you can use CCAnim just as with any other sprite.
Is it possible to load an image file into opengl? We are developing a realistic scene of a robot in both linux and VC++.
What libraies and methods are available to insert an image? also link good examples and references.
The general technique is to bind your image to a texture, and apply it to a quad rendered in your scene. You can use any image library to load the image (DevIL is pretty good); and you'll probably need to rescale or pad it to be a square with power-of-two dimension.