opengl


What am I doing wrong, in regards to multi-texture(OpenGL)?


I am writing a bump mapping demo, so I need an image texture, and a normal texture which should be loaded into the fragment shader.
This is the texture part of my OpenGL code:
glActiveTexture(GL_TEXTURE0);
GLuint textureID;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE, brick);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLint textureLocation = glGetUniformLocation(shader, "texture");
glUniform1i(textureLocation, 0);
glActiveTexture(GL_TEXTURE1);
GLuint normal_textureID;
glGenTextures(1, &normal_textureID);
glBindTexture(GL_TEXTURE_2D, normal_textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE,
brick_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLint normalTextureLocation = glGetUniformLocation(shader, "normal_texture");
glUniform1i(normalTextureLocation, 1);
Here is the fragment shader:
uniform vec3 light;
uniform sampler2D texture;
uniform sampler2D normal_texture;
void main() {
vec3 tex = texture2D(normal_texture, gl_TexCoord[0].st).rgb;
gl_FragColor = vec4(tex, 1.0);
}
I am sure that the brick array contains the image texture, and the brick_texture array contains the normal texture; but it seems normal_texture and texture are both the image texture, not the normal texture. What am I doing wrong, in regards to multi-texture?

Related Links

Do GLSL uniform blocks consume components?
OpenGL simple mesh doesnt show
Transparency in ProcessingJS in OpenGL mode
GL_QUADS state does not support multiple glBindTexture?
Opengl calculate triangle derivatives
Use of glDrawElements I Don't Understand
Translation is inaccurate n orthogonal view
Box selection with color picking
Display latency using OpenGL Quad Buffer with nvidia stereoscopic 3D
FxPlug Inverts Cube Map At A Distance
understanding glVertexAttribPointer?
GLSL uchar input shared with OpenCL
NSight (NVIDIA) does not work correctly using 'Pause and Capture frame' functionality with Visual Studio
How to calculate UP and position of my camera?
How does a projection Matrix work?
Can I use an OpenGL compute shader to resolve a multisample texture?

Categories

HOME
flask
vagrant
exchange-server
selenium-builder
scroll
operating-system
initialization
magento-2.0
tibco
apache-kafka-connect
facebook-android-sdk
angular-meteor
javafx-8
specifications
swarm
chromecast
mailmerge
asp.net-core-1.0
synthesis
robolectric
pe
spring-ldap
fluent-migrator
ava
chronicle-queue
quartz.net
window-managers
django-import-export
amazon-cloudtrail
ibm-connections
envoy
location-services
snap-framework
series
restful-architecture
db2-luw
cups
cargo
variable-variables
windows-store
spooler
web-inspector
morphline
asihttprequest
return-type
aws-kinesis-firehose
beeline
sonicmq
mura
freshdesk
pen
portability
openerp-6
google-shopping-api
d3v4
haraka
system.web.optimization
clp
p6spy
zynq
oci
groovyfx
deferred-rendering
ajaxmin
accessibilityservice
vim-plugin
smart-tv
lowercase
astropy
enaml
apple
ngcordova
compositetype
abstract-factory
deque
scala-swing
sablecc
incron
lifetime
nesper
xhprof
neo4jphp
xulrunner
armv6
libxml-js
web-frameworks
asp.net-mvc-3-areas
system-requirements
prefuse
prototypal-inheritance
yuidoc
zend-server-ce
filelock
jmenu
webresponse
tabbarcontroller
.net-services
icon-language
watchpoint
regioninfo

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile